From 0d16e3e35a8175e21fe8085010be92f794f7acf3 Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Wed, 24 Jul 2024 00:14:55 +0200 Subject: [PATCH] Make driver initialization easier in manager.asm With this change, the driver's setup function only has to be added to the 'driver_init_functions'-array and it will be called once 'setup_drivers' is called. --- i386/loader/src-asm/drivers/manager.asm | 33 +++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/i386/loader/src-asm/drivers/manager.asm b/i386/loader/src-asm/drivers/manager.asm index 1f7a589..f28956c 100644 --- a/i386/loader/src-asm/drivers/manager.asm +++ b/i386/loader/src-asm/drivers/manager.asm @@ -26,13 +26,41 @@ setup_drivers: mov [esi + (64 - 16)], edx mov [esi + (64 - 20)], edi + ; [esi + 8]: Pointer to the current driver init function + ; [esi + 12]L Pointer to current driver slot + ; ecx: Driver slot index + + xor ecx, ecx + +.driver_setup_loop: + cmp ecx, DRIVER_SLOT_COUNT + jae .epilog + + mov ebx, ecx + shl ebx, 2 + add ebx, driver_init_functions + mov eax, [ebx] + mov [esi + 8], eax + + cmp eax, 0 + je .epilog + + mov eax, ecx + mov edx, DRIVER_SLOT_SIZE + mul edx + mov [esi + 12], eax + push ebp mov ebp, esp - push dword DRIVER_MEMORY_AREA - call initialize_pci_driver + push dword [esi + 12] + mov eax, [esi + 8] + call eax mov esp, ebp pop ebp + inc ecx + jmp .driver_setup_loop + .epilog: mov eax, [esi + (64 - 4)] mov ebx, [esi + (64 - 8)] @@ -45,3 +73,4 @@ setup_drivers: ret %include "drivers/pci/driver.asm" +%include "drivers/acpi/driver.asm"