OK, but one more problem with the PCI BIOS on real PCs. When I call it I get a genral protection fault. Although I?ve setup the selectors!
This is my PCI init function:
Code: Select all
;----------------------------
init_pci:
call search_bios32
and eax,eax
jnz .end_error
call bios32_scan_pci_entry
and al,al
jnz .end_error
mov [pcibios_seg],ebx
mov [pcibios_size],ecx
mov [pcibios_offset],edx
mov eax,[pcibios_seg]
mov ebx,[pcibios_size]
mov ecx,9ah
mov edx,0c0h
call add_gdt_entry
mov [pcibios_code],eax
mov eax,[pcibios_seg]
mov ebx,[pcibios_size]
mov ecx,92h
mov edx,0c0h
call add_gdt_entry
mov [pcibios_data],eax
mov eax,[pcibios_code]
mov [.code],ax
mov eax,[pcibios_offset]
mov [.offset],eax
mov ax,[pcibios_data]
mov ds,ax
mov al,1
mov ah,0b1h
db 66h,9ah
.code
dw 0
.offset
dd 0
; call far [pcibios_code]:[pcibios_offset]
.end
xor eax,eax
ret
.end_error
mov eax,1
ret
;----------------------------
And this is my add GDT entry function:
Code: Select all
;----------------------------
; Input:
; EAX - base address
; EBX - limit
; ECX - access byte
; EDX - flags
; Output:
; EAX - 0 -> GDT is full / -> # of entry in the GDT
add_gdt_entry:
sgdt [GDTR]
xor edi,edi
mov di,[GDTR]
cmp di,0ffffh
je .end_error
add edi,3000h
mov [edi],bx
mov [edi + 2],ax
shr eax,16
mov [edi + 4],al
mov [edi + 5],cl
shr ebx,16
shl edx,4
or ebx,edx
mov [edi + 6],bl
mov [edi + 7],ah
xor eax,eax
mov ax,[GDTR]
shr ax,3
add word[GDTR],8
lgdt [GDTR]
.end
ret
.end_error
mov eax,1
ret
;----------------------------