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