uefi_raw/protocol/
block.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::{guid, Guid, Status};
4use core::ffi::c_void;
5
6/// Logical block address.
7pub type Lba = u64;
8
9/// Media information structure
10#[repr(C)]
11#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub struct BlockIoMedia {
13    pub media_id: u32,
14    pub removable_media: bool,
15    pub media_present: bool,
16    pub logical_partition: bool,
17    pub read_only: bool,
18    pub write_caching: bool,
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)]
33pub struct BlockIoProtocol {
34    pub revision: u64,
35    pub media: *const BlockIoMedia,
36    pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: bool) -> 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
54impl BlockIoProtocol {
55    pub const GUID: Guid = guid!("964e5b21-6459-11d2-8e39-00a0c969723b");
56}