|
iPXE
|
iPXE PCI I/O API for EFI More...
#include <stdlib.h>#include <string.h>#include <errno.h>#include <ipxe/pci.h>#include <ipxe/acpi.h>#include <ipxe/efi/efi.h>#include <ipxe/efi/efi_pci.h>#include <ipxe/efi/efi_driver.h>#include <ipxe/efi/Protocol/PciIo.h>#include <ipxe/efi/Protocol/PciRootBridgeIo.h>Go to the source code of this file.
Macros | |
| #define | EINFO_EEFI_PCI |
| #define | EINFO_EEFI_PCI_NOT_PCI |
| #define | EEFI_PCI_NOT_PCI __einfo_error ( EINFO_EEFI_PCI_NOT_PCI ) |
| #define | EINFO_EEFI_PCI_IN_USE |
| #define | EEFI_PCI_IN_USE __einfo_error ( EINFO_EEFI_PCI_IN_USE ) |
| #define | EEFI_PCI(efirc) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| 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. | |
| 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. | |
| static void | efipci_discover (uint32_t busdevfn, struct pci_range *range) |
| Find next PCI bus:dev.fn address range in system. | |
| 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. | |
| static unsigned long | efipci_address (struct pci_device *pci, unsigned long location) |
| Calculate EFI PCI configuration space address. | |
| 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. | |
| void * | efipci_ioremap (struct pci_device *pci, unsigned long bus_addr, size_t len) |
| Map PCI bus address as an I/O address. | |
| PROVIDE_PCIAPI_INLINE (efi, pci_can_probe) | |
| PROVIDE_PCIAPI (efi, pci_discover, efipci_discover) | |
| 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) | |
| PROVIDE_PCIAPI (efi, pci_ioremap, efipci_ioremap) | |
| PROVIDE_PCIAPI_RUNTIME (efi, PCIAPI_PRIORITY_EFI) | |
| static int | efipci_dma_map (struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len, int flags) |
| Map buffer for DMA. | |
| static void | efipci_dma_unmap (struct dma_device *dma, struct dma_mapping *map, size_t len __unused) |
| Unmap buffer. | |
| 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. | |
| static void | efipci_dma_free (struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len) |
| Unmap and free DMA-coherent buffer. | |
| static void | efipci_dma_set_mask (struct dma_device *dma, physaddr_t mask) |
| Set addressable space mask. | |
| int | efipci_info (EFI_HANDLE device, struct efi_pci_device *efipci) |
| Get EFI PCI device information. | |
| static int | efipci_supported (EFI_HANDLE device) |
| Check to see if driver supports a device. | |
| static int | efipci_exclude (EFI_HANDLE device) |
| Exclude existing drivers. | |
| static int | efipci_start (struct efi_device *efidev) |
| Attach driver to device. | |
| static void | efipci_stop (struct efi_device *efidev) |
| Detach driver from device. | |
| struct efi_driver efipci_driver | __efi_driver (EFI_DRIVER_HARDWARE) |
| EFI PCI driver. | |
Variables | |
| static struct dma_operations | efipci_dma_operations |
| EFI PCI DMA operations. | |
iPXE PCI I/O API for EFI
Definition in file efi_pci.c.
| #define EINFO_EEFI_PCI |
Definition at line 45 of file efi_pci.c.
| #define EINFO_EEFI_PCI_NOT_PCI |
Definition at line 48 of file efi_pci.c.
| #define EEFI_PCI_NOT_PCI __einfo_error ( EINFO_EEFI_PCI_NOT_PCI ) |
| #define EINFO_EEFI_PCI_IN_USE |
| #define EEFI_PCI_IN_USE __einfo_error ( EINFO_EEFI_PCI_IN_USE ) |
| #define EEFI_PCI | ( | efirc | ) |
Definition at line 56 of file efi_pci.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
static |
Find closest bus:dev.fn address range within a root bridge.
| pci | Starting PCI device |
| handle | EFI PCI root bridge handle |
| range | PCI bus:dev.fn address range to fill in |
| rc | Return status code |
Definition at line 75 of file efi_pci.c.
References acpi, ACPI_ADDRESS_TYPE_BUS, ACPI_END_RESOURCE, ACPI_QWORD_ADDRESS_SPACE_RESOURCE, acpi_resource_next(), acpi_resource_tag(), pci_device::busdevfn, count, DBGC, DBGC2, EEFI, EFI_HANDLE, efi_handle_name(), efi_open, efi_pci_root_bridge_io_protocol_guid, handle, index, le64_to_cpu, PCI_ARGS, PCI_BUS, PCI_BUSDEVFN, PCI_FMT, range, raw, rc, root, start, strerror(), and tag.
Referenced by efipci_discover_any().
|
static |
Find closest bus:dev.fn address range within any root bridge.
| pci | Starting PCI device |
| range | PCI bus:dev.fn address range to fill in |
| handle | PCI root bridge I/O handle to fill in |
| rc | Return status code |
Definition at line 166 of file efi_pci.c.
References pci_device::busdevfn, ByProtocol, DBGC, EEFI, EFI_HANDLE, efi_pci_root_bridge_io_protocol_guid, efi_systab, efipci_discover_one(), ENOENT, EFI_BOOT_SERVICES::FreePool, handle, index, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, PCI_ARGS, PCI_FMT, range, rc, strerror(), and tmp.
Referenced by efipci_discover(), and efipci_root_open().
Find next PCI bus:dev.fn address range in system.
| busdevfn | Starting PCI bus:dev.fn address |
| range | PCI bus:dev.fn address range to fill in |
Definition at line 238 of file efi_pci.c.
References busdevfn, EFI_HANDLE, efipci_discover_any(), handle, memset(), pci_init(), and range.
Referenced by PROVIDE_PCIAPI().
|
static |
Open EFI PCI root bridge I/O protocol for ephemeral use.
| pci | PCI device |
| handle | EFI PCI root bridge handle |
| root | EFI PCI root bridge I/O protocol, or NULL if not found |
| rc | Return status code |
Definition at line 256 of file efi_pci.c.
References pci_device::busdevfn, DBGC, EFI_HANDLE, efi_handle_name(), efi_open, efi_pci_root_bridge_io_protocol_guid, efipci_discover_any(), ENOENT, handle, PCI_ARGS, PCI_FMT, range, rc, root, and strerror().
Referenced by efipci_ioremap(), efipci_read(), and efipci_write().
|
static |
Calculate EFI PCI configuration space address.
| pci | PCI device |
| location | Encoded offset and width |
| address | EFI PCI address |
Definition at line 290 of file efi_pci.c.
References pci_device::busdevfn, EFI_PCI_ADDRESS, EFIPCI_OFFSET, PCI_BUS, PCI_FUNC, and PCI_SLOT.
Referenced by efipci_read(), and efipci_write().
| int efipci_read | ( | struct pci_device * | pci, |
| unsigned long | location, | ||
| void * | value ) |
Read from PCI configuration space.
| pci | PCI device |
| location | Encoded offset and width |
| value | Value |
| rc | Return status code |
Definition at line 307 of file efi_pci.c.
References DBGC, EEFI, EFI_HANDLE, efipci_address(), EFIPCI_OFFSET, efipci_root_open(), EFIPCI_WIDTH, handle, PCI_ARGS, PCI_FMT, rc, root, strerror(), and value.
| int efipci_write | ( | struct pci_device * | pci, |
| unsigned long | location, | ||
| unsigned long | value ) |
Write to PCI configuration space.
| pci | PCI device |
| location | Encoded offset and width |
| value | Value |
| rc | Return status code |
Definition at line 340 of file efi_pci.c.
References DBGC, EEFI, EFI_HANDLE, efipci_address(), EFIPCI_OFFSET, efipci_root_open(), EFIPCI_WIDTH, handle, PCI_ARGS, PCI_FMT, rc, root, strerror(), and value.
Referenced by PCIAPI_INLINE(), PCIAPI_INLINE(), and PCIAPI_INLINE().
| void * efipci_ioremap | ( | struct pci_device * | pci, |
| unsigned long | bus_addr, | ||
| size_t | len ) |
Map PCI bus address as an I/O address.
| bus_addr | PCI bus address |
| len | Length of region |
| io_addr | I/O address, or NULL on error |
Definition at line 372 of file efi_pci.c.
References ACPI_ADDRESS_TYPE_MEM, ACPI_END_RESOURCE, ACPI_QWORD_ADDRESS_SPACE_RESOURCE, acpi_resource_next(), acpi_resource_tag(), bus_addr, DBGC, DBGC2, EEFI, EFI_HANDLE, efipci_root_open(), end, handle, ioremap(), le64_to_cpu, len, offset, PCI_ARGS, PCI_FMT, raw, rc, root, start, strerror(), tag, and u.
Referenced by PROVIDE_PCIAPI().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_can_probe | ) |
References pci_can_probe().
| PROVIDE_PCIAPI | ( | efi | , |
| pci_discover | , | ||
| efipci_discover | ) |
References efipci_discover(), and pci_discover().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_read_config_byte | ) |
References pci_read_config_byte().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_read_config_word | ) |
References pci_read_config_word().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_read_config_dword | ) |
References pci_read_config_dword().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_write_config_byte | ) |
References pci_write_config_byte().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_write_config_word | ) |
References pci_write_config_word().
| PROVIDE_PCIAPI_INLINE | ( | efi | , |
| pci_write_config_dword | ) |
References pci_write_config_dword().
| PROVIDE_PCIAPI | ( | efi | , |
| pci_ioremap | , | ||
| efipci_ioremap | ) |
References efipci_ioremap(), and pci_ioremap().
| PROVIDE_PCIAPI_RUNTIME | ( | efi | , |
| PCIAPI_PRIORITY_EFI | ) |
References PCIAPI_PRIORITY_EFI.
|
static |
Map buffer for DMA.
| dma | DMA device |
| map | DMA mapping to fill in |
| addr | Buffer address |
| len | Length of buffer |
| flags | Mapping flags |
| rc | Return status code |
Definition at line 465 of file efi_pci.c.
References addr, assert, bus, container_of, count, DBG_LOG, DBGC, dma(), pci_device::dma, DMA_RX, DMA_TX, EEFI, EfiPciIoOperationBusMasterCommonBuffer, EfiPciIoOperationBusMasterRead, EfiPciIoOperationBusMasterWrite, ENOTSUP, flags, efi_pci_device::io, len, _EFI_PCI_IO_PROTOCOL::Map, map, NULL, op, efi_pci_device::pci, PCI_ARGS, PCI_FMT, phys, rc, strerror(), _EFI_PCI_IO_PROTOCOL::Unmap, and VOID.
Referenced by efipci_dma_alloc().
|
static |
Unmap buffer.
| dma | DMA device |
| map | DMA mapping |
| len | Used length |
Definition at line 550 of file efi_pci.c.
References __unused, container_of, DBG_LOG, dma(), pci_device::dma, efi_pci_device::io, len, map, NULL, efi_pci_device::pci, and _EFI_PCI_IO_PROTOCOL::Unmap.
Referenced by efipci_dma_alloc(), and efipci_dma_free().
|
static |
Allocate and map DMA-coherent buffer.
| dma | DMA device |
| map | DMA mapping to fill in |
| len | Length of buffer |
| align | Physical alignment |
| addr | Buffer address, or NULL on error |
Definition at line 579 of file efi_pci.c.
References __unused, addr, AllocateAnyPages, _EFI_PCI_IO_PROTOCOL::AllocateBuffer, container_of, DBG_LOG, DBGC, dma(), pci_device::dma, DMA_BI, EEFI, EFI_PAGE_SIZE, EfiBootServicesData, efipci_dma_map(), efipci_dma_unmap(), _EFI_PCI_IO_PROTOCOL::FreeBuffer, efi_pci_device::io, len, map, memset(), NULL, efi_pci_device::pci, PCI_ARGS, PCI_FMT, rc, strerror(), and VOID.
|
static |
Unmap and free DMA-coherent buffer.
| dma | DMA device |
| map | DMA mapping |
| addr | Buffer address |
| len | Length of buffer |
Definition at line 633 of file efi_pci.c.
References addr, container_of, DBG_LOG, dma(), pci_device::dma, EFI_PAGE_SIZE, efipci_dma_unmap(), _EFI_PCI_IO_PROTOCOL::FreeBuffer, efi_pci_device::io, len, map, and efi_pci_device::pci.
|
static |
Set addressable space mask.
| dma | DMA device |
| mask | Addressable space mask |
Definition at line 660 of file efi_pci.c.
References _EFI_PCI_IO_PROTOCOL::Attributes, container_of, DBGC, dma(), pci_device::dma, EEFI, EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, EfiPciIoAttributeOperationDisable, EfiPciIoAttributeOperationEnable, efi_pci_device::io, NULL, op, efi_pci_device::pci, PCI_ARGS, PCI_FMT, rc, and strerror().
| int efipci_info | ( | EFI_HANDLE | device, |
| struct efi_pci_device * | efipci ) |
Get EFI PCI device information.
| device | EFI device handle |
| efipci | EFI PCI device to fill in |
| rc | Return status code |
Definition at line 711 of file efi_pci.c.
References _EFI_PCI_IO_PROTOCOL::Attributes, busdevfn, DBGC, DBGCP, pci_device::dma, dma_init(), EEFI, EFI_HANDLE, 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().
|
static |
Check to see if driver supports a device.
| device | EFI device handle |
| rc | Return status code |
Definition at line 778 of file efi_pci.c.
References pci_device::class, DBGC, pci_device::device, EFI_HANDLE, efipci_info(), ENOTTY, pci_device::hdrtype, pci_device::id, pci_device_id::name, efi_pci_device::pci, PCI_ARGS, pci_find_driver(), PCI_FMT, PCI_HEADER_TYPE_MASK, PCI_HEADER_TYPE_NORMAL, rc, and pci_device::vendor.
Referenced by __efi_driver().
|
static |
Exclude existing drivers.
| device | EFI device handle |
| rc | Return status code |
Definition at line 817 of file efi_pci.c.
References DBGC, efi_driver_exclude(), EFI_HANDLE, efi_handle_name(), efi_pci_io_protocol_guid, protocol, rc, and strerror().
Referenced by __efi_driver().
|
static |
Attach driver to device.
| efidev | EFI device |
| rc | Return status code |
Definition at line 837 of file efi_pci.c.
References device::children, DBGC, DBGC_EFI_OPENERS, efi_device::dev, pci_device::dev, efi_device::device, efi_close_by_driver(), EFI_HANDLE, efi_handle_name(), efi_open_by_driver, efi_pci_io_protocol_guid, efidev_set_drvdata(), efipci_info(), ENOMEM, free, pci_device::id, efi_pci_device::io, list_add, list_del, pci_device_id::name, device::parent, efi_pci_device::pci, PCI_ARGS, pci_find_driver(), PCI_FMT, pci_probe(), pci_remove(), rc, device::siblings, strerror(), and zalloc().
Referenced by __efi_driver().
|
static |
Detach driver from device.
| efidev | EFI device |
Definition at line 903 of file efi_pci.c.
References dma_device::allocated, assert, pci_device::dev, efi_device::device, pci_device::dma, efi_close_by_driver(), EFI_HANDLE, efi_pci_io_protocol_guid, efidev_get_drvdata(), free, list_del, dma_device::mapped, efi_pci_device::pci, pci_remove(), and device::siblings.
Referenced by __efi_driver().
| struct efi_driver efipci_driver __efi_driver | ( | EFI_DRIVER_HARDWARE | ) |
EFI PCI driver.
References __efi_driver, EFI_DRIVER_HARDWARE, efipci_exclude(), efipci_start(), efipci_stop(), and efipci_supported().
|
static |
EFI PCI DMA operations.
Definition at line 687 of file efi_pci.c.
Referenced by efipci_info().