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.

Referenced by pcicloud_init().

◆ 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_range range;
169  unsigned int i;
170 
171  /* Select first API that successfully discovers an address range */
172  for ( i = 0 ; i < ( sizeof ( apis ) / sizeof ( apis[0] ) ) ; i++ ) {
173  pcicloud = apis[i];
174  pcicloud_discover ( 0, &range );
175  if ( range.count != 0 ) {
176  DBGC ( pcicloud, "PCICLOUD selected %s API\n",
177  pcicloud->name );
178  break;
179  }
180  }
181 
182  /* The PCI direct API can never fail discovery since the range
183  * is hardcoded.
184  */
185  assert ( range.count != 0 );
186 }
static void pcicloud_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
Definition: pcicloud.c:49
static __always_inline void struct pci_range * range
Definition: efi_pci_api.h:43
#define DBGC(...)
Definition: compiler.h:505
struct pci_api ecam_api
Definition: ecam.c:267
struct pci_api pcidirect_api
Definition: pcidirect.c:57
struct pci_api pcibios_api
Definition: pcibios.c:132
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
const char * name
Definition: pci_io.h:155
A PCI bus:dev.fn address range.
Definition: pci_io.h:21
A runtime selectable PCI I/O API.
Definition: pci_io.h:154
unsigned int count
Number of bus:dev.fn addresses within this range.
Definition: pci_io.h:25
static struct pci_api * pcicloud
Selected PCI configuration space access API.
Definition: pcicloud.c:41

References assert(), pci_range::count, DBGC, ecam_api, pci_api::name, pcibios_api, pcicloud, pcicloud_discover(), pcidirect_api, and range.

◆ __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