- PCI: hal_driver 'x86-pci' (BUS, priority 10) — self-registers via pci_driver_register()
- E1000: hal_driver 'e1000' (NET, priority 20) — probe checks PCI for Intel 82540EM
- init.c: replace explicit pci_init()/e1000_init() with driver registration + hal_drivers_init_all()
- Drivers init in priority order: PCI bus first, then E1000 probes and inits
- Pattern ready for additional drivers to self-register
20/20 smoke, cppcheck clean
/* Check if the NIC is initialized and link is up. */
int e1000_link_up(void);
+void e1000_driver_register(void);
+
#endif
const struct pci_device* pci_find_device(uint16_t vendor, uint16_t device);
const struct pci_device* pci_find_class(uint8_t class_code, uint8_t subclass);
+void pci_driver_register(void);
+
#endif
#include "e1000.h"
+#include "hal/driver.h"
#include "kernel_va_map.h"
#include "pci.h"
#include "vmm.h"
if (!e1000_ready) return 0;
return (e1000_read(E1000_STATUS) & (1U << 1)) ? 1 : 0;
}
+
+/* HAL driver registration */
+static int e1000_drv_probe(void) {
+ return pci_find_device(0x8086, 0x100E) ? 0 : -1;
+}
+
+static const struct hal_driver e1000_hal_driver = {
+ .name = "e1000",
+ .type = HAL_DRV_NET,
+ .priority = 20,
+ .ops = { .probe = e1000_drv_probe, .init = e1000_init, .shutdown = NULL }
+};
+
+void e1000_driver_register(void) {
+ hal_driver_register(&e1000_hal_driver);
+}
#include "pci.h"
+#include "hal/driver.h"
#include "console.h"
#include "utils.h"
#include "io.h"
}
return 0;
}
+
+/* HAL driver registration */
+static int pci_drv_init(void) { pci_init(); return 0; }
+
+static const struct hal_driver pci_hal_driver = {
+ .name = "x86-pci",
+ .type = HAL_DRV_BUS,
+ .priority = 10,
+ .ops = { .probe = NULL, .init = pci_drv_init, .shutdown = NULL }
+};
+
+void pci_driver_register(void) {
+ hal_driver_register(&pci_hal_driver);
+}
#include "kernel/init.h"
#include "arch/arch_platform.h"
+#include "hal/driver.h"
#include "fs.h"
#include "initrd.h"
(void)vfs_mount("/tmp", tmp);
}
- pci_init();
- e1000_init();
+ /* Register hardware drivers with HAL and init in priority order */
+ pci_driver_register(); /* priority 10: bus */
+ e1000_driver_register(); /* priority 20: NIC (probes PCI) */
+ hal_drivers_init_all();
+
net_init();
net_ping_test();
ksocket_init();