BIOS32/PCI BIOS problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
FlashBurn

BIOS32/PCI BIOS problem

Post 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?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:BIOS32/PCI BIOS problem

Post by df »

have you got the latest bochs?

i know bochs has bios32 support
-- Stu --
FlashBurn

Re:BIOS32/PCI BIOS problem

Post by FlashBurn »

Yeah, I have the newest Bochs version and the newest BIOS version.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:BIOS32/PCI BIOS problem

Post 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...
-- Stu --
FlashBurn

Re:BIOS32/PCI BIOS problem

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:BIOS32/PCI BIOS problem

Post by df »

aah. did you setup a selector for it?
-- Stu --
FlashBurn

Re:BIOS32/PCI BIOS problem

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:BIOS32/PCI BIOS problem

Post 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....
-- Stu --
FlashBurn

Re:BIOS32/PCI BIOS problem

Post 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
;----------------------------
FlashBurn

Re:BIOS32/PCI BIOS problem

Post by FlashBurn »

Isn?t here anyone who could help me with that?!
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:BIOS32/PCI BIOS problem

Post by df »

my c code works.. so why your asm doesnt, i dunno...

::)
-- Stu --
FlashBurn

Re:BIOS32/PCI BIOS problem

Post 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"!
FlashBurn

Re:BIOS32/PCI BIOS problem

Post 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
;----------------------------
K.J.

Re:BIOS32/PCI BIOS problem

Post by K.J. »

You may need to enable the Boch's PCI controller(snoop around in the configuration menu).

K.J.
Post Reply