[platform][pc] fix up bios32 PCI support, get pci IDE working again

-Spiff up the device driver starting logic to allow for statically
started devices, instead of always automatic.
This commit is contained in:
Travis Geiselbrecht
2018-12-31 16:47:32 -08:00
parent 1fbb67228d
commit 4c29a608e9
10 changed files with 166 additions and 118 deletions

View File

@@ -26,6 +26,7 @@
#include <err.h>
#include <trace.h>
/* static list of devices constructed with DEVICE_INSTANCE macros */
extern struct device __devices[];
extern struct device __devices_end[];
@@ -35,14 +36,15 @@ status_t device_init_all(void)
struct device *dev = __devices;
while (dev != __devices_end) {
dprintf(INFO, "dev: initializing device %s:%s\n", dev->driver->type, dev->name);
status_t code = device_init(dev);
if (dev->flags & DEVICE_FLAG_AUTOINIT) {
status_t code = device_init(dev);
if (code < 0) {
TRACEF("Driver init failed for driver \"%s\", device \"%s\", reason %d\n",
dev->driver->type, dev->name, code);
if (code < 0) {
TRACEF("Driver init failed for driver \"%s\", device \"%s\", reason %d\n",
dev->driver->type, dev->name, code);
res = code;
res = code;
}
}
dev++;
@@ -81,10 +83,18 @@ status_t device_init(struct device *dev)
const struct driver_ops *ops = dev->driver->ops;
if (ops && ops->init)
return ops->init(dev);
else
if (ops && ops->init) {
dprintf(INFO, "dev: initializing device %s:%s\n", dev->driver->type, dev->name);
status_t err = ops->init(dev);
if (err < 0) {
dev->device_state = DEVICE_INITIALIZED_FAILED;
} else {
dev->device_state = DEVICE_INITIALIZED;
}
return err;
} else {
return ERR_NOT_SUPPORTED;
}
}
status_t device_fini(struct device *dev)