Skip to content

Commit 691a3ed

Browse files
authored
Merge pull request #1591 from seijikun/mr-raw-nvmept
uefi-raw: Add EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL bindings
2 parents 3b17445 + fd564f8 commit 691a3ed

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

uefi-raw/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
address types.
1010
- Added `DiskInfoProtocol`.
1111
- Added `ExtScsiPassThruProtocol`.
12+
- Added `NvmExpressPassThruProtocol`.
1213

1314

1415
# uefi-raw - 0.10.0 (2025-02-07)

uefi-raw/src/protocol/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod media;
1919
pub mod memory_protection;
2020
pub mod misc;
2121
pub mod network;
22+
pub mod nvme;
2223
pub mod rng;
2324
pub mod scsi;
2425
pub mod shell_params;

uefi-raw/src/protocol/nvme.rs

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
use super::device_path::DevicePathProtocol;
4+
use crate::Status;
5+
use core::ffi::c_void;
6+
use uguid::{guid, Guid};
7+
8+
#[derive(Debug)]
9+
#[repr(C)]
10+
pub struct NvmExpressPassThruMode {
11+
pub attributes: u32,
12+
pub io_align: u32,
13+
pub nvme_version: u32,
14+
}
15+
16+
/// This structure maps to the NVM Express specification Submission Queue Entry
17+
#[derive(Debug)]
18+
#[repr(C)]
19+
pub struct NvmExpressCommand {
20+
pub cdw0: u32,
21+
pub flags: u8,
22+
pub nsid: u32,
23+
pub cdw2: u32,
24+
pub cdw3: u32,
25+
pub cdw10: u32,
26+
pub cdw11: u32,
27+
pub cdw12: u32,
28+
pub cdw13: u32,
29+
pub cdw14: u32,
30+
pub cdw15: u32,
31+
}
32+
33+
/// This structure maps to the NVM Express specification Completion Queue Entry
34+
#[derive(Debug)]
35+
#[repr(C)]
36+
pub struct NvmExpressCompletion {
37+
pub dw0: u32,
38+
pub dw1: u32,
39+
pub dw2: u32,
40+
pub dw3: u32,
41+
}
42+
43+
#[derive(Debug)]
44+
#[repr(C)]
45+
pub struct NvmExpressPassThruCommandPacket {
46+
pub command_timeout: u64,
47+
pub transfer_buffer: *mut c_void,
48+
pub transfer_length: u32,
49+
pub meta_data_buffer: *mut c_void,
50+
pub meta_data_length: u32,
51+
pub queue_type: u8,
52+
pub nvme_cmd: *const NvmExpressCommand,
53+
pub nvme_completion: *mut NvmExpressCompletion,
54+
}
55+
56+
#[derive(Debug)]
57+
#[repr(C)]
58+
pub struct NvmExpressPassThruProtocol {
59+
pub mode: *const NvmExpressPassThruMode,
60+
pub pass_thru: unsafe extern "efiapi" fn(
61+
this: *const Self,
62+
namespace_id: u32,
63+
packet: *mut NvmExpressPassThruCommandPacket,
64+
event: *mut c_void,
65+
) -> Status,
66+
pub get_next_namespace:
67+
unsafe extern "efiapi" fn(this: *const Self, namespace_id: *mut u32) -> Status,
68+
pub build_device_path: unsafe extern "efiapi" fn(
69+
this: *const Self,
70+
namespace_id: u32,
71+
device_path: *mut *mut DevicePathProtocol,
72+
) -> Status,
73+
pub get_namespace: unsafe extern "efiapi" fn(
74+
this: *const Self,
75+
device_path: *const DevicePathProtocol,
76+
namespace_id: *mut u32,
77+
) -> Status,
78+
}
79+
80+
impl NvmExpressPassThruProtocol {
81+
pub const GUID: Guid = guid!("52c78312-8edc-4233-98f2-1a1aa5e388a5");
82+
}

0 commit comments

Comments
 (0)