From 680d9eea68a7e56ff019e2a40ea0f3bef6f891b1 Mon Sep 17 00:00:00 2001 From: thorpej Date: Sat, 18 Feb 2006 05:04:11 +0000 Subject: [PATCH] - Don't expose dev_propdb directly -- provide devprop_*() wrappers instead. - Rework the ARMADILLO / epe device properties interaction so that it actually associates the MAC address property with the epe device instance. --- sys/arch/algor/algor/autoconf.c | 6 +-- sys/arch/arm/ep93xx/epe.c | 6 +-- sys/arch/evbarm/armadillo/armadillo9_iic.c | 19 ++++---- .../evbarm/armadillo/armadillo9_machdep.c | 30 ++++++++++++- sys/arch/evbarm/armadillo/armadillo9var.h | 4 +- sys/arch/evbmips/alchemy/autoconf.c | 6 +-- sys/arch/evbppc/walnut/autoconf.c | 8 ++-- sys/arch/mips/alchemy/dev/if_aumac.c | 6 +-- sys/arch/powerpc/ibm4xx/dev/com_opb.c | 8 ++-- sys/arch/powerpc/ibm4xx/dev/if_emac.c | 6 +-- sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c | 8 ++-- sys/dev/i2c/lm75.c | 4 +- sys/dev/pci/if_tlp_pci.c | 9 ++-- sys/kern/subr_autoconf.c | 45 +++++++++++++++++-- sys/sys/device.h | 10 +++-- 15 files changed, 123 insertions(+), 52 deletions(-) diff --git a/sys/arch/algor/algor/autoconf.c b/sys/arch/algor/algor/autoconf.c index ee01f8472ed8..e522c75e0913 100644 --- a/sys/arch/algor/algor/autoconf.c +++ b/sys/arch/algor/algor/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.7 2006/02/16 18:20:31 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.8 2006/02/18 05:04:11 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.7 2006/02/16 18:20:31 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.8 2006/02/18 05:04:11 thorpej Exp $"); #include "opt_algor_p4032.h" #include "opt_algor_p5064.h" @@ -107,7 +107,7 @@ device_register(struct device *dev, void *aux) struct pci_attach_args *pa = aux; if (BUILTIN_ETHERNET_P(pa)) { - if (prop_set(dev_propdb, dev, "mac-addr", + if (devprop_set(dev, "mac-addr", algor_ethaddr, sizeof(algor_ethaddr), 0, 0) != 0) { printf("WARNING: unable to set mac-addr " diff --git a/sys/arch/arm/ep93xx/epe.c b/sys/arch/arm/ep93xx/epe.c index 54ef95c021b3..ecf186c6efa1 100644 --- a/sys/arch/arm/ep93xx/epe.c +++ b/sys/arch/arm/ep93xx/epe.c @@ -1,4 +1,4 @@ -/* $NetBSD: epe.c,v 1.5 2005/12/24 20:06:52 perry Exp $ */ +/* $NetBSD: epe.c,v 1.6 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (c) 2004 Jesse Off @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.5 2005/12/24 20:06:52 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.6 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -159,7 +159,7 @@ epe_attach(struct device *parent, struct device *self, void *aux) panic("%s: Cannot map registers", self->dv_xname); /* Fetch the Ethernet address from property if set. */ - if (prop_get(dev_propdb, 0, "mac-addr", sc->sc_enaddr, + if (devprop_get(self, "mac-addr", sc->sc_enaddr, ETHER_ADDR_LEN, NULL) == ETHER_ADDR_LEN) { bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPE_AFP, 0); bus_space_write_region_1(sc->sc_iot, sc->sc_ioh, EPE_IndAd, diff --git a/sys/arch/evbarm/armadillo/armadillo9_iic.c b/sys/arch/evbarm/armadillo/armadillo9_iic.c index 7ec0a06dfde6..7c363f4a433f 100644 --- a/sys/arch/evbarm/armadillo/armadillo9_iic.c +++ b/sys/arch/evbarm/armadillo/armadillo9_iic.c @@ -1,4 +1,4 @@ -/* $NetBSD: armadillo9_iic.c,v 1.1 2005/11/13 06:33:05 hamajima Exp $ */ +/* $NetBSD: armadillo9_iic.c,v 1.2 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: armadillo9_iic.c,v 1.1 2005/11/13 06:33:05 hamajima Exp $"); +__KERNEL_RCSID(0, "$NetBSD: armadillo9_iic.c,v 1.2 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: armadillo9_iic.c,v 1.1 2005/11/13 06:33:05 hamajima #include #include #include +#include #include "seeprom.h" #if NSEEPROM > 0 @@ -93,7 +94,6 @@ armadillo9iic_attach(struct device *parent, struct device *self, void *aux) struct i2cbus_attach_args iba; #if NSEEPROM > 0 struct epgpio_attach_args *ga = aux; - u_int8_t enaddr[ETHER_ADDR_LEN]; #endif lockinit(&sc->sc_buslock, PRIBIO|PCATCH, "armadillo9iiclk", 0, 0); @@ -128,13 +128,12 @@ armadillo9iic_attach(struct device *parent, struct device *self, void *aux) config_found(&sc->sc_dev, &iba, iicbus_print); #if NSEEPROM > 0 - /* read and set mac address */ - if (!seeprom_bootstrap_read(&sc->sc_i2c, 0x50, 0x00, 128, - (uint8_t *)enaddr, ETHER_ADDR_LEN) - && (prop_set(dev_propdb, 0, "mac-addr", - enaddr, ETHER_ADDR_LEN, PROP_ARRAY, 0) != 0)) { - printf("WARNING: unable to set mac-addr property for %s\n", - sc->sc_dev.dv_xname); + /* read mac address */ + /* XXX This should probably be done elsewhere, earlier in bootstrap. */ + if (seeprom_bootstrap_read(&sc->sc_i2c, 0x50, 0x00, 128, + armadillo9_ethaddr, ETHER_ADDR_LEN) != 0) { + printf("%s: WARNING: unable to read MAC address from SEEPROM\n", + sc->sc_dev.dv_xname); } #endif } diff --git a/sys/arch/evbarm/armadillo/armadillo9_machdep.c b/sys/arch/evbarm/armadillo/armadillo9_machdep.c index 69e384137b77..9aaaa3cde1ae 100644 --- a/sys/arch/evbarm/armadillo/armadillo9_machdep.c +++ b/sys/arch/evbarm/armadillo/armadillo9_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: armadillo9_machdep.c,v 1.4 2006/02/13 12:24:21 hamajima Exp $ */ +/* $NetBSD: armadillo9_machdep.c,v 1.5 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: armadillo9_machdep.c,v 1.4 2006/02/13 12:24:21 hamajima Exp $"); +__KERNEL_RCSID(0, "$NetBSD: armadillo9_machdep.c,v 1.5 2006/02/18 05:04:11 thorpej Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -127,6 +127,9 @@ __KERNEL_RCSID(0, "$NetBSD: armadillo9_machdep.c,v 1.4 2006/02/13 12:24:21 hamaj #include #include +#include +#include + #include #include @@ -137,6 +140,7 @@ __KERNEL_RCSID(0, "$NetBSD: armadillo9_machdep.c,v 1.4 2006/02/13 12:24:21 hamaj #define DRAM_BLOCKS 4 #include +#include #include #include #include @@ -304,6 +308,25 @@ int kgdb_devrate = KGDB_DEVRATE; int kgdb_devmode = KGDB_DEVMODE; #endif /* KGDB */ +/* + * MAC address for the built-in Ethernet. + */ +uint8_t armadillo9_ethaddr[ETHER_ADDR_LEN]; + +static void +armadillo9_device_register(device_t dev, void *aux) +{ + + /* MAC address for the built-in Ethernet. */ + if (strcmp(dev->dv_cfdata->cf_name, "epe") == 0) { + if (devprop_set(dev, "mac-addr", armadillo9_ethaddr, + ETHER_ADDR_LEN, PROP_ARRAY, 0) != 0) { + printf("WARNING: unable to set mac-addr property " + "for %s\n", dev->dv_xname); + } + } +} + /* * void cpu_reboot(int howto, char *bootstr) * @@ -877,6 +900,9 @@ initarm(void *arg) Debugger(); #endif + /* We have our own device_register() */ + evbarm_device_register = armadillo9_device_register; + /* We return the new stack pointer address */ return(kernelstack.pv_va + USPACE_SVC_STACK_TOP); } diff --git a/sys/arch/evbarm/armadillo/armadillo9var.h b/sys/arch/evbarm/armadillo/armadillo9var.h index f69fa8f1c69a..7ea8dcdc03b9 100644 --- a/sys/arch/evbarm/armadillo/armadillo9var.h +++ b/sys/arch/evbarm/armadillo/armadillo9var.h @@ -1,4 +1,4 @@ -/* $NetBSD: armadillo9var.h,v 1.1 2006/02/13 12:24:21 hamajima Exp $ */ +/* $NetBSD: armadillo9var.h,v 1.2 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (c) 2006 HAMAJIMA Katsuomi. All rights reserved. @@ -74,4 +74,6 @@ struct bootparam_tag { extern char bootparam[]; +extern uint8_t armadillo9_ethaddr[]; + #endif /* _ARMADILLO9VAR_H_ */ diff --git a/sys/arch/evbmips/alchemy/autoconf.c b/sys/arch/evbmips/alchemy/autoconf.c index ac5a92e4b89f..099fa65591f9 100644 --- a/sys/arch/evbmips/alchemy/autoconf.c +++ b/sys/arch/evbmips/alchemy/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.9 2005/12/11 12:17:11 christos Exp $ */ +/* $NetBSD: autoconf.c,v 1.10 2006/02/18 05:04:11 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2005/12/11 12:17:11 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -117,7 +117,7 @@ device_register(struct device *dev, void *aux) */ ethaddr[4] += 0x10; } - if (prop_set(dev_propdb, dev, "mac-addr", + if (devprop_set(dev, "mac-addr", ethaddr, sizeof(ethaddr), 0, 0) != 0) { printf("WARNING: unable to set mac-addr " "property for %s\n", dev->dv_xname); diff --git a/sys/arch/evbppc/walnut/autoconf.c b/sys/arch/evbppc/walnut/autoconf.c index 9810a81eead3..cd74085d0546 100644 --- a/sys/arch/evbppc/walnut/autoconf.c +++ b/sys/arch/evbppc/walnut/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.9 2005/12/24 22:45:35 perry Exp $ */ +/* $NetBSD: autoconf.c,v 1.10 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2005/12/24 22:45:35 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -100,7 +100,7 @@ device_register(struct device *dev, void *aux) /* Set the frequency of the on-chip UART. */ int freq = COM_FREQ * 6; - if (prop_set(dev_propdb, dev, "frequency", + if (devprop_set(dev, "frequency", &freq, sizeof(freq), PROP_INT, 0) != 0) printf("WARNING: unable to set frequency " "property for %s\n", dev->dv_xname); @@ -111,7 +111,7 @@ device_register(struct device *dev, void *aux) strcmp(parent->dv_cfdata->cf_name, "opb") == 0) { /* Set the mac-addr of the on-chip Ethernet. */ /* XXX 405GP only has one; what about CPUs with two? */ - if (prop_set(dev_propdb, dev, "mac-addr", + if (devprop_set(dev, "mac-addr", &board_data.mac_address_local, sizeof(board_data.mac_address_local), PROP_CONST, 0) != 0) diff --git a/sys/arch/mips/alchemy/dev/if_aumac.c b/sys/arch/mips/alchemy/dev/if_aumac.c index d0f398a41be6..eb11498a630d 100644 --- a/sys/arch/mips/alchemy/dev/if_aumac.c +++ b/sys/arch/mips/alchemy/dev/if_aumac.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_aumac.c,v 1.13 2005/12/08 22:41:44 yamt Exp $ */ +/* $NetBSD: if_aumac.c,v 1.14 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.13 2005/12/08 22:41:44 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.14 2006/02/18 05:04:11 thorpej Exp $"); #include "bpfilter.h" @@ -235,7 +235,7 @@ aumac_attach(struct device *parent, struct device *self, void *aux) sc->sc_st = aa->aa_st; /* Get the MAC address. */ - if (prop_get(dev_propdb, &sc->sc_dev, "mac-addr", enaddr, + if (devprop_get(&sc->sc_dev, "mac-addr", enaddr, sizeof(enaddr), NULL) != sizeof(enaddr)) { printf("%s: unable to get mac-addr property\n", sc->sc_dev.dv_xname); diff --git a/sys/arch/powerpc/ibm4xx/dev/com_opb.c b/sys/arch/powerpc/ibm4xx/dev/com_opb.c index 586dfc8f1ba5..e6c71a9ab6c2 100644 --- a/sys/arch/powerpc/ibm4xx/dev/com_opb.c +++ b/sys/arch/powerpc/ibm4xx/dev/com_opb.c @@ -1,4 +1,4 @@ -/* $NetBSD: com_opb.c,v 1.13 2005/12/11 12:18:42 christos Exp $ */ +/* $NetBSD: com_opb.c,v 1.14 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: com_opb.c,v 1.13 2005/12/11 12:18:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_opb.c,v 1.14 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -119,7 +119,7 @@ com_opb_attach(struct device *parent, struct device *self, void *aux) bus_space_map(sc->sc_iot, oaa->opb_addr, COM_NPORTS, 0, &sc->sc_ioh); - if (prop_get(dev_propdb, &sc->sc_dev, "frequency", + if (devprop_get(&sc->sc_dev, "frequency", &sc->sc_frequency, sizeof(sc->sc_frequency), NULL) == -1) { printf(": unable to get frequency property\n"); return; @@ -169,7 +169,7 @@ com_opb_device_register(struct device *dev, int frequency) int com_freq = frequency; /* Set the frequency of the on-chip UART. */ - if (prop_set(dev_propdb, dev, "frequency", + if (devprop_set(dev, "frequency", &com_freq, sizeof(com_freq), PROP_INT, 0) != 0) printf("WARNING: unable to set frequency " "property for %s\n", dev->dv_xname); diff --git a/sys/arch/powerpc/ibm4xx/dev/if_emac.c b/sys/arch/powerpc/ibm4xx/dev/if_emac.c index 925aa12f87a4..ca0eed7169eb 100644 --- a/sys/arch/powerpc/ibm4xx/dev/if_emac.c +++ b/sys/arch/powerpc/ibm4xx/dev/if_emac.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_emac.c,v 1.23 2005/12/11 12:18:42 christos Exp $ */ +/* $NetBSD: if_emac.c,v 1.24 2006/02/18 05:04:11 thorpej Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.23 2005/12/11 12:18:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.24 2006/02/18 05:04:11 thorpej Exp $"); #include "bpfilter.h" @@ -397,7 +397,7 @@ emac_attach(struct device *parent, struct device *self, void *aux) emac_reset(sc); /* Fetch the Ethernet address. */ - if (prop_get(dev_propdb, &sc->sc_dev, "mac-addr", enaddr, + if (devprop_get(&sc->sc_dev, "mac-addr", enaddr, sizeof(enaddr), NULL) != sizeof(enaddr)) { printf("%s: unable to get mac-addr property\n", sc->sc_dev.dv_xname); diff --git a/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c b/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c index dfe9b0ea6d63..23dbbface8b9 100644 --- a/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c +++ b/sys/arch/powerpc/ibm4xx/ibm4xx_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibm4xx_autoconf.c,v 1.3 2005/12/11 12:18:42 christos Exp $ */ +/* $NetBSD: ibm4xx_autoconf.c,v 1.4 2006/02/18 05:04:11 thorpej Exp $ */ /* Original Tag: ibm4xxgpx_autoconf.c,v 1.2 2004/10/23 17:12:22 thorpej Exp $ */ /* @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ibm4xx_autoconf.c,v 1.3 2005/12/11 12:18:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ibm4xx_autoconf.c,v 1.4 2006/02/18 05:04:11 thorpej Exp $"); #include #include @@ -58,6 +58,8 @@ ibm4xx_device_register(struct device *dev, void *aux) uint8_t enaddr[ETHER_ADDR_LEN]; unsigned char prop_name[15]; + /* XXX dv_unit abuse */ + /* XXX Should be using index / offset */ snprintf(prop_name, sizeof(prop_name), "emac%d-mac-addr", dev->dv_unit); @@ -68,7 +70,7 @@ ibm4xx_device_register(struct device *dev, void *aux) return; } - if (prop_set(dev_propdb, dev, "mac-addr", + if (devprop_set(dev, "mac-addr", enaddr, sizeof(enaddr), PROP_ARRAY, 0) != 0) printf("WARNING: unable to set mac-addr " diff --git a/sys/dev/i2c/lm75.c b/sys/dev/i2c/lm75.c index 560e2f3a7058..6621a3db5ea3 100644 --- a/sys/dev/i2c/lm75.c +++ b/sys/dev/i2c/lm75.c @@ -1,4 +1,4 @@ -/* $NetBSD: lm75.c,v 1.3 2005/12/11 12:21:22 christos Exp $ */ +/* $NetBSD: lm75.c,v 1.4 2006/02/18 05:04:12 thorpej Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -120,7 +120,7 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux) sc->sc_sensor[0].warnflags = ENVSYS_WARN_OK; sc->sc_sensor[0].units = sc->sc_info[0].units = ENVSYS_STEMP; - if (prop_get(dev_propdb, &sc->sc_dev, "description", + if (devprop_get(&sc->sc_dev, "description", sc->sc_info[0].desc, sizeof(sc->sc_info[0].desc), &ptype) < 1 || ptype != PROP_STRING) diff --git a/sys/dev/pci/if_tlp_pci.c b/sys/dev/pci/if_tlp_pci.c index 85949fd77da2..b4dfce3771f3 100644 --- a/sys/dev/pci/if_tlp_pci.c +++ b/sys/dev/pci/if_tlp_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tlp_pci.c,v 1.85 2006/02/16 18:20:31 thorpej Exp $ */ +/* $NetBSD: if_tlp_pci.c,v 1.86 2006/02/18 05:04:12 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.85 2006/02/16 18:20:31 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.86 2006/02/18 05:04:12 thorpej Exp $"); #include #include @@ -632,9 +632,8 @@ tlp_pci_attach(struct device *parent, struct device *self, void *aux) * XXX logic, and for now we can at least remove a machine- * XXX dependent wart from the PCI front-end. */ - if (prop_get(dev_propdb, &sc->sc_dev, "mac-addr", - enaddr, sizeof(enaddr), NULL) == - sizeof(enaddr)) { + if (devprop_get(&sc->sc_dev, "mac-addr", + enaddr, sizeof(enaddr), NULL) == sizeof(enaddr)) { extern int tlp_srom_debug; sc->sc_srom_addrbits = 6; sc->sc_srom = malloc(TULIP_ROM_SIZE(6), M_DEVBUF, diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index a0ea943394ac..9381e9bc0606 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.103 2005/12/24 19:12:23 perry Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.104 2006/02/18 05:04:13 thorpej Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.103 2005/12/24 19:12:23 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.104 2006/02/18 05:04:13 thorpej Exp $"); #include "opt_ddb.h" @@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.103 2005/12/24 19:12:23 perry Ex #include #include #include +#include #include #include "opt_userconf.h" @@ -129,7 +130,7 @@ static struct cftable initcftable; /* * Database of device properties. */ -propdb_t dev_propdb; +static propdb_t dev_propdb; #define ROOT ((device_t)NULL) @@ -1467,3 +1468,41 @@ config_finalize(void) } } +/* + * Wrappers around prop_*() for handling device properties. + */ +int +devprop_set(device_t dev, const char *name, void *val, size_t len, + int type, int wait) +{ + + return (prop_set(dev_propdb, dev, name, val, len, type, wait)); +} + +size_t +devprop_list(device_t dev, char *names, size_t len) +{ + + return (prop_list(dev_propdb, dev, names, len)); +} + +size_t +devprop_get(device_t dev, const char *name, void *val, size_t len, int *typep) +{ + + return (prop_get(dev_propdb, dev, name, val, len, typep)); +} + +int +devprop_delete(device_t dev, const char *name) +{ + + return (prop_delete(dev_propdb, dev, name)); +} + +int +devprop_copy(device_t from, device_t to, int wait) +{ + + return (prop_copy(dev_propdb, from, to, wait)); +} diff --git a/sys/sys/device.h b/sys/sys/device.h index d684879da65f..ef4eb493ee93 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.84 2005/12/24 19:01:28 perry Exp $ */ +/* $NetBSD: device.h,v 1.85 2006/02/18 05:04:13 thorpej Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -303,8 +303,6 @@ extern int booted_partition; /* or the partition on that device */ extern volatile int config_pending; /* semaphore for mountroot */ -extern propdb_t dev_propdb; /* device properties database */ - void config_init(void); void configure(void); @@ -354,6 +352,12 @@ void config_finalize(void); void device_register(device_t, void *); #endif +int devprop_set(device_t, const char *, void *, size_t, int, int); +size_t devprop_list(device_t, char *, size_t); +size_t devprop_get(device_t, const char *, void *, size_t, int *); +int devprop_delete(device_t, const char *); +int devprop_copy(device_t, device_t, int); + /* convenience definitions */ #define device_lookup(cfd, unit) \ (((unit) < (cfd)->cd_ndevs) ? (cfd)->cd_devs[(unit)] : NULL)