iPXE
|
iPXE PCI I/O API for EFI More...
#include <stdlib.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) | |
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. More... | |
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. More... | |
static void | efipci_discover (uint32_t busdevfn, struct pci_range *range) |
Find next PCI bus:dev.fn address range in system. More... | |
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. More... | |
static void | efipci_root_close (EFI_HANDLE handle) |
Close EFI PCI root bridge I/O protocol. More... | |
static unsigned long | efipci_address (struct pci_device *pci, unsigned long location) |
Calculate EFI PCI configuration space address. More... | |
int | efipci_read (struct pci_device *pci, unsigned long location, void *value) |
Read from PCI configuration space. More... | |
int | efipci_write (struct pci_device *pci, unsigned long location, unsigned long value) |
Write to PCI configuration space. More... | |
void * | efipci_ioremap (struct pci_device *pci, unsigned long bus_addr, size_t len) |
Map PCI bus address as an I/O address. More... | |
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) | |
static int | efipci_dma_map (struct dma_device *dma, struct dma_mapping *map, physaddr_t addr, size_t len, int flags) |
Map buffer for DMA. More... | |
static void | efipci_dma_unmap (struct dma_device *dma, struct dma_mapping *map) |
Unmap buffer. More... | |
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. More... | |
static void | efipci_dma_free (struct dma_device *dma, struct dma_mapping *map, void *addr, size_t len) |
Unmap and free DMA-coherent buffer. More... | |
static userptr_t | efipci_dma_umalloc (struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align) |
Allocate and map DMA-coherent buffer from external (user) memory. More... | |
static void | efipci_dma_ufree (struct dma_device *dma, struct dma_mapping *map, userptr_t addr, size_t len) |
Unmap and free DMA-coherent buffer from external (user) memory. More... | |
static void | efipci_dma_set_mask (struct dma_device *dma, physaddr_t mask) |
Set addressable space mask. More... | |
int | efipci_open (EFI_HANDLE device, UINT32 attributes, struct efi_pci_device *efipci) |
Open EFI PCI device. More... | |
void | efipci_close (EFI_HANDLE device) |
Close EFI PCI device. More... | |
int | efipci_info (EFI_HANDLE device, struct efi_pci_device *efipci) |
Get EFI PCI device information. More... | |
static int | efipci_supported (EFI_HANDLE device) |
Check to see if driver supports a device. More... | |
static int | efipci_start (struct efi_device *efidev) |
Attach driver to device. More... | |
static void | efipci_stop (struct efi_device *efidev) |
Detach driver from device. More... | |
struct efi_driver efipci_driver | __efi_driver (EFI_DRIVER_NORMAL) |
EFI PCI driver. More... | |
Variables | |
static struct dma_operations | efipci_dma_operations |
EFI PCI DMA operations. More... | |
iPXE PCI I/O API for EFI
Definition in file efi_pci.c.
#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 | ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
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 73 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(), EFI_SYSTEM_TABLE::BootServices, pci_device::busdevfn, EFI_BOOT_SERVICES::CloseProtocol, count, pci_range::count, DBGC, DBGC2, EEFI, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_pci_root_bridge_io_protocol_guid, efi_systab, handle, index, le64_to_cpu, EFI_BOOT_SERVICES::OpenProtocol, PCI_ARGS, PCI_BUS, PCI_BUSDEVFN, PCI_FMT, range, raw, rc, root, start, pci_range::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 180 of file efi_pci.c.
References EFI_SYSTEM_TABLE::BootServices, pci_device::busdevfn, ByProtocol, pci_range::count, DBGC, EEFI, 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, pci_range::start, 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 252 of file efi_pci.c.
References busdevfn, efipci_discover_any(), handle, memset(), pci_init(), and range.
|
static |
Open EFI PCI root bridge I/O protocol.
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 270 of file efi_pci.c.
References EFI_SYSTEM_TABLE::BootServices, DBGC, EEFI, efi_handle_name(), efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_pci_root_bridge_io_protocol_guid, efi_systab, efipci_discover_any(), handle, EFI_BOOT_SERVICES::OpenProtocol, PCI_ARGS, PCI_FMT, rc, root, strerror(), tmp, and u.
Referenced by efipci_ioremap(), efipci_read(), and efipci_write().
|
static |
Close EFI PCI root bridge I/O protocol.
handle | EFI PCI root bridge handle |
Definition at line 308 of file efi_pci.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, efi_image_handle, efi_pci_root_bridge_io_protocol_guid, efi_systab, and handle.
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 323 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 340 of file efi_pci.c.
References DBGC, EEFI, efipci_address(), EFIPCI_OFFSET, efipci_root_close(), 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 376 of file efi_pci.c.
References DBGC, EEFI, efipci_address(), EFIPCI_OFFSET, efipci_root_close(), efipci_root_open(), EFIPCI_WIDTH, handle, PCI_ARGS, PCI_FMT, rc, root, strerror(), and value.
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 411 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, efipci_root_close(), efipci_root_open(), end, handle, ioremap(), le64_to_cpu, len, offset, PCI_ARGS, PCI_FMT, raw, rc, root, start, strerror(), tag, and u.
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 | |||
) |
|
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 504 of file efi_pci.c.
References addr, assert(), bus, container_of, count, DBG_LOG, DBGC, dma_mapping::dma, pci_device::dma, dma(), DMA_RX, DMA_TX, EEFI, EfiPciIoOperationBusMasterCommonBuffer, EfiPciIoOperationBusMasterRead, EfiPciIoOperationBusMasterWrite, ENOTSUP, flags, efi_pci_device::io, len, map, _EFI_PCI_IO_PROTOCOL::Map, NULL, dma_mapping::offset, op, efi_pci_device::pci, PCI_ARGS, PCI_FMT, phys_to_virt(), rc, strerror(), dma_mapping::token, _EFI_PCI_IO_PROTOCOL::Unmap, and VOID.
Referenced by efipci_dma_alloc().
|
static |
Unmap buffer.
dma | DMA device |
map | DMA mapping |
Definition at line 586 of file efi_pci.c.
References container_of, DBG_LOG, dma_mapping::dma, pci_device::dma, dma(), efi_pci_device::io, map, NULL, dma_mapping::offset, efi_pci_device::pci, dma_mapping::token, 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 615 of file efi_pci.c.
References addr, AllocateAnyPages, _EFI_PCI_IO_PROTOCOL::AllocateBuffer, container_of, DBG_LOG, DBGC, pci_device::dma, 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(), virt_to_phys(), and VOID.
Referenced by efipci_dma_umalloc().
|
static |
Unmap and free DMA-coherent buffer.
dma | DMA device |
map | DMA mapping |
addr | Buffer address |
len | Length of buffer |
Definition at line 670 of file efi_pci.c.
References addr, container_of, DBG_LOG, pci_device::dma, dma(), EFI_PAGE_SIZE, efipci_dma_unmap(), _EFI_PCI_IO_PROTOCOL::FreeBuffer, efi_pci_device::io, len, map, and efi_pci_device::pci.
Referenced by efipci_dma_ufree().
|
static |
Allocate and map DMA-coherent buffer from external (user) memory.
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 700 of file efi_pci.c.
References addr, align, dma(), efipci_dma_alloc(), len, map, and virt_to_user().
|
static |
Unmap and free DMA-coherent buffer from external (user) memory.
dma | DMA device |
map | DMA mapping |
addr | Buffer address |
len | Length of buffer |
Definition at line 717 of file efi_pci.c.
References addr, dma(), efipci_dma_free(), len, map, and user_to_virt().
|
static |
Set addressable space mask.
dma | DMA device |
mask | Addressable space mask |
Definition at line 729 of file efi_pci.c.
References _EFI_PCI_IO_PROTOCOL::Attributes, attrs, container_of, DBGC, pci_device::dma, 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_open | ( | EFI_HANDLE | device, |
UINT32 | attributes, | ||
struct efi_pci_device * | efipci | ||
) |
Open EFI PCI device.
device | EFI device handle |
attributes | Protocol opening attributes |
efipci | EFI PCI device to fill in |
rc | Return status code |
Definition at line 781 of file efi_pci.c.
References EFI_SYSTEM_TABLE::BootServices, busdevfn, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGCP, pci_device::dma, dma_init(), EEFI, EEFI_PCI, efi_handle_name(), efi_image_handle, EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, EFI_PCI_IO_ATTRIBUTE_IO, EFI_PCI_IO_ATTRIBUTE_MEMORY, efi_pci_io_protocol_guid, efi_systab, efipci_dma_operations, EfiPciIoAttributeOperationEnable, efi_pci_device::io, NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_pci_device::pci, PCI_ARGS, PCI_BUSDEVFN, PCI_FMT, pci_init(), pci_read_config(), rc, and strerror().
Referenced by efi_bofm_start(), efipci_info(), and efipci_start().
void efipci_close | ( | EFI_HANDLE | device | ) |
Close EFI PCI device.
device | EFI device handle |
Definition at line 858 of file efi_pci.c.
References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, efi_image_handle, efi_pci_io_protocol_guid, and efi_systab.
Referenced by efi_bofm_start(), efipci_info(), efipci_start(), and efipci_stop().
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 872 of file efi_pci.c.
References EFI_OPEN_PROTOCOL_GET_PROTOCOL, efipci_close(), efipci_open(), and rc.
Referenced by efi_bofm_supported(), efi_pci_info(), and efipci_supported().
|
static |
Check to see if driver supports a device.
device | EFI device handle |
rc | Return status code |
Definition at line 899 of file efi_pci.c.
References pci_device::class, DBGC, pci_device::device, 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.
|
static |
Attach driver to device.
efidev | EFI device |
rc | Return status code |
Definition at line 938 of file efi_pci.c.
References device::children, DBGC, DBGC_EFI_OPENERS, efi_device::dev, pci_device::dev, efi_device::device, efi_handle_name(), EFI_OPEN_PROTOCOL_BY_DRIVER, EFI_OPEN_PROTOCOL_EXCLUSIVE, efi_pci_io_protocol_guid, efidev_set_drvdata(), efipci_close(), efipci_open(), ENOMEM, free, pci_device::id, 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().
|
static |
Detach driver from device.
efidev | EFI device |
Definition at line 1000 of file efi_pci.c.
References dma_device::allocated, assert(), pci_device::dev, efi_device::device, pci_device::dma, efidev_get_drvdata(), efipci_close(), free, list_del, dma_device::mapped, efi_pci_device::pci, pci_remove(), and device::siblings.
struct efi_driver efipci_driver __efi_driver | ( | EFI_DRIVER_NORMAL | ) |
EFI PCI driver.
|
static |
EFI PCI DMA operations.
Definition at line 756 of file efi_pci.c.
Referenced by efipci_open().