2 NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
3 NVM Express specification.
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _EFI_NVM_EXPRESS_H_
18 #define _EFI_NVM_EXPRESS_H_
22 #include <IndustryStandard/Pci.h>
23 #include <IndustryStandard/Nvme.h>
25 #include <Protocol/ComponentName.h>
26 #include <Protocol/ComponentName2.h>
27 #include <Protocol/DriverBinding.h>
28 #include <Protocol/LoadedImage.h>
29 #include <Protocol/DevicePath.h>
30 #include <Protocol/PciIo.h>
31 #include <Protocol/NvmExpressPassthru.h>
32 #include <Protocol/BlockIo.h>
33 #include <Protocol/BlockIo2.h>
34 #include <Protocol/DiskInfo.h>
35 #include <Protocol/DriverSupportedEfiVersion.h>
36 #include <Protocol/StorageSecurityCommand.h>
37 #include <Protocol/ResetNotification.h>
39 #include <Library/BaseLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/DebugLib.h>
42 #include <Library/PrintLib.h>
43 #include <Library/UefiLib.h>
44 #include <Library/DevicePathLib.h>
45 #include <Library/MemoryAllocationLib.h>
46 #include <Library/UefiBootServicesTableLib.h>
47 #include <Library/UefiDriverEntryPoint.h>
48 #include <Library/ReportStatusCodeLib.h>
50 typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA
;
51 typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA
;
53 #include "NvmExpressBlockIo.h"
54 #include "NvmExpressDiskInfo.h"
55 #include "NvmExpressHci.h"
57 extern EFI_DRIVER_BINDING_PROTOCOL gNvmExpressDriverBinding
;
58 extern EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentName
;
59 extern EFI_COMPONENT_NAME2_PROTOCOL gNvmExpressComponentName2
;
60 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion
;
62 #define PCI_CLASS_MASS_STORAGE_NVM 0x08 // mass storage sub-class non-volatile memory.
63 #define PCI_IF_NVMHCI 0x02 // mass storage programming interface NVMHCI.
65 #define NVME_ASQ_SIZE 1 // Number of admin submission queue entries, which is 0-based
66 #define NVME_ACQ_SIZE 1 // Number of admin completion queue entries, which is 0-based
68 #define NVME_CSQ_SIZE 1 // Number of I/O submission queue entries, which is 0-based
69 #define NVME_CCQ_SIZE 1 // Number of I/O completion queue entries, which is 0-based
72 // Number of asynchronous I/O submission queue entries, which is 0-based.
73 // The asynchronous I/O submission queue size is 4kB in total.
75 #define NVME_ASYNC_CSQ_SIZE 63
77 // Number of asynchronous I/O completion queue entries, which is 0-based.
78 // The asynchronous I/O completion queue size is 4kB in total.
80 #define NVME_ASYNC_CCQ_SIZE 255
82 #define NVME_MAX_QUEUES 3 // Number of queues supported by the driver
84 #define NVME_CONTROLLER_ID 0
87 // Time out value for Nvme transaction execution
89 #define NVME_GENERIC_TIMEOUT EFI_TIMER_PERIOD_SECONDS (5)
92 // Nvme async transfer timer interval, set by experience.
94 #define NVME_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS (1)
97 // Unique signature for private data structure.
99 #define NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N','V','M','E')
102 // Nvme private data structure.
104 struct _NVME_CONTROLLER_PRIVATE_DATA
{
107 EFI_HANDLE ControllerHandle
;
108 EFI_HANDLE ImageHandle
;
109 EFI_HANDLE DriverBindingHandle
;
111 EFI_PCI_IO_PROTOCOL
*PciIo
;
112 UINT64 PciAttributes
;
114 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
116 EFI_NVM_EXPRESS_PASS_THRU_MODE PassThruMode
;
117 EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL Passthru
;
120 // pointer to identify controller data
122 NVME_ADMIN_CONTROLLER_DATA
*ControllerData
;
125 // 6 x 4kB aligned buffers will be carved out of this buffer.
126 // 1st 4kB boundary is the start of the admin submission queue.
127 // 2nd 4kB boundary is the start of the admin completion queue.
128 // 3rd 4kB boundary is the start of I/O submission queue #1.
129 // 4th 4kB boundary is the start of I/O completion queue #1.
130 // 5th 4kB boundary is the start of I/O submission queue #2.
131 // 6th 4kB boundary is the start of I/O completion queue #2.
134 UINT8
*BufferPciAddr
;
137 // Pointers to 4kB aligned submission & completion queues.
139 NVME_SQ
*SqBuffer
[NVME_MAX_QUEUES
];
140 NVME_CQ
*CqBuffer
[NVME_MAX_QUEUES
];
141 NVME_SQ
*SqBufferPciAddr
[NVME_MAX_QUEUES
];
142 NVME_CQ
*CqBufferPciAddr
[NVME_MAX_QUEUES
];
145 // Submission and completion queue indices.
147 NVME_SQTDBL SqTdbl
[NVME_MAX_QUEUES
];
148 NVME_CQHDBL CqHdbl
[NVME_MAX_QUEUES
];
152 // Flag to indicate internal IO queue creation.
154 BOOLEAN CreateIoQueue
;
156 UINT8 Pt
[NVME_MAX_QUEUES
];
157 UINT16 Cid
[NVME_MAX_QUEUES
];
160 // Nvme controller capabilities
167 // For Non-blocking operations.
169 EFI_EVENT TimerEvent
;
170 LIST_ENTRY AsyncPassThruQueue
;
171 LIST_ENTRY UnsubmittedSubtasks
;
174 #define NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU(a) \
176 NVME_CONTROLLER_PRIVATE_DATA, \
178 NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE \
182 // Unique signature for private data structure.
184 #define NVME_DEVICE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X','S','S','D')
187 // Nvme device private data structure
189 struct _NVME_DEVICE_PRIVATE_DATA
{
192 EFI_HANDLE DeviceHandle
;
193 EFI_HANDLE ControllerHandle
;
194 EFI_HANDLE DriverBindingHandle
;
196 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
198 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
201 UINT64 NamespaceUuid
;
203 EFI_BLOCK_IO_MEDIA Media
;
204 EFI_BLOCK_IO_PROTOCOL BlockIo
;
205 EFI_BLOCK_IO2_PROTOCOL BlockIo2
;
206 EFI_DISK_INFO_PROTOCOL DiskInfo
;
207 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity
;
209 LIST_ENTRY AsyncQueue
;
213 CHAR16 ModelName
[80];
214 NVME_ADMIN_NAMESPACE_DATA NamespaceData
;
216 NVME_CONTROLLER_PRIVATE_DATA
*Controller
;
221 // Statments to retrieve the private data from produced protocols.
223 #define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO(a) \
225 NVME_DEVICE_PRIVATE_DATA, \
227 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
230 #define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO2(a) \
232 NVME_DEVICE_PRIVATE_DATA, \
234 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
237 #define NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO(a) \
239 NVME_DEVICE_PRIVATE_DATA, \
241 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
244 #define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a)\
246 NVME_DEVICE_PRIVATE_DATA, \
248 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
252 // Nvme block I/O 2 request.
254 #define NVME_BLKIO2_REQUEST_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'R')
260 EFI_BLOCK_IO2_TOKEN
*Token
;
261 UINTN UnsubmittedSubtaskNum
;
262 BOOLEAN LastSubtaskSubmitted
;
264 // The queue for Nvme read/write sub-tasks of a BlockIo2 request.
266 LIST_ENTRY SubtasksQueue
;
267 } NVME_BLKIO2_REQUEST
;
269 #define NVME_BLKIO2_REQUEST_FROM_LINK(a) \
270 CR (a, NVME_BLKIO2_REQUEST, Link, NVME_BLKIO2_REQUEST_SIGNATURE)
272 #define NVME_BLKIO2_SUBTASK_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'S')
281 EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
*CommandPacket
;
283 // The BlockIo2 request this subtask belongs to
285 NVME_BLKIO2_REQUEST
*BlockIo2Request
;
286 } NVME_BLKIO2_SUBTASK
;
288 #define NVME_BLKIO2_SUBTASK_FROM_LINK(a) \
289 CR (a, NVME_BLKIO2_SUBTASK, Link, NVME_BLKIO2_SUBTASK_SIGNATURE)
292 // Nvme asynchronous passthru request.
294 #define NVME_PASS_THRU_ASYNC_REQ_SIG SIGNATURE_32 ('N', 'P', 'A', 'R')
300 EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
*Packet
;
307 EFI_EVENT CallerEvent
;
308 } NVME_PASS_THRU_ASYNC_REQ
;
310 #define NVME_PASS_THRU_ASYNC_REQ_FROM_THIS(a) \
312 NVME_PASS_THRU_ASYNC_REQ, \
314 NVME_PASS_THRU_ASYNC_REQ_SIG \
318 Retrieves a Unicode string that is the user readable name of the driver.
320 This function retrieves the user readable name of a driver in the form of a
321 Unicode string. If the driver specified by This has a user readable name in
322 the language specified by Language, then a pointer to the driver name is
323 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
324 by This does not support the language specified by Language,
325 then EFI_UNSUPPORTED is returned.
327 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
328 EFI_COMPONENT_NAME_PROTOCOL instance.
330 @param Language[in] A pointer to a Null-terminated ASCII string
331 array indicating the language. This is the
332 language of the driver name that the caller is
333 requesting, and it must match one of the
334 languages specified in SupportedLanguages. The
335 number of languages supported by a driver is up
336 to the driver writer. Language is specified
337 in RFC 4646 or ISO 639-2 language code format.
339 @param DriverName[out] A pointer to the Unicode string to return.
340 This Unicode string is the name of the
341 driver specified by This in the language
342 specified by Language.
344 @retval EFI_SUCCESS The Unicode string for the Driver specified by
345 This and the language specified by Language was
346 returned in DriverName.
348 @retval EFI_INVALID_PARAMETER Language is NULL.
350 @retval EFI_INVALID_PARAMETER DriverName is NULL.
352 @retval EFI_UNSUPPORTED The driver specified by This does not support
353 the language specified by Language.
358 NvmExpressComponentNameGetDriverName (
359 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
361 OUT CHAR16
**DriverName
365 Retrieves a Unicode string that is the user readable name of the controller
366 that is being managed by a driver.
368 This function retrieves the user readable name of the controller specified by
369 ControllerHandle and ChildHandle in the form of a Unicode string. If the
370 driver specified by This has a user readable name in the language specified by
371 Language, then a pointer to the controller name is returned in ControllerName,
372 and EFI_SUCCESS is returned. If the driver specified by This is not currently
373 managing the controller specified by ControllerHandle and ChildHandle,
374 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
375 support the language specified by Language, then EFI_UNSUPPORTED is returned.
377 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
378 EFI_COMPONENT_NAME_PROTOCOL instance.
380 @param ControllerHandle[in] The handle of a controller that the driver
381 specified by This is managing. This handle
382 specifies the controller whose name is to be
385 @param ChildHandle[in] The handle of the child controller to retrieve
386 the name of. This is an optional parameter that
387 may be NULL. It will be NULL for device
388 drivers. It will also be NULL for a bus drivers
389 that wish to retrieve the name of the bus
390 controller. It will not be NULL for a bus
391 driver that wishes to retrieve the name of a
394 @param Language[in] A pointer to a Null-terminated ASCII string
395 array indicating the language. This is the
396 language of the driver name that the caller is
397 requesting, and it must match one of the
398 languages specified in SupportedLanguages. The
399 number of languages supported by a driver is up
400 to the driver writer. Language is specified in
401 RFC 4646 or ISO 639-2 language code format.
403 @param ControllerName[out] A pointer to the Unicode string to return.
404 This Unicode string is the name of the
405 controller specified by ControllerHandle and
406 ChildHandle in the language specified by
407 Language from the point of view of the driver
410 @retval EFI_SUCCESS The Unicode string for the user readable name in
411 the language specified by Language for the
412 driver specified by This was returned in
415 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
417 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
420 @retval EFI_INVALID_PARAMETER Language is NULL.
422 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
424 @retval EFI_UNSUPPORTED The driver specified by This is not currently
425 managing the controller specified by
426 ControllerHandle and ChildHandle.
428 @retval EFI_UNSUPPORTED The driver specified by This does not support
429 the language specified by Language.
434 NvmExpressComponentNameGetControllerName (
435 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
436 IN EFI_HANDLE ControllerHandle
,
437 IN EFI_HANDLE ChildHandle OPTIONAL
,
439 OUT CHAR16
**ControllerName
443 Tests to see if this driver supports a given controller. If a child device is provided,
444 it further tests to see if this driver supports creating a handle for the specified child device.
446 This function checks to see if the driver specified by This supports the device specified by
447 ControllerHandle. Drivers will typically use the device path attached to
448 ControllerHandle and/or the services from the bus I/O abstraction attached to
449 ControllerHandle to determine if the driver supports ControllerHandle. This function
450 may be called many times during platform initialization. In order to reduce boot times, the tests
451 performed by this function must be very small, and take as little time as possible to execute. This
452 function must not change the state of any hardware devices, and this function must be aware that the
453 device specified by ControllerHandle may already be managed by the same driver or a
454 different driver. This function must match its calls to AllocatePages() with FreePages(),
455 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
456 Since ControllerHandle may have been previously started by the same driver, if a protocol is
457 already in the opened state, then it must not be closed with CloseProtocol(). This is required
458 to guarantee the state of ControllerHandle is not modified by this function.
460 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
461 @param[in] ControllerHandle The handle of the controller to test. This handle
462 must support a protocol interface that supplies
463 an I/O abstraction to the driver.
464 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
465 parameter is ignored by device drivers, and is optional for bus
466 drivers. For bus drivers, if this parameter is not NULL, then
467 the bus driver must determine if the bus controller specified
468 by ControllerHandle and the child controller specified
469 by RemainingDevicePath are both supported by this
472 @retval EFI_SUCCESS The device specified by ControllerHandle and
473 RemainingDevicePath is supported by the driver specified by This.
474 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
475 RemainingDevicePath is already being managed by the driver
477 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
478 RemainingDevicePath is already being managed by a different
479 driver or an application that requires exclusive access.
480 Currently not implemented.
481 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
482 RemainingDevicePath is not supported by the driver specified by This.
486 NvmExpressDriverBindingSupported (
487 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
488 IN EFI_HANDLE Controller
,
489 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
493 Starts a device controller or a bus controller.
495 The Start() function is designed to be invoked from the EFI boot service ConnectController().
496 As a result, much of the error checking on the parameters to Start() has been moved into this
497 common boot service. It is legal to call Start() from other locations,
498 but the following calling restrictions must be followed or the system behavior will not be deterministic.
499 1. ControllerHandle must be a valid EFI_HANDLE.
500 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
501 EFI_DEVICE_PATH_PROTOCOL.
502 3. Prior to calling Start(), the Supported() function for the driver specified by This must
503 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
505 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
506 @param[in] ControllerHandle The handle of the controller to start. This handle
507 must support a protocol interface that supplies
508 an I/O abstraction to the driver.
509 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
510 parameter is ignored by device drivers, and is optional for bus
511 drivers. For a bus driver, if this parameter is NULL, then handles
512 for all the children of Controller are created by this driver.
513 If this parameter is not NULL and the first Device Path Node is
514 not the End of Device Path Node, then only the handle for the
515 child device specified by the first Device Path Node of
516 RemainingDevicePath is created by this driver.
517 If the first Device Path Node of RemainingDevicePath is
518 the End of Device Path Node, no child handle is created by this
521 @retval EFI_SUCCESS The device was started.
522 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
523 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
524 @retval Others The driver failded to start the device.
529 NvmExpressDriverBindingStart (
530 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
531 IN EFI_HANDLE Controller
,
532 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
536 Stops a device controller or a bus controller.
538 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
539 As a result, much of the error checking on the parameters to Stop() has been moved
540 into this common boot service. It is legal to call Stop() from other locations,
541 but the following calling restrictions must be followed or the system behavior will not be deterministic.
542 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
543 same driver's Start() function.
544 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
545 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
546 Start() function, and the Start() function must have called OpenProtocol() on
547 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
549 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
550 @param[in] ControllerHandle A handle to the device being stopped. The handle must
551 support a bus specific I/O protocol for the driver
552 to use to stop the device.
553 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
554 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
555 if NumberOfChildren is 0.
557 @retval EFI_SUCCESS The device was stopped.
558 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
563 NvmExpressDriverBindingStop (
564 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
565 IN EFI_HANDLE Controller
,
566 IN UINTN NumberOfChildren
,
567 IN EFI_HANDLE
*ChildHandleBuffer
571 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
572 both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
573 I/O functionality is optional.
575 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
576 @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
577 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
578 ID specifies that the command packet should be sent to all valid namespaces.
579 @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
581 @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
582 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O
583 is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM
584 Express Command Packet completes.
586 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
587 to, or from DataBuffer.
588 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred
589 is returned in TransferLength.
590 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
591 may retry again later.
592 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
593 @retval EFI_INVALID_PARAMETER Namespace, or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
594 Express Command Packet was not sent, so no additional status information is available.
595 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
596 The NVM Express Command Packet was not sent, so no additional status information is available.
597 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.
603 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
604 IN UINT32 NamespaceId
,
605 IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
*Packet
,
606 IN EFI_EVENT Event OPTIONAL
610 Used to retrieve the next namespace ID for this NVM Express controller.
612 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid
613 namespace ID on this NVM Express controller.
615 If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace
616 ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId
617 and a status of EFI_SUCCESS is returned.
619 If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,
620 then EFI_INVALID_PARAMETER is returned.
622 If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid
623 namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,
624 and EFI_SUCCESS is returned.
626 If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM
627 Express controller, then EFI_NOT_FOUND is returned.
629 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
630 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
631 namespace present on the NVM Express controller. On output, a
632 pointer to the next NamespaceId of an NVM Express namespace on
633 an NVM Express controller. An input value of 0xFFFFFFFF retrieves
634 the first NamespaceId for an NVM Express namespace present on an
635 NVM Express controller.
637 @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.
638 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
639 @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.
644 NvmExpressGetNextNamespace (
645 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
646 IN OUT UINT32
*NamespaceId
650 Used to translate a device path node to a namespace ID.
652 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the
653 namespace described by DevicePath.
655 If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express
656 Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.
658 If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned
660 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
661 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
662 the NVM Express controller.
663 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
665 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.
666 @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.
667 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
668 supports, then EFI_UNSUPPORTED is returned.
669 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver
670 supports, but there is not a valid translation from DevicePath to a namespace ID,
671 then EFI_NOT_FOUND is returned.
675 NvmExpressGetNamespace (
676 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
677 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
678 OUT UINT32
*NamespaceId
682 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
684 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
685 path node for the NVM Express namespace specified by NamespaceId.
687 If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.
689 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
691 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
693 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
694 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
696 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
697 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
698 allocated and built. Caller must set the NamespaceId to zero if the
699 device path node will contain a valid UUID.
700 @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
701 namespace specified by NamespaceId. This function is responsible for
702 allocating the buffer DevicePath with the boot service AllocatePool().
703 It is the caller's responsibility to free DevicePath when the caller
704 is finished with DevicePath.
705 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
706 by NamespaceId was allocated and returned in DevicePath.
707 @retval EFI_NOT_FOUND The NamespaceId is not valid.
708 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
709 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
714 NvmExpressBuildDevicePath (
715 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
716 IN UINT32 NamespaceId
,
717 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
721 Dump the execution status from a given completion queue entry.
723 @param[in] Cq A pointer to the NVME_CQ item.
732 Register the shutdown notification through the ResetNotification protocol.
734 Register the shutdown notification when mNvmeControllerNumber increased from 0 to 1.
737 NvmeRegisterShutdownNotification (
742 Unregister the shutdown notification through the ResetNotification protocol.
744 Unregister the shutdown notification when mNvmeControllerNumber decreased from 1 to 0.
747 NvmeUnregisterShutdownNotification (