iPXE
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.
int pcibios_read (struct pci_device *pci, uint32_t command, uint32_t *value)
 Read configuration space via PCI BIOS.
int pcibios_write (struct pci_device *pci, uint32_t command, uint32_t value)
 Write configuration space via PCI BIOS.
 PROVIDE_PCIAPI_INLINE (pcbios, pci_can_probe)
 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)
 PROVIDE_PCIAPI_RUNTIME (pcbios, PCIAPI_PRIORITY_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()

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}
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
unsigned short uint16_t
Definition stdint.h:11
void * discard_D
Definition bigint.h:32
#define PCI_BUSDEVFN(segment, bus, slot, func)
Definition pci_io.h:30
#define REAL_CODE(asm_code_str)
Definition libkir.h:226
#define PCIBIOS_INSTALLATION_CHECK
Definition pcibios.h:23
struct pci_range range
PCI bus:dev.fn address range.
Definition pcicloud.c:40
__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")

References __asm__(), __unused, __volatile__(), busdevfn, discard_D, PCI_BUSDEVFN, PCIBIOS_INSTALLATION_CHECK, range, and REAL_CODE.

Referenced by PROVIDE_PCIAPI().

◆ 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}
pseudo_bit_t value[0x00020]
Definition arbel.h:2
uint8_t status
Status.
Definition ena.h:5
A command-line command.
Definition command.h:10
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition pci.h:238

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

Referenced by PCIAPI_INLINE(), and PCIAPI_INLINE().

◆ 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}
long discard_c
Definition bigint.h:33

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

Referenced by PCIAPI_INLINE(), PCIAPI_INLINE(), and PCIAPI_INLINE().

◆ PROVIDE_PCIAPI_INLINE() [1/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_can_probe  )

References pci_can_probe().

◆ PROVIDE_PCIAPI()

PROVIDE_PCIAPI ( pcbios ,
pci_discover ,
pcibios_discover  )

◆ PROVIDE_PCIAPI_INLINE() [2/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_read_config_byte  )

◆ PROVIDE_PCIAPI_INLINE() [3/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_read_config_word  )

◆ PROVIDE_PCIAPI_INLINE() [4/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_read_config_dword  )

◆ PROVIDE_PCIAPI_INLINE() [5/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_write_config_byte  )

◆ PROVIDE_PCIAPI_INLINE() [6/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_write_config_word  )

◆ PROVIDE_PCIAPI_INLINE() [7/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_write_config_dword  )

◆ PROVIDE_PCIAPI_INLINE() [8/8]

PROVIDE_PCIAPI_INLINE ( pcbios ,
pci_ioremap  )

References pci_ioremap().

◆ PROVIDE_PCIAPI_RUNTIME()

PROVIDE_PCIAPI_RUNTIME ( pcbios ,
PCIAPI_PRIORITY_PCBIOS  )