]>
Commit | Line | Data |
---|---|---|
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 | |
e79bed78 | 5 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
63d8431a | 6 | Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
eb290d02 FT |
8 | \r |
9 | **/\r | |
10 | \r | |
11 | #ifndef _EFI_NVM_EXPRESS_H_\r | |
12 | #define _EFI_NVM_EXPRESS_H_\r | |
13 | \r | |
14 | #include <Uefi.h>\r | |
15 | \r | |
16 | #include <IndustryStandard/Pci.h>\r | |
e79bed78 | 17 | #include <IndustryStandard/Nvme.h>\r |
eb290d02 FT |
18 | \r |
19 | #include <Protocol/ComponentName.h>\r | |
20 | #include <Protocol/ComponentName2.h>\r | |
21 | #include <Protocol/DriverBinding.h>\r | |
22 | #include <Protocol/LoadedImage.h>\r | |
23 | #include <Protocol/DevicePath.h>\r | |
24 | #include <Protocol/PciIo.h>\r | |
d6c55989 | 25 | #include <Protocol/NvmExpressPassthru.h>\r |
eb290d02 | 26 | #include <Protocol/BlockIo.h>\r |
758ea946 | 27 | #include <Protocol/BlockIo2.h>\r |
eb290d02 FT |
28 | #include <Protocol/DiskInfo.h>\r |
29 | #include <Protocol/DriverSupportedEfiVersion.h>\r | |
754b489b | 30 | #include <Protocol/StorageSecurityCommand.h>\r |
7111e46f | 31 | #include <Protocol/ResetNotification.h>\r |
eb290d02 FT |
32 | \r |
33 | #include <Library/BaseLib.h>\r | |
34 | #include <Library/BaseMemoryLib.h>\r | |
35 | #include <Library/DebugLib.h>\r | |
36 | #include <Library/PrintLib.h>\r | |
37 | #include <Library/UefiLib.h>\r | |
38 | #include <Library/DevicePathLib.h>\r | |
39 | #include <Library/MemoryAllocationLib.h>\r | |
40 | #include <Library/UefiBootServicesTableLib.h>\r | |
41 | #include <Library/UefiDriverEntryPoint.h>\r | |
63d8431a | 42 | #include <Library/ReportStatusCodeLib.h>\r |
eb290d02 | 43 | \r |
1436aea4 MK |
44 | typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA;\r |
45 | typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;\r | |
eb290d02 | 46 | \r |
eb290d02 FT |
47 | #include "NvmExpressBlockIo.h"\r |
48 | #include "NvmExpressDiskInfo.h"\r | |
49 | #include "NvmExpressHci.h"\r | |
50 | \r | |
51 | extern EFI_DRIVER_BINDING_PROTOCOL gNvmExpressDriverBinding;\r | |
52 | extern EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentName;\r | |
53 | extern EFI_COMPONENT_NAME2_PROTOCOL gNvmExpressComponentName2;\r | |
54 | extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion;\r | |
55 | \r | |
1436aea4 MK |
56 | #define PCI_CLASS_MASS_STORAGE_NVM 0x08 // mass storage sub-class non-volatile memory.\r |
57 | #define PCI_IF_NVMHCI 0x02 // mass storage programming interface NVMHCI.\r | |
eb290d02 | 58 | \r |
1436aea4 MK |
59 | #define NVME_ASQ_SIZE 1 // Number of admin submission queue entries, which is 0-based\r |
60 | #define NVME_ACQ_SIZE 1 // Number of admin completion queue entries, which is 0-based\r | |
eb290d02 | 61 | \r |
1436aea4 MK |
62 | #define NVME_CSQ_SIZE 1 // Number of I/O submission queue entries, which is 0-based\r |
63 | #define NVME_CCQ_SIZE 1 // Number of I/O completion queue entries, which is 0-based\r | |
eb290d02 | 64 | \r |
758ea946 HW |
65 | //\r |
66 | // Number of asynchronous I/O submission queue entries, which is 0-based.\r | |
67 | // The asynchronous I/O submission queue size is 4kB in total.\r | |
68 | //\r | |
1436aea4 | 69 | #define NVME_ASYNC_CSQ_SIZE 63\r |
758ea946 HW |
70 | //\r |
71 | // Number of asynchronous I/O completion queue entries, which is 0-based.\r | |
72 | // The asynchronous I/O completion queue size is 4kB in total.\r | |
73 | //\r | |
1436aea4 | 74 | #define NVME_ASYNC_CCQ_SIZE 255\r |
758ea946 | 75 | \r |
1436aea4 | 76 | #define NVME_MAX_QUEUES 3 // Number of queues supported by the driver\r |
eb290d02 | 77 | \r |
1436aea4 | 78 | #define NVME_CONTROLLER_ID 0\r |
eb290d02 FT |
79 | \r |
80 | //\r | |
81 | // Time out value for Nvme transaction execution\r | |
82 | //\r | |
1436aea4 | 83 | #define NVME_GENERIC_TIMEOUT EFI_TIMER_PERIOD_SECONDS (5)\r |
eb290d02 | 84 | \r |
758ea946 HW |
85 | //\r |
86 | // Nvme async transfer timer interval, set by experience.\r | |
87 | //\r | |
1436aea4 | 88 | #define NVME_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS (1)\r |
758ea946 | 89 | \r |
eb290d02 FT |
90 | //\r |
91 | // Unique signature for private data structure.\r | |
92 | //\r | |
1436aea4 | 93 | #define NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N','V','M','E')\r |
eb290d02 FT |
94 | \r |
95 | //\r | |
96 | // Nvme private data structure.\r | |
97 | //\r | |
98 | struct _NVME_CONTROLLER_PRIVATE_DATA {\r | |
1436aea4 | 99 | UINT32 Signature;\r |
eb290d02 | 100 | \r |
1436aea4 MK |
101 | EFI_HANDLE ControllerHandle;\r |
102 | EFI_HANDLE ImageHandle;\r | |
103 | EFI_HANDLE DriverBindingHandle;\r | |
eb290d02 | 104 | \r |
1436aea4 MK |
105 | EFI_PCI_IO_PROTOCOL *PciIo;\r |
106 | UINT64 PciAttributes;\r | |
eb290d02 | 107 | \r |
1436aea4 | 108 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r |
eb290d02 | 109 | \r |
1436aea4 MK |
110 | EFI_NVM_EXPRESS_PASS_THRU_MODE PassThruMode;\r |
111 | EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL Passthru;\r | |
eb290d02 FT |
112 | \r |
113 | //\r | |
114 | // pointer to identify controller data\r | |
115 | //\r | |
1436aea4 | 116 | NVME_ADMIN_CONTROLLER_DATA *ControllerData;\r |
eb290d02 FT |
117 | \r |
118 | //\r | |
758ea946 | 119 | // 6 x 4kB aligned buffers will be carved out of this buffer.\r |
eb290d02 | 120 | // 1st 4kB boundary is the start of the admin submission queue.\r |
5db1ac89 FT |
121 | // 2nd 4kB boundary is the start of the admin completion queue.\r |
122 | // 3rd 4kB boundary is the start of I/O submission queue #1.\r | |
123 | // 4th 4kB boundary is the start of I/O completion queue #1.\r | |
758ea946 HW |
124 | // 5th 4kB boundary is the start of I/O submission queue #2.\r |
125 | // 6th 4kB boundary is the start of I/O completion queue #2.\r | |
eb290d02 | 126 | //\r |
1436aea4 MK |
127 | UINT8 *Buffer;\r |
128 | UINT8 *BufferPciAddr;\r | |
eb290d02 FT |
129 | \r |
130 | //\r | |
131 | // Pointers to 4kB aligned submission & completion queues.\r | |
132 | //\r | |
1436aea4 MK |
133 | NVME_SQ *SqBuffer[NVME_MAX_QUEUES];\r |
134 | NVME_CQ *CqBuffer[NVME_MAX_QUEUES];\r | |
135 | NVME_SQ *SqBufferPciAddr[NVME_MAX_QUEUES];\r | |
136 | NVME_CQ *CqBufferPciAddr[NVME_MAX_QUEUES];\r | |
eb290d02 FT |
137 | \r |
138 | //\r | |
139 | // Submission and completion queue indices.\r | |
140 | //\r | |
1436aea4 MK |
141 | NVME_SQTDBL SqTdbl[NVME_MAX_QUEUES];\r |
142 | NVME_CQHDBL CqHdbl[NVME_MAX_QUEUES];\r | |
143 | UINT16 AsyncSqHead;\r | |
eb290d02 | 144 | \r |
8411c9d5 HW |
145 | //\r |
146 | // Flag to indicate internal IO queue creation.\r | |
147 | //\r | |
1436aea4 | 148 | BOOLEAN CreateIoQueue;\r |
8411c9d5 | 149 | \r |
1436aea4 MK |
150 | UINT8 Pt[NVME_MAX_QUEUES];\r |
151 | UINT16 Cid[NVME_MAX_QUEUES];\r | |
eb290d02 FT |
152 | \r |
153 | //\r | |
154 | // Nvme controller capabilities\r | |
155 | //\r | |
1436aea4 | 156 | NVME_CAP Cap;\r |
eb290d02 | 157 | \r |
1436aea4 | 158 | VOID *Mapping;\r |
758ea946 HW |
159 | \r |
160 | //\r | |
161 | // For Non-blocking operations.\r | |
162 | //\r | |
1436aea4 MK |
163 | EFI_EVENT TimerEvent;\r |
164 | LIST_ENTRY AsyncPassThruQueue;\r | |
165 | LIST_ENTRY UnsubmittedSubtasks;\r | |
eb290d02 FT |
166 | };\r |
167 | \r | |
168 | #define NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU(a) \\r | |
169 | CR (a, \\r | |
170 | NVME_CONTROLLER_PRIVATE_DATA, \\r | |
171 | Passthru, \\r | |
172 | NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE \\r | |
173 | )\r | |
174 | \r | |
175 | //\r | |
176 | // Unique signature for private data structure.\r | |
177 | //\r | |
1436aea4 | 178 | #define NVME_DEVICE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X','S','S','D')\r |
eb290d02 FT |
179 | \r |
180 | //\r | |
181 | // Nvme device private data structure\r | |
182 | //\r | |
183 | struct _NVME_DEVICE_PRIVATE_DATA {\r | |
754b489b | 184 | UINT32 Signature;\r |
eb290d02 | 185 | \r |
754b489b TF |
186 | EFI_HANDLE DeviceHandle;\r |
187 | EFI_HANDLE ControllerHandle;\r | |
188 | EFI_HANDLE DriverBindingHandle;\r | |
eb290d02 | 189 | \r |
754b489b | 190 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r |
eb290d02 | 191 | \r |
754b489b | 192 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r |
eb290d02 | 193 | \r |
754b489b TF |
194 | UINT32 NamespaceId;\r |
195 | UINT64 NamespaceUuid;\r | |
eb290d02 | 196 | \r |
754b489b TF |
197 | EFI_BLOCK_IO_MEDIA Media;\r |
198 | EFI_BLOCK_IO_PROTOCOL BlockIo;\r | |
758ea946 | 199 | EFI_BLOCK_IO2_PROTOCOL BlockIo2;\r |
754b489b TF |
200 | EFI_DISK_INFO_PROTOCOL DiskInfo;\r |
201 | EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;\r | |
eb290d02 | 202 | \r |
758ea946 HW |
203 | LIST_ENTRY AsyncQueue;\r |
204 | \r | |
754b489b | 205 | EFI_LBA NumBlocks;\r |
eb290d02 | 206 | \r |
754b489b TF |
207 | CHAR16 ModelName[80];\r |
208 | NVME_ADMIN_NAMESPACE_DATA NamespaceData;\r | |
eb290d02 | 209 | \r |
754b489b | 210 | NVME_CONTROLLER_PRIVATE_DATA *Controller;\r |
eb290d02 FT |
211 | };\r |
212 | \r | |
213 | //\r | |
214 | // Statments to retrieve the private data from produced protocols.\r | |
215 | //\r | |
216 | #define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO(a) \\r | |
217 | CR (a, \\r | |
218 | NVME_DEVICE_PRIVATE_DATA, \\r | |
219 | BlockIo, \\r | |
220 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
221 | )\r | |
222 | \r | |
758ea946 HW |
223 | #define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO2(a) \\r |
224 | CR (a, \\r | |
225 | NVME_DEVICE_PRIVATE_DATA, \\r | |
226 | BlockIo2, \\r | |
227 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
228 | )\r | |
229 | \r | |
eb290d02 FT |
230 | #define NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO(a) \\r |
231 | CR (a, \\r | |
232 | NVME_DEVICE_PRIVATE_DATA, \\r | |
233 | DiskInfo, \\r | |
234 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
235 | )\r | |
236 | \r | |
1436aea4 | 237 | #define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a) \\r |
754b489b TF |
238 | CR (a, \\r |
239 | NVME_DEVICE_PRIVATE_DATA, \\r | |
240 | StorageSecurity, \\r | |
241 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
242 | )\r | |
243 | \r | |
758ea946 HW |
244 | //\r |
245 | // Nvme block I/O 2 request.\r | |
246 | //\r | |
1436aea4 | 247 | #define NVME_BLKIO2_REQUEST_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'R')\r |
758ea946 HW |
248 | \r |
249 | typedef struct {\r | |
1436aea4 MK |
250 | UINT32 Signature;\r |
251 | LIST_ENTRY Link;\r | |
758ea946 | 252 | \r |
1436aea4 MK |
253 | EFI_BLOCK_IO2_TOKEN *Token;\r |
254 | UINTN UnsubmittedSubtaskNum;\r | |
255 | BOOLEAN LastSubtaskSubmitted;\r | |
758ea946 HW |
256 | //\r |
257 | // The queue for Nvme read/write sub-tasks of a BlockIo2 request.\r | |
258 | //\r | |
1436aea4 | 259 | LIST_ENTRY SubtasksQueue;\r |
758ea946 HW |
260 | } NVME_BLKIO2_REQUEST;\r |
261 | \r | |
262 | #define NVME_BLKIO2_REQUEST_FROM_LINK(a) \\r | |
263 | CR (a, NVME_BLKIO2_REQUEST, Link, NVME_BLKIO2_REQUEST_SIGNATURE)\r | |
264 | \r | |
1436aea4 | 265 | #define NVME_BLKIO2_SUBTASK_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'S')\r |
758ea946 HW |
266 | \r |
267 | typedef struct {\r | |
1436aea4 MK |
268 | UINT32 Signature;\r |
269 | LIST_ENTRY Link;\r | |
758ea946 | 270 | \r |
1436aea4 MK |
271 | BOOLEAN IsLast;\r |
272 | UINT32 NamespaceId;\r | |
273 | EFI_EVENT Event;\r | |
274 | EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *CommandPacket;\r | |
758ea946 HW |
275 | //\r |
276 | // The BlockIo2 request this subtask belongs to\r | |
277 | //\r | |
1436aea4 | 278 | NVME_BLKIO2_REQUEST *BlockIo2Request;\r |
758ea946 HW |
279 | } NVME_BLKIO2_SUBTASK;\r |
280 | \r | |
281 | #define NVME_BLKIO2_SUBTASK_FROM_LINK(a) \\r | |
282 | CR (a, NVME_BLKIO2_SUBTASK, Link, NVME_BLKIO2_SUBTASK_SIGNATURE)\r | |
283 | \r | |
284 | //\r | |
285 | // Nvme asynchronous passthru request.\r | |
286 | //\r | |
1436aea4 | 287 | #define NVME_PASS_THRU_ASYNC_REQ_SIG SIGNATURE_32 ('N', 'P', 'A', 'R')\r |
758ea946 HW |
288 | \r |
289 | typedef struct {\r | |
1436aea4 MK |
290 | UINT32 Signature;\r |
291 | LIST_ENTRY Link;\r | |
292 | \r | |
293 | EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet;\r | |
294 | UINT16 CommandId;\r | |
295 | VOID *MapPrpList;\r | |
296 | UINTN PrpListNo;\r | |
297 | VOID *PrpListHost;\r | |
298 | VOID *MapData;\r | |
299 | VOID *MapMeta;\r | |
300 | EFI_EVENT CallerEvent;\r | |
758ea946 HW |
301 | } NVME_PASS_THRU_ASYNC_REQ;\r |
302 | \r | |
303 | #define NVME_PASS_THRU_ASYNC_REQ_FROM_THIS(a) \\r | |
304 | CR (a, \\r | |
305 | NVME_PASS_THRU_ASYNC_REQ, \\r | |
306 | Link, \\r | |
307 | NVME_PASS_THRU_ASYNC_REQ_SIG \\r | |
308 | )\r | |
309 | \r | |
eb290d02 FT |
310 | /**\r |
311 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
312 | \r | |
313 | This function retrieves the user readable name of a driver in the form of a\r | |
314 | Unicode string. If the driver specified by This has a user readable name in\r | |
315 | the language specified by Language, then a pointer to the driver name is\r | |
316 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
317 | by This does not support the language specified by Language,\r | |
318 | then EFI_UNSUPPORTED is returned.\r | |
319 | \r | |
320 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
321 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
322 | \r | |
323 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
324 | array indicating the language. This is the\r | |
325 | language of the driver name that the caller is\r | |
326 | requesting, and it must match one of the\r | |
327 | languages specified in SupportedLanguages. The\r | |
328 | number of languages supported by a driver is up\r | |
329 | to the driver writer. Language is specified\r | |
330 | in RFC 4646 or ISO 639-2 language code format.\r | |
331 | \r | |
332 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
333 | This Unicode string is the name of the\r | |
334 | driver specified by This in the language\r | |
335 | specified by Language.\r | |
336 | \r | |
337 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
338 | This and the language specified by Language was\r | |
339 | returned in DriverName.\r | |
340 | \r | |
341 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
342 | \r | |
343 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
344 | \r | |
345 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
346 | the language specified by Language.\r | |
347 | \r | |
348 | **/\r | |
349 | EFI_STATUS\r | |
350 | EFIAPI\r | |
351 | NvmExpressComponentNameGetDriverName (\r | |
352 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
353 | IN CHAR8 *Language,\r | |
354 | OUT CHAR16 **DriverName\r | |
355 | );\r | |
356 | \r | |
357 | /**\r | |
358 | Retrieves a Unicode string that is the user readable name of the controller\r | |
359 | that is being managed by a driver.\r | |
360 | \r | |
361 | This function retrieves the user readable name of the controller specified by\r | |
362 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
363 | driver specified by This has a user readable name in the language specified by\r | |
364 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
365 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
366 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
367 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
368 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
369 | \r | |
370 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
371 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
372 | \r | |
373 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
374 | specified by This is managing. This handle\r | |
375 | specifies the controller whose name is to be\r | |
376 | returned.\r | |
377 | \r | |
378 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
379 | the name of. This is an optional parameter that\r | |
380 | may be NULL. It will be NULL for device\r | |
381 | drivers. It will also be NULL for a bus drivers\r | |
382 | that wish to retrieve the name of the bus\r | |
383 | controller. It will not be NULL for a bus\r | |
384 | driver that wishes to retrieve the name of a\r | |
385 | child controller.\r | |
386 | \r | |
387 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
388 | array indicating the language. This is the\r | |
389 | language of the driver name that the caller is\r | |
390 | requesting, and it must match one of the\r | |
391 | languages specified in SupportedLanguages. The\r | |
392 | number of languages supported by a driver is up\r | |
393 | to the driver writer. Language is specified in\r | |
394 | RFC 4646 or ISO 639-2 language code format.\r | |
395 | \r | |
396 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
397 | This Unicode string is the name of the\r | |
398 | controller specified by ControllerHandle and\r | |
399 | ChildHandle in the language specified by\r | |
400 | Language from the point of view of the driver\r | |
401 | specified by This.\r | |
402 | \r | |
403 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
404 | the language specified by Language for the\r | |
405 | driver specified by This was returned in\r | |
406 | DriverName.\r | |
407 | \r | |
408 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r | |
409 | \r | |
410 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
411 | EFI_HANDLE.\r | |
412 | \r | |
413 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
414 | \r | |
415 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
416 | \r | |
417 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
418 | managing the controller specified by\r | |
419 | ControllerHandle and ChildHandle.\r | |
420 | \r | |
421 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
422 | the language specified by Language.\r | |
423 | \r | |
424 | **/\r | |
425 | EFI_STATUS\r | |
426 | EFIAPI\r | |
427 | NvmExpressComponentNameGetControllerName (\r | |
1436aea4 MK |
428 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
429 | IN EFI_HANDLE ControllerHandle,\r | |
430 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
431 | IN CHAR8 *Language,\r | |
432 | OUT CHAR16 **ControllerName\r | |
eb290d02 FT |
433 | );\r |
434 | \r | |
435 | /**\r | |
436 | Tests to see if this driver supports a given controller. If a child device is provided,\r | |
437 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
438 | \r | |
439 | This function checks to see if the driver specified by This supports the device specified by\r | |
440 | ControllerHandle. Drivers will typically use the device path attached to\r | |
441 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
442 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
443 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
444 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
445 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
446 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
447 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
448 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
449 | Since ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
450 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
451 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
452 | \r | |
453 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
454 | @param[in] ControllerHandle The handle of the controller to test. This handle\r | |
455 | must support a protocol interface that supplies\r | |
456 | an I/O abstraction to the driver.\r | |
457 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
458 | parameter is ignored by device drivers, and is optional for bus\r | |
459 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
460 | the bus driver must determine if the bus controller specified\r | |
461 | by ControllerHandle and the child controller specified\r | |
462 | by RemainingDevicePath are both supported by this\r | |
463 | bus driver.\r | |
464 | \r | |
465 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
466 | RemainingDevicePath is supported by the driver specified by This.\r | |
467 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
468 | RemainingDevicePath is already being managed by the driver\r | |
469 | specified by This.\r | |
470 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
471 | RemainingDevicePath is already being managed by a different\r | |
472 | driver or an application that requires exclusive access.\r | |
473 | Currently not implemented.\r | |
474 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
475 | RemainingDevicePath is not supported by the driver specified by This.\r | |
476 | **/\r | |
477 | EFI_STATUS\r | |
478 | EFIAPI\r | |
479 | NvmExpressDriverBindingSupported (\r | |
480 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
481 | IN EFI_HANDLE Controller,\r | |
482 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
483 | );\r | |
484 | \r | |
485 | /**\r | |
486 | Starts a device controller or a bus controller.\r | |
487 | \r | |
488 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
489 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
490 | common boot service. It is legal to call Start() from other locations,\r | |
491 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
492 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
493 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
494 | EFI_DEVICE_PATH_PROTOCOL.\r | |
495 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
496 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r | |
497 | \r | |
498 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
499 | @param[in] ControllerHandle The handle of the controller to start. This handle\r | |
500 | must support a protocol interface that supplies\r | |
501 | an I/O abstraction to the driver.\r | |
502 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
503 | parameter is ignored by device drivers, and is optional for bus\r | |
504 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
505 | for all the children of Controller are created by this driver.\r | |
506 | If this parameter is not NULL and the first Device Path Node is\r | |
507 | not the End of Device Path Node, then only the handle for the\r | |
508 | child device specified by the first Device Path Node of\r | |
509 | RemainingDevicePath is created by this driver.\r | |
510 | If the first Device Path Node of RemainingDevicePath is\r | |
511 | the End of Device Path Node, no child handle is created by this\r | |
512 | driver.\r | |
513 | \r | |
514 | @retval EFI_SUCCESS The device was started.\r | |
515 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
516 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
517 | @retval Others The driver failded to start the device.\r | |
518 | \r | |
519 | **/\r | |
520 | EFI_STATUS\r | |
521 | EFIAPI\r | |
522 | NvmExpressDriverBindingStart (\r | |
523 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
524 | IN EFI_HANDLE Controller,\r | |
525 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
526 | );\r | |
527 | \r | |
528 | /**\r | |
529 | Stops a device controller or a bus controller.\r | |
530 | \r | |
531 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
532 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
533 | into this common boot service. It is legal to call Stop() from other locations,\r | |
534 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
535 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
536 | same driver's Start() function.\r | |
537 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
538 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
539 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
540 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
541 | \r | |
542 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
543 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
544 | support a bus specific I/O protocol for the driver\r | |
545 | to use to stop the device.\r | |
546 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
547 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
548 | if NumberOfChildren is 0.\r | |
549 | \r | |
550 | @retval EFI_SUCCESS The device was stopped.\r | |
551 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
552 | \r | |
553 | **/\r | |
554 | EFI_STATUS\r | |
555 | EFIAPI\r | |
556 | NvmExpressDriverBindingStop (\r | |
1436aea4 MK |
557 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
558 | IN EFI_HANDLE Controller,\r | |
559 | IN UINTN NumberOfChildren,\r | |
560 | IN EFI_HANDLE *ChildHandleBuffer\r | |
eb290d02 FT |
561 | );\r |
562 | \r | |
563 | /**\r | |
564 | Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports\r | |
565 | both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking\r | |
566 | I/O functionality is optional.\r | |
567 | \r | |
d6c55989 | 568 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
569 | @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.\r |
570 | A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace\r | |
571 | ID specifies that the command packet should be sent to all valid namespaces.\r | |
eb290d02 FT |
572 | @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified\r |
573 | by NamespaceId.\r | |
574 | @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.\r | |
575 | If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O\r | |
576 | is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM\r | |
577 | Express Command Packet completes.\r | |
578 | \r | |
579 | @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred\r | |
580 | to, or from DataBuffer.\r | |
581 | @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred\r | |
582 | is returned in TransferLength.\r | |
583 | @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller\r | |
584 | may retry again later.\r | |
585 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.\r | |
d6c55989 | 586 | @retval EFI_INVALID_PARAMETER Namespace, or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM\r |
eb290d02 FT |
587 | Express Command Packet was not sent, so no additional status information is available.\r |
588 | @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.\r | |
589 | The NVM Express Command Packet was not sent, so no additional status information is available.\r | |
590 | @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.\r | |
591 | \r | |
592 | **/\r | |
593 | EFI_STATUS\r | |
594 | EFIAPI\r | |
595 | NvmExpressPassThru (\r | |
1436aea4 MK |
596 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
597 | IN UINT32 NamespaceId,\r | |
598 | IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,\r | |
599 | IN EFI_EVENT Event OPTIONAL\r | |
eb290d02 FT |
600 | );\r |
601 | \r | |
602 | /**\r | |
d6c55989 FT |
603 | Used to retrieve the next namespace ID for this NVM Express controller.\r |
604 | \r | |
605 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid\r | |
606 | namespace ID on this NVM Express controller.\r | |
eb290d02 | 607 | \r |
d6c55989 FT |
608 | If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace\r |
609 | ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId\r | |
610 | and a status of EFI_SUCCESS is returned.\r | |
eb290d02 | 611 | \r |
d6c55989 FT |
612 | If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,\r |
613 | then EFI_INVALID_PARAMETER is returned.\r | |
eb290d02 | 614 | \r |
d6c55989 FT |
615 | If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid\r |
616 | namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,\r | |
617 | and EFI_SUCCESS is returned.\r | |
eb290d02 | 618 | \r |
d6c55989 FT |
619 | If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM\r |
620 | Express controller, then EFI_NOT_FOUND is returned.\r | |
eb290d02 | 621 | \r |
d6c55989 | 622 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
623 | @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express\r |
624 | namespace present on the NVM Express controller. On output, a\r | |
625 | pointer to the next NamespaceId of an NVM Express namespace on\r | |
626 | an NVM Express controller. An input value of 0xFFFFFFFF retrieves\r | |
627 | the first NamespaceId for an NVM Express namespace present on an\r | |
628 | NVM Express controller.\r | |
eb290d02 | 629 | \r |
d6c55989 | 630 | @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.\r |
eb290d02 | 631 | @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.\r |
d6c55989 | 632 | @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.\r |
eb290d02 FT |
633 | \r |
634 | **/\r | |
635 | EFI_STATUS\r | |
636 | EFIAPI\r | |
637 | NvmExpressGetNextNamespace (\r | |
1436aea4 MK |
638 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
639 | IN OUT UINT32 *NamespaceId\r | |
eb290d02 FT |
640 | );\r |
641 | \r | |
642 | /**\r | |
d6c55989 FT |
643 | Used to translate a device path node to a namespace ID.\r |
644 | \r | |
645 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the\r | |
646 | namespace described by DevicePath.\r | |
647 | \r | |
648 | If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express\r | |
649 | Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.\r | |
eb290d02 | 650 | \r |
d6c55989 | 651 | If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned\r |
eb290d02 | 652 | \r |
d6c55989 | 653 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
654 | @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on\r |
655 | the NVM Express controller.\r | |
656 | @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.\r | |
eb290d02 | 657 | \r |
d6c55989 FT |
658 | @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.\r |
659 | @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.\r | |
eb290d02 FT |
660 | @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver\r |
661 | supports, then EFI_UNSUPPORTED is returned.\r | |
d6c55989 FT |
662 | @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver\r |
663 | supports, but there is not a valid translation from DevicePath to a namespace ID,\r | |
664 | then EFI_NOT_FOUND is returned.\r | |
eb290d02 FT |
665 | **/\r |
666 | EFI_STATUS\r | |
667 | EFIAPI\r | |
668 | NvmExpressGetNamespace (\r | |
1436aea4 MK |
669 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
670 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
671 | OUT UINT32 *NamespaceId\r | |
eb290d02 FT |
672 | );\r |
673 | \r | |
674 | /**\r | |
675 | Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.\r | |
676 | \r | |
d6c55989 | 677 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device\r |
eb290d02 FT |
678 | path node for the NVM Express namespace specified by NamespaceId.\r |
679 | \r | |
d6c55989 | 680 | If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.\r |
eb290d02 FT |
681 | \r |
682 | If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r | |
683 | \r | |
684 | If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r | |
685 | \r | |
686 | Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are\r | |
687 | initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.\r | |
688 | \r | |
d6c55989 | 689 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
690 | @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be\r |
691 | allocated and built. Caller must set the NamespaceId to zero if the\r | |
692 | device path node will contain a valid UUID.\r | |
eb290d02 FT |
693 | @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express\r |
694 | namespace specified by NamespaceId. This function is responsible for\r | |
695 | allocating the buffer DevicePath with the boot service AllocatePool().\r | |
696 | It is the caller's responsibility to free DevicePath when the caller\r | |
697 | is finished with DevicePath.\r | |
698 | @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified\r | |
699 | by NamespaceId was allocated and returned in DevicePath.\r | |
d6c55989 | 700 | @retval EFI_NOT_FOUND The NamespaceId is not valid.\r |
eb290d02 FT |
701 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r |
702 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.\r | |
703 | \r | |
704 | **/\r | |
705 | EFI_STATUS\r | |
706 | EFIAPI\r | |
707 | NvmExpressBuildDevicePath (\r | |
1436aea4 MK |
708 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
709 | IN UINT32 NamespaceId,\r | |
710 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
eb290d02 FT |
711 | );\r |
712 | \r | |
758ea946 HW |
713 | /**\r |
714 | Dump the execution status from a given completion queue entry.\r | |
715 | \r | |
716 | @param[in] Cq A pointer to the NVME_CQ item.\r | |
717 | \r | |
718 | **/\r | |
719 | VOID\r | |
720 | NvmeDumpStatus (\r | |
1436aea4 | 721 | IN NVME_CQ *Cq\r |
758ea946 HW |
722 | );\r |
723 | \r | |
7111e46f RN |
724 | /**\r |
725 | Register the shutdown notification through the ResetNotification protocol.\r | |
726 | \r | |
727 | Register the shutdown notification when mNvmeControllerNumber increased from 0 to 1.\r | |
728 | **/\r | |
729 | VOID\r | |
730 | NvmeRegisterShutdownNotification (\r | |
731 | VOID\r | |
732 | );\r | |
733 | \r | |
734 | /**\r | |
735 | Unregister the shutdown notification through the ResetNotification protocol.\r | |
736 | \r | |
737 | Unregister the shutdown notification when mNvmeControllerNumber decreased from 1 to 0.\r | |
738 | **/\r | |
739 | VOID\r | |
740 | NvmeUnregisterShutdownNotification (\r | |
741 | VOID\r | |
742 | );\r | |
743 | \r | |
eb290d02 | 744 | #endif\r |