uefi_raw/protocol/
nvme.rs1use super::device_path::DevicePathProtocol;
4use crate::{Status, newtype_enum};
5use core::ffi::c_void;
6use uguid::{Guid, guid};
7
8bitflags::bitflags! {
9 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
12 #[repr(transparent)]
13 pub struct NvmExpressCommandCdwValidity: u8 {
14 const CDW_2 = 0x01;
15 const CDW_3 = 0x02;
16 const CDW_10 = 0x04;
17 const CDW_11 = 0x08;
18 const CDW_12 = 0x10;
19 const CDW_13 = 0x20;
20 const CDW_14 = 0x40;
21 const CDW_15 = 0x80;
22 }
23
24 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
38 #[repr(transparent)]
39 pub struct NvmExpressPassThruAttributes: u32 {
40 const PHYSICAL = 0x0001;
42
43 const LOGICAL = 0x0002;
45
46 const NONBLOCKIO = 0x0004;
49
50 const CMD_SET_NVM = 0x0008;
52 }
53}
54
55#[derive(Clone, Debug)]
56#[repr(C)]
57pub struct NvmExpressPassThruMode {
58 pub attributes: NvmExpressPassThruAttributes,
59 pub io_align: u32,
60 pub nvme_version: u32,
61}
62
63#[derive(Debug, Default)]
65#[repr(C)]
66pub struct NvmExpressCommand {
67 pub cdw0: u32,
68 pub flags: u8,
69 pub nsid: u32,
70 pub cdw2: u32,
71 pub cdw3: u32,
72 pub cdw10: u32,
73 pub cdw11: u32,
74 pub cdw12: u32,
75 pub cdw13: u32,
76 pub cdw14: u32,
77 pub cdw15: u32,
78}
79
80newtype_enum! {
81 #[derive(Default)]
84 pub enum NvmExpressQueueType: u8 => {
85 ADMIN = 0,
87 IO = 1,
89 }
90}
91
92#[derive(Debug, Default)]
94#[repr(C)]
95pub struct NvmExpressCompletion {
96 pub dw0: u32,
97 pub dw1: u32,
98 pub dw2: u32,
99 pub dw3: u32,
100}
101
102#[derive(Debug)]
103#[repr(C)]
104pub struct NvmExpressPassThruCommandPacket {
105 pub command_timeout: u64,
106 pub transfer_buffer: *mut c_void,
107 pub transfer_length: u32,
108 pub meta_data_buffer: *mut c_void,
109 pub meta_data_length: u32,
110 pub queue_type: NvmExpressQueueType,
111 pub nvme_cmd: *const NvmExpressCommand,
112 pub nvme_completion: *mut NvmExpressCompletion,
113}
114
115#[derive(Debug)]
116#[repr(C)]
117pub struct NvmExpressPassThruProtocol {
118 pub mode: *const NvmExpressPassThruMode,
119 pub pass_thru: unsafe extern "efiapi" fn(
120 this: *mut Self,
121 namespace_id: u32,
122 packet: *mut NvmExpressPassThruCommandPacket,
123 event: *mut c_void,
124 ) -> Status,
125 pub get_next_namespace:
126 unsafe extern "efiapi" fn(this: *const Self, namespace_id: *mut u32) -> Status,
127 pub build_device_path: unsafe extern "efiapi" fn(
128 this: *const Self,
129 namespace_id: u32,
130 device_path: *mut *const DevicePathProtocol,
131 ) -> Status,
132 pub get_namespace: unsafe extern "efiapi" fn(
133 this: *const Self,
134 device_path: *const DevicePathProtocol,
135 namespace_id: *mut u32,
136 ) -> Status,
137}
138
139impl NvmExpressPassThruProtocol {
140 pub const GUID: Guid = guid!("52c78312-8edc-4233-98f2-1a1aa5e388a5");
141}