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