Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | struct driverlink { | ||||
TAILQ_ENTRY(driverlink) passlink; | TAILQ_ENTRY(driverlink) passlink; | ||||
}; | }; | ||||
/* | /* | ||||
* Forward declarations | * Forward declarations | ||||
*/ | */ | ||||
typedef TAILQ_HEAD(devclass_list, devclass) devclass_list_t; | typedef TAILQ_HEAD(devclass_list, devclass) devclass_list_t; | ||||
typedef TAILQ_HEAD(driver_list, driverlink) driver_list_t; | typedef TAILQ_HEAD(driver_list, driverlink) driver_list_t; | ||||
typedef TAILQ_HEAD(device_list, device) device_list_t; | typedef TAILQ_HEAD(device_list, device_) device_list_t; | ||||
struct devclass { | struct devclass { | ||||
TAILQ_ENTRY(devclass) link; | TAILQ_ENTRY(devclass) link; | ||||
devclass_t parent; /* parent in devclass hierarchy */ | devclass_t parent; /* parent in devclass hierarchy */ | ||||
driver_list_t drivers; /* bus devclasses store drivers for bus */ | driver_list_t drivers; /* bus devclasses store drivers for bus */ | ||||
char *name; | char *name; | ||||
device_t *devices; /* array of devices indexed by unit */ | device_t *devices; /* array of devices indexed by unit */ | ||||
int maxunit; /* size of devices array */ | int maxunit; /* size of devices array */ | ||||
int flags; | int flags; | ||||
#define DC_HAS_CHILDREN 1 | #define DC_HAS_CHILDREN 1 | ||||
struct sysctl_ctx_list sysctl_ctx; | struct sysctl_ctx_list sysctl_ctx; | ||||
struct sysctl_oid *sysctl_tree; | struct sysctl_oid *sysctl_tree; | ||||
}; | }; | ||||
/** | /** | ||||
* @brief Implementation of device. | * @brief Implementation of device. | ||||
*/ | */ | ||||
struct device { | struct device_ { | ||||
/* | /* | ||||
* A device is a kernel object. The first field must be the | * A device is a kernel object. The first field must be the | ||||
* current ops table for the object. | * current ops table for the object. | ||||
*/ | */ | ||||
KOBJ_FIELDS; | KOBJ_FIELDS; | ||||
/* | /* | ||||
* Device hierarchy. | * Device hierarchy. | ||||
*/ | */ | ||||
TAILQ_ENTRY(device) link; /**< list of devices in parent */ | TAILQ_ENTRY(device_) link; /**< list of devices in parent */ | ||||
TAILQ_ENTRY(device) devlink; /**< global device list membership */ | TAILQ_ENTRY(device_) devlink; /**< global device list membership */ | ||||
device_t parent; /**< parent of this device */ | device_t parent; /**< parent of this device */ | ||||
device_list_t children; /**< list of child devices */ | device_list_t children; /**< list of child devices */ | ||||
/* | /* | ||||
* Details of this device. | * Details of this device. | ||||
*/ | */ | ||||
driver_t *driver; /**< current driver */ | driver_t *driver; /**< current driver */ | ||||
devclass_t devclass; /**< current device class */ | devclass_t devclass; /**< current device class */ | ||||
▲ Show 20 Lines • Show All 744 Lines • ▼ Show 20 Lines | while (src != NULL && walker < ep) | ||||
} | } | ||||
*walker++ = *src++; | *walker++ = *src++; | ||||
} | } | ||||
*walker = '\0'; | *walker = '\0'; | ||||
} | } | ||||
/* End of /dev/devctl code */ | /* End of /dev/devctl code */ | ||||
static TAILQ_HEAD(,device) bus_data_devices; | static TAILQ_HEAD(,device_) bus_data_devices; | ||||
static int bus_data_generation = 1; | static int bus_data_generation = 1; | ||||
static kobj_method_t null_methods[] = { | static kobj_method_t null_methods[] = { | ||||
KOBJMETHOD_END | KOBJMETHOD_END | ||||
}; | }; | ||||
DEFINE_CLASS(null, null_methods, 0); | DEFINE_CLASS(null, null_methods, 0); | ||||
▲ Show 20 Lines • Show All 902 Lines • ▼ Show 20 Lines | if (!dc) { | ||||
printf("make_device: can't find device class %s\n", | printf("make_device: can't find device class %s\n", | ||||
name); | name); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} else { | } else { | ||||
dc = NULL; | dc = NULL; | ||||
} | } | ||||
dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT|M_ZERO); | dev = malloc(sizeof(struct device_), M_BUS, M_NOWAIT|M_ZERO); | ||||
if (!dev) | if (!dev) | ||||
return (NULL); | return (NULL); | ||||
dev->parent = parent; | dev->parent = parent; | ||||
TAILQ_INIT(&dev->children); | TAILQ_INIT(&dev->children); | ||||
kobj_init((kobj_t) dev, &null_class); | kobj_init((kobj_t) dev, &null_class); | ||||
dev->driver = NULL; | dev->driver = NULL; | ||||
dev->devclass = NULL; | dev->devclass = NULL; | ||||
▲ Show 20 Lines • Show All 3,467 Lines • ▼ Show 20 Lines | SYSCTL_NODE(_hw_bus, OID_AUTO, info, CTLFLAG_RW, sysctl_bus, | ||||
"bus-related data"); | "bus-related data"); | ||||
static int | static int | ||||
sysctl_devices(SYSCTL_HANDLER_ARGS) | sysctl_devices(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int *name = (int *)arg1; | int *name = (int *)arg1; | ||||
u_int namelen = arg2; | u_int namelen = arg2; | ||||
int index; | int index; | ||||
struct device *dev; | device_t dev; | ||||
struct u_device udev; /* XXX this is a bit big */ | struct u_device udev; /* XXX this is a bit big */ | ||||
int error; | int error; | ||||
if (namelen != 2) | if (namelen != 2) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (bus_data_generation_check(name[0])) | if (bus_data_generation_check(name[0])) | ||||
return (EINVAL); | return (EINVAL); | ||||
▲ Show 20 Lines • Show All 348 Lines • Show Last 20 Lines |