28c28
< __FBSDID("$FreeBSD: head/sys/sparc64/central/central.c 146398 2005-05-19 15:09:56Z marius $");
---
> __FBSDID("$FreeBSD: head/sys/sparc64/central/central.c 152684 2005-11-22 16:39:44Z marius $");
37a38
> #include <dev/ofw/ofw_bus_subr.h>
50,54c51
< char *cdi_compat;
< char *cdi_model;
< char *cdi_name;
< char *cdi_type;
< phandle_t cdi_node;
---
> struct ofw_bus_devinfo cdi_obdinfo;
70,74c67
< static ofw_bus_get_compat_t central_get_compat;
< static ofw_bus_get_model_t central_get_model;
< static ofw_bus_get_name_t central_get_name;
< static ofw_bus_get_node_t central_get_node;
< static ofw_bus_get_type_t central_get_type;
---
> static ofw_bus_get_devinfo_t central_get_devinfo;
75a69,70
> static int central_print_res(struct central_devinfo *);
>
94,98c89,94
< DEVMETHOD(ofw_bus_get_compat, central_get_compat),
< DEVMETHOD(ofw_bus_get_model, central_get_model),
< DEVMETHOD(ofw_bus_get_name, central_get_name),
< DEVMETHOD(ofw_bus_get_node, central_get_node),
< DEVMETHOD(ofw_bus_get_type, central_get_type),
---
> DEVMETHOD(ofw_bus_get_devinfo, central_get_devinfo),
> DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
> DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
> DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
> DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
> DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
132,133d127
< bus_addr_t size;
< bus_addr_t off;
135d128
< char *name;
151c144,146
< if ((OF_getprop_alloc(child, "name", 1, (void **)&name)) == -1)
---
> cdi = malloc(sizeof(*cdi), M_DEVBUF, M_WAITOK | M_ZERO);
> if (ofw_bus_gen_setup_devinfo(&cdi->cdi_obdinfo, child) != 0) {
> free(cdi, M_DEVBUF);
152a148,163
> }
> nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
> (void **)®);
> if (nreg == -1) {
> device_printf(dev, "<%s>: incomplete\n",
> cdi->cdi_obdinfo.obd_name);
> ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo);
> free(cdi, M_DEVBUF);
> continue;
> }
> resource_list_init(&cdi->cdi_rl);
> for (i = 0; i < nreg; i++)
> resource_list_add(&cdi->cdi_rl, SYS_RES_MEMORY, i,
> reg[i].sbr_offset, reg[i].sbr_offset +
> reg[i].sbr_size, reg[i].sbr_size);
> free(reg, M_OFWPROP);
154,181c165,173
< if (cdev != NULL) {
< cdi = malloc(sizeof(*cdi), M_DEVBUF, M_WAITOK | M_ZERO);
< if (cdi == NULL)
< continue;
< cdi->cdi_name = name;
< cdi->cdi_node = child;
< OF_getprop_alloc(child, "compatible", 1,
< (void **)&cdi->cdi_compat);
< OF_getprop_alloc(child, "device_type", 1,
< (void **)&cdi->cdi_type);
< OF_getprop_alloc(child, "model", 1,
< (void **)&cdi->cdi_model);
< resource_list_init(&cdi->cdi_rl);
< nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
< (void **)®);
< if (nreg != -1) {
< for (i = 0; i < nreg; i++) {
< off = reg[i].sbr_offset;
< size = reg[i].sbr_size;
< resource_list_add(&cdi->cdi_rl,
< SYS_RES_MEMORY, i, off, off + size,
< size);
< }
< free(reg, M_OFWPROP);
< }
< device_set_ivars(cdev, cdi);
< } else
< free(name, M_OFWPROP);
---
> if (cdev == NULL) {
> device_printf(dev, "<%s>: device_add_child failed\n",
> cdi->cdi_obdinfo.obd_name);
> resource_list_free(&cdi->cdi_rl);
> ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo);
> free(cdi, M_DEVBUF);
> continue;
> }
> device_set_ivars(cdev, cdi);
190d181
< struct central_devinfo *cdi;
193d183
< cdi = device_get_ivars(child);
195,196c185
< rv += resource_list_print_type(&cdi->cdi_rl, "mem",
< SYS_RES_MEMORY, "%#lx");
---
> rv += central_print_res(device_get_ivars(child));
204c193
< struct central_devinfo *cdi;
---
> const char *type;
206,208c195,197
< cdi = device_get_ivars(child);
< device_printf(dev, "<%s>", cdi->cdi_name);
< resource_list_print_type(&cdi->cdi_rl, "mem", SYS_RES_MEMORY, "%#lx");
---
> device_printf(dev, "<%s>", ofw_bus_get_name(child));
> central_print_res(device_get_ivars(child));
> type = ofw_bus_get_type(child);
210c199
< cdi->cdi_type != NULL ? cdi->cdi_type : "unknown");
---
> type != NULL ? type : "unknown");
281,282c270,271
< static const char *
< central_get_compat(device_t bus, device_t dev)
---
> static const struct ofw_bus_devinfo *
> central_get_devinfo(device_t bus, device_t child)
284,293c273
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_compat);
< }
<
< static const char *
< central_get_model(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
---
> struct central_devinfo *cdi;
295,296c275,276
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_model);
---
> cdi = device_get_ivars(child);
> return (&cdi->cdi_obdinfo);
299,300c279,280
< static const char *
< central_get_name(device_t bus, device_t dev)
---
> static int
> central_print_res(struct central_devinfo *cdi)
302d281
< struct central_devinfo *dinfo;
304,305c283,284
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_name);
---
> return (resource_list_print_type(&cdi->cdi_rl, "mem", SYS_RES_MEMORY,
> "%#lx"));
307,324d285
<
< static phandle_t
< central_get_node(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_node);
< }
<
< static const char *
< central_get_type(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_type);
< }
< __FBSDID("$FreeBSD: head/sys/sparc64/central/central.c 146398 2005-05-19 15:09:56Z marius $");
---
> __FBSDID("$FreeBSD: head/sys/sparc64/central/central.c 152684 2005-11-22 16:39:44Z marius $");
37a38
> #include <dev/ofw/ofw_bus_subr.h>
50,54c51
< char *cdi_compat;
< char *cdi_model;
< char *cdi_name;
< char *cdi_type;
< phandle_t cdi_node;
---
> struct ofw_bus_devinfo cdi_obdinfo;
70,74c67
< static ofw_bus_get_compat_t central_get_compat;
< static ofw_bus_get_model_t central_get_model;
< static ofw_bus_get_name_t central_get_name;
< static ofw_bus_get_node_t central_get_node;
< static ofw_bus_get_type_t central_get_type;
---
> static ofw_bus_get_devinfo_t central_get_devinfo;
75a69,70
> static int central_print_res(struct central_devinfo *);
>
94,98c89,94
< DEVMETHOD(ofw_bus_get_compat, central_get_compat),
< DEVMETHOD(ofw_bus_get_model, central_get_model),
< DEVMETHOD(ofw_bus_get_name, central_get_name),
< DEVMETHOD(ofw_bus_get_node, central_get_node),
< DEVMETHOD(ofw_bus_get_type, central_get_type),
---
> DEVMETHOD(ofw_bus_get_devinfo, central_get_devinfo),
> DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
> DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
> DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
> DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
> DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
132,133d127
< bus_addr_t size;
< bus_addr_t off;
135d128
< char *name;
151c144,146
< if ((OF_getprop_alloc(child, "name", 1, (void **)&name)) == -1)
---
> cdi = malloc(sizeof(*cdi), M_DEVBUF, M_WAITOK | M_ZERO);
> if (ofw_bus_gen_setup_devinfo(&cdi->cdi_obdinfo, child) != 0) {
> free(cdi, M_DEVBUF);
152a148,163
> }
> nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
> (void **)®);
> if (nreg == -1) {
> device_printf(dev, "<%s>: incomplete\n",
> cdi->cdi_obdinfo.obd_name);
> ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo);
> free(cdi, M_DEVBUF);
> continue;
> }
> resource_list_init(&cdi->cdi_rl);
> for (i = 0; i < nreg; i++)
> resource_list_add(&cdi->cdi_rl, SYS_RES_MEMORY, i,
> reg[i].sbr_offset, reg[i].sbr_offset +
> reg[i].sbr_size, reg[i].sbr_size);
> free(reg, M_OFWPROP);
154,181c165,173
< if (cdev != NULL) {
< cdi = malloc(sizeof(*cdi), M_DEVBUF, M_WAITOK | M_ZERO);
< if (cdi == NULL)
< continue;
< cdi->cdi_name = name;
< cdi->cdi_node = child;
< OF_getprop_alloc(child, "compatible", 1,
< (void **)&cdi->cdi_compat);
< OF_getprop_alloc(child, "device_type", 1,
< (void **)&cdi->cdi_type);
< OF_getprop_alloc(child, "model", 1,
< (void **)&cdi->cdi_model);
< resource_list_init(&cdi->cdi_rl);
< nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
< (void **)®);
< if (nreg != -1) {
< for (i = 0; i < nreg; i++) {
< off = reg[i].sbr_offset;
< size = reg[i].sbr_size;
< resource_list_add(&cdi->cdi_rl,
< SYS_RES_MEMORY, i, off, off + size,
< size);
< }
< free(reg, M_OFWPROP);
< }
< device_set_ivars(cdev, cdi);
< } else
< free(name, M_OFWPROP);
---
> if (cdev == NULL) {
> device_printf(dev, "<%s>: device_add_child failed\n",
> cdi->cdi_obdinfo.obd_name);
> resource_list_free(&cdi->cdi_rl);
> ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo);
> free(cdi, M_DEVBUF);
> continue;
> }
> device_set_ivars(cdev, cdi);
190d181
< struct central_devinfo *cdi;
193d183
< cdi = device_get_ivars(child);
195,196c185
< rv += resource_list_print_type(&cdi->cdi_rl, "mem",
< SYS_RES_MEMORY, "%#lx");
---
> rv += central_print_res(device_get_ivars(child));
204c193
< struct central_devinfo *cdi;
---
> const char *type;
206,208c195,197
< cdi = device_get_ivars(child);
< device_printf(dev, "<%s>", cdi->cdi_name);
< resource_list_print_type(&cdi->cdi_rl, "mem", SYS_RES_MEMORY, "%#lx");
---
> device_printf(dev, "<%s>", ofw_bus_get_name(child));
> central_print_res(device_get_ivars(child));
> type = ofw_bus_get_type(child);
210c199
< cdi->cdi_type != NULL ? cdi->cdi_type : "unknown");
---
> type != NULL ? type : "unknown");
281,282c270,271
< static const char *
< central_get_compat(device_t bus, device_t dev)
---
> static const struct ofw_bus_devinfo *
> central_get_devinfo(device_t bus, device_t child)
284,293c273
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_compat);
< }
<
< static const char *
< central_get_model(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
---
> struct central_devinfo *cdi;
295,296c275,276
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_model);
---
> cdi = device_get_ivars(child);
> return (&cdi->cdi_obdinfo);
299,300c279,280
< static const char *
< central_get_name(device_t bus, device_t dev)
---
> static int
> central_print_res(struct central_devinfo *cdi)
302d281
< struct central_devinfo *dinfo;
304,305c283,284
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_name);
---
> return (resource_list_print_type(&cdi->cdi_rl, "mem", SYS_RES_MEMORY,
> "%#lx"));
307,324d285
<
< static phandle_t
< central_get_node(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_node);
< }
<
< static const char *
< central_get_type(device_t bus, device_t dev)
< {
< struct central_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->cdi_type);
< }