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  * @v pci PCI device
39  * @ret ok Bus probing is allowed
40  */
41 static inline __always_inline int
42 PCIAPI_INLINE ( pcbios, pci_can_probe ) ( struct pci_device *pci __unused ) {
43  return 1;
44 }
45 
46 /**
47  * Read byte from PCI configuration space via PCI BIOS
48  *
49  * @v pci PCI device
50  * @v where Location within PCI configuration space
51  * @v value Value read
52  * @ret rc Return status code
53  */
54 static inline __always_inline int
55 PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci,
56  unsigned int where,
58  uint32_t tmp;
59  int rc;
60 
62  *value = tmp;
63  return rc;
64 }
65 
66 /**
67  * Read word from PCI configuration space via PCI BIOS
68  *
69  * @v pci PCI device
70  * @v where Location within PCI configuration space
71  * @v value Value read
72  * @ret rc Return status code
73  */
74 static inline __always_inline int
75 PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci,
76  unsigned int where,
77  uint16_t *value ) {
78  uint32_t tmp;
79  int rc;
80 
82  *value = tmp;
83  return rc;
84 }
85 
86 /**
87  * Read dword from PCI configuration space via PCI BIOS
88  *
89  * @v pci PCI device
90  * @v where Location within PCI configuration space
91  * @v value Value read
92  * @ret rc Return status code
93  */
94 static inline __always_inline int
95 PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci,
96  unsigned int where,
97  uint32_t *value ) {
99 }
100 
101 /**
102  * Write byte to PCI configuration space via PCI BIOS
103  *
104  * @v pci PCI device
105  * @v where Location within PCI configuration space
106  * @v value Value to be written
107  * @ret rc Return status code
108  */
109 static inline __always_inline int
110 PCIAPI_INLINE ( pcbios, pci_write_config_byte ) ( struct pci_device *pci,
111  unsigned int where,
112  uint8_t value ) {
114 }
115 
116 /**
117  * Write word to PCI configuration space via PCI BIOS
118  *
119  * @v pci PCI device
120  * @v where Location within PCI configuration space
121  * @v value Value to be written
122  * @ret rc Return status code
123  */
124 static inline __always_inline int
125 PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci,
126  unsigned int where,
127  uint16_t value ) {
129 }
130 
131 /**
132  * Write dword to PCI configuration space via PCI BIOS
133  *
134  * @v pci PCI device
135  * @v where Location within PCI configuration space
136  * @v value Value to be written
137  * @ret rc Return status code
138  */
139 static inline __always_inline int
140 PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
141  unsigned int where,
142  uint32_t value ) {
144 }
145 
146 /**
147  * Map PCI bus address as an I/O address
148  *
149  * @v bus_addr PCI bus address
150  * @v len Length of region
151  * @ret io_addr I/O address, or NULL on error
152  */
153 static inline __always_inline void *
154 PCIAPI_INLINE ( pcbios, pci_ioremap ) ( struct pci_device *pci __unused,
155  unsigned long bus_addr, size_t len ) {
156  return ioremap ( bus_addr, len );
157 }
158 
159 #endif /* _IPXE_PCIBIOS_H */
unsigned short uint16_t
Definition: stdint.h:11
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:42
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 rc
Definition: pcibios.h:59
#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:155
unsigned long tmp
Definition: linux_pci.h:64
static __always_inline void unsigned long size_t len
Definition: pcibios.h:155
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:57
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:210
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: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:56
#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.