iPXE
Defines | Functions | Variables
efi_pci_api.h File Reference

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

Go to the source code of this file.

Defines

#define PCIAPI_PREFIX_efi   __efi_
#define EFIPCI_WIDTH_BYTE   0
#define EFIPCI_WIDTH_WORD   1
#define EFIPCI_WIDTH_DWORD   2
#define EFIPCI_LOCATION(_offset, _width)   ( (_offset) | ( (_width) << 16 ) )
#define EFIPCI_OFFSET(_location)   ( (_location) & 0xffff )
#define EFIPCI_WIDTH(_location)   ( (_location) >> 16 )

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int efipci_read (struct pci_device *pci, unsigned long location, void *value)
 Read from PCI configuration space.
int efipci_write (struct pci_device *pci, unsigned long location, unsigned long value)
 Write to PCI configuration space.
static __always_inline int PCIAPI_INLINE (efi, pci_num_bus)(void)
 Determine number of PCI buses within system.
static __always_inline int PCIAPI_INLINE (efi, pci_read_config_byte)(struct pci_device *pci
 Read byte from PCI configuration space via EFI.

Variables

static __always_inline int
unsigned int 
where

Detailed Description

iPXE PCI I/O API for EFI

Definition in file efi_pci_api.h.


Define Documentation

#define PCIAPI_PREFIX_efi   __efi_

Definition at line 15 of file efi_pci_api.h.

#define EFIPCI_WIDTH_BYTE   0

Definition at line 19 of file efi_pci_api.h.

#define EFIPCI_WIDTH_WORD   1

Definition at line 20 of file efi_pci_api.h.

#define EFIPCI_WIDTH_DWORD   2

Definition at line 21 of file efi_pci_api.h.

#define EFIPCI_LOCATION (   _offset,
  _width 
)    ( (_offset) | ( (_width) << 16 ) )

Definition at line 23 of file efi_pci_api.h.

#define EFIPCI_OFFSET (   _location)    ( (_location) & 0xffff )

Definition at line 25 of file efi_pci_api.h.

Referenced by efipci_address(), efipci_read(), and efipci_write().

#define EFIPCI_WIDTH (   _location)    ( (_location) >> 16 )

Definition at line 26 of file efi_pci_api.h.

Referenced by efipci_read(), and efipci_write().


Function Documentation

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

Read from PCI configuration space.

Parameters:
pciPCI device
locationEncoded offset and width
Return values:
valueValue
rcReturn status code

Definition at line 150 of file efi_pci.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, EEFI, efi_image_handle, efi_pci_root_bridge_io_protocol_guid, efi_systab, efipci_address(), EFIPCI_OFFSET, efipci_root(), EFIPCI_WIDTH, handle, _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Pci, PCI_ARGS, PCI_FMT, rc, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS::Read, root, and strerror().

                                {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
        EFI_HANDLE handle;
        EFI_STATUS efirc;
        int rc;

        /* Identify root bridge */
        if ( ( rc = efipci_root ( pci, &handle, &root ) ) != 0 )
                goto err_root;

        /* Read from configuration space */
        if ( ( efirc = root->Pci.Read ( root, EFIPCI_WIDTH ( location ),
                                        efipci_address ( pci, location ), 1,
                                        value ) ) != 0 ) {
                rc = -EEFI ( efirc );
                DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx "
                       "failed: %s\n", PCI_ARGS ( pci ),
                       EFIPCI_OFFSET ( location ), strerror ( rc ) );
                goto err_read;
        }

 err_read:
        bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
                            efi_image_handle, handle );
 err_root:
        return rc;
}
int efipci_write ( struct pci_device pci,
unsigned long  location,
unsigned long  value 
)

Write to PCI configuration space.

Parameters:
pciPCI device
locationEncoded offset and width
valueValue
Return values:
rcReturn status code

Definition at line 188 of file efi_pci.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, EEFI, efi_image_handle, efi_pci_root_bridge_io_protocol_guid, efi_systab, efipci_address(), EFIPCI_OFFSET, efipci_root(), EFIPCI_WIDTH, handle, _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Pci, PCI_ARGS, PCI_FMT, rc, root, strerror(), and EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS::Write.

                                         {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
        EFI_HANDLE handle;
        EFI_STATUS efirc;
        int rc;

        /* Identify root bridge */
        if ( ( rc = efipci_root ( pci, &handle, &root ) ) != 0 )
                goto err_root;

        /* Read from configuration space */
        if ( ( efirc = root->Pci.Write ( root, EFIPCI_WIDTH ( location ),
                                         efipci_address ( pci, location ), 1,
                                         &value ) ) != 0 ) {
                rc = -EEFI ( efirc );
                DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx "
                       "failed: %s\n", PCI_ARGS ( pci ),
                       EFIPCI_OFFSET ( location ), strerror ( rc ) );
                goto err_write;
        }

 err_write:
        bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
                            efi_image_handle, handle );
 err_root:
        return rc;
}
static __always_inline int PCIAPI_INLINE ( efi  ,
pci_num_bus   
) [inline, static]

Determine number of PCI buses within system.

Return values:
num_busNumber of buses

Definition at line 41 of file efi_pci_api.h.

                                            {
        /* EFI does not want us to scan the PCI bus ourselves */
        return 0;
}
static __always_inline int PCIAPI_INLINE ( efi  ,
pci_read_config_byte   
) [inline, static]

Read byte from PCI configuration space via EFI.

Parameters:
pciPCI device
whereLocation within PCI configuration space
valueValue read
Return values:
rcReturn status code

Variable Documentation

__always_inline int unsigned int where

Definition at line 56 of file efi_pci_api.h.