fhc.c (131536) | fhc.c (133589) |
---|---|
1/*- 2 * Copyright (c) 2003 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2003 Jake Burkholder. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/sparc64/fhc/fhc.c 131536 2004-07-03 20:49:00Z imp $ | 26 * $FreeBSD: head/sys/sparc64/fhc/fhc.c 133589 2004-08-12 17:41:33Z marius $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/bus.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/pcpu.h> 35 | 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/bus.h> 32#include <sys/kernel.h> 33#include <sys/malloc.h> 34#include <sys/pcpu.h> 35 |
36#include <dev/ofw/ofw_bus.h> |
|
36#include <dev/ofw/openfirm.h> 37 38#include <machine/bus.h> 39#include <machine/bus_common.h> 40#include <machine/resource.h> 41 42#include <sys/rman.h> 43 --- 7 unchanged lines hidden (view full) --- 51 driver_intr_t *fc_func; 52 void *fc_arg; 53 void *fc_cookie; 54 bus_space_tag_t fc_bt; 55 bus_space_handle_t fc_bh; 56}; 57 58struct fhc_devinfo { | 37#include <dev/ofw/openfirm.h> 38 39#include <machine/bus.h> 40#include <machine/bus_common.h> 41#include <machine/resource.h> 42 43#include <sys/rman.h> 44 --- 7 unchanged lines hidden (view full) --- 52 driver_intr_t *fc_func; 53 void *fc_arg; 54 void *fc_cookie; 55 bus_space_tag_t fc_bt; 56 bus_space_handle_t fc_bh; 57}; 58 59struct fhc_devinfo { |
60 char *fdi_compat; 61 char *fdi_model; |
|
59 char *fdi_name; 60 char *fdi_type; 61 phandle_t fdi_node; 62 struct resource_list fdi_rl; 63}; 64 65static void fhc_intr_stub(void *); 66 --- 55 unchanged lines hidden (view full) --- 122 if ((OF_getprop_alloc(child, "name", 1, (void **)&name)) == -1) 123 continue; 124 cdev = device_add_child(dev, NULL, -1); 125 if (cdev != NULL) { 126 fdi = malloc(sizeof(*fdi), M_DEVBUF, 127 M_WAITOK | M_ZERO); 128 fdi->fdi_name = name; 129 fdi->fdi_node = child; | 62 char *fdi_name; 63 char *fdi_type; 64 phandle_t fdi_node; 65 struct resource_list fdi_rl; 66}; 67 68static void fhc_intr_stub(void *); 69 --- 55 unchanged lines hidden (view full) --- 125 if ((OF_getprop_alloc(child, "name", 1, (void **)&name)) == -1) 126 continue; 127 cdev = device_add_child(dev, NULL, -1); 128 if (cdev != NULL) { 129 fdi = malloc(sizeof(*fdi), M_DEVBUF, 130 M_WAITOK | M_ZERO); 131 fdi->fdi_name = name; 132 fdi->fdi_node = child; |
133 OF_getprop_alloc(child, "compatible", 1, 134 (void **)&fdi->fdi_compat); |
|
130 OF_getprop_alloc(child, "device_type", 1, 131 (void **)&fdi->fdi_type); | 135 OF_getprop_alloc(child, "device_type", 1, 136 (void **)&fdi->fdi_type); |
137 OF_getprop_alloc(child, "model", 1, 138 (void **)&fdi->fdi_model); |
|
132 resource_list_init(&fdi->fdi_rl); 133 nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), 134 (void **)®); 135 if (nreg != -1) { 136 for (i = 0; i < nreg; i++) { 137 off = reg[i].sbr_offset; 138 size = reg[i].sbr_size; 139 resource_list_add(&fdi->fdi_rl, --- 32 unchanged lines hidden (view full) --- 172 fdi = device_get_ivars(child); 173 device_printf(dev, "<%s>", fdi->fdi_name); 174 resource_list_print_type(&fdi->fdi_rl, "mem", SYS_RES_MEMORY, "%#lx"); 175 printf(" type %s (no driver attached)\n", 176 fdi->fdi_type != NULL ? fdi->fdi_type : "unknown"); 177} 178 179int | 139 resource_list_init(&fdi->fdi_rl); 140 nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), 141 (void **)®); 142 if (nreg != -1) { 143 for (i = 0; i < nreg; i++) { 144 off = reg[i].sbr_offset; 145 size = reg[i].sbr_size; 146 resource_list_add(&fdi->fdi_rl, --- 32 unchanged lines hidden (view full) --- 179 fdi = device_get_ivars(child); 180 device_printf(dev, "<%s>", fdi->fdi_name); 181 resource_list_print_type(&fdi->fdi_rl, "mem", SYS_RES_MEMORY, "%#lx"); 182 printf(" type %s (no driver attached)\n", 183 fdi->fdi_type != NULL ? fdi->fdi_type : "unknown"); 184} 185 186int |
180fhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 181{ 182 struct fhc_devinfo *fdi; 183 184 if ((fdi = device_get_ivars(child)) == 0) 185 return (ENOENT); 186 switch (which) { 187 case FHC_IVAR_NAME: 188 *result = (uintptr_t)fdi->fdi_name; 189 break; 190 case FHC_IVAR_NODE: 191 *result = fdi->fdi_node; 192 break; 193 case FHC_IVAR_TYPE: 194 *result = (uintptr_t)fdi->fdi_type; 195 break; 196 default: 197 return (ENOENT); 198 } 199 return (0); 200} 201 202int 203fhc_write_ivar(device_t dev, device_t child, int which, uintptr_t value) 204{ 205 struct fhc_devinfo *fdi; 206 207 if ((fdi = device_get_ivars(child)) == 0) 208 return (ENOENT); 209 switch (which) { 210 case FHC_IVAR_NAME: 211 case FHC_IVAR_NODE: 212 case FHC_IVAR_TYPE: 213 return (EINVAL); 214 default: 215 return (ENOENT); 216 } 217 return (0); 218} 219 220int | |
221fhc_setup_intr(device_t bus, device_t child, struct resource *r, int flags, 222 driver_intr_t *func, void *arg, void **cookiep) 223{ 224 struct fhc_softc *sc; 225 struct fhc_clr *fc; 226 int error; 227 int rid; 228 --- 138 unchanged lines hidden (view full) --- 367 rle = resource_list_find(&fdi->fdi_rl, type, rid); 368 if (rle == NULL) 369 panic("fhc_release_resource: can't find resource"); 370 if (rle->res == NULL) 371 panic("fhc_release_resource: resource entry is not busy"); 372 rle->res = NULL; 373 return (error); 374} | 187fhc_setup_intr(device_t bus, device_t child, struct resource *r, int flags, 188 driver_intr_t *func, void *arg, void **cookiep) 189{ 190 struct fhc_softc *sc; 191 struct fhc_clr *fc; 192 int error; 193 int rid; 194 --- 138 unchanged lines hidden (view full) --- 333 rle = resource_list_find(&fdi->fdi_rl, type, rid); 334 if (rle == NULL) 335 panic("fhc_release_resource: can't find resource"); 336 if (rle->res == NULL) 337 panic("fhc_release_resource: resource entry is not busy"); 338 rle->res = NULL; 339 return (error); 340} |
341 342const char * 343fhc_get_compat(device_t bus, device_t dev) 344{ 345 struct fhc_devinfo *dinfo; 346 347 dinfo = device_get_ivars(dev); 348 return (dinfo->fdi_compat); 349} 350 351const char * 352fhc_get_model(device_t bus, device_t dev) 353{ 354 struct fhc_devinfo *dinfo; 355 356 dinfo = device_get_ivars(dev); 357 return (dinfo->fdi_model); 358} 359 360const char * 361fhc_get_name(device_t bus, device_t dev) 362{ 363 struct fhc_devinfo *dinfo; 364 365 dinfo = device_get_ivars(dev); 366 return (dinfo->fdi_name); 367} 368 369phandle_t 370fhc_get_node(device_t bus, device_t dev) 371{ 372 struct fhc_devinfo *dinfo; 373 374 dinfo = device_get_ivars(dev); 375 return (dinfo->fdi_node); 376} 377 378const char * 379fhc_get_type(device_t bus, device_t dev) 380{ 381 struct fhc_devinfo *dinfo; 382 383 dinfo = device_get_ivars(dev); 384 return (dinfo->fdi_type); 385} |
|