pcibios.c File Reference

PCI configuration space access via PCI BIOS. More...

#include <stdint.h>
#include <gpxe/pci.h>
#include <realmode.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int pcibios_max_bus (void)
 Determine maximum PCI bus number within system.
int pcibios_read (struct pci_device *pci, uint32_t command, uint32_t *value)
 Read configuration space via PCI BIOS.
int pcibios_write (struct pci_device *pci, uint32_t command, uint32_t value)
 Write configuration space via PCI BIOS.
 PROVIDE_PCIAPI (pcbios, pci_max_bus, pcibios_max_bus)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_byte)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_word)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_dword)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_byte)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_word)
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_dword)


Detailed Description

PCI configuration space access via PCI BIOS.

Definition in file pcibios.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static int pcibios_max_bus ( void   )  [static]

Determine maximum PCI bus number within system.

Return values:
max_bus Maximum bus number

Definition at line 36 of file pcibios.c.

References __asm__(), PCIBIOS_INSTALLATION_CHECK, and REAL_CODE.

00036                                     {
00037         int discard_a, discard_D;
00038         uint8_t max_bus;
00039 
00040         __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00041                                            "int $0x1a\n\t"
00042                                            "jnc 1f\n\t"
00043                                            "xorw %%cx, %%cx\n\t"
00044                                            "\n1:\n\t" )
00045                                : "=c" ( max_bus ), "=a" ( discard_a ),
00046                                  "=D" ( discard_D )
00047                                : "a" ( PCIBIOS_INSTALLATION_CHECK >> 16 ),
00048                                  "D" ( 0 )
00049                                : "ebx", "edx" );
00050 
00051         return max_bus;
00052 }

int pcibios_read ( struct pci_device pci,
uint32_t  command,
uint32_t value 
)

Read configuration space via PCI BIOS.

Parameters:
pci PCI device
command PCI BIOS command
value Value read
Return values:
rc Return status code

Definition at line 62 of file pcibios.c.

References __asm__(), pci_device::bus, pci_device::devfn, PCI_BUSDEVFN, and REAL_CODE.

00062                                                                               {
00063         int discard_b, discard_D;
00064         int status;
00065 
00066         __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00067                                            "int $0x1a\n\t"
00068                                            "jnc 1f\n\t"
00069                                            "xorl %%eax, %%eax\n\t"
00070                                            "decl %%eax\n\t"
00071                                            "movl %%eax, %%ecx\n\t"
00072                                            "\n1:\n\t" )
00073                                : "=a" ( status ), "=b" ( discard_b ),
00074                                  "=c" ( *value ), "=D" ( discard_D )
00075                                : "a" ( command >> 16 ), "D" ( command ),
00076                                  "b" ( PCI_BUSDEVFN ( pci->bus, pci->devfn ) )
00077                                : "edx" );
00078 
00079         return ( ( status >> 8 ) & 0xff );
00080 }

int pcibios_write ( struct pci_device pci,
uint32_t  command,
uint32_t  value 
)

Write configuration space via PCI BIOS.

Parameters:
pci PCI device
command PCI BIOS command
value Value to be written
Return values:
rc Return status code

Definition at line 90 of file pcibios.c.

References __asm__(), pci_device::bus, pci_device::devfn, PCI_BUSDEVFN, and REAL_CODE.

00090                                                                               {
00091         int discard_b, discard_c, discard_D;
00092         int status;
00093 
00094         __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00095                                            "int $0x1a\n\t"
00096                                            "jnc 1f\n\t"
00097                                            "movb $0xff, %%ah\n\t"
00098                                            "\n1:\n\t" )
00099                                : "=a" ( status ), "=b" ( discard_b ),
00100                                  "=c" ( discard_c ), "=D" ( discard_D )
00101                                : "a" ( command >> 16 ), "D" ( command ),
00102                                  "b" ( PCI_BUSDEVFN ( pci->bus, pci->devfn ) ),
00103                                  "c" ( value )
00104                                : "edx" );
00105         
00106         return ( ( status >> 8 ) & 0xff );
00107 }

PROVIDE_PCIAPI ( pcbios  ,
pci_max_bus  ,
pcibios_max_bus   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_byte   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_word   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_dword   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_byte   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_word   
)

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_dword   
)


Generated on Tue Apr 6 20:01:13 2010 for gPXE by  doxygen 1.5.7.1