iPXE
Data Structures | Macros | Functions
pci_io.h File Reference

PCI I/O API. More...

#include <stdint.h>
#include <ipxe/api.h>
#include <ipxe/iomap.h>
#include <config/ioapi.h>
#include <ipxe/ecam_io.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)   SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
 Calculate static inline PCI I/O API function name. More...
 
#define PROVIDE_PCIAPI(_subsys, _api_func, _func)   PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )
 Provide a PCI I/O API implementation. More...
 
#define PROVIDE_PCIAPI_INLINE(_subsys, _api_func)   PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )
 Provide a static inline PCI I/O API implementation. More...
 
#define PCIAPI_RUNTIME(_subsys)
 Provide a runtime selectable PCI I/O API. More...
 

Functions

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

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 ) )
uint16_t segment
Code segment.
Definition: librm.h:252
uint8_t slot
Slot.
Definition: edd.h:16
uint8_t bus
Bus.
Definition: edd.h:14

Definition at line 28 of file pci_io.h.

◆ PCIAPI_INLINE

#define PCIAPI_INLINE (   _subsys,
  _api_func 
)    SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )

Calculate static inline PCI I/O API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 39 of file pci_io.h.

◆ PROVIDE_PCIAPI

#define PROVIDE_PCIAPI (   _subsys,
  _api_func,
  _func 
)    PROVIDE_SINGLE_API ( PCIAPI_PREFIX_ ## _subsys, _api_func, _func )

Provide a PCI I/O API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 49 of file pci_io.h.

◆ PROVIDE_PCIAPI_INLINE

#define PROVIDE_PCIAPI_INLINE (   _subsys,
  _api_func 
)    PROVIDE_SINGLE_API_INLINE ( PCIAPI_PREFIX_ ## _subsys, _api_func )

Provide a static inline PCI I/O API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 58 of file pci_io.h.

◆ PCIAPI_RUNTIME

#define PCIAPI_RUNTIME (   _subsys)
Value:
{ \
.name = #_subsys, \
.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_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_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define PCIAPI_INLINE(_subsys, _api_func)
Calculate static inline PCI I/O API function name.
Definition: pci_io.h:39
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.
void pci_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
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.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.

Provide a runtime selectable PCI I/O API.

Definition at line 167 of file pci_io.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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

Referenced by pci_find_next().

◆ pci_read_config_byte()

int pci_read_config_byte ( struct pci_device pci,
unsigned int  where,
uint8_t value 
)

◆ pci_read_config_word()

int pci_read_config_word ( struct pci_device pci,
unsigned int  where,
uint16_t value 
)

◆ pci_read_config_dword()

int pci_read_config_dword ( struct pci_device pci,
unsigned int  where,
uint32_t value 
)

◆ pci_write_config_byte()

int pci_write_config_byte ( struct pci_device pci,
unsigned int  where,
uint8_t  value 
)

◆ pci_write_config_word()

int pci_write_config_word ( struct pci_device pci,
unsigned int  where,
uint16_t  value 
)

◆ pci_write_config_dword()

int pci_write_config_dword ( struct pci_device pci,
unsigned int  where,
uint32_t  value 
)

◆ pci_ioremap()

void* pci_ioremap ( struct pci_device pci,
unsigned long  bus_addr,
size_t  len 
)