44 #define EINFO_EEFI_PCI \ 45 __einfo_uniqify ( EINFO_EPLATFORM, 0x01, \ 46 "Could not open PCI I/O protocol" ) 47 #define EINFO_EEFI_PCI_NOT_PCI \ 48 __einfo_platformify ( EINFO_EEFI_PCI, EFI_UNSUPPORTED, \ 50 #define EEFI_PCI_NOT_PCI __einfo_error ( EINFO_EEFI_PCI_NOT_PCI ) 51 #define EINFO_EEFI_PCI_IN_USE \ 52 __einfo_platformify ( EINFO_EEFI_PCI, EFI_ACCESS_DENIED, \ 53 "PCI device already has a driver" ) 54 #define EEFI_PCI_IN_USE __einfo_error ( EINFO_EEFI_PCI_IN_USE ) 55 #define EEFI_PCI( efirc ) \ 56 EPLATFORM ( EINFO_EEFI_PCI, efirc, \ 57 EEFI_PCI_NOT_PCI, EEFI_PCI_IN_USE ) 96 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot open %s: %s\n",
103 if ( ( efirc =
root->Configuration (
root, &
acpi.raw ) ) != 0 ) {
105 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot get configuration for " 128 DBGC2 ( pci,
"EFIPCI " PCI_FMT " found %04x:[%02x-%02x] via " 186 NULL, &num_handles, &handles ) ) != 0 ) {
188 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot locate root bridges: " 194 for ( i = 0 ; i < num_handles ; i++ ) {
242 memset ( &pci, 0,
sizeof ( pci ) );
267 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot open %s: %s\n",
284 unsigned long location ) {
316 DBGC ( pci,
"EFIPCI " PCI_FMT " config read from offset %02lx " 334 unsigned long value ) {
349 DBGC ( pci,
"EFIPCI " PCI_FMT " config write to offset %02lx " 385 if ( ( efirc =
root->Configuration (
root, &
u.raw ) ) != 0 ) {
387 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot get configuration: " 406 DBGC2 ( pci,
"EFIPCI " PCI_FMT " found range [%08llx,%08llx) " 420 DBGC ( pci,
"EFIPCI " PCI_FMT " %08lx+%zx is not within " 421 "root bridge address space\n",
495 &mapping ) ) != 0 ) {
497 DBGC ( pci,
"EFIPCI " PCI_FMT " cannot map %p+%zx: " 513 DBGC ( pci,
"EFIPCI " PCI_FMT " attempted split mapping for " 531 pci_io->
Unmap ( pci_io, mapping );
590 &
addr, 0 ) ) != 0 ) {
592 DBGC ( pci,
"EFIPCI " PCI_FMT " could not allocate %zd bytes: " 665 is64 = ( ( ( (
uint64_t ) mask ) + 1 ) == 0 );
671 DBGC ( pci,
"EFIPCI " PCI_FMT " could not %sable DAC: %s\n",
672 PCI_ARGS ( pci ), ( is64 ?
"en" :
"dis" ),
706 UINTN pci_segment, pci_bus, pci_dev, pci_fn;
714 DBGCP (
device,
"EFIPCI %s cannot open PCI protocols: %s\n",
721 if ( ( efirc = pci_io->
GetLocation ( pci_io, &pci_segment, &pci_bus,
722 &pci_dev, &pci_fn ) ) != 0 ) {
724 DBGC (
device,
"EFIPCI %s could not get PCI location: %s\n",
750 "configuration: %s\n",
816 DBGC (
device,
"EFIPCI %s could not exclude drivers: %s\n",
836 efipci =
zalloc (
sizeof ( *efipci ) );
848 &efipci->
io ) ) != 0 ) {
849 DBGC (
device,
"EFIPCI %s could not open PCI device: %s\n",
859 goto err_find_driver;
#define PCI_FUNC(busdevfn)
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
uint32_t start
Starting bus:dev.fn address.
#define PCI_BUS(busdevfn)
struct arbelprm_rc_send_wqe rc
#define DMA_TX
Device will read data from host memory.
#define EFI_PCI_ADDRESS(bus, dev, func, reg)
struct dma_device dma
DMA device.
static void efipci_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
struct pci_range range
PCI bus:dev.fn address range.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
int efipci_info(EFI_HANDLE device, struct efi_pci_device *efipci)
Get EFI PCI device information.
static int efipci_dma_map(struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len, int flags)
Map buffer for DMA.
int pci_find_driver(struct pci_device *pci)
Find driver for PCI device.
struct dma_device * dma
DMA device (if unmapping is required)
struct pci_device pci
PCI device.
struct stp_switch root
Root switch.
uint32_t class
Device class.
int pci_can_probe(struct pci_device *pci)
Check if PCI bus probing is allowed.
#define list_add(new, head)
Add a new entry to the head of a list.
128 bit buffer containing a unique identifier value.
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
static int efipci_root_open(struct pci_device *pci, EFI_HANDLE *handle, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root)
Open EFI PCI root bridge I/O protocol for ephemeral use.
A read operation from system memory by a bus master.
static int efipci_start(struct efi_device *efidev)
Attach driver to device.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define ACPI_QWORD_ADDRESS_SPACE_RESOURCE
An ACPI QWORD address space resource descriptor.
#define DMA_RX
Device will write data to host memory.
#define PCI_HEADER_TYPE_MASK
Header type mask.
EFI_PCI_IO_PROTOCOL_MAP Map
#define ENOENT
No such file or directory.
unsigned long long uint64_t
EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer
int efipci_write(struct pci_device *pci, unsigned long location, unsigned long value)
Write to PCI configuration space.
#define EFIPCI_OFFSET(_location)
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define DBGC_EFI_OPENERS(...)
EFI_HANDLE device
EFI device handle.
#define DMA_BI
Device will both read data from and write data to host memory.
UINT64 EFI_PHYSICAL_ADDRESS
64-bit physical memory address.
struct device * parent
Bus device.
static __always_inline void unsigned long bus_addr
struct device dev
Generic device.
static union acpi_resource * acpi_resource_next(union acpi_resource *res)
Get next ACPI resource descriptor.
#define ENOTSUP
Operation not supported.
uint32_t start
Starting offset.
static unsigned int acpi_resource_tag(union acpi_resource *res)
Get ACPI resource tag.
#define list_del(list)
Delete an entry from a list.
uint16_t busdevfn
PCI bus:dev.fn address.
#define ENOMEM
Not enough space.
#define EFI_PCI_IO_ATTRIBUTE_MEMORY
Enable the Memory decode bit in the PCI Config Header.
static signed char phys[4]
PROVIDE_PCIAPI_RUNTIME(efi, PCIAPI_PRIORITY_EFI)
void * efipci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
uint16_t device
Device ID.
#define PCI_HEADER_TYPE_NORMAL
Normal header.
PROVIDE_PCIAPI(efi, pci_discover, efipci_discover)
static int efipci_discover_any(struct pci_device *pci, struct pci_range *range, EFI_HANDLE *handle)
Find closest bus:dev.fn address range within any root bridge.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
void efi_close_by_driver(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for persistent use by a driver.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
pseudo_bit_t value[0x00020]
#define __unused
Declare a variable or data structure as unused.
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
#define efi_open_by_driver(handle, protocol, interface)
Open protocol for persistent use by a driver.
EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION
A PCI bus:dev.fn address range.
EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes
EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation
static unsigned int count
Number of entries.
#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER
Enable the DMA bit in the PCI Config Header.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void efipci_stop(struct efi_device *efidev)
Detach driver from device.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
#define ACPI_ADDRESS_TYPE_BUS
A bus number address space type.
static int efipci_exclude(EFI_HANDLE device)
Exclude existing drivers.
#define PCI_BUSDEVFN(segment, bus, slot, func)
EFI_PCI_IO_PROTOCOL_UNMAP Unmap
uint8_t hdrtype
Header type.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
physaddr_t offset
Address offset.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
void * zalloc(size_t size)
Allocate cleared memory.
#define PCI_FMT
PCI device debug message format.
#define PCI_SLOT(busdevfn)
struct list_head siblings
Devices on the same bus.
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
uint32_t addr
Buffer address.
int pci_read_config(struct pci_device *pci)
Read PCI device configuration.
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
int efi_driver_exclude(EFI_HANDLE device, EFI_GUID *protocol)
Try to disconnect an existing EFI driver.
#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE
Clear for PCI controllers that can not genrate a DAC.
void pci_remove(struct pci_device *pci)
Remove a PCI device.
#define ACPI_END_RESOURCE
An ACPI end resource descriptor.
struct efi_driver efipci_driver __efi_driver(EFI_DRIVER_HARDWARE)
EFI PCI driver.
static int efipci_supported(EFI_HANDLE device)
Check to see if driver supports a device.
UINT64 UINTN
Unsigned value of native width.
Disable the attributes specified by the bits that are set in Attributes for this PCI controller.
Provides both read and write access to system memory by both the processor and a bus master.
#define EFI_PCI_IO_ATTRIBUTE_IO
Enable the I/O decode bit in the PCI Config Header.
#define VOID
Undeclared type.
An ACPI resource descriptor.
unsigned long long UINT64
unsigned int count
Number of bus:dev.fn addresses within this range.
EFI_PCI_IO_PROTOCOL_OPERATION
uint16_t vendor
Vendor ID.
PROVIDE_PCIAPI_INLINE(efi, pci_can_probe)
Enable the attributes specified by the bits that are set in Attributes for this PCI controller.
#define PCIAPI_PRIORITY_EFI
EFI PCI I/O protocols.
void pci_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
EFI_PCI_IO_PROTOCOL * io
PCI I/O protocol.
#define EFI_DRIVER_HARDWARE
Hardware drivers.
Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are used to abstract acces...
unsigned int mapped
Total number of mappings (for debugging)
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
static uint16_t struct vmbus_xfer_pages_operations * op
unsigned int allocated
Total number of allocations (for debugging)
static __always_inline void dma_init(struct dma_device *dma, struct dma_operations *op)
Initialise DMA device.
#define EFIPCI_WIDTH(_location)
static __always_inline int struct dma_mapping * map
int(* map)(struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len, int flags)
Map buffer for DMA.
#define ENOTTY
Inappropriate I/O control operation.
#define ACPI_ADDRESS_TYPE_MEM
A memory address space type.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct list_head children
Devices attached to this device.
PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.
void * token
Platform mapping token.
#define PCI_ARGS(pci)
PCI device debug message arguments.
struct pci_device_id * id
Driver device ID.
EFI_GUID efi_pci_root_bridge_io_protocol_guid
PCI root bridge I/O protocol GUID.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
static int efipci_discover_one(struct pci_device *pci, EFI_HANDLE handle, struct pci_range *range)
Find closest bus:dev.fn address range within a root bridge.
Allocate any available range of pages that satisfies the request.
uint32_t end
Ending offset.
Retrieve the set of handles from the handle database that support a specified protocol.
EFI_SYSTEM_TABLE * efi_systab
static struct dma_operations efipci_dma_operations
EFI PCI DMA operations.
uint16_t protocol
Protocol ID.
A write operation from system memory by a bus master.
uint16_t offset
Offset to command line.
static void efipci_dma_set_mask(struct dma_device *dma, physaddr_t mask)
Set addressable space mask.
The data portions of a loaded Boot Serves Driver, and the default data allocation type used by a Boot...
EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer
static unsigned long efipci_address(struct pci_device *pci, unsigned long location)
Calculate EFI PCI configuration space address.
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration, and DMA interfaces that a dri...
static void efipci_dma_unmap(struct dma_device *dma, struct dma_mapping *map, size_t len __unused)
Unmap buffer.
#define le64_to_cpu(value)
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
The EFI_PCI_IO_PROTOCOL provides the basic Memory, I/O, PCI configuration, and DMA interfaces used to...
uint64_t tag
Identity tag.
struct device dev
Generic device.
static void efipci_dma_free(struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
#define NULL
NULL pointer (VOID *)
int pci_probe(struct pci_device *pci)
Probe a PCI device.
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
static void * efipci_dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align __unused)
Allocate and map DMA-coherent buffer.
int efipci_read(struct pci_device *pci, unsigned long location, void *value)
Read from PCI configuration space.
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
void * memset(void *dest, int character, size_t len) __nonnull
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.