From 78ea65ec7574e1895a90922b3b62b050682df7e3 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 1 Jun 2023 13:50:51 +0200 Subject: [PATCH] fix (drivers): pushing without testing was a bad idea ^^ --- src/boot/kmain.c | 2 +- src/drivers/driver.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/boot/kmain.c b/src/boot/kmain.c index eff44e2..b57f097 100644 --- a/src/boot/kmain.c +++ b/src/boot/kmain.c @@ -97,7 +97,7 @@ void kmain(boot_info_T boot_info) { void (*drv_test)() = entry; drv_test(); - driver_T* resolved = driver_lookup_pci_device(0x886, 0x2920); + driver_T* resolved = driver_lookup_pci_device(0x8086, 0x2922); DEBUG("driver: 0x%x", drv); DEBUG("resolved: 0x%x", resolved); diff --git a/src/drivers/driver.c b/src/drivers/driver.c index aaa83dd..c49e258 100644 --- a/src/drivers/driver.c +++ b/src/drivers/driver.c @@ -32,22 +32,22 @@ driver_manager_chunk_T* driver_manager_chunk_alloc(driver_manager_chunk_T* prev) } driver_T* driver_find_pci_device(uint16_t vendor_id, uint16_t device_id) { - log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + log(LOG_WARNING, "driver manager -> pci driver lookup on disk is not implemented yet"); return NULL; } driver_T* driver_find_usb_device(uint16_t vendor_id, uint16_t device_id) { - log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + log(LOG_WARNING, "driver manager -> usb driver lookup on disk is not implemented yet"); return NULL; } driver_T* driver_find_fs_gpt(uint8_t guid[16]) { - log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + log(LOG_WARNING, "driver manager -> gpt driver lookup on disk is not implemented yet"); return NULL; } driver_T* driver_find_fs_mbr(uint8_t type) { - log(LOG_WARNING, "driver manager -> driver lookup on disk is not implemented yet"); + log(LOG_WARNING, "driver manager -> mbr driver lookup on disk is not implemented yet"); return NULL; } @@ -58,6 +58,7 @@ void driver_init_pci(driver_T* driver, driver_config_pci_T* conf) { hashmap_T* level_2 = hashmap_lookup(&g_driver_manager.lookup_table_pci, device_id->vendor_id); if (level_2 == NULL) { level_2 = memory_allocate(sizeof(hashmap_T)); + *level_2 = hashmap_create(DRIVER_MANAGER_HASHMAP_SIZE); hashmap_insert(&g_driver_manager.lookup_table_pci, device_id->vendor_id, level_2); } @@ -130,9 +131,18 @@ void driver_init_fs(driver_T* driver, driver_config_fs_T* conf) { void driver_init(driver_T* driver, driver_transport_protocol_E protocol, conf_U conf) { switch (protocol) { - case DRIVER_TRANSPORT_PCI: driver_init_pci(driver, conf.pci); - case DRIVER_TRANSPORT_USB: driver_init_usb(driver, conf.usb); - case DRIVER_TRANSPORT_FS: driver_init_fs (driver, conf.fs); + case DRIVER_TRANSPORT_PCI: { + driver_init_pci(driver, conf.pci); + break; + } + case DRIVER_TRANSPORT_USB: { + driver_init_usb(driver, conf.usb); + break; + } + case DRIVER_TRANSPORT_FS: { + driver_init_fs(driver, conf.fs); + break; + } } }