From 94e5e703052c02946b6206ab2303d714fbfb6333 Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Tue, 23 Jul 2024 01:04:35 +0200 Subject: [PATCH] Add driver manager's setup routine The setup_drivers routine existed locally for some time now, so now it also exists in the repository. It has gone through two iterations: 1. The drivers are all listed in a null-terminated array of function pointers to initialization functions (this didn't work and the time for debugging just wasn't there). 2. All drivers (currently, only the PCI driver, because that's the only one that exists) are initialized after each other; their initialization functions are called manually. It might be possible that the bug from the first iteration was due to the memory space being offset by 128 or 256 bytes; it might be useful to use that concept again because then, it will be easier to add new drivers. That's not of high importance now, though. --- i386/loader/src-asm/drivers/manager.asm | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 i386/loader/src-asm/drivers/manager.asm diff --git a/i386/loader/src-asm/drivers/manager.asm b/i386/loader/src-asm/drivers/manager.asm new file mode 100644 index 0000000..1f7a589 --- /dev/null +++ b/i386/loader/src-asm/drivers/manager.asm @@ -0,0 +1,47 @@ + +; Start with the driver data at 1 MiB, continue for 2 MiB +DRIVER_MEMORY_AREA equ 0x100000 +DRIVER_SLOT_SIZE equ 65536 +DRIVER_SLOT_COUNT equ 32 + +; Functions of all drivers which get initialized (in the order of +; initialization); the last entry must be a zero, but at 32 entries, +; the end is forced by the main initialization function. +driver_init_functions: + dd initialize_pci_driver + ; Ending Entry + dd 0 + +; [Furthest from EBP] +; -- No Arguments -- +; [Nearest to EBP] +setup_drivers: + push dword esi + sub esp, 64 + mov esi, esp + + mov [esi + (64 - 4)], eax + mov [esi + (64 - 8)], ebx + mov [esi + (64 - 12)], ecx + mov [esi + (64 - 16)], edx + mov [esi + (64 - 20)], edi + + push ebp + mov ebp, esp + push dword DRIVER_MEMORY_AREA + call initialize_pci_driver + mov esp, ebp + pop ebp + +.epilog: + mov eax, [esi + (64 - 4)] + mov ebx, [esi + (64 - 8)] + mov ecx, [esi + (64 - 12)] + mov edx, [esi + (64 - 16)] + mov edi, [esi + (64 - 20)] + + add esp, 64 + pop dword esi + ret + +%include "drivers/pci/driver.asm"