]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.h
MdeModulePkg/NvmExpressDxe: fix build error
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressDxe / NvmExpressPassthru.h
CommitLineData
eb290d02
FT
1/** @file\r
2 NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows\r
3 NVM Express specification.\r
4\r
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _NVM_EXPRESS_PASS_THRU_H_\r
17#define _NVM_EXPRESS_PASS_THRU_H_\r
18\r
19#define NVM_EXPRESS_PASS_THRU_PROTOCOL_GUID \\r
20 { \\r
21 0xec51ef5c, 0x2cf3, 0x4a55, {0xbf, 0x85, 0xb6, 0x3c, 0xa3, 0xb1, 0x3f, 0x44 } \\r
22 }\r
23\r
24typedef struct _NVM_EXPRESS_PASS_THRU_PROTOCOL NVM_EXPRESS_PASS_THRU_PROTOCOL;\r
25\r
26typedef struct {\r
27 UINT32 AdapterId;\r
28 UINT32 Attributes;\r
29 UINT32 IoAlign;\r
30 UINT32 HciVersion;\r
31 UINT64 Timeout;\r
32 UINT32 MaxNamespace;\r
33} NVM_EXPRESS_PASS_THRU_MODE;\r
34\r
35//\r
36// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for directly addressable namespaces.\r
37//\r
38#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001\r
39//\r
40// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for a single volume logical namespace\r
41// comprised of multiple namespaces.\r
42//\r
43#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002\r
44//\r
45// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports non blocking I/O.\r
46//\r
47#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004\r
48//\r
49// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports NVM command set commands.\r
50//\r
51#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVME 0x0008\r
52\r
53//\r
54// QueueId\r
55//\r
56#define NVME_ADMIN_QUEUE 0x00\r
57#define NVME_IO_QUEUE 0x01\r
58\r
59//\r
60// ControllerStatus\r
61//\r
62#define NVM_EXPRESS_STATUS_CONTROLLER_READY 0x00\r
63#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ERROR 0x01\r
64#define NVM_EXPRESS_STATUS_CONTROLLER_FATAL 0x02\r
65#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_DATA_ERROR 0x04\r
66#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ABORT 0x05\r
67#define NVM_EXPRESS_STATUS_CONTROLLER_DEVICE_ERROR 0x06\r
68#define NVM_EXPRESS_STATUS_CONTROLLER_TIMEOUT_COMMAND 0x09\r
69#define NVM_EXPRESS_STATUS_CONTROLLER_INVALID_NAMESPACE 0x0B\r
70#define NVM_EXPRESS_STATUS_CONTROLLER_NOT_READY 0x0C\r
71#define NVM_EXPRESS_STATUS_CONTROLLER_OTHER 0x7F\r
72\r
73typedef struct {\r
74 UINT8 Opcode;\r
75 UINT8 FusedOperation;\r
76 #define NORMAL_CMD 0x00\r
77 #define FUSED_FIRST_CMD 0x01\r
78 #define FUSED_SECOND_CMD 0x02\r
79 UINT16 Cid;\r
80} NVME_CDW0;\r
81\r
82typedef struct {\r
83 NVME_CDW0 Cdw0;\r
84 UINT8 Flags;\r
85 #define CDW10_VALID 0x01\r
86 #define CDW11_VALID 0x02\r
87 #define CDW12_VALID 0x04\r
88 #define CDW13_VALID 0x08\r
89 #define CDW14_VALID 0x10\r
90 #define CDW15_VALID 0x20\r
91 UINT32 Nsid;\r
92 UINT32 Cdw10;\r
93 UINT32 Cdw11;\r
94 UINT32 Cdw12;\r
95 UINT32 Cdw13;\r
96 UINT32 Cdw14;\r
97 UINT32 Cdw15;\r
98} NVM_EXPRESS_COMMAND;\r
99\r
100typedef struct {\r
101 UINT32 Cdw0;\r
102 UINT32 Cdw1;\r
103 UINT32 Cdw2;\r
104 UINT32 Cdw3;\r
105} NVM_EXPRESS_RESPONSE;\r
106\r
107typedef struct {\r
108 UINT64 CommandTimeout;\r
109 VOID *TransferBuffer;\r
110 UINT32 TransferLength;\r
111 VOID *MetadataBuffer;\r
112 UINT32 MetadataLength;\r
113 UINT8 QueueId;\r
114 NVM_EXPRESS_COMMAND *NvmeCmd;\r
115 NVM_EXPRESS_RESPONSE *NvmeResponse;\r
116 UINT8 ControllerStatus;\r
117} NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;\r
118\r
119//\r
120// Protocol funtion prototypes\r
121//\r
122/**\r
123 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports\r
124 both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking\r
125 I/O functionality is optional.\r
126\r
127 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
128 @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.\r
129 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace\r
130 ID specifies that the command packet should be sent to all valid namespaces.\r
131 @param[in] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.\r
132 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace\r
133 UUID specifies that the command packet should be sent to all valid namespaces.\r
134 @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified\r
135 by NamespaceId.\r
136 @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.\r
137 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O\r
138 is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM\r
139 Express Command Packet completes.\r
140\r
141 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred\r
142 to, or from DataBuffer.\r
143 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred\r
144 is returned in TransferLength.\r
145 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller\r
146 may retry again later.\r
147 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.\r
148 @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM\r
149 Express Command Packet was not sent, so no additional status information is available.\r
150 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.\r
151 The NVM Express Command Packet was not sent, so no additional status information is available.\r
152 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.\r
153\r
154**/\r
155typedef\r
156EFI_STATUS\r
157(EFIAPI *NVM_EXPRESS_PASS_THRU_PASSTHRU)(\r
158 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
159 IN UINT32 NamespaceId,\r
160 IN UINT64 NamespaceUuid,\r
161 IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,\r
162 IN EFI_EVENT Event OPTIONAL\r
163 );\r
164\r
165/**\r
166 Used to retrieve the list of namespaces defined on an NVM Express controller.\r
167\r
168 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces\r
169 defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the\r
170 namespace buffer, then the first namespace defined on the NVM Express controller is returned in\r
171 NamespaceID, and a status of EFI_SUCCESS is returned.\r
172\r
173 If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),\r
174 then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller\r
175 is returned in NamespaceId, and EFI_SUCCESS is returned.\r
176\r
177 If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to\r
178 GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.\r
179\r
180 If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then\r
181 EFI_NOT_FOUND is returned\r
182\r
183 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
184 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express\r
185 namespace present on the NVM Express controller. On output, a\r
186 pointer to the next NamespaceId of an NVM Express namespace on\r
187 an NVM Express controller. An input value of 0xFFFFFFFF retrieves\r
188 the first NamespaceId for an NVM Express namespace present on an\r
189 NVM Express controller.\r
190 @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID\r
191 is defined for that NamespaceId, otherwise, zero is returned in\r
192 this parameter. If the caller does not require a UUID, then a NULL\r
193 pointer may be passed.\r
194\r
195 @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.\r
196 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.\r
197 @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned\r
198 on a previous call to GetNextNamespace().\r
199\r
200**/\r
201typedef\r
202EFI_STATUS\r
203(EFIAPI *NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE)(\r
204 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
205 IN OUT UINT32 *NamespaceId,\r
206 OUT UINT64 *NamespaceUuid OPTIONAL\r
207 );\r
208\r
209/**\r
210 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.\r
211\r
212 The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device\r
213 path node for the NVM Express namespace specified by NamespaceId.\r
214\r
215 If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.\r
216\r
217 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r
218\r
219 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r
220\r
221 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are\r
222 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.\r
223\r
224 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
225 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be\r
226 allocated and built. Caller must set the NamespaceId to zero if the\r
227 device path node will contain a valid UUID.\r
228 @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be\r
229 allocated and built. UUID will only be valid of the Namespace ID is zero.\r
230 @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express\r
231 namespace specified by NamespaceId. This function is responsible for\r
232 allocating the buffer DevicePath with the boot service AllocatePool().\r
233 It is the caller's responsibility to free DevicePath when the caller\r
234 is finished with DevicePath.\r
235 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified\r
236 by NamespaceId was allocated and returned in DevicePath.\r
237 @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the\r
238 NVM Express controller.\r
239 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
240 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.\r
241\r
242**/\r
243typedef\r
244EFI_STATUS\r
245(EFIAPI *NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH)(\r
246 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
247 IN UINT32 NamespaceId,\r
248 IN UINT64 NamespaceUuid,\r
249 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
250 );\r
251\r
252/**\r
253 Used to translate a device path node to a Namespace ID and Namespace UUID.\r
254\r
255 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID\r
256 associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type\r
257 that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate\r
258 the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID\r
259 and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.\r
260\r
261 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
262 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on\r
263 the NVM Express controller.\r
264 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.\r
265 @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.\r
266\r
267 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.\r
268 @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER\r
269 is returned.\r
270 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver\r
271 supports, then EFI_UNSUPPORTED is returned.\r
272 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver\r
273 supports, but there is not a valid translation from DevicePath to a NamespaceID\r
274 and NamespaceUuid, then EFI_NOT_FOUND is returned.\r
275**/\r
276typedef\r
277EFI_STATUS\r
278(EFIAPI *NVM_EXPRESS_PASS_THRU_GET_NAMESPACE)(\r
279 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
280 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
281 OUT UINT32 *NamespaceId,\r
282 OUT UINT64 *NamespaceUuid\r
283 );\r
284\r
285//\r
286// Protocol Interface Structure\r
287//\r
288struct _NVM_EXPRESS_PASS_THRU_PROTOCOL {\r
289 NVM_EXPRESS_PASS_THRU_MODE *Mode;\r
290 NVM_EXPRESS_PASS_THRU_PASSTHRU PassThru;\r
291 NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE GetNextNamespace;\r
292 NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
293 NVM_EXPRESS_PASS_THRU_GET_NAMESPACE GetNamespace;\r
294};\r
295\r
296//extern EFI_GUID gNvmExpressPassThruProtocolGuid;\r
297\r
298#endif\r
299\r