Changeset View
Changeset View
Standalone View
Standalone View
stand/kshim/bsd_kernel.c
| Show First 20 Lines • Show All 551 Lines • ▼ Show 20 Lines | |||||
| static const char unknown_string[] = { "unknown" }; | static const char unknown_string[] = { "unknown" }; | ||||
| static TAILQ_HEAD(, module_data) module_head = | static TAILQ_HEAD(, module_data) module_head = | ||||
| TAILQ_HEAD_INITIALIZER(module_head); | TAILQ_HEAD_INITIALIZER(module_head); | ||||
| static TAILQ_HEAD(, devclass) devclasses = | static TAILQ_HEAD(, devclass) devclasses = | ||||
| TAILQ_HEAD_INITIALIZER(devclasses); | TAILQ_HEAD_INITIALIZER(devclasses); | ||||
| static uint8_t | |||||
| devclass_equal(const char *a, const char *b) | |||||
| { | |||||
| char ta, tb; | |||||
| if (a == b) | |||||
| return (1); | |||||
| while (1) { | |||||
| ta = *a; | |||||
| tb = *b; | |||||
| if (ta != tb) | |||||
| return (0); | |||||
| if (ta == 0) | |||||
| break; | |||||
| a++; | |||||
| b++; | |||||
| } | |||||
| return (1); | |||||
| } | |||||
| int | int | ||||
| bus_generic_resume(device_t dev) | bus_generic_resume(device_t dev) | ||||
| { | { | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| int | int | ||||
| bus_generic_shutdown(device_t dev) | bus_generic_shutdown(device_t dev) | ||||
| ▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | |||||
| void * | void * | ||||
| device_get_method(device_t dev, const char *what) | device_get_method(device_t dev, const char *what) | ||||
| { | { | ||||
| const struct device_method *mtod; | const struct device_method *mtod; | ||||
| mtod = dev->dev_module->driver->methods; | mtod = dev->dev_module->driver->methods; | ||||
| while (mtod->func != NULL) { | while (mtod->func != NULL) { | ||||
| if (devclass_equal(mtod->desc, what)) { | if (strcmp(mtod->desc, what) == 0) { | ||||
imp: So hps was a smart fellow. Why did he do it this odd, tortued way? | |||||
Done Inline ActionsMaybe the a == b check? I'm not sure. It is also odd how many places it was used in places that had nothing to do with devclasses. jhb: Maybe the a == b check? I'm not sure. It is also odd how many places it was used in places… | |||||
| return (mtod->func); | return (mtod->func); | ||||
| } | } | ||||
| mtod++; | mtod++; | ||||
| } | } | ||||
| return ((void *)&default_method); | return ((void *)&default_method); | ||||
| } | } | ||||
| const char * | const char * | ||||
| Show All 36 Lines | if (dev->dev_attached) | ||||
| return (0); /* fail-safe */ | return (0); /* fail-safe */ | ||||
| /* | /* | ||||
| * Find a module for our device, if any | * Find a module for our device, if any | ||||
| */ | */ | ||||
| bus_name_parent = device_get_name(device_get_parent(dev)); | bus_name_parent = device_get_name(device_get_parent(dev)); | ||||
| TAILQ_FOREACH(mod, &module_head, entry) { | TAILQ_FOREACH(mod, &module_head, entry) { | ||||
| if (!devclass_equal(mod->bus_name, bus_name_parent)) | if (strcmp(mod->bus_name, bus_name_parent) != 0) | ||||
| continue; | continue; | ||||
| dc = devclass_find(mod->mod_name); | dc = devclass_find(mod->mod_name); | ||||
| /* Does this device need assigning to the new devclass? */ | /* Does this device need assigning to the new devclass? */ | ||||
| if (dev->dev_class != dc) { | if (dev->dev_class != dc) { | ||||
| if (dev->dev_fixed_class) | if (dev->dev_fixed_class) | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| devclass_t | devclass_t | ||||
| devclass_find(const char *classname) | devclass_find(const char *classname) | ||||
| { | { | ||||
| devclass_t dc; | devclass_t dc; | ||||
| TAILQ_FOREACH(dc, &devclasses, link) { | TAILQ_FOREACH(dc, &devclasses, link) { | ||||
| if (devclass_equal(dc->name, classname)) | if (strcmp(dc->name, classname) == 0) | ||||
| return (dc); | return (dc); | ||||
| } | } | ||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| void | void | ||||
| module_register(void *data) | module_register(void *data) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 365 Lines • Show Last 20 Lines | |||||
So hps was a smart fellow. Why did he do it this odd, tortued way?