@@ -5,16 +5,63 @@ use crate::Status;
5
5
use core:: ffi:: c_void;
6
6
use uguid:: { guid, Guid } ;
7
7
8
- #[ derive( Debug ) ]
8
+ bitflags:: bitflags! {
9
+ /// In an NVMe command, the `flags` field specifies which cdw (command specific word)
10
+ /// contains a value.
11
+ #[ 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
+ /// Represents the `EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_*` defines from the UEFI specification.
25
+ ///
26
+ /// # UEFI Specification Description
27
+ /// Tells if the interface is for physical NVM Express controllers or logical NVM Express controllers.
28
+ ///
29
+ /// Drivers for non-RAID NVM Express controllers will set both the `PHYSICAL` and the `LOGICAL` bit.
30
+ ///
31
+ /// Drivers for RAID controllers that allow access to the underlying physical controllers will produces
32
+ /// two protocol instances. One where the `LOGICAL` bit is set (representing the logical RAID volume),
33
+ /// and one where the `PHYSICAL` bit is set, which can be used to access the underlying NVMe controllers.
34
+ ///
35
+ /// Drivers for RAID controllers that do not allow access of the underlying NVMe controllers will only
36
+ /// produce one protocol instance for the logical RAID volume with the `LOGICAL` bit set.
37
+ #[ derive( Clone , Copy , Debug , Default , PartialEq , Eq , PartialOrd , Ord ) ]
38
+ #[ repr( transparent) ]
39
+ pub struct NvmExpressPassThruAttributes : u32 {
40
+ /// If this bit is set, the interface is for directly addressable namespaces.
41
+ const PHYSICAL = 0x0001 ;
42
+
43
+ /// If this bit is set, the interface is for a single logical namespace comprising multiple namespaces.
44
+ const LOGICAL = 0x0002 ;
45
+
46
+ /// If this bit is set, the interface supports both blocking and non-blocking I/O.
47
+ /// - All interfaces must support blocking I/O, but this bit indicates that non-blocking I/O is also supported.
48
+ const NONBLOCKIO = 0x0004 ;
49
+
50
+ /// If this bit is set, the interface supports the NVM Express command set.
51
+ const CMD_SET_NVM = 0x0008 ;
52
+ }
53
+ }
54
+
55
+ #[ derive( Clone , Debug ) ]
9
56
#[ repr( C ) ]
10
57
pub struct NvmExpressPassThruMode {
11
- pub attributes : u32 ,
58
+ pub attributes : NvmExpressPassThruAttributes ,
12
59
pub io_align : u32 ,
13
60
pub nvme_version : u32 ,
14
61
}
15
62
16
63
/// This structure maps to the NVM Express specification Submission Queue Entry
17
- #[ derive( Debug ) ]
64
+ #[ derive( Debug , Default ) ]
18
65
#[ repr( C ) ]
19
66
pub struct NvmExpressCommand {
20
67
pub cdw0 : u32 ,
@@ -30,8 +77,20 @@ pub struct NvmExpressCommand {
30
77
pub cdw15 : u32 ,
31
78
}
32
79
80
+ newtype_enum ! {
81
+ /// Type of queues an NVMe command can be placed into
82
+ /// (Which queue a command should be placed into depends on the command)
83
+ #[ derive( Default ) ]
84
+ pub enum NvmExpressQueueType : u8 => {
85
+ /// Admin Submission Queue
86
+ ADMIN = 0 ,
87
+ /// 1) I/O Submission Queue
88
+ IO = 1 ,
89
+ }
90
+ }
91
+
33
92
/// This structure maps to the NVM Express specification Completion Queue Entry
34
- #[ derive( Debug ) ]
93
+ #[ derive( Debug , Default ) ]
35
94
#[ repr( C ) ]
36
95
pub struct NvmExpressCompletion {
37
96
pub dw0 : u32 ,
@@ -48,7 +107,7 @@ pub struct NvmExpressPassThruCommandPacket {
48
107
pub transfer_length : u32 ,
49
108
pub meta_data_buffer : * mut c_void ,
50
109
pub meta_data_length : u32 ,
51
- pub queue_type : u8 ,
110
+ pub queue_type : NvmExpressQueueType ,
52
111
pub nvme_cmd : * const NvmExpressCommand ,
53
112
pub nvme_completion : * mut NvmExpressCompletion ,
54
113
}
@@ -58,7 +117,7 @@ pub struct NvmExpressPassThruCommandPacket {
58
117
pub struct NvmExpressPassThruProtocol {
59
118
pub mode : * const NvmExpressPassThruMode ,
60
119
pub pass_thru : unsafe extern "efiapi" fn (
61
- this : * const Self ,
120
+ this : * mut Self ,
62
121
namespace_id : u32 ,
63
122
packet : * mut NvmExpressPassThruCommandPacket ,
64
123
event : * mut c_void ,
@@ -68,7 +127,7 @@ pub struct NvmExpressPassThruProtocol {
68
127
pub build_device_path : unsafe extern "efiapi" fn (
69
128
this : * const Self ,
70
129
namespace_id : u32 ,
71
- device_path : * mut * mut DevicePathProtocol ,
130
+ device_path : * mut * const DevicePathProtocol ,
72
131
) -> Status ,
73
132
pub get_namespace : unsafe extern "efiapi" fn (
74
133
this : * const Self ,
0 commit comments