iPXE
pcibios.h
Go to the documentation of this file.
1 #ifndef _IPXE_PCIBIOS_H
2 #define _IPXE_PCIBIOS_H
3 
4 #include <stdint.h>
5 
6 /** @file
7  *
8  * PCI configuration space access via PCI BIOS
9  *
10  */
11 
12 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 
14 #ifdef PCIAPI_PCBIOS
15 #define PCIAPI_PREFIX_pcbios
16 #else
17 #define PCIAPI_PREFIX_pcbios __pcbios_
18 #endif
19 
20 struct pci_device;
21 
22 #define PCIBIOS_INSTALLATION_CHECK 0xb1010000
23 #define PCIBIOS_READ_CONFIG_BYTE 0xb1080000
24 #define PCIBIOS_READ_CONFIG_WORD 0xb1090000
25 #define PCIBIOS_READ_CONFIG_DWORD 0xb10a0000
26 #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b0000
27 #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000
28 #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000
29 
30 extern int pcibios_read ( struct pci_device *pci, uint32_t command,
31  uint32_t *value );
32 extern int pcibios_write ( struct pci_device *pci, uint32_t command,
33  uint32_t value );
34 
35 /**
36  * Check if PCI bus probing is allowed
37  *
38  * @ret ok Bus probing is allowed
39  */
40 static inline __always_inline int
41 PCIAPI_INLINE ( pcbios, pci_can_probe ) ( void ) {
42  return 1;
43 }
44 
45 /**
46  * Read byte from PCI configuration space via PCI BIOS
47  *
48  * @v pci PCI device
49  * @v where Location within PCI configuration space
50  * @v value Value read
51  * @ret rc Return status code
52  */
53 static inline __always_inline int
54 PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci,
55  unsigned int where,
57  uint32_t tmp;
58  int rc;
59 
61  *value = tmp;
62  return rc;
63 }
64 
65 /**
66  * Read word from PCI configuration space via PCI BIOS
67  *
68  * @v pci PCI device
69  * @v where Location within PCI configuration space
70  * @v value Value read
71  * @ret rc Return status code
72  */
73 static inline __always_inline int
74 PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci,
75  unsigned int where,
76  uint16_t *value ) {
77  uint32_t tmp;
78  int rc;
79 
81  *value = tmp;
82  return rc;
83 }
84 
85 /**
86  * Read dword from PCI configuration space via PCI BIOS
87  *
88  * @v pci PCI device
89  * @v where Location within PCI configuration space
90  * @v value Value read
91  * @ret rc Return status code
92  */
93 static inline __always_inline int
94 PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci,
95  unsigned int where,
96  uint32_t *value ) {
98 }
99 
100 /**
101  * Write byte to PCI configuration space via PCI BIOS
102  *
103  * @v pci PCI device
104  * @v where Location within PCI configuration space
105  * @v value Value to be written
106  * @ret rc Return status code
107  */
108 static inline __always_inline int
109 PCIAPI_INLINE ( pcbios, pci_write_config_byte ) ( struct pci_device *pci,
110  unsigned int where,
111  uint8_t value ) {
113 }
114 
115 /**
116  * Write word to PCI configuration space via PCI BIOS
117  *
118  * @v pci PCI device
119  * @v where Location within PCI configuration space
120  * @v value Value to be written
121  * @ret rc Return status code
122  */
123 static inline __always_inline int
124 PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci,
125  unsigned int where,
126  uint16_t value ) {
128 }
129 
130 /**
131  * Write dword to PCI configuration space via PCI BIOS
132  *
133  * @v pci PCI device
134  * @v where Location within PCI configuration space
135  * @v value Value to be written
136  * @ret rc Return status code
137  */
138 static inline __always_inline int
139 PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
140  unsigned int where,
141  uint32_t value ) {
143 }
144 
145 /**
146  * Map PCI bus address as an I/O address
147  *
148  * @v bus_addr PCI bus address
149  * @v len Length of region
150  * @ret io_addr I/O address, or NULL on error
151  */
152 static inline __always_inline void *
153 PCIAPI_INLINE ( pcbios, pci_ioremap ) ( struct pci_device *pci __unused,
154  unsigned long bus_addr, size_t len ) {
155  return ioremap ( bus_addr, len );
156 }
157 
158 extern struct pci_api pcibios_api;
159 
160 #endif /* _IPXE_PCIBIOS_H */
unsigned short uint16_t
Definition: stdint.h:11
A command-line command.
Definition: command.h:9
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_can_probe(void)
Check if PCI bus probing is allowed.
int rc
Definition: pcibios.h:58
#define PCIBIOS_READ_CONFIG_DWORD
Definition: pcibios.h:25
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
static __always_inline void unsigned long bus_addr
Definition: pcibios.h:154
unsigned long tmp
Definition: linux_pci.h:63
static __always_inline void unsigned long size_t len
Definition: pcibios.h:154
struct pci_api pcibios_api
Definition: pcibios.c:133
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static __always_inline int PCIAPI_INLINE(pcbios, pci_can_probe)(void)
Check if PCI bus probing is allowed.
Definition: pcibios.h:41
static __always_inline int unsigned int uint8_t * value
Definition: pcibios.h:56
int pcibios_write(struct pci_device *pci, uint32_t command, uint32_t value)
Write configuration space via PCI BIOS.
Definition: pcibios.c:105
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
A PCI device.
Definition: pci.h:206
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A runtime selectable PCI I/O API.
Definition: pci_io.h:162
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
#define PCIBIOS_WRITE_CONFIG_BYTE
Definition: pcibios.h:26
#define PCIBIOS_WRITE_CONFIG_DWORD
Definition: pcibios.h:28
unsigned char uint8_t
Definition: stdint.h:10
#define PCIBIOS_READ_CONFIG_BYTE
Definition: pcibios.h:23
unsigned int uint32_t
Definition: stdint.h:12
int pcibios_read(struct pci_device *pci, uint32_t command, uint32_t *value)
Read configuration space via PCI BIOS.
Definition: pcibios.c:77
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
static __always_inline int unsigned int where
Definition: pcibios.h:55
#define PCIBIOS_WRITE_CONFIG_WORD
Definition: pcibios.h:27
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define PCIBIOS_READ_CONFIG_WORD
Definition: pcibios.h:24
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.