iPXE
Macros | Functions | Variables
pcibios.h File Reference

PCI configuration space access via PCI BIOS. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define PCIAPI_PREFIX_pcbios   __pcbios_
 
#define PCIBIOS_INSTALLATION_CHECK   0xb1010000
 
#define PCIBIOS_READ_CONFIG_BYTE   0xb1080000
 
#define PCIBIOS_READ_CONFIG_WORD   0xb1090000
 
#define PCIBIOS_READ_CONFIG_DWORD   0xb10a0000
 
#define PCIBIOS_WRITE_CONFIG_BYTE   0xb10b0000
 
#define PCIBIOS_WRITE_CONFIG_WORD   0xb10c0000
 
#define PCIBIOS_WRITE_CONFIG_DWORD   0xb10d0000
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int pcibios_read (struct pci_device *pci, uint32_t command, uint32_t *value)
 Read configuration space via PCI BIOS. More...
 
int pcibios_write (struct pci_device *pci, uint32_t command, uint32_t value)
 Write configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_read_config_byte)(struct pci_device *pci
 Read byte from PCI configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_read_config_word)(struct pci_device *pci
 Read word from PCI configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_read_config_dword)(struct pci_device *pci
 Read dword from PCI configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_write_config_byte)(struct pci_device *pci
 Write byte to PCI configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_write_config_word)(struct pci_device *pci
 Write word to PCI configuration space via PCI BIOS. More...
 
static __always_inline int PCIAPI_INLINE (pcbios, pci_write_config_dword)(struct pci_device *pci
 Write dword to PCI configuration space via PCI BIOS. More...
 
static __always_inline void * PCIAPI_INLINE (pcbios, pci_ioremap)(struct pci_device *pci __unused
 Map PCI bus address as an I/O address. More...
 

Variables

static __always_inline int unsigned int where
 
static __always_inline int unsigned int uint8_tvalue
 
int rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_BYTE | where, &tmp )
 
static __always_inline void unsigned long bus_addr
 
static __always_inline void unsigned long size_t len
 
struct pci_api pcibios_api
 

Detailed Description

PCI configuration space access via PCI BIOS.

Definition in file pcibios.h.

Macro Definition Documentation

◆ PCIAPI_PREFIX_pcbios

#define PCIAPI_PREFIX_pcbios   __pcbios_

Definition at line 17 of file pcibios.h.

◆ PCIBIOS_INSTALLATION_CHECK

#define PCIBIOS_INSTALLATION_CHECK   0xb1010000

Definition at line 22 of file pcibios.h.

◆ PCIBIOS_READ_CONFIG_BYTE

#define PCIBIOS_READ_CONFIG_BYTE   0xb1080000

Definition at line 23 of file pcibios.h.

◆ PCIBIOS_READ_CONFIG_WORD

#define PCIBIOS_READ_CONFIG_WORD   0xb1090000

Definition at line 24 of file pcibios.h.

◆ PCIBIOS_READ_CONFIG_DWORD

#define PCIBIOS_READ_CONFIG_DWORD   0xb10a0000

Definition at line 25 of file pcibios.h.

◆ PCIBIOS_WRITE_CONFIG_BYTE

#define PCIBIOS_WRITE_CONFIG_BYTE   0xb10b0000

Definition at line 26 of file pcibios.h.

◆ PCIBIOS_WRITE_CONFIG_WORD

#define PCIBIOS_WRITE_CONFIG_WORD   0xb10c0000

Definition at line 27 of file pcibios.h.

◆ PCIBIOS_WRITE_CONFIG_DWORD

#define PCIBIOS_WRITE_CONFIG_DWORD   0xb10d0000

Definition at line 28 of file pcibios.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pcibios_read()

int pcibios_read ( struct pci_device pci,
uint32_t  command,
uint32_t value 
)

Read configuration space via PCI BIOS.

Parameters
pciPCI device
commandPCI BIOS command
valueValue read
Return values
rcReturn status code

Definition at line 77 of file pcibios.c.

77  {
78  int discard_b, discard_D;
80 
81  __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
82  "int $0x1a\n\t"
83  "jnc 1f\n\t"
84  "xorl %%eax, %%eax\n\t"
85  "decl %%eax\n\t"
86  "movl %%eax, %%ecx\n\t"
87  "\n1:\n\t" )
88  : "=a" ( status ), "=b" ( discard_b ),
89  "=c" ( *value ), "=D" ( discard_D )
90  : "a" ( command >> 16 ), "D" ( command ),
91  "b" ( pci->busdevfn )
92  : "edx" );
93 
94  return ( status >> 8 );
95 }
unsigned short uint16_t
Definition: stdint.h:11
A command-line command.
Definition: command.h:9
uint8_t status
Status.
Definition: ena.h:16
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
void * discard_D
Definition: bigint.h:31
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:231
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226

References __asm__(), __volatile__(), pci_device::busdevfn, discard_D, REAL_CODE, status, and value.

◆ pcibios_write()

int pcibios_write ( struct pci_device pci,
uint32_t  command,
uint32_t  value 
)

Write configuration space via PCI BIOS.

Parameters
pciPCI device
commandPCI BIOS command
valueValue to be written
Return values
rcReturn status code

Definition at line 105 of file pcibios.c.

105  {
106  int discard_b, discard_c, discard_D;
108 
109  __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
110  "int $0x1a\n\t"
111  "jnc 1f\n\t"
112  "movb $0xff, %%ah\n\t"
113  "\n1:\n\t" )
114  : "=a" ( status ), "=b" ( discard_b ),
115  "=c" ( discard_c ), "=D" ( discard_D )
116  : "a" ( command >> 16 ), "D" ( command ),
117  "b" ( pci->busdevfn ), "c" ( value )
118  : "edx" );
119 
120  return ( status >> 8 );
121 }
unsigned short uint16_t
Definition: stdint.h:11
A command-line command.
Definition: command.h:9
uint8_t status
Status.
Definition: ena.h:16
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
void * discard_D
Definition: bigint.h:31
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:231
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
long discard_c
Definition: bigint.h:32
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226

References __asm__(), __volatile__(), pci_device::busdevfn, discard_c, discard_D, REAL_CODE, status, and value.

◆ PCIAPI_INLINE() [1/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_read_config_byte   
)
inlinestatic

Read byte from PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [2/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_read_config_word   
)
inlinestatic

Read word from PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [3/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_read_config_dword   
)
inlinestatic

Read dword from PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [4/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_write_config_byte   
)
inlinestatic

Write byte to PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [5/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_write_config_word   
)
inlinestatic

Write word to PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [6/7]

static __always_inline int PCIAPI_INLINE ( pcbios  ,
pci_write_config_dword   
)
inlinestatic

Write dword to PCI configuration space via PCI BIOS.

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

◆ PCIAPI_INLINE() [7/7]

static __always_inline void* PCIAPI_INLINE ( pcbios  ,
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

◆ where

__always_inline int unsigned int where

Definition at line 45 of file pcibios.h.

◆ value

__always_inline int unsigned int uint32_t value
Initial value:
{
uint8_t * tmp
Definition: entropy.h:156
unsigned int uint32_t
Definition: stdint.h:12

Definition at line 46 of file pcibios.h.

◆ rc

Definition at line 48 of file pcibios.h.

◆ bus_addr

__always_inline void unsigned long bus_addr

Definition at line 144 of file pcibios.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: pcibios.h:144
static __always_inline void unsigned long size_t len
Definition: pcibios.h:144
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.

Definition at line 144 of file pcibios.h.

◆ pcibios_api

struct pci_api pcibios_api

Definition at line 132 of file pcibios.c.

Referenced by pcicloud_init().