Hi,
iocoder wrote:is there a way to detect whether there is a PCI or not??
Yes (sort of).
Normally you'd want to know if PCI exists, and if it does, which mechanism you have to use to access PCI configuration space. There are 4 different cases:
- No PCI at all
- mechanism #1
- mechanism #2
- PCI Express memory mapped configuration space (with mechanism #1 too, for backward compatibility)
Start by checking for the existence of an MCFG ACPI table. If this table exists then you've got PCI Express memory mapped configuration space (with mechanism #1 too).
Otherwise, if the system is UEFI you could see if "EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL" exists and either assume mechanism #1 (given that you know PCI Express isn't supported) or attempt to actually use "EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL" functions to get better information.
For "PC BIOS" try the
PCI BIOS v2.0c+ - INSTALLATION CHECK BIOS function. If this is supported then it'll give you the information you need. If it's not supported it doesn't mean that there is no PCI though (only that there's no PCI BIOS functions).
After you've tried everything else, the next step is manual probing. Here's some code from a version of my OS:
Code: Select all
;Detect if mechanism #1 is supported
mov dx,0x0CF8
in eax,dx
mov ebx,eax
mov eax,0x80000000
out dx,eax
in eax,dx
cmp eax,0x80000000
jne .noMech1
mov eax,0x01
jmp .gotPCI
.noMech1:
mov eax,ebx
out dx, eax
;Detect if mechanism #2 is supported
mov dx,0x0CF8
in al,dx
mov bl,al
clr al
out dx,al
in al,dx
test al,al
jne .noPCI
mov dx,0x0CFA
in al,dx
mov bh,al
clr al
out dx,al
in al,dx
test al,al
jne .noPCI
mov eax,0x02
.gotPCI: ; Value in EAX will be 1 if mechanism #1 is supported, or 2 if mechanism #2 is supported
Cheers,
Brendan