aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / uefi-raw / src / protocol / pci / root_bridge.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | use crate::table::boot::{AllocateType, MemoryType}; |
| 4 | use crate::{Handle, PhysicalAddress, Status, newtype_enum}; |
| 5 | use bitflags::bitflags; |
| 6 | use core::ffi::c_void; |
| 7 | use uguid::{Guid, guid}; |
| 8 | |
| 9 | newtype_enum! { |
| 10 | /// Corresponds to the `EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH` enum. |
| 11 | pub enum PciRootBridgeIoProtocolWidth: u32 => { |
| 12 | UINT8 = 0, |
| 13 | UINT16 = 1, |
| 14 | UINT32 = 2, |
| 15 | UINT64 = 3, |
| 16 | FIFO_UINT8 = 4, |
| 17 | FIFO_UINT16 = 5, |
| 18 | FIFO_UINT32 = 6, |
| 19 | FIFO_UINT64 = 7, |
| 20 | FILL_UINT8 = 8, |
| 21 | FILL_UINT16 = 9, |
| 22 | FILL_UINT32 = 10, |
| 23 | FILL_UINT64 = 11, |
| 24 | MAXIMUM = 12, |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | newtype_enum! { |
| 29 | /// Corresponds to the `EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION` enum. |
| 30 | pub enum PciRootBridgeIoProtocolOperation: u32 => { |
| 31 | BUS_MASTER_READ = 0, |
| 32 | BUS_MASTER_WRITE = 1, |
| 33 | BUS_MASTER_COMMON_BUFFER = 2, |
| 34 | BUS_MASTER_READ64 = 3, |
| 35 | BUS_MASTER_WRITE64 = 4, |
| 36 | BUS_MASTER_COMMON_BUFFER64 = 5, |
| 37 | MAXIMUM = 6, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | bitflags! { |
| 42 | /// Corresponds to the `EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL` attribute bitflags. |
| 43 | #[repr(transparent)] |
| 44 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
| 45 | pub struct PciRootBridgeIoProtocolAttributes: u64 { |
| 46 | const EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO = 0x0001; |
| 47 | const EFI_PCI_ATTRIBUTE_ISA_IO = 0x0002; |
| 48 | const EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO = 0x0004; |
| 49 | const EFI_PCI_ATTRIBUTE_VGA_MEMORY = 0x0008; |
| 50 | const EFI_PCI_ATTRIBUTE_VGA_IO = 0x0010; |
| 51 | const EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO = 0x0020; |
| 52 | const EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO = 0x0040; |
| 53 | const EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE = 0x0080; |
| 54 | const EFI_PCI_ATTRIBUTE_MEMORY_CACHED = 0x0800; |
| 55 | const EFI_PCI_ATTRIBUTE_MEMORY_DISABLE = 0x1000; |
| 56 | const EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE = 0x8000; |
| 57 | const EFI_PCI_ATTRIBUTE_ISA_IO_16 = 0x10000; |
| 58 | const EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 = 0x20000; |
| 59 | const EFI_PCI_ATTRIBUTE_VGA_IO_16 = 0x40000; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | #[derive(Copy, Clone, Debug)] |
| 64 | #[repr(C)] |
| 65 | pub struct PciRootBridgeIoAccess { |
| 66 | pub read: unsafe extern "efiapi" fn( |
| 67 | this: *mut PciRootBridgeIoProtocol, |
| 68 | width: PciRootBridgeIoProtocolWidth, |
| 69 | address: u64, |
| 70 | count: usize, |
| 71 | buffer: *mut c_void, |
| 72 | ) -> Status, |
| 73 | pub write: unsafe extern "efiapi" fn( |
| 74 | this: *mut PciRootBridgeIoProtocol, |
| 75 | width: PciRootBridgeIoProtocolWidth, |
| 76 | address: u64, |
| 77 | count: usize, |
| 78 | buffer: *const c_void, |
| 79 | ) -> Status, |
| 80 | } |
| 81 | |
| 82 | #[derive(Debug)] |
| 83 | #[repr(C)] |
| 84 | pub struct PciRootBridgeIoProtocol { |
| 85 | pub parent_handle: Handle, |
| 86 | pub poll_mem: unsafe extern "efiapi" fn( |
| 87 | this: *mut Self, |
| 88 | width: PciRootBridgeIoProtocolWidth, |
| 89 | address: u64, |
| 90 | mask: u64, |
| 91 | value: u64, |
| 92 | delay: u64, |
| 93 | result: *mut u64, |
| 94 | ) -> Status, |
| 95 | pub poll_io: unsafe extern "efiapi" fn( |
| 96 | this: *mut Self, |
| 97 | width: PciRootBridgeIoProtocolWidth, |
| 98 | address: u64, |
| 99 | mask: u64, |
| 100 | value: u64, |
| 101 | delay: u64, |
| 102 | result: *mut u64, |
| 103 | ) -> Status, |
| 104 | pub mem: PciRootBridgeIoAccess, |
| 105 | pub io: PciRootBridgeIoAccess, |
| 106 | pub pci: PciRootBridgeIoAccess, |
| 107 | pub copy_mem: unsafe extern "efiapi" fn( |
| 108 | this: *mut Self, |
| 109 | width: PciRootBridgeIoProtocolWidth, |
| 110 | dest_addr: u64, |
| 111 | src_addr: u64, |
| 112 | count: usize, |
| 113 | ) -> Status, |
| 114 | pub map: unsafe extern "efiapi" fn( |
| 115 | this: *const Self, |
| 116 | operation: PciRootBridgeIoProtocolOperation, |
| 117 | host_addr: *const c_void, |
| 118 | num_bytes: *mut usize, |
| 119 | device_addr: *mut PhysicalAddress, |
| 120 | mapping: *mut *mut c_void, |
| 121 | ) -> Status, |
| 122 | pub unmap: unsafe extern "efiapi" fn(this: *const Self, mapping: *const c_void) -> Status, |
| 123 | pub allocate_buffer: unsafe extern "efiapi" fn( |
| 124 | this: *const Self, |
| 125 | alloc_ty: AllocateType, |
| 126 | memory_ty: MemoryType, |
| 127 | pages: usize, |
| 128 | host_addr: *mut *mut c_void, |
| 129 | attributes: u64, |
| 130 | ) -> Status, |
| 131 | pub free_buffer: unsafe extern "efiapi" fn( |
| 132 | this: *const Self, |
| 133 | pages: usize, |
| 134 | host_addr: *const c_void, |
| 135 | ) -> Status, |
| 136 | pub flush: unsafe extern "efiapi" fn(this: *mut Self) -> Status, |
| 137 | pub get_attributes: unsafe extern "efiapi" fn( |
| 138 | this: *const Self, |
| 139 | supports: *mut u64, |
| 140 | attributes: *mut u64, |
| 141 | ) -> Status, |
| 142 | pub set_attributes: unsafe extern "efiapi" fn( |
| 143 | this: *mut Self, |
| 144 | attributes: u64, |
| 145 | resource_base: *mut u64, |
| 146 | resource_length: *mut u64, |
| 147 | ) -> Status, |
| 148 | pub configuration: |
| 149 | unsafe extern "efiapi" fn(this: *const Self, resources: *mut *const c_void) -> Status, |
| 150 | pub segment_number: u32, |
| 151 | } |
| 152 | |
| 153 | impl PciRootBridgeIoProtocol { |
| 154 | pub const GUID: Guid = guid!("2f707ebb-4a1a-11d4-9a38-0090273fc14d"); |
| 155 | } |