2024-07-22 23:04:35 +00:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2024-07-23 22:14:55 +00:00
|
|
|
; [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
|
|
|
|
|
2024-07-22 23:04:35 +00:00
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
2024-07-23 22:14:55 +00:00
|
|
|
push dword [esi + 12]
|
|
|
|
mov eax, [esi + 8]
|
|
|
|
call eax
|
2024-07-22 23:04:35 +00:00
|
|
|
mov esp, ebp
|
|
|
|
pop ebp
|
|
|
|
|
2024-07-23 22:14:55 +00:00
|
|
|
inc ecx
|
|
|
|
jmp .driver_setup_loop
|
|
|
|
|
2024-07-22 23:04:35 +00:00
|
|
|
.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"
|