iPXE
Macros | Functions | Variables
pcidirect.h File Reference

PCI configuration space access via Type 1 accesses. More...

#include <stdint.h>
#include <ipxe/io.h>

Go to the source code of this file.

Macros

#define PCIAPI_PREFIX_direct   __direct_
 
#define PCIDIRECT_CONFIG_ADDRESS   0xcf8
 
#define PCIDIRECT_CONFIG_DATA   0xcfc
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void pcidirect_prepare (struct pci_device *pci, int where)
 Prepare for Type 1 PCI configuration space access. More...
 
static __always_inline void PCIAPI_INLINE (direct, pci_discover)(uint32_t busdevfn __unused
 Find next PCI bus:dev.fn address range in system. More...
 
static __always_inline int PCIAPI_INLINE (direct, pci_read_config_byte)(struct pci_device *pci
 Read byte from PCI configuration space via Type 1 access. More...
 
static __always_inline int PCIAPI_INLINE (direct, pci_read_config_word)(struct pci_device *pci
 Read word from PCI configuration space via Type 1 access. More...
 
static __always_inline int PCIAPI_INLINE (direct, pci_read_config_dword)(struct pci_device *pci
 Read dword from PCI configuration space via Type 1 access. More...
 
static __always_inline int PCIAPI_INLINE (direct, pci_write_config_byte)(struct pci_device *pci
 Write byte to PCI configuration space via Type 1 access. More...
 
 outb (value, PCIDIRECT_CONFIG_DATA+(where &3))
 
static __always_inline int PCIAPI_INLINE (direct, pci_write_config_word)(struct pci_device *pci
 Write word to PCI configuration space via Type 1 access. More...
 
 outw (value, PCIDIRECT_CONFIG_DATA+(where &2))
 
static __always_inline int PCIAPI_INLINE (direct, pci_write_config_dword)(struct pci_device *pci
 Write dword to PCI configuration space via Type 1 access. More...
 
 outl (value, PCIDIRECT_CONFIG_DATA)
 
static __always_inline void * PCIAPI_INLINE (direct, pci_ioremap)(struct pci_device *pci __unused
 Map PCI bus address as an I/O address. More...
 

Variables

static __always_inline void struct pci_rangerange
 
range count = PCI_BUSDEVFN ( 0, 1, 0, 0 )
 
static __always_inline int unsigned int where
 
static __always_inline int unsigned int uint8_tvalue
 
 return
 
static __always_inline void unsigned long bus_addr
 
static __always_inline void unsigned long size_t len
 
struct pci_api pcidirect_api
 

Detailed Description

PCI configuration space access via Type 1 accesses.

Definition in file pcidirect.h.

Macro Definition Documentation

◆ PCIAPI_PREFIX_direct

#define PCIAPI_PREFIX_direct   __direct_

Definition at line 12 of file pcidirect.h.

◆ PCIDIRECT_CONFIG_ADDRESS

#define PCIDIRECT_CONFIG_ADDRESS   0xcf8

Definition at line 21 of file pcidirect.h.

◆ PCIDIRECT_CONFIG_DATA

#define PCIDIRECT_CONFIG_DATA   0xcfc

Definition at line 22 of file pcidirect.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pcidirect_prepare()

void pcidirect_prepare ( struct pci_device pci,
int  where 
)

Prepare for Type 1 PCI configuration space access.

Parameters
pciPCI device
whereLocation within PCI configuration space

Definition at line 41 of file pcidirect.c.

41  {
42  uint16_t busdevfn = ( pci->busdevfn & 0xffff );
43 
44  outl ( ( 0x80000000 | ( busdevfn << 8 ) | ( where & ~3 ) ),
46 }
unsigned short uint16_t
Definition: stdint.h:11
uint16_t busdevfn
PCI bus:dev.fn address.
Definition: ena.h:28
#define outl(data, io_addr)
Definition: io.h:329
#define PCIDIRECT_CONFIG_ADDRESS
Definition: pcidirect.h:21
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:233
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References busdevfn, pci_device::busdevfn, outl, PCIDIRECT_CONFIG_ADDRESS, and where.

◆ PCIAPI_INLINE() [1/8]

static __always_inline void PCIAPI_INLINE ( direct  ,
pci_discover   
)
inlinestatic

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

◆ PCIAPI_INLINE() [2/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_read_config_byte   
)
inlinestatic

Read byte from PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue read
Return values
rcReturn status code

◆ PCIAPI_INLINE() [3/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_read_config_word   
)
inlinestatic

Read word from PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue read
Return values
rcReturn status code

◆ PCIAPI_INLINE() [4/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_read_config_dword   
)
inlinestatic

Read dword from PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue read
Return values
rcReturn status code

◆ PCIAPI_INLINE() [5/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_write_config_byte   
)
inlinestatic

Write byte to PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue to be written
Return values
rcReturn status code

◆ outb()

outb ( value  ,
PCIDIRECT_CONFIG_DATA where &3 
)

◆ PCIAPI_INLINE() [6/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_write_config_word   
)
inlinestatic

Write word to PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue to be written
Return values
rcReturn status code

◆ outw()

outw ( value  ,
PCIDIRECT_CONFIG_DATA where &2 
)

◆ PCIAPI_INLINE() [7/8]

static __always_inline int PCIAPI_INLINE ( direct  ,
pci_write_config_dword   
)
inlinestatic

Write dword to PCI configuration space via Type 1 access.

Parameters
pciPCI device
whereLocation within PCI configuration space
valueValue to be written
Return values
rcReturn status code

◆ outl()

outl ( value  ,
PCIDIRECT_CONFIG_DATA   
)

◆ PCIAPI_INLINE() [8/8]

static __always_inline void* PCIAPI_INLINE ( direct  ,
pci_ioremap   
)
inlinestatic

Map PCI bus address as an I/O address.

Parameters
bus_addrPCI bus address
lenLength of region
Return values
io_addrI/O address, or NULL on error

Variable Documentation

◆ range

__always_inline void struct pci_range* range
Initial value:
{
range->start = PCI_BUSDEVFN ( 0, 0, 0, 0 )
uint32_t start
Starting bus:dev.fn address.
Definition: pci_io.h:23
static __always_inline void struct pci_range * range
Definition: pcidirect.h:36
#define PCI_BUSDEVFN(segment, bus, slot, func)
Definition: pci_io.h:28

Definition at line 36 of file pcidirect.h.

◆ count

range count = PCI_BUSDEVFN ( 0, 1, 0, 0 )

Definition at line 40 of file pcidirect.h.

◆ where

__always_inline int unsigned int where

Definition at line 53 of file pcidirect.h.

◆ value

__always_inline int unsigned int uint32_t value
Initial value:
{
void pcidirect_prepare(struct pci_device *pci, int where)
Prepare for Type 1 PCI configuration space access.
Definition: pcidirect.c:41
static __always_inline int unsigned int where
Definition: pcidirect.h:53

Definition at line 54 of file pcidirect.h.

◆ return

return

Definition at line 57 of file pcidirect.h.

◆ bus_addr

__always_inline void unsigned long bus_addr

Definition at line 154 of file pcidirect.h.

◆ len

__always_inline void unsigned long size_t len
Initial value:
{
return ioremap ( bus_addr, len )
static __always_inline void unsigned long bus_addr
Definition: pcidirect.h:154
static __always_inline void unsigned long size_t len
Definition: pcidirect.h:154
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.

Definition at line 154 of file pcidirect.h.

◆ pcidirect_api

struct pci_api pcidirect_api

Definition at line 57 of file pcidirect.c.

Referenced by pcicloud_init().