iPXE
Functions
pcibios.c File Reference

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

#include <stdint.h>
#include <ipxe/pci.h>
#include <realmode.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int pcibios_num_bus (void)
 Determine number of PCI buses within system. More...
 
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...
 
 PROVIDE_PCIAPI (pcbios, pci_num_bus, pcibios_num_bus)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_byte)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_word)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_read_config_dword)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_byte)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_word)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_write_config_dword)
 

Detailed Description

PCI configuration space access via PCI BIOS.

Definition in file pcibios.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pcibios_num_bus()

static int pcibios_num_bus ( void  )
static

Determine number of PCI buses within system.

Return values
num_busNumber of buses

Definition at line 41 of file pcibios.c.

41  {
42  int discard_a, discard_D;
43  uint8_t max_bus;
44 
45  /* We issue this call using flat real mode, to work around a
46  * bug in some HP BIOSes.
47  */
48  __asm__ __volatile__ ( REAL_CODE ( "call flatten_real_mode\n\t"
49  "stc\n\t"
50  "int $0x1a\n\t"
51  "jnc 1f\n\t"
52  "xorw %%cx, %%cx\n\t"
53  "\n1:\n\t" )
54  : "=c" ( max_bus ), "=a" ( discard_a ),
55  "=D" ( discard_D )
56  : "a" ( PCIBIOS_INSTALLATION_CHECK >> 16 ),
57  "D" ( 0 )
58  : "ebx", "edx" );
59 
60  return ( max_bus + 1 );
61 }
#define PCIBIOS_INSTALLATION_CHECK
Definition: pcibios.h:22
unsigned char uint8_t
Definition: stdint.h:10
void * discard_D
Definition: bigint.h:29
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__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__(), discard_D, PCIBIOS_INSTALLATION_CHECK, and REAL_CODE.

◆ 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 71 of file pcibios.c.

71  {
72  int discard_b, discard_D;
74 
75  __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
76  "int $0x1a\n\t"
77  "jnc 1f\n\t"
78  "xorl %%eax, %%eax\n\t"
79  "decl %%eax\n\t"
80  "movl %%eax, %%ecx\n\t"
81  "\n1:\n\t" )
82  : "=a" ( status ), "=b" ( discard_b ),
83  "=c" ( *value ), "=D" ( discard_D )
84  : "a" ( command >> 16 ), "D" ( command ),
85  "b" ( pci->busdevfn )
86  : "edx" );
87 
88  return ( status >> 8 );
89 }
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
void * discard_D
Definition: bigint.h:29
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
__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 99 of file pcibios.c.

99  {
100  int discard_b, discard_c, discard_D;
102 
103  __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
104  "int $0x1a\n\t"
105  "jnc 1f\n\t"
106  "movb $0xff, %%ah\n\t"
107  "\n1:\n\t" )
108  : "=a" ( status ), "=b" ( discard_b ),
109  "=c" ( discard_c ), "=D" ( discard_D )
110  : "a" ( command >> 16 ), "D" ( command ),
111  "b" ( pci->busdevfn ), "c" ( value )
112  : "edx" );
113 
114  return ( status >> 8 );
115 }
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
void * discard_D
Definition: bigint.h:29
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
__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:30
#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.

◆ PROVIDE_PCIAPI()

PROVIDE_PCIAPI ( pcbios  ,
pci_num_bus  ,
pcibios_num_bus   
)

◆ PROVIDE_PCIAPI_INLINE() [1/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_byte   
)

◆ PROVIDE_PCIAPI_INLINE() [2/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_word   
)

◆ PROVIDE_PCIAPI_INLINE() [3/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_dword   
)

◆ PROVIDE_PCIAPI_INLINE() [4/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_byte   
)

◆ PROVIDE_PCIAPI_INLINE() [5/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_word   
)

◆ PROVIDE_PCIAPI_INLINE() [6/6]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_dword   
)