iPXE
pci_io.h File Reference

PCI I/O API. More...

#include <stdint.h>
#include <ipxe/api.h>
#include <ipxe/tables.h>
#include <ipxe/iomap.h>
#include <config/ioapi.h>
#include <ipxe/null_pci.h>
#include <ipxe/ecam_io.h>
#include <ipxe/pcicloud.h>
#include <ipxe/efi/efi_pci_api.h>
#include <ipxe/linux/linux_pci.h>
#include <bits/pci_io.h>

Go to the source code of this file.

Data Structures

struct  pci_range
 A PCI bus:dev.fn address range. More...
struct  pci_api
 A runtime selectable PCI I/O API. More...

Macros

#define PCI_BUSDEVFN(segment, bus, slot, func)
#define PCIAPI_INLINE(_subsys, _api_func)
 Calculate static inline PCI I/O API function name.
#define PROVIDE_PCIAPI(_subsys, _api_func, _func)
 Provide a PCI I/O API implementation.
#define PROVIDE_PCIAPI_INLINE(_subsys, _api_func)
 Provide a static inline PCI I/O API implementation.
#define PCI_APIS   __table ( struct pci_api, "pci_apis" )
 Runtime selectable PCI API table.
#define __pci_api(priority)
 Declare a runtime selectable PCI API.
#define PCIAPI_PRIORITY_EFI   01
 EFI PCI I/O protocols.
#define PCIAPI_PRIORITY_ECAM   02
 ACPI ECAM.
#define PCIAPI_PRIORITY_PCBIOS   03
 PCI BIOS calls.
#define PCIAPI_PRIORITY_DIRECT   04
 Direct Type 1 accesses.
#define PROVIDE_PCIAPI_RUNTIME(subsys, priority)
 Provide a runtime selectable PCI I/O API.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int pci_can_probe (struct pci_device *pci)
 Check if PCI bus probing is allowed.
void pci_discover (uint32_t busdevfn, struct pci_range *range)
 Find next PCI bus:dev.fn address range in system.
int pci_read_config_byte (struct pci_device *pci, unsigned int where, uint8_t *value)
 Read byte from PCI configuration space.
int pci_read_config_word (struct pci_device *pci, unsigned int where, uint16_t *value)
 Read 16-bit word from PCI configuration space.
int pci_read_config_dword (struct pci_device *pci, unsigned int where, uint32_t *value)
 Read 32-bit dword from PCI configuration space.
int pci_write_config_byte (struct pci_device *pci, unsigned int where, uint8_t value)
 Write byte to PCI configuration space.
int pci_write_config_word (struct pci_device *pci, unsigned int where, uint16_t value)
 Write 16-bit word to PCI configuration space.
int pci_write_config_dword (struct pci_device *pci, unsigned int where, uint32_t value)
 Write 32-bit dword to PCI configuration space.
void * pci_ioremap (struct pci_device *pci, unsigned long bus_addr, size_t len)
 Map PCI bus address as an I/O address.

Detailed Description

PCI I/O API.

Definition in file pci_io.h.

Macro Definition Documentation

◆ PCI_BUSDEVFN

#define PCI_BUSDEVFN ( segment,
bus,
slot,
func )
Value:
( ( (segment) << 16 ) | ( (bus) << 8 ) | \
( (slot) << 3 ) | ( (func) << 0 ) )
uint8_t bus
Bus.
Definition edd.h:1
uint8_t slot
Slot.
Definition edd.h:3
uint16_t segment
Code segment.
Definition librm.h:3

Definition at line 30 of file pci_io.h.

30#define PCI_BUSDEVFN( segment, bus, slot, func ) \
31 ( ( (segment) << 16 ) | ( (bus) << 8 ) | \
32 ( (slot) << 3 ) | ( (func) << 0 ) )

Referenced by ecam_access(), ecam_find(), efipci_discover_one(), efipci_info(), pci_find_next(), pcibios_discover(), and phantom_probe().

◆ PCIAPI_INLINE

#define PCIAPI_INLINE ( _subsys,
_api_func )
Value:
SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
#define SINGLE_API_INLINE(_prefix, _api_func)
Calculate static inline function name.
Definition api.h:45

Calculate static inline PCI I/O API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 41 of file pci_io.h.

41#define PCIAPI_INLINE( _subsys, _api_func ) \
42 SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )

◆ PROVIDE_PCIAPI

#define PROVIDE_PCIAPI ( _subsys,
_api_func,
_func )
Value:
PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )
#define PROVIDE_SINGLE_API(_prefix, _api_func, _func)
Provide an API implementation.
Definition api.h:55

Provide a PCI I/O API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 51 of file pci_io.h.

51#define PROVIDE_PCIAPI( _subsys, _api_func, _func ) \
52 PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )

◆ PROVIDE_PCIAPI_INLINE

#define PROVIDE_PCIAPI_INLINE ( _subsys,
_api_func )
Value:
PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
#define PROVIDE_SINGLE_API_INLINE(_prefix, _api_func)
Provide a static inline API implementation.
Definition api.h:74

Provide a static inline PCI I/O API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 60 of file pci_io.h.

60#define PROVIDE_PCIAPI_INLINE( _subsys, _api_func ) \
61 PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )

◆ PCI_APIS

#define PCI_APIS   __table ( struct pci_api, "pci_apis" )

Runtime selectable PCI API table.

Definition at line 180 of file pci_io.h.

Referenced by pcicloud_api(), and pcicloud_find().

◆ __pci_api

#define __pci_api ( priority)

Declare a runtime selectable PCI API.

In the common case of a non-runtime-selectable PCI I/O API, allow the runtime API code to be garbage-collected at link time to save space.

Definition at line 192 of file pci_io.h.

◆ PCIAPI_PRIORITY_EFI

#define PCIAPI_PRIORITY_EFI   01

EFI PCI I/O protocols.

Definition at line 196 of file pci_io.h.

Referenced by PROVIDE_PCIAPI_RUNTIME().

◆ PCIAPI_PRIORITY_ECAM

#define PCIAPI_PRIORITY_ECAM   02

ACPI ECAM.

Definition at line 197 of file pci_io.h.

Referenced by PROVIDE_PCIAPI_RUNTIME().

◆ PCIAPI_PRIORITY_PCBIOS

#define PCIAPI_PRIORITY_PCBIOS   03

PCI BIOS calls.

Definition at line 198 of file pci_io.h.

Referenced by PROVIDE_PCIAPI_RUNTIME().

◆ PCIAPI_PRIORITY_DIRECT

#define PCIAPI_PRIORITY_DIRECT   04

Direct Type 1 accesses.

Definition at line 199 of file pci_io.h.

Referenced by PROVIDE_PCIAPI_RUNTIME().

◆ PROVIDE_PCIAPI_RUNTIME

#define PROVIDE_PCIAPI_RUNTIME ( subsys,
priority )
Value:
struct pci_api pciapi_ ## subsys __pci_api ( priority ) = { \
.name = #subsys, \
.pci_can_probe = PCIAPI_INLINE ( subsys, pci_can_probe ), \
.pci_discover = PCIAPI_INLINE ( subsys, pci_discover ), \
.pci_read_config_byte = \
PCIAPI_INLINE ( subsys, pci_read_config_byte ), \
.pci_read_config_word = \
PCIAPI_INLINE ( subsys, pci_read_config_word ), \
.pci_read_config_dword = \
PCIAPI_INLINE ( subsys, pci_read_config_dword ), \
.pci_write_config_byte = \
PCIAPI_INLINE ( subsys, pci_write_config_byte ), \
.pci_write_config_word = \
PCIAPI_INLINE ( subsys, pci_write_config_word ), \
.pci_write_config_dword = \
PCIAPI_INLINE ( subsys, pci_write_config_dword ), \
.pci_ioremap = PCIAPI_INLINE ( subsys, pci_ioremap ), \
}
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_can_probe(struct pci_device *pci)
Check if PCI bus probing is allowed.
void pci_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define __pci_api(priority)
Declare a runtime selectable PCI API.
Definition pci_io.h:192
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define PCIAPI_INLINE(_subsys, _api_func)
Calculate static inline PCI I/O API function name.
Definition pci_io.h:41
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
uint16_t priority
Priotity.
Definition stp.h:1
A runtime selectable PCI I/O API.
Definition pci_io.h:166

Provide a runtime selectable PCI I/O API.

Definition at line 202 of file pci_io.h.

202#define PROVIDE_PCIAPI_RUNTIME( subsys, priority ) \
203 struct pci_api pciapi_ ## subsys __pci_api ( priority ) = { \
204 .name = #subsys, \
205 .pci_can_probe = PCIAPI_INLINE ( subsys, pci_can_probe ), \
206 .pci_discover = PCIAPI_INLINE ( subsys, pci_discover ), \
207 .pci_read_config_byte = \
208 PCIAPI_INLINE ( subsys, pci_read_config_byte ), \
209 .pci_read_config_word = \
210 PCIAPI_INLINE ( subsys, pci_read_config_word ), \
211 .pci_read_config_dword = \
212 PCIAPI_INLINE ( subsys, pci_read_config_dword ), \
213 .pci_write_config_byte = \
214 PCIAPI_INLINE ( subsys, pci_write_config_byte ), \
215 .pci_write_config_word = \
216 PCIAPI_INLINE ( subsys, pci_write_config_word ), \
217 .pci_write_config_dword = \
218 PCIAPI_INLINE ( subsys, pci_write_config_dword ), \
219 .pci_ioremap = PCIAPI_INLINE ( subsys, pci_ioremap ), \
220 }

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ pci_can_probe()

int pci_can_probe ( struct pci_device * pci)

◆ pci_discover()

void pci_discover ( uint32_t busdevfn,
struct pci_range * range )

Find next PCI bus:dev.fn address range in system.

Parameters
busdevfnStarting PCI bus:dev.fn address
rangePCI bus:dev.fn address range to fill in

References busdevfn, and range.

Referenced by pci_find_next(), PCIAPI_INLINE(), PCIAPI_INLINE(), PCIAPI_INLINE(), PROVIDE_PCIAPI(), PROVIDE_PCIAPI(), PROVIDE_PCIAPI(), PROVIDE_PCIAPI(), PROVIDE_PCIAPI_INLINE(), and PROVIDE_PCIAPI_INLINE().

◆ pci_read_config_byte()

◆ pci_read_config_word()

◆ pci_read_config_dword()

◆ pci_write_config_byte()

◆ pci_write_config_word()

◆ pci_write_config_dword()

◆ pci_ioremap()