Page 1 of 1
help about function pcibios_read_config_byte
Posted: Wed Sep 24, 2008 2:35 am
by micro
Code: Select all
int pcibios_read_config_byte(unsigned char bus,
unsigned char device_fn, unsigned char where, unsigned char *value)
{
unsigned long ret;
unsigned long bx = (bus << 8) | device_fn;
__asm__("lcall (%%esi)\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
: "=c" (*value),
"=a" (ret)
: "1" (PCIBIOS_READ_CONFIG_BYTE),
"b" (bx),
"D" ((long) where),
"S" (&pci_indirect));
return (int) (ret & 0xff00) >> 8;
}
Code: Select all
static struct {
unsigned long address;
unsigned short segment;
} pci_indirect = { 0, KERNEL_CS };
KERNEL_CS =0x10
the code come from the driver of PCI, but i do not understand it clearly...
especially how does "lcall (%%esi)" works...
Re: help about function pcibios_read_config_byte
Posted: Wed Sep 24, 2008 6:53 am
by JamesM
Hi,
Firstly, where did you get this code from?
Secondly, the code does a far call to the address 0x10:0x00000000, with "PCIBIOS_READ_CONFIG_BYTE" in eax, (bus <<
|device_fn in ebx, the "where" argument in edi (which I assume is the pci config space offset). It expects, on return from the far call, ecx to hold the byte returned, and eax to hold a return value.
The "jc" is a jump conditional, but I can't remember... - carry? that would make sense. If the carry bit is NOT set, the xor instruction is executed, which clears ah.
The return value of the function is (ret&0xFF00)>>8, which extracts the value of ah out of the eax register.
Again, where did you get it?!
Re: help about function pcibios_read_config_byte
Posted: Wed Sep 24, 2008 7:43 am
by micro
thank you for you help
the code come from linux kernel 1.3xxxx , it is the PCI driver (use the BIOS method scan bus)
now i see
a far call to the address 0x10:0x00000000
and this address "unsigned long address" is the function
thank you again.....
Re: help about function pcibios_read_config_byte
Posted: Wed Sep 24, 2008 9:09 pm
by micro
i am back
"lcall (%%esi)" is a far call....
however, i really do not know how it work clearly....
i do know what the parameters do
,such as "EAX,BX..and so on"
anyone know about the informations about PCI interface with BIOS????
Re: help about function pcibios_read_config_byte
Posted: Thu Sep 25, 2008 4:05 am
by Combuster
I suggest you start by grabbing a copy of the Intel Manuals...