iPXE
Data Structures | Functions
efi_pci.h File Reference

EFI driver interface. More...

#include <ipxe/pci.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/PciIo.h>

Go to the source code of this file.

Data Structures

struct  efi_pci_device
 An EFI PCI device. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static EFIAPI uint64_t LShiftU64 (UINT64 value, UINTN shift)
 
int efipci_info (EFI_HANDLE device, struct efi_pci_device *efipci)
 Get EFI PCI device information. More...
 

Detailed Description

EFI driver interface.

Definition in file efi_pci.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ LShiftU64()

static EFIAPI uint64_t LShiftU64 ( UINT64  value,
UINTN  shift 
)
inlinestatic

Definition at line 17 of file efi_pci.h.

17  {
18  return ( value << shift );
19 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13

References value.

◆ efipci_info()

int efipci_info ( EFI_HANDLE  device,
struct efi_pci_device efipci 
)

Get EFI PCI device information.

Parameters
deviceEFI device handle
efipciEFI PCI device to fill in
Return values
rcReturn status code

Definition at line 705 of file efi_pci.c.

705  {
706  EFI_PCI_IO_PROTOCOL *pci_io;
707  UINTN pci_segment, pci_bus, pci_dev, pci_fn;
708  unsigned int busdevfn;
709  EFI_STATUS efirc;
710  int rc;
711 
712  /* See if device is a PCI device */
714  &pci_io ) ) != 0 ) {
715  DBGCP ( device, "EFIPCI %s cannot open PCI protocols: %s\n",
716  efi_handle_name ( device ), strerror ( rc ) );
717  return rc;
718  }
719  efipci->io = pci_io;
720 
721  /* Get PCI bus:dev.fn address */
722  if ( ( efirc = pci_io->GetLocation ( pci_io, &pci_segment, &pci_bus,
723  &pci_dev, &pci_fn ) ) != 0 ) {
724  rc = -EEFI ( efirc );
725  DBGC ( device, "EFIPCI %s could not get PCI location: %s\n",
726  efi_handle_name ( device ), strerror ( rc ) );
727  return rc;
728  }
729  busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
730  pci_init ( &efipci->pci, busdevfn );
731  dma_init ( &efipci->pci.dma, &efipci_dma_operations );
732  DBGCP ( device, "EFIPCI " PCI_FMT " is %s\n",
733  PCI_ARGS ( &efipci->pci ), efi_handle_name ( device ) );
734 
735  /* Try to enable I/O cycles, memory cycles, and bus mastering.
736  * Some platforms will 'helpfully' report errors if these bits
737  * can't be enabled (for example, if the card doesn't actually
738  * support I/O cycles). Work around any such platforms by
739  * enabling bits individually and simply ignoring any errors.
740  */
747 
748  /* Populate PCI device */
749  if ( ( rc = pci_read_config ( &efipci->pci ) ) != 0 ) {
750  DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI "
751  "configuration: %s\n",
752  PCI_ARGS ( &efipci->pci ), strerror ( rc ) );
753  return rc;
754  }
755 
756  return 0;
757 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct dma_device dma
DMA device.
Definition: pci.h:215
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
struct pci_device pci
PCI device.
Definition: efi_pci.h:24
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:313
#define DBGC(...)
Definition: compiler.h:505
uint16_t busdevfn
PCI bus:dev.fn address.
Definition: ena.h:28
A hardware device.
Definition: device.h:77
#define EFI_PCI_IO_ATTRIBUTE_MEMORY
Enable the Memory decode bit in the PCI Config Header.
Definition: PciIo.h:61
EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes
Definition: PciIo.h:532
EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation
Definition: PciIo.h:531
#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER
Enable the DMA bit in the PCI Config Header.
Definition: PciIo.h:62
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
#define PCI_BUSDEVFN(segment, bus, slot, func)
Definition: pci_io.h:30
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:312
int pci_read_config(struct pci_device *pci)
Read PCI device configuration.
Definition: pci.c:269
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:444
UINT64 UINTN
Unsigned value of native width.
#define EFI_PCI_IO_ATTRIBUTE_IO
Enable the I/O decode bit in the PCI Config Header.
Definition: PciIo.h:60
Enable the attributes specified by the bits that are set in Attributes for this PCI controller.
Definition: PciIo.h:114
EFI_PCI_IO_PROTOCOL * io
PCI I/O protocol.
Definition: efi_pci.h:26
static __always_inline void dma_init(struct dma_device *dma, struct dma_operations *op)
Initialise DMA device.
Definition: dma.h:454
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:315
#define DBGCP(...)
Definition: compiler.h:539
static struct dma_operations efipci_dma_operations
EFI PCI DMA operations.
Definition: efi_pci.c:681
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
Definition: pci.h:341
The EFI_PCI_IO_PROTOCOL provides the basic Memory, I/O, PCI configuration, and DMA interfaces used to...
Definition: PciIo.h:519
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References _EFI_PCI_IO_PROTOCOL::Attributes, busdevfn, DBGC, DBGCP, pci_device::dma, dma_init(), EEFI, efi_handle_name(), efi_open, EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, EFI_PCI_IO_ATTRIBUTE_IO, EFI_PCI_IO_ATTRIBUTE_MEMORY, efi_pci_io_protocol_guid, efipci_dma_operations, EfiPciIoAttributeOperationEnable, _EFI_PCI_IO_PROTOCOL::GetLocation, efi_pci_device::io, NULL, efi_pci_device::pci, PCI_ARGS, PCI_BUSDEVFN, PCI_FMT, pci_init(), pci_read_config(), rc, and strerror().

Referenced by efi_bofm_start(), efi_bofm_supported(), efi_device_info_pci(), efipci_start(), and efipci_supported().