Page 1 of 1
BIOS32/PCI BIOS problem
Posted: Thu Apr 03, 2003 7:33 am
by FlashBurn
I?ve ported the example from the os-faq to assembler. So I these 2 functions:
Code: Select all
;----------------------------
; Output:
; EAX - 0 -> found / 1 -> not found
search_bios32:
mov esi,0e0000h
.loop
cmp esi,100000h
je .end_error
mov eax,[esi]
cmp eax,5f32335fh
je .end_loop
add esi,10h
jmp .loop
.end_loop
mov edi,bios32_struc
mov ecx,4
rep movsd
.end
xor eax,eax
ret
.end_error
mov eax,1
ret
;----------------------------
;----------------------------
bios32_scan_pci_entry:
push ebp
mov eax,49435024h
xor ebx,ebx
mov ebp,[bios32_struc + 4]
push cs
call ebp
pop ebp
.end
ret
;----------------------------
So I start Bochs for testing and call "search_bios32" and all things go well. But when I call then "bios32_scan_pci_entry" I get 80h back, which means "unknown service identifier". On a real PC I get 0h back. What made I wrong?
Re:BIOS32/PCI BIOS problem
Posted: Thu Apr 03, 2003 11:26 am
by df
have you got the latest bochs?
i know bochs has bios32 support
Re:BIOS32/PCI BIOS problem
Posted: Thu Apr 03, 2003 12:29 pm
by FlashBurn
Yeah, I have the newest Bochs version and the newest BIOS version.
Re:BIOS32/PCI BIOS problem
Posted: Thu Apr 03, 2003 2:53 pm
by df
try the following
Code: Select all
;----------------------------
; Output:
; EAX - 0 -> found / 1 -> not found
search_bios32:
mov esi,0C0000h
.loop
cmp esi,100000h
je .end_error
cmp [esi],5f32335fh
je .end_loop
add esi,4h
jmp .loop
.end_loop
mov edi,bios32_struc
mov ecx,4
rep movsd
.end
xor eax,eax
ret
.end_error
mov eax,1
ret
this starts looking at 0xC0000 instead of 0xE0000, and increments in 4 byte blocks instead of 16byte paragraphs...
Re:BIOS32/PCI BIOS problem
Posted: Fri Apr 04, 2003 12:41 am
by FlashBurn
This function isn?t the problem. Because I find the BIOS32 and then I call it with the parameters for the PCI BIOS. There I get back that there isn?t a PCI BIOS.
Re:BIOS32/PCI BIOS problem
Posted: Sat Apr 05, 2003 1:42 pm
by df
aah. did you setup a selector for it?
Re:BIOS32/PCI BIOS problem
Posted: Sat Apr 05, 2003 2:38 pm
by FlashBurn
Correct me if I?m wrong. But For this call I needn?t to setup a selector, because I get the selector from this call, which I need for the PCi BIOS call! And the function gives me 80h back, which means that there is no PCI BIOS.
Re:BIOS32/PCI BIOS problem
Posted: Sat Apr 05, 2003 3:10 pm
by df
hm ok. yeah.
maybe its returning 80 because it does not infact have a valid PCI bios32 call interface, but only a bios32 data block....
Re:BIOS32/PCI BIOS problem
Posted: Sat Apr 05, 2003 4:51 pm
by FlashBurn
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
;----------------------------
Re:BIOS32/PCI BIOS problem
Posted: Mon Apr 07, 2003 8:52 am
by FlashBurn
Isn?t here anyone who could help me with that?!
Re:BIOS32/PCI BIOS problem
Posted: Mon Apr 07, 2003 11:20 am
by df
my c code works.. so why your asm doesnt, i dunno...
::)
Re:BIOS32/PCI BIOS problem
Posted: Mon Apr 07, 2003 11:33 am
by FlashBurn
Yeah, on a real PC this codes works ,too. But when I then call the PCI BIOS with the selectors I get a "General Protection Fault"!
Re:BIOS32/PCI BIOS problem
Posted: Fri Apr 11, 2003 12:39 pm
by FlashBurn
I corrected my code a little bit, but it is still not working. I still get a general protection fault!
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 [.selector],ax
mov eax,[pcibios_offset]
mov [.offset],eax
mov eax,[pcibios_data]
mov ds,ax
mov al,1
mov ah,0b1h
db 9ah
.offset
dd 0
.selector
dw 0
; call far [pcibios_code]:[pcibios_offset]
.end
xor eax,eax
ret
.end_error
mov eax,1
ret
;----------------------------
Re:BIOS32/PCI BIOS problem
Posted: Fri Apr 11, 2003 9:00 pm
by K.J.
You may need to enable the Boch's PCI controller(snoop around in the configuration menu).
K.J.