iPXE
efi_pci_api.h
Go to the documentation of this file.
1#ifndef _IPXE_EFI_PCI_API_H
2#define _IPXE_EFI_PCI_API_H
3
4/** @file
5 *
6 * iPXE PCI I/O API for EFI
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#ifdef PCIAPI_EFI
14#define PCIAPI_PREFIX_efi
15#else
16#define PCIAPI_PREFIX_efi __efi_
17#endif
18
19/* EFI PCI width codes defined by EFI spec */
20#define EFIPCI_WIDTH_BYTE 0
21#define EFIPCI_WIDTH_WORD 1
22#define EFIPCI_WIDTH_DWORD 2
23
24#define EFIPCI_LOCATION( _offset, _width ) \
25 ( (_offset) | ( (_width) << 16 ) )
26#define EFIPCI_OFFSET( _location ) ( (_location) & 0xffff )
27#define EFIPCI_WIDTH( _location ) ( (_location) >> 16 )
28
29struct pci_device;
30
31extern int efipci_read ( struct pci_device *pci, unsigned long location,
32 void *value );
33extern int efipci_write ( struct pci_device *pci, unsigned long location,
34 unsigned long 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 */
42static inline __always_inline int
44 return 0;
45}
46
47/**
48 * Read byte from PCI configuration space via EFI
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 */
55static inline __always_inline int
57 unsigned int where,
59 *value = 0xff;
60 return efipci_read ( pci,
62 value );
63}
64
65/**
66 * Read word from PCI configuration space via EFI
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 */
73static inline __always_inline int
75 unsigned int where,
76 uint16_t *value ) {
77 *value = 0xffff;
78 return efipci_read ( pci,
80 value );
81}
82
83/**
84 * Read dword from PCI configuration space via EFI
85 *
86 * @v pci PCI device
87 * @v where Location within PCI configuration space
88 * @v value Value read
89 * @ret rc Return status code
90 */
91static inline __always_inline int
93 unsigned int where,
94 uint32_t *value ) {
95 *value = 0xffffffffUL;
96 return efipci_read ( pci,
98 value );
99}
100
101/**
102 * Write byte to PCI configuration space via EFI
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 */
109static inline __always_inline int
111 unsigned int where,
112 uint8_t value ) {
113 return efipci_write ( pci,
115 value );
116}
117
118/**
119 * Write word to PCI configuration space via EFI
120 *
121 * @v pci PCI device
122 * @v where Location within PCI configuration space
123 * @v value Value to be written
124 * @ret rc Return status code
125 */
126static inline __always_inline int
128 unsigned int where,
129 uint16_t value ) {
130 return efipci_write ( pci,
132 value );
133}
134
135/**
136 * Write dword to PCI configuration space via EFI
137 *
138 * @v pci PCI device
139 * @v where Location within PCI configuration space
140 * @v value Value to be written
141 * @ret rc Return status code
142 */
143static inline __always_inline int
145 unsigned int where,
146 uint32_t value ) {
147 return efipci_write ( pci,
149 value );
150}
151
152#endif /* _IPXE_EFI_PCI_API_H */
pseudo_bit_t value[0x00020]
Definition arbel.h:2
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
#define EFIPCI_WIDTH_WORD
Definition efi_pci_api.h:21
int efipci_read(struct pci_device *pci, unsigned long location, void *value)
Read from PCI configuration space.
Definition efi_pci.c:307
#define EFIPCI_WIDTH_BYTE
Definition efi_pci_api.h:20
#define EFIPCI_LOCATION(_offset, _width)
Definition efi_pci_api.h:24
int efipci_write(struct pci_device *pci, unsigned long location, unsigned long value)
Write to PCI configuration space.
Definition efi_pci.c:340
#define EFIPCI_WIDTH_DWORD
Definition efi_pci_api.h:22
#define __always_inline
Declare a function to be always inline.
Definition compiler.h:611
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_can_probe(struct pci_device *pci)
Check if PCI bus probing is allowed.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
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_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define PCIAPI_INLINE(_subsys, _api_func)
Calculate static inline PCI I/O API function name.
Definition pci_io.h:41
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
A PCI device.
Definition pci.h:211