Nightloader/i386/legacy-boot/src-asm/drivers/pci/driver.asm

65 lines
1.6 KiB
NASM
Raw Normal View History

PCI_CONFIG_ADDRESS_PORT equ 0x0cf8
PCI_CONFIG_DATA_PORT equ 0x0cfc
PCI_DEVICE_COUNT_OFFSET equ 0xffe
PCI_DEVICE_AREA_OFFSET equ 0x1000
; [FURTHEST FROM BP]
; 0. Ptr32 Pointer to 65536B slot for PCI driver
; [NEAREST TO BP]
initialize_pci_driver:
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
.body:
mov ebx, [ebp - 4]
push ebp
mov ebp, esp
push ebx
push dword 0 ; No Maximum Device Limit
call pci_enumerate
mov esp, ebp
pop ebp
mov ebx, [ebp - 4]
add ebx, PCI_DEVICE_COUNT_OFFSET
push ebp
mov ebp, esp
push dword PCI_DEVICE_COUNT_OFFSET
push dword 2
push dword 0
push dword 0
call write_hexadecimal_string
mov esp, ebp
pop ebp
; todo(wip): Remove this once the PCI Driver
; is debugged completely.
cli
hlt
.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
.storage:
dd 0
%include "drivers/pci/enumerate.asm"