efi_pci.c File Reference

gPXE PCI I/O API for EFI More...

#include <errno.h>
#include <gpxe/pci.h>
#include <gpxe/efi/efi.h>
#include <gpxe/efi/Protocol/PciRootBridgeIo.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 EFI_REQUIRE_PROTOCOL (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL,&efipci)
static unsigned long efipci_address (struct pci_device *pci, unsigned long location)
int efipci_read (struct pci_device *pci, unsigned long location, void *value)
int efipci_write (struct pci_device *pci, unsigned long location, unsigned long value)
 PROVIDE_PCIAPI_INLINE (efi, pci_max_bus)
 PROVIDE_PCIAPI_INLINE (efi, pci_read_config_byte)
 PROVIDE_PCIAPI_INLINE (efi, pci_read_config_word)
 PROVIDE_PCIAPI_INLINE (efi, pci_read_config_dword)
 PROVIDE_PCIAPI_INLINE (efi, pci_write_config_byte)
 PROVIDE_PCIAPI_INLINE (efi, pci_write_config_word)
 PROVIDE_PCIAPI_INLINE (efi, pci_write_config_dword)

Variables

static
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
efipci
 PCI root bridge I/O protocol.


Detailed Description

gPXE PCI I/O API for EFI

Definition in file efi_pci.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

EFI_REQUIRE_PROTOCOL ( EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  ,
efipci 
)

static unsigned long efipci_address ( struct pci_device pci,
unsigned long  location 
) [static]

Definition at line 36 of file efi_pci.c.

References pci_device::bus, pci_device::devfn, EFI_PCI_ADDRESS, EFIPCI_OFFSET, PCI_FUNC, and PCI_SLOT.

Referenced by efipci_read(), and efipci_write().

00037                                                                {
00038         return EFI_PCI_ADDRESS ( pci->bus, PCI_SLOT ( pci->devfn ),
00039                                  PCI_FUNC ( pci->devfn ),
00040                                  EFIPCI_OFFSET ( location ) );
00041 }

int efipci_read ( struct pci_device pci,
unsigned long  location,
void *  value 
)

Definition at line 43 of file efi_pci.c.

References pci_device::bus, DBG, pci_device::devfn, efi_strerror(), efipci_address(), EFIPCI_OFFSET, EFIPCI_WIDTH, EIO, _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Pci, PCI_FUNC, PCI_SLOT, and EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS::Read.

00044                                 {
00045         EFI_STATUS efirc;
00046 
00047         if ( ( efirc = efipci->Pci.Read ( efipci, EFIPCI_WIDTH ( location ),
00048                                           efipci_address ( pci, location ), 1,
00049                                           value ) ) != 0 ) {
00050                 DBG ( "EFIPCI config read from %02x:%02x.%x offset %02lx "
00051                       "failed: %s\n", pci->bus, PCI_SLOT ( pci->devfn ),
00052                       PCI_FUNC ( pci->devfn ), EFIPCI_OFFSET ( location ),
00053                       efi_strerror ( efirc ) );
00054                 return -EIO;
00055         }
00056 
00057         return 0;
00058 }

int efipci_write ( struct pci_device pci,
unsigned long  location,
unsigned long  value 
)

Definition at line 60 of file efi_pci.c.

References pci_device::bus, DBG, pci_device::devfn, efi_strerror(), efipci_address(), EFIPCI_OFFSET, EFIPCI_WIDTH, EIO, _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Pci, PCI_FUNC, PCI_SLOT, and EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS::Write.

00061                                          {
00062         EFI_STATUS efirc;
00063 
00064         if ( ( efirc = efipci->Pci.Write ( efipci, EFIPCI_WIDTH ( location ),
00065                                            efipci_address ( pci, location ), 1,
00066                                            &value ) ) != 0 ) {
00067                 DBG ( "EFIPCI config write to %02x:%02x.%x offset %02lx "
00068                       "failed: %s\n", pci->bus, PCI_SLOT ( pci->devfn ),
00069                       PCI_FUNC ( pci->devfn ), EFIPCI_OFFSET ( location ),
00070                       efi_strerror ( efirc ) );
00071                 return -EIO;
00072         }
00073 
00074         return 0;
00075 }

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_max_bus   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_read_config_byte   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_read_config_word   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_read_config_dword   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_write_config_byte   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_write_config_word   
)

PROVIDE_PCIAPI_INLINE ( efi  ,
pci_write_config_dword   
)


Variable Documentation

PCI root bridge I/O protocol.

Definition at line 33 of file efi_pci.c.


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