iPXE
Functions | Variables
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 void pcibios_discover (uint32_t busdevfn __unused, struct pci_range *range)
 Find next PCI bus:dev.fn address range in 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_discover, pcibios_discover)
 
 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)
 
 PROVIDE_PCIAPI_INLINE (pcbios, pci_ioremap)
 

Variables

struct pci_api pcibios_api = PCIAPI_RUNTIME ( pcbios )
 

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_discover()

static void pcibios_discover ( uint32_t busdevfn  __unused,
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 42 of file pcibios.c.

43  {
44  int discard_a, discard_D;
45  uint16_t num_bus;
46 
47  /* We issue this call using flat real mode, to work around a
48  * bug in some HP BIOSes.
49  */
50  __asm__ __volatile__ ( REAL_CODE ( "call flatten_real_mode\n\t"
51  "stc\n\t"
52  "int $0x1a\n\t"
53  "movzbw %%cl, %%cx\n\t"
54  "incw %%cx\n\t"
55  "jnc 1f\n\t"
56  "xorw %%cx, %%cx\n\t"
57  "\n1:\n\t" )
58  : "=c" ( num_bus ), "=a" ( discard_a ),
59  "=D" ( discard_D )
60  : "a" ( PCIBIOS_INSTALLATION_CHECK >> 16 ),
61  "D" ( 0 )
62  : "ebx", "edx" );
63 
64  /* Populate range */
65  range->start = PCI_BUSDEVFN ( 0, 0, 0, 0 );
66  range->count = PCI_BUSDEVFN ( 0, num_bus, 0, 0 );
67 }
uint32_t start
Starting bus:dev.fn address.
Definition: pci_io.h:23
unsigned short uint16_t
Definition: stdint.h:11
static __always_inline void struct pci_range * range
Definition: efi_pci_api.h:43
#define PCI_BUSDEVFN(segment, bus, slot, func)
Definition: pci_io.h:28
#define PCIBIOS_INSTALLATION_CHECK
Definition: pcibios.h:22
__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
unsigned int count
Number of bus:dev.fn addresses within this range.
Definition: pci_io.h:25
__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_range::count, discard_D, PCI_BUSDEVFN, PCIBIOS_INSTALLATION_CHECK, range, REAL_CODE, and pci_range::start.

◆ 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:233
__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:233
__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.

◆ PROVIDE_PCIAPI()

PROVIDE_PCIAPI ( pcbios  ,
pci_discover  ,
pcibios_discover   
)

◆ PROVIDE_PCIAPI_INLINE() [1/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_byte   
)

◆ PROVIDE_PCIAPI_INLINE() [2/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_word   
)

◆ PROVIDE_PCIAPI_INLINE() [3/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_read_config_dword   
)

◆ PROVIDE_PCIAPI_INLINE() [4/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_byte   
)

◆ PROVIDE_PCIAPI_INLINE() [5/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_word   
)

◆ PROVIDE_PCIAPI_INLINE() [6/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_write_config_dword   
)

◆ PROVIDE_PCIAPI_INLINE() [7/7]

PROVIDE_PCIAPI_INLINE ( pcbios  ,
pci_ioremap   
)

Variable Documentation

◆ pcibios_api

struct pci_api pcibios_api = PCIAPI_RUNTIME ( pcbios )

Definition at line 132 of file pcibios.c.

Referenced by pcicloud_init().