iPXE
Functions | Variables
pcicloud.c File Reference

Cloud VM PCI configuration space access. More...

#include <stdint.h>
#include <ipxe/init.h>
#include <ipxe/pci.h>
#include <ipxe/ecam.h>
#include <ipxe/pcibios.h>
#include <ipxe/pcidirect.h>
#include <ipxe/pcicloud.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void pcicloud_discover (uint32_t busdevfn, struct pci_range *range)
 Find next PCI bus:dev.fn address range in system. More...
 
static int pcicloud_read_config_byte (struct pci_device *pci, unsigned int where, uint8_t *value)
 Read byte from PCI configuration space. More...
 
static int pcicloud_read_config_word (struct pci_device *pci, unsigned int where, uint16_t *value)
 Read 16-bit word from PCI configuration space. More...
 
static int pcicloud_read_config_dword (struct pci_device *pci, unsigned int where, uint32_t *value)
 Read 32-bit dword from PCI configuration space. More...
 
static int pcicloud_write_config_byte (struct pci_device *pci, unsigned int where, uint8_t value)
 Write byte to PCI configuration space. More...
 
static int pcicloud_write_config_word (struct pci_device *pci, unsigned int where, uint16_t value)
 Write 16-bit word to PCI configuration space. More...
 
static int pcicloud_write_config_dword (struct pci_device *pci, unsigned int where, uint32_t value)
 Write 32-bit dword to PCI configuration space. More...
 
static void * pcicloud_ioremap (struct pci_device *pci, unsigned long bus_addr, size_t len)
 Map PCI bus address as an I/O address. More...
 
 PROVIDE_PCIAPI (cloud, pci_discover, pcicloud_discover)
 
 PROVIDE_PCIAPI (cloud, pci_read_config_byte, pcicloud_read_config_byte)
 
 PROVIDE_PCIAPI (cloud, pci_read_config_word, pcicloud_read_config_word)
 
 PROVIDE_PCIAPI (cloud, pci_read_config_dword, pcicloud_read_config_dword)
 
 PROVIDE_PCIAPI (cloud, pci_write_config_byte, pcicloud_write_config_byte)
 
 PROVIDE_PCIAPI (cloud, pci_write_config_word, pcicloud_write_config_word)
 
 PROVIDE_PCIAPI (cloud, pci_write_config_dword, pcicloud_write_config_dword)
 
 PROVIDE_PCIAPI (cloud, pci_ioremap, pcicloud_ioremap)
 
static void pcicloud_init (void)
 Initialise cloud VM PCI configuration space access. More...
 
struct init_fn pcicloud_init_fn __init_fn (INIT_EARLY)
 Cloud VM PCI configuration space access initialisation function. More...
 

Variables

static struct pci_apipcicloud = &ecam_api
 Selected PCI configuration space access API. More...
 

Detailed Description

Cloud VM PCI configuration space access.

Definition in file pcicloud.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pcicloud_discover()

static void pcicloud_discover ( uint32_t  busdevfn,
struct pci_range range 
)
static

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

Definition at line 49 of file pcicloud.c.

49  {
50 
52 }
static __always_inline void struct pci_range * range
Definition: efi_pci_api.h:43
typeof() pci_discover * pci_discover
Definition: pci_io.h:156
uint16_t busdevfn
PCI bus:dev.fn address.
Definition: ena.h:28
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41

References busdevfn, pci_api::pci_discover, pcicloud, and range.

◆ pcicloud_read_config_byte()

static int pcicloud_read_config_byte ( struct pci_device pci,
unsigned int  where,
uint8_t value 
)
static

Read byte from PCI configuration space.

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

Definition at line 62 of file pcicloud.c.

63  {
64 
65  return pcicloud->pci_read_config_byte ( pci, where, value );
66 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
typeof() pci_read_config_byte * pci_read_config_byte
Definition: pci_io.h:157
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References pci_api::pci_read_config_byte, pcicloud, value, and where.

◆ pcicloud_read_config_word()

static int pcicloud_read_config_word ( struct pci_device pci,
unsigned int  where,
uint16_t value 
)
static

Read 16-bit word from PCI configuration space.

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

Definition at line 76 of file pcicloud.c.

77  {
78 
79  return pcicloud->pci_read_config_word ( pci, where, value );
80 }
typeof() pci_read_config_word * pci_read_config_word
Definition: pci_io.h:158
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References pci_api::pci_read_config_word, pcicloud, value, and where.

◆ pcicloud_read_config_dword()

static int pcicloud_read_config_dword ( struct pci_device pci,
unsigned int  where,
uint32_t value 
)
static

Read 32-bit dword from PCI configuration space.

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

Definition at line 90 of file pcicloud.c.

91  {
92 
93  return pcicloud->pci_read_config_dword ( pci, where, value );
94 }
typeof() pci_read_config_dword * pci_read_config_dword
Definition: pci_io.h:159
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References pci_api::pci_read_config_dword, pcicloud, value, and where.

◆ pcicloud_write_config_byte()

static int pcicloud_write_config_byte ( struct pci_device pci,
unsigned int  where,
uint8_t  value 
)
static

Write byte to PCI configuration space.

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

Definition at line 104 of file pcicloud.c.

105  {
106 
107  return pcicloud->pci_write_config_byte ( pci, where, value );
108 }
typeof() pci_write_config_byte * pci_write_config_byte
Definition: pci_io.h:160
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References pci_api::pci_write_config_byte, pcicloud, value, and where.

◆ pcicloud_write_config_word()

static int pcicloud_write_config_word ( struct pci_device pci,
unsigned int  where,
uint16_t  value 
)
static

Write 16-bit word to PCI configuration space.

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

Definition at line 118 of file pcicloud.c.

119  {
120 
121  return pcicloud->pci_write_config_word ( pci, where, value );
122 }
typeof() pci_write_config_word * pci_write_config_word
Definition: pci_io.h:161
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46

References pci_api::pci_write_config_word, pcicloud, value, and where.

◆ pcicloud_write_config_dword()

static int pcicloud_write_config_dword ( struct pci_device pci,
unsigned int  where,
uint32_t  value 
)
static

Write 32-bit dword to PCI configuration space.

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

Definition at line 132 of file pcicloud.c.

133  {
134 
135  return pcicloud->pci_write_config_dword ( pci, where, value );
136 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline int unsigned int where
Definition: ecam_io.h:46
typeof() pci_write_config_dword * pci_write_config_dword
Definition: pci_io.h:162

References pci_api::pci_write_config_dword, pcicloud, value, and where.

◆ pcicloud_ioremap()

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

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

Definition at line 145 of file pcicloud.c.

146  {
147 
148  return pcicloud->pci_ioremap ( pci, bus_addr, len );
149 }
typeof() pci_ioremap * pci_ioremap
Definition: pci_io.h:163
uint32_t len
Length.
Definition: ena.h:14
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
static __always_inline void unsigned long bus_addr
Definition: ecam_io.h:135

References bus_addr, len, pci_api::pci_ioremap, and pcicloud.

◆ PROVIDE_PCIAPI() [1/8]

PROVIDE_PCIAPI ( cloud  ,
pci_discover  ,
pcicloud_discover   
)

◆ PROVIDE_PCIAPI() [2/8]

PROVIDE_PCIAPI ( cloud  ,
pci_read_config_byte  ,
pcicloud_read_config_byte   
)

◆ PROVIDE_PCIAPI() [3/8]

PROVIDE_PCIAPI ( cloud  ,
pci_read_config_word  ,
pcicloud_read_config_word   
)

◆ PROVIDE_PCIAPI() [4/8]

PROVIDE_PCIAPI ( cloud  ,
pci_read_config_dword  ,
pcicloud_read_config_dword   
)

◆ PROVIDE_PCIAPI() [5/8]

PROVIDE_PCIAPI ( cloud  ,
pci_write_config_byte  ,
pcicloud_write_config_byte   
)

◆ PROVIDE_PCIAPI() [6/8]

PROVIDE_PCIAPI ( cloud  ,
pci_write_config_word  ,
pcicloud_write_config_word   
)

◆ PROVIDE_PCIAPI() [7/8]

PROVIDE_PCIAPI ( cloud  ,
pci_write_config_dword  ,
pcicloud_write_config_dword   
)

◆ PROVIDE_PCIAPI() [8/8]

PROVIDE_PCIAPI ( cloud  ,
pci_ioremap  ,
pcicloud_ioremap   
)

◆ pcicloud_init()

static void pcicloud_init ( void  )
static

Initialise cloud VM PCI configuration space access.

Definition at line 164 of file pcicloud.c.

164  {
165  static struct pci_api *apis[] = {
167  };
168  struct pci_device pci;
170  unsigned int i;
171  int rc;
172 
173  /* Select first API that successfully discovers a PCI device */
174  for ( i = 0 ; i < ( sizeof ( apis ) / sizeof ( apis[0] ) ) ; i++ ) {
175  pcicloud = apis[i];
176  busdevfn = 0;
177  if ( ( rc = pci_find_next ( &pci, &busdevfn ) ) == 0 ) {
178  DBGC ( pcicloud, "PCICLOUD selected %s API (found "
179  PCI_FMT ")\n", pcicloud->name,
180  PCI_ARGS ( &pci ) );
181  return;
182  }
183  }
184 
185  /* Fall back to using final attempted API if no devices found */
186  pcicloud = apis[ i - 1 ];
187  DBGC ( pcicloud, "PCICLOUD selected %s API (nothing detected)\n",
188  pcicloud->name );
189 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
struct pci_api ecam_api
Definition: ecam.c:288
struct pci_api pcidirect_api
Definition: pcidirect.c:57
struct pci_api pcibios_api
Definition: pcibios.c:132
uint16_t busdevfn
PCI bus:dev.fn address.
Definition: ena.h:28
int pci_find_next(struct pci_device *pci, uint32_t *busdevfn)
Find next device on PCI bus.
Definition: pci.c:236
const char * name
Definition: pci_io.h:155
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:307
A PCI device.
Definition: pci.h:206
A runtime selectable PCI I/O API.
Definition: pci_io.h:154
unsigned int uint32_t
Definition: stdint.h:12
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:310

References busdevfn, DBGC, ecam_api, pci_api::name, PCI_ARGS, pci_find_next(), PCI_FMT, pcibios_api, pcicloud, pcidirect_api, and rc.

◆ __init_fn()

struct init_fn pcicloud_init_fn __init_fn ( INIT_EARLY  )

Cloud VM PCI configuration space access initialisation function.

Variable Documentation

◆ pcicloud

struct pci_api* pcicloud = &ecam_api
static