| 1 |
//! PCI I/O Protocol |
| 2 |
//! |
| 3 |
//! Used by code, typically drivers, running in the EFI boot services |
| 4 |
//! environment to access memory and I/O on a PCI controller. |
| 5 |
|
| 6 |
pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 7 |
0x4cf5b200, |
| 8 |
0x68b8, |
| 9 |
0x4ca5, |
| 10 |
0x9e, |
| 11 |
0xec, |
| 12 |
&[0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a], |
| 13 |
); |
| 14 |
|
| 15 |
pub type Width = u32; |
| 16 |
|
| 17 |
pub const WIDTH_UINT8: Width = 0x00000000; |
| 18 |
pub const WIDTH_UINT16: Width = 0x00000001; |
| 19 |
pub const WIDTH_UINT32: Width = 0x00000002; |
| 20 |
pub const WIDTH_UINT64: Width = 0x00000003; |
| 21 |
pub const WIDTH_FIFO_UINT8: Width = 0x00000004; |
| 22 |
pub const WIDTH_FIFO_UINT16: Width = 0x00000005; |
| 23 |
pub const WIDTH_FIFO_UINT32: Width = 0x00000006; |
| 24 |
pub const WIDTH_FIFO_UINT64: Width = 0x00000007; |
| 25 |
pub const WIDTH_FILL_UINT8: Width = 0x00000008; |
| 26 |
pub const WIDTH_FILL_UINT16: Width = 0x00000009; |
| 27 |
pub const WIDTH_FILL_UINT32: Width = 0x0000000a; |
| 28 |
pub const WIDTH_FILL_UINT64: Width = 0x0000000b; |
| 29 |
pub const WIDTH_MAXIMUM: Width = 0x0000000c; |
| 30 |
|
| 31 |
pub type Operation = u32; |
| 32 |
|
| 33 |
pub const OPERATION_BUS_MASTER_READ: Operation = 0x00000000; |
| 34 |
pub const OPERATION_BUS_MASTER_WRITE: Operation = 0x00000001; |
| 35 |
pub const OPERATION_BUS_MASTER_COMMON_BUFFER: Operation = 0x00000002; |
| 36 |
pub const OPERATION_MAXIMUM: Operation = 0x00000003; |
| 37 |
|
| 38 |
pub type Attribute = u64; |
| 39 |
|
| 40 |
pub const ATTRIBUTE_ISA_MOTHERBOARD_IO: Attribute = 0x00000001; |
| 41 |
pub const ATTRIBUTE_ISA_IO: Attribute = 0x00000002; |
| 42 |
pub const ATTRIBUTE_VGA_PALETTE_IO: Attribute = 0x00000004; |
| 43 |
pub const ATTRIBUTE_VGA_MEMORY: Attribute = 0x00000008; |
| 44 |
pub const ATTRIBUTE_VGA_IO: Attribute = 0x00000010; |
| 45 |
pub const ATTRIBUTE_IDE_PRIMARY_IO: Attribute = 0x00000020; |
| 46 |
pub const ATTRIBUTE_IDE_SECONDARY_IO: Attribute = 0x00000040; |
| 47 |
pub const ATTRIBUTE_MEMORY_WRITE_COMBINE: Attribute = 0x00000080; |
| 48 |
pub const ATTRIBUTE_IO: Attribute = 0x00000100; |
| 49 |
pub const ATTRIBUTE_MEMORY: Attribute = 0x00000200; |
| 50 |
pub const ATTRIBUTE_BUS_MASTER: Attribute = 0x00000400; |
| 51 |
pub const ATTRIBUTE_MEMORY_CACHED: Attribute = 0x00000800; |
| 52 |
pub const ATTRIBUTE_MEMORY_DISABLE: Attribute = 0x00001000; |
| 53 |
pub const ATTRIBUTE_EMBEDDED_DEVICE: Attribute = 0x00002000; |
| 54 |
pub const ATTRIBUTE_EMBEDDED_ROM: Attribute = 0x00004000; |
| 55 |
pub const ATTRIBUTE_DUAL_ADDRESS_CYCLE: Attribute = 0x00008000; |
| 56 |
pub const ATTRIBUTE_ISA_IO_16: Attribute = 0x00010000; |
| 57 |
pub const ATTRIBUTE_VGA_PALETTE_IO_16: Attribute = 0x00020000; |
| 58 |
pub const ATTRIBUTE_VGA_IO_16: Attribute = 0x00040000; |
| 59 |
|
| 60 |
pub type AttributeOperation = u32; |
| 61 |
|
| 62 |
pub const ATTRIBUTE_OPERATION_GET: AttributeOperation = 0x00000000; |
| 63 |
pub const ATTRIBUTE_OPERATION_SET: AttributeOperation = 0x00000001; |
| 64 |
pub const ATTRIBUTE_OPERATION_ENABLE: AttributeOperation = 0x00000002; |
| 65 |
pub const ATTRIBUTE_OPERATION_DISABLE: AttributeOperation = 0x00000003; |
| 66 |
pub const ATTRIBUTE_OPERATION_SUPPORTED: AttributeOperation = 0x00000004; |
| 67 |
pub const ATTRIBUTE_OPERATION_MAXIMUM: AttributeOperation = 0x00000005; |
| 68 |
|
| 69 |
pub const PASS_THROUGH_BAR: u8 = 0xff; |
| 70 |
|
| 71 |
pub type ProtocolPollIoMem = eficall! {fn( |
| 72 |
*mut Protocol, |
| 73 |
Width, |
| 74 |
u8, |
| 75 |
u64, |
| 76 |
u64, |
| 77 |
u64, |
| 78 |
u64, |
| 79 |
*mut u64, |
| 80 |
) -> crate::base::Status}; |
| 81 |
|
| 82 |
pub type ProtocolIoMem = eficall! {fn( |
| 83 |
*mut Protocol, |
| 84 |
Width, |
| 85 |
u8, |
| 86 |
u64, |
| 87 |
usize, |
| 88 |
*mut core::ffi::c_void, |
| 89 |
) -> crate::base::Status}; |
| 90 |
|
| 91 |
pub type ProtocolConfig = eficall! {fn( |
| 92 |
*mut Protocol, |
| 93 |
Width, |
| 94 |
u32, |
| 95 |
usize, |
| 96 |
*mut core::ffi::c_void, |
| 97 |
) -> crate::base::Status}; |
| 98 |
|
| 99 |
pub type ProtocolCopyMem = eficall! {fn( |
| 100 |
*mut Protocol, |
| 101 |
Width, |
| 102 |
u8, |
| 103 |
u64, |
| 104 |
u8, |
| 105 |
u64, |
| 106 |
usize, |
| 107 |
) -> crate::base::Status}; |
| 108 |
|
| 109 |
pub type ProtocolMap = eficall! {fn( |
| 110 |
*mut Protocol, |
| 111 |
Operation, |
| 112 |
*mut core::ffi::c_void, |
| 113 |
*mut usize, |
| 114 |
*mut crate::base::PhysicalAddress, |
| 115 |
*mut *mut core::ffi::c_void, |
| 116 |
) -> crate::base::Status}; |
| 117 |
|
| 118 |
pub type ProtocolUnmap = eficall! {fn( |
| 119 |
*mut Protocol, |
| 120 |
*mut core::ffi::c_void, |
| 121 |
) -> crate::base::Status}; |
| 122 |
|
| 123 |
pub type ProtocolAllocateBuffer = eficall! {fn( |
| 124 |
*mut Protocol, |
| 125 |
crate::system::AllocateType, |
| 126 |
crate::system::MemoryType, |
| 127 |
usize, |
| 128 |
*mut *mut core::ffi::c_void, |
| 129 |
Attribute, |
| 130 |
) -> crate::base::Status}; |
| 131 |
|
| 132 |
pub type ProtocolFreeBuffer = eficall! {fn( |
| 133 |
*mut Protocol, |
| 134 |
usize, |
| 135 |
*mut core::ffi::c_void, |
| 136 |
) -> crate::base::Status}; |
| 137 |
|
| 138 |
pub type ProtocolFlush = eficall! {fn( |
| 139 |
*mut Protocol, |
| 140 |
) -> crate::base::Status}; |
| 141 |
|
| 142 |
pub type ProtocolGetLocation = eficall! {fn( |
| 143 |
*mut Protocol, |
| 144 |
*mut usize, |
| 145 |
*mut usize, |
| 146 |
*mut usize, |
| 147 |
*mut usize, |
| 148 |
) -> crate::base::Status}; |
| 149 |
|
| 150 |
pub type ProtocolAttributes = eficall! {fn( |
| 151 |
*mut Protocol, |
| 152 |
AttributeOperation, |
| 153 |
Attribute, |
| 154 |
*mut Attribute, |
| 155 |
) -> crate::base::Status}; |
| 156 |
|
| 157 |
pub type ProtocolGetBarAttributes = eficall! {fn( |
| 158 |
*mut Protocol, |
| 159 |
u8, |
| 160 |
*mut Attribute, |
| 161 |
*mut *mut core::ffi::c_void, |
| 162 |
) -> crate::base::Status}; |
| 163 |
|
| 164 |
pub type ProtocolSetBarAttributes = eficall! {fn( |
| 165 |
*mut Protocol, |
| 166 |
Attribute, |
| 167 |
u8, |
| 168 |
*mut u64, |
| 169 |
*mut u64, |
| 170 |
) -> crate::base::Status}; |
| 171 |
|
| 172 |
#[repr(C)] |
| 173 |
pub struct Access { |
| 174 |
pub read: ProtocolIoMem, |
| 175 |
pub write: ProtocolIoMem, |
| 176 |
} |
| 177 |
|
| 178 |
#[repr(C)] |
| 179 |
pub struct ConfigAccess { |
| 180 |
pub read: ProtocolConfig, |
| 181 |
pub write: ProtocolConfig, |
| 182 |
} |
| 183 |
|
| 184 |
#[repr(C)] |
| 185 |
pub struct Protocol { |
| 186 |
pub poll_mem: ProtocolPollIoMem, |
| 187 |
pub poll_io: ProtocolPollIoMem, |
| 188 |
pub mem: Access, |
| 189 |
pub io: Access, |
| 190 |
pub pci: ConfigAccess, |
| 191 |
pub copy_mem: ProtocolCopyMem, |
| 192 |
pub map: ProtocolMap, |
| 193 |
pub unmap: ProtocolUnmap, |
| 194 |
pub allocate_buffer: ProtocolAllocateBuffer, |
| 195 |
pub free_buffer: ProtocolFreeBuffer, |
| 196 |
pub flush: ProtocolFlush, |
| 197 |
pub get_location: ProtocolGetLocation, |
| 198 |
pub attributes: ProtocolAttributes, |
| 199 |
pub get_bar_attributes: ProtocolGetBarAttributes, |
| 200 |
pub set_bar_attributes: ProtocolSetBarAttributes, |
| 201 |
pub rom_size: u64, |
| 202 |
pub rom_image: *mut core::ffi::c_void, |
| 203 |
} |