Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/uefi-raw/src/protocol/block.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / uefi-raw / src / protocol / block.rs` 100 lines ยท 2897 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 use crate::{Boolean, Event, Guid, Status, guid}; 4 use core::ffi::c_void; 5 6 /// Logical block address. 7 pub type Lba = u64; 8 9 /// Media information structure 10 #[repr(C)] 11 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 12 pub struct BlockIoMedia { 13 pub media_id: u32, 14 pub removable_media: Boolean, 15 pub media_present: Boolean, 16 pub logical_partition: Boolean, 17 pub read_only: Boolean, 18 pub write_caching: Boolean, 19 pub block_size: u32, 20 pub io_align: u32, 21 pub last_block: Lba, 22 23 // Added in revision 2. 24 pub lowest_aligned_lba: Lba, 25 pub logical_blocks_per_physical_block: u32, 26 27 // Added in revision 3. 28 pub optimal_transfer_length_granularity: u32, 29 } 30 31 #[derive(Debug)] 32 #[repr(C)] 33 pub struct BlockIoProtocol { 34 pub revision: u64, 35 pub media: *const BlockIoMedia, 36 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status, 37 pub read_blocks: unsafe extern "efiapi" fn( 38 this: *const Self, 39 media_id: u32, 40 lba: Lba, 41 buffer_size: usize, 42 buffer: *mut c_void, 43 ) -> Status, 44 pub write_blocks: unsafe extern "efiapi" fn( 45 this: *mut Self, 46 media_id: u32, 47 lba: Lba, 48 buffer_size: usize, 49 buffer: *const c_void, 50 ) -> Status, 51 pub flush_blocks: unsafe extern "efiapi" fn(this: *mut Self) -> Status, 52 } 53 54 impl BlockIoProtocol { 55 pub const GUID: Guid = guid!("`964e5b21`-6459-11d2-8e39-`00a0c969723b`"); 56 57 // Revision 1 is only indirectly defined in the spec, but present in edk2. 58 /// EFI_BLOCK_IO_PROTOCOL_REVISION 59 pub const REVISION: u64 = 0x0001_0000; 60 /// EFI_BLOCK_IO_PROTOCOL_REVISION2 61 pub const REVISION_2: u64 = 0x0002_0001; 62 /// EFI_BLOCK_IO_PROTOCOL_REVISION3 63 pub const REVISION_3: u64 = (2 << 16) | 31; 64 } 65 66 #[repr(C)] 67 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] 68 pub struct BlockIo2Token { 69 pub event: Event, 70 pub transaction_status: Status, 71 } 72 73 #[derive(Debug)] 74 #[repr(C)] 75 pub struct BlockIo2Protocol { 76 pub media: *const BlockIoMedia, 77 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status, 78 pub read_blocks_ex: unsafe extern "efiapi" fn( 79 this: *const Self, 80 media_id: u32, 81 lba: Lba, 82 token: *mut BlockIo2Token, 83 buffer_size: usize, 84 buffer: *mut c_void, 85 ) -> Status, 86 pub write_blocks_ex: unsafe extern "efiapi" fn( 87 this: *mut Self, 88 media_id: u32, 89 lba: Lba, 90 token: *mut BlockIo2Token, 91 buffer_size: usize, 92 buffer: *const c_void, 93 ) -> Status, 94 pub flush_blocks_ex: 95 unsafe extern "efiapi" fn(this: *mut Self, token: *mut BlockIo2Token) -> Status, 96 } 97 98 impl BlockIo2Protocol { 99 pub const GUID: Guid = guid!("`a77b2472`-e282-4e9f-a245-`c2c0e27bbcc1`"); 100 }