help about function pcibios_read_config_byte

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
micro
Member
Member
Posts: 27
Joined: Sun May 04, 2008 5:40 pm

help about function pcibios_read_config_byte

Post 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... :oops:
especially how does "lcall (%%esi)" works... :oops:
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: help about function pcibios_read_config_byte

Post 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 << 8)|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?!
micro
Member
Member
Posts: 27
Joined: Sun May 04, 2008 5:40 pm

Re: help about function pcibios_read_config_byte

Post 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) :oops:

now i see
a far call to the address 0x10:0x00000000

and this address "unsigned long address" is the function :P

thank you again.....
micro
Member
Member
Posts: 27
Joined: Sun May 04, 2008 5:40 pm

Re: help about function pcibios_read_config_byte

Post by micro »

i am back :oops:

"lcall (%%esi)" is a far call....
however, i really do not know how it work clearly....
i do know what the parameters do :oops: ,such as "EAX,BX..and so on"

anyone know about the informations about PCI interface with BIOS???? :oops:
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: help about function pcibios_read_config_byte

Post by Combuster »

I suggest you start by grabbing a copy of the Intel Manuals...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply