diff options
author | Feng Tian <feng.tian@intel.com> | 2015-05-04 11:08:09 +0000 |
---|---|---|
committer | erictian <erictian@Edk2> | 2015-05-04 11:08:09 +0000 |
commit | d6c5598941502ad0f7b842662147ff167782203f (patch) | |
tree | d5d6e25108d9378d49e39acf252a9817c073025c | |
parent | 04789f89d5c762d3dc2274bd26a42b7badd46634 (diff) | |
download | edk2-d6c5598941502ad0f7b842662147ff167782203f.tar.gz edk2-d6c5598941502ad0f7b842662147ff167782203f.tar.bz2 edk2-d6c5598941502ad0f7b842662147ff167782203f.zip |
MdeModulePkg/NvmExpressDxe: Expose EFI_NVM_EXPRESS_PASS_THRU protocol
This patch produces a EFI_NVM_EXPRESS_PASS_THRU protocol instance
on device handle to provide upper user a way to send cmd to NVMe
device.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17286 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c | 91 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h | 155 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c | 62 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf | 4 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 121 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 243 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.h | 299 |
7 files changed, 324 insertions, 651 deletions
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c index 7d6d798e1f..99f89f1d45 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c @@ -35,6 +35,15 @@ EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion = 0 // Version number to be filled at start up.
};
+//
+// Template for NVM Express Pass Thru Mode data structure.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_NVM_EXPRESS_PASS_THRU_MODE gEfiNvmExpressPassThruMode = {
+ EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL | EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVM,
+ sizeof (UINTN),
+ 0x10100
+};
+
/**
Check if the specified Nvm Express device namespace is active, and create child handles
for them with BlockIo and DiskInfo protocol instances.
@@ -43,8 +52,6 @@ EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion = @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
allocated and built. Caller must set the NamespaceId to zero if the
device path node will contain a valid UUID.
- @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
- allocated and built. UUID will only be valid of the Namespace ID is zero.
@retval EFI_SUCCESS All the namespaces in the device are successfully enumerated.
@return Others Some error occurs when enumerating the namespaces.
@@ -53,8 +60,7 @@ EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion = EFI_STATUS
EnumerateNvmeDevNamespace (
IN NVME_CONTROLLER_PRIVATE_DATA *Private,
- UINT32 NamespaceId,
- UINT64 NamespaceUuid
+ UINT32 NamespaceId
)
{
NVME_ADMIN_NAMESPACE_DATA *NamespaceData;
@@ -159,7 +165,6 @@ EnumerateNvmeDevNamespace ( Status = Private->Passthru.BuildDevicePath (
&Private->Passthru,
Device->NamespaceId,
- Device->NamespaceUuid,
&NewDevicePathNode
);
@@ -281,18 +286,15 @@ DiscoverAllNamespaces ( {
EFI_STATUS Status;
UINT32 NamespaceId;
- UINT64 NamespaceUuid;
- NVM_EXPRESS_PASS_THRU_PROTOCOL *Passthru;
+ EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *Passthru;
NamespaceId = 0xFFFFFFFF;
- NamespaceUuid = 0;
Passthru = &Private->Passthru;
while (TRUE) {
Status = Passthru->GetNextNamespace (
Passthru,
- (UINT32 *)&NamespaceId,
- (UINT64 *)&NamespaceUuid
+ (UINT32 *)&NamespaceId
);
if (EFI_ERROR (Status)) {
@@ -301,8 +303,7 @@ DiscoverAllNamespaces ( Status = EnumerateNvmeDevNamespace (
Private,
- NamespaceId,
- NamespaceUuid
+ NamespaceId
);
if (EFI_ERROR(Status)) {
@@ -609,18 +610,19 @@ NvmExpressDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- NVME_CONTROLLER_PRIVATE_DATA *Private;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- UINT32 NamespaceId;
- UINT64 NamespaceUuid;
- EFI_PHYSICAL_ADDRESS MappedAddr;
- UINTN Bytes;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ NVME_CONTROLLER_PRIVATE_DATA *Private;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ UINT32 NamespaceId;
+ EFI_PHYSICAL_ADDRESS MappedAddr;
+ UINTN Bytes;
+ EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *Passthru;
DEBUG ((EFI_D_INFO, "NvmExpressDriverBindingStart: start\n"));
- Private = NULL;
+ Private = NULL;
+ Passthru = NULL;
ParentDevicePath = NULL;
Status = gBS->OpenProtocol (
@@ -657,7 +659,7 @@ NvmExpressDriverBindingStart ( if (Private == NULL) {
DEBUG ((EFI_D_ERROR, "NvmExpressDriverBindingStart: allocating pool for Nvme Private Data failed!\n"));
Status = EFI_OUT_OF_RESOURCES;
- goto Exit2;
+ goto Exit;
}
//
@@ -678,7 +680,7 @@ NvmExpressDriverBindingStart ( 0
);
if (EFI_ERROR (Status)) {
- goto Exit2;
+ goto Exit;
}
Bytes = EFI_PAGES_TO_SIZE (4);
@@ -692,7 +694,7 @@ NvmExpressDriverBindingStart ( );
if (EFI_ERROR (Status) || (Bytes != EFI_PAGES_TO_SIZE (4))) {
- goto Exit2;
+ goto Exit;
}
Private->BufferPciAddr = (UINT8 *)(UINTN)MappedAddr;
@@ -709,36 +711,36 @@ NvmExpressDriverBindingStart ( Private->Passthru.GetNextNamespace = NvmExpressGetNextNamespace;
Private->Passthru.BuildDevicePath = NvmExpressBuildDevicePath;
Private->Passthru.GetNamespace = NvmExpressGetNamespace;
- Private->PassThruMode.Attributes = NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL;
+ CopyMem (&Private->PassThruMode, &gEfiNvmExpressPassThruMode, sizeof (EFI_NVM_EXPRESS_PASS_THRU_MODE));
Status = NvmeControllerInit (Private);
-
if (EFI_ERROR(Status)) {
- goto Exit2;
+ goto Exit;
}
Status = gBS->InstallMultipleProtocolInterfaces (
&Controller,
- &gEfiCallerIdGuid,
- Private,
+ &gEfiNvmExpressPassThruProtocolGuid,
+ &Private->Passthru,
NULL
);
if (EFI_ERROR (Status)) {
- goto Exit2;
+ goto Exit;
}
} else {
Status = gBS->OpenProtocol (
Controller,
- &gEfiCallerIdGuid,
- (VOID **) &Private,
+ &gEfiNvmExpressPassThruProtocolGuid,
+ (VOID **) &Passthru,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
- Private = NULL;
- goto Exit1;
+ goto Exit;
}
+
+ Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (Passthru);
}
if (RemainingDevicePath == NULL) {
@@ -756,30 +758,21 @@ NvmExpressDriverBindingStart ( Status = Private->Passthru.GetNamespace (
&Private->Passthru,
RemainingDevicePath,
- &NamespaceId,
- &NamespaceUuid
+ &NamespaceId
);
if (!EFI_ERROR (Status)) {
- Status = EnumerateNvmeDevNamespace (
- Private,
- NamespaceId,
- NamespaceUuid
- );
+ Status = EnumerateNvmeDevNamespace (
+ Private,
+ NamespaceId
+ );
}
}
DEBUG ((EFI_D_INFO, "NvmExpressDriverBindingStart: end successfully\n"));
return EFI_SUCCESS;
-Exit1:
- gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiCallerIdGuid,
- Private,
- NULL
- );
-Exit2:
+Exit:
if ((Private != NULL) && (Private->Mapping != NULL)) {
PciIo->Unmap (PciIo, Private->Mapping);
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h index 79ab927edb..54baac6f00 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h @@ -2,7 +2,7 @@ NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
NVM Express specification.
- Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -26,6 +26,7 @@ #include <Protocol/LoadedImage.h>
#include <Protocol/DevicePath.h>
#include <Protocol/PciIo.h>
+#include <Protocol/NvmExpressPassthru.h>
#include <Protocol/BlockIo.h>
#include <Protocol/DiskInfo.h>
#include <Protocol/DriverSupportedEfiVersion.h>
@@ -43,7 +44,6 @@ typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA;
typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;
-#include "NvmExpressPassthru.h"
#include "NvmExpressBlockIo.h"
#include "NvmExpressDiskInfo.h"
#include "NvmExpressHci.h"
@@ -62,7 +62,7 @@ extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiV #define NVME_CSQ_SIZE 1 // Number of I/O submission queue entries, which is 0-based
#define NVME_CCQ_SIZE 1 // Number of I/O completion queue entries, which is 0-based
-#define NVME_MAX_IO_QUEUES 2 // Number of I/O queues supported by the driver
+#define NVME_MAX_QUEUES 2 // Number of queues supported by the driver
#define NVME_CONTROLLER_ID 0
@@ -80,60 +80,60 @@ extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiV // Nvme private data structure.
//
struct _NVME_CONTROLLER_PRIVATE_DATA {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_HANDLE ControllerHandle;
- EFI_HANDLE ImageHandle;
- EFI_HANDLE DriverBindingHandle;
+ EFI_HANDLE ControllerHandle;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DriverBindingHandle;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT64 PciAttributes;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 PciAttributes;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- NVM_EXPRESS_PASS_THRU_MODE PassThruMode;
- NVM_EXPRESS_PASS_THRU_PROTOCOL Passthru;
+ EFI_NVM_EXPRESS_PASS_THRU_MODE PassThruMode;
+ EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL Passthru;
//
// pointer to identify controller data
//
- NVME_ADMIN_CONTROLLER_DATA *ControllerData;
+ NVME_ADMIN_CONTROLLER_DATA *ControllerData;
//
// 6 x 4kB aligned buffers will be carved out of this buffer.
// 1st 4kB boundary is the start of the admin submission queue.
- // 2nd 4kB boundary is the start of submission queue #1.
+ // 2nd 4kB boundary is the start of the I/O submission queue #1.
// 3rd 4kB boundary is the start of the admin completion queue.
- // 4th 4kB boundary is the start of completion queue #1.
+ // 4th 4kB boundary is the start of the I/O completion queue #1.
// 5th 4kB boundary is the start of the first PRP list page.
// 6th 4kB boundary is the start of the second PRP list page.
//
- UINT8 *Buffer;
- UINT8 *BufferPciAddr;
+ UINT8 *Buffer;
+ UINT8 *BufferPciAddr;
//
// Pointers to 4kB aligned submission & completion queues.
//
- NVME_SQ *SqBuffer[NVME_MAX_IO_QUEUES];
- NVME_CQ *CqBuffer[NVME_MAX_IO_QUEUES];
- NVME_SQ *SqBufferPciAddr[NVME_MAX_IO_QUEUES];
- NVME_CQ *CqBufferPciAddr[NVME_MAX_IO_QUEUES];
+ NVME_SQ *SqBuffer[NVME_MAX_QUEUES];
+ NVME_CQ *CqBuffer[NVME_MAX_QUEUES];
+ NVME_SQ *SqBufferPciAddr[NVME_MAX_QUEUES];
+ NVME_CQ *CqBufferPciAddr[NVME_MAX_QUEUES];
//
// Submission and completion queue indices.
//
- NVME_SQTDBL SqTdbl[NVME_MAX_IO_QUEUES];
- NVME_CQHDBL CqHdbl[NVME_MAX_IO_QUEUES];
+ NVME_SQTDBL SqTdbl[NVME_MAX_QUEUES];
+ NVME_CQHDBL CqHdbl[NVME_MAX_QUEUES];
- UINT8 Pt[2];
- UINT16 Cid[2];
+ UINT8 Pt[NVME_MAX_QUEUES];
+ UINT16 Cid[NVME_MAX_QUEUES];
//
// Nvme controller capabilities
//
- NVME_CAP Cap;
+ NVME_CAP Cap;
- VOID *Mapping;
+ VOID *Mapping;
};
#define NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU(a) \
@@ -453,13 +453,10 @@ NvmExpressDriverBindingStop ( both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
I/O functionality is optional.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
ID specifies that the command packet should be sent to all valid namespaces.
- @param[in] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
- A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
- UUID specifies that the command packet should be sent to all valid namespaces.
@param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
by NamespaceId.
@param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
@@ -474,7 +471,7 @@ NvmExpressDriverBindingStop ( @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
may retry again later.
@retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
- @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
+ @retval EFI_INVALID_PARAMETER Namespace, or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
Express Command Packet was not sent, so no additional status information is available.
@retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
The NVM Express Command Packet was not sent, so no additional status information is available.
@@ -484,97 +481,91 @@ NvmExpressDriverBindingStop ( EFI_STATUS
EFIAPI
NvmExpressPassThru (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
- IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
+ IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
IN EFI_EVENT Event OPTIONAL
);
/**
- Used to retrieve the list of namespaces defined on an NVM Express controller.
+ Used to retrieve the next namespace ID for this NVM Express controller.
+
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid
+ namespace ID on this NVM Express controller.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces
- defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the
- namespace buffer, then the first namespace defined on the NVM Express controller is returned in
- NamespaceID, and a status of EFI_SUCCESS is returned.
+ If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace
+ ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId
+ and a status of EFI_SUCCESS is returned.
- If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),
- then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller
- is returned in NamespaceId, and EFI_SUCCESS is returned.
+ If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,
+ then EFI_INVALID_PARAMETER is returned.
- If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to
- GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.
+ If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid
+ namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,
+ and EFI_SUCCESS is returned.
- If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then
- EFI_NOT_FOUND is returned
+ If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM
+ Express controller, then EFI_NOT_FOUND is returned.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
namespace present on the NVM Express controller. On output, a
pointer to the next NamespaceId of an NVM Express namespace on
an NVM Express controller. An input value of 0xFFFFFFFF retrieves
the first NamespaceId for an NVM Express namespace present on an
NVM Express controller.
- @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID
- is defined for that NamespaceId, otherwise, zero is returned in
- this parameter. If the caller does not require a UUID, then a NULL
- pointer may be passed.
- @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.
+ @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.
@retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
- @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned
- on a previous call to GetNextNamespace().
+ @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.
**/
EFI_STATUS
EFIAPI
NvmExpressGetNextNamespace (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid OPTIONAL
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT32 *NamespaceId
);
/**
- Used to translate a device path node to a Target ID and LUN.
+ Used to translate a device path node to a namespace ID.
+
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the
+ namespace described by DevicePath.
+
+ If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express
+ Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID
- associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type
- that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate
- the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID
- and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.
+ If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
the NVM Express controller.
@param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
- @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.
- @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.
- @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER
- is returned.
+ @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.
+ @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.
@retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
supports, then EFI_UNSUPPORTED is returned.
- @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver
- supports, but there is not a valid translation from DevicePath to a NamespaceID
- and NamespaceUuid, then EFI_NOT_FOUND is returned.
+ @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver
+ supports, but there is not a valid translation from DevicePath to a namespace ID,
+ then EFI_NOT_FOUND is returned.
**/
EFI_STATUS
EFIAPI
NvmExpressGetNamespace (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid
+ OUT UINT32 *NamespaceId
);
/**
Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
path node for the NVM Express namespace specified by NamespaceId.
- If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.
+ If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.
If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
@@ -583,12 +574,10 @@ NvmExpressGetNamespace ( Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
allocated and built. Caller must set the NamespaceId to zero if the
device path node will contain a valid UUID.
- @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
- allocated and built. UUID will only be valid of the Namespace ID is zero.
@param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
namespace specified by NamespaceId. This function is responsible for
allocating the buffer DevicePath with the boot service AllocatePool().
@@ -596,8 +585,7 @@ NvmExpressGetNamespace ( is finished with DevicePath.
@retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
by NamespaceId was allocated and returned in DevicePath.
- @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the
- NVM Express controller.
+ @retval EFI_NOT_FOUND The NamespaceId is not valid.
@retval EFI_INVALID_PARAMETER DevicePath is NULL.
@retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
@@ -605,9 +593,8 @@ NvmExpressGetNamespace ( EFI_STATUS
EFIAPI
NvmExpressBuildDevicePath (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c index c1aad6b813..0b17ebd4b7 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c @@ -2,7 +2,7 @@ NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
NVM Express specification.
- Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -37,9 +37,9 @@ ReadSectors ( {
NVME_CONTROLLER_PRIVATE_DATA *Controller;
UINT32 Bytes;
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
UINT32 BlockSize;
@@ -47,21 +47,20 @@ ReadSectors ( BlockSize = Device->Media.BlockSize;
Bytes = Blocks * BlockSize;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_READ_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Controller->Cid[1]++;
CommandPacket.NvmeCmd->Nsid = Device->NamespaceId;
CommandPacket.TransferBuffer = (VOID *)(UINTN)Buffer;
CommandPacket.TransferLength = Bytes;
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
+ CommandPacket.QueueType = NVME_IO_QUEUE;
CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
CommandPacket.NvmeCmd->Cdw11 = (UINT32)(Lba >> 32);
@@ -72,7 +71,6 @@ ReadSectors ( Status = Controller->Passthru.PassThru (
&Controller->Passthru,
Device->NamespaceId,
- 0,
&CommandPacket,
NULL
);
@@ -101,9 +99,9 @@ WriteSectors ( )
{
NVME_CONTROLLER_PRIVATE_DATA *Controller;
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
UINT32 Bytes;
UINT32 BlockSize;
@@ -112,21 +110,20 @@ WriteSectors ( BlockSize = Device->Media.BlockSize;
Bytes = Blocks * BlockSize;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_WRITE_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Controller->Cid[1]++;
CommandPacket.NvmeCmd->Nsid = Device->NamespaceId;
CommandPacket.TransferBuffer = (VOID *)(UINTN)Buffer;
CommandPacket.TransferLength = Bytes;
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
+ CommandPacket.QueueType = NVME_IO_QUEUE;
CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
CommandPacket.NvmeCmd->Cdw11 = (UINT32)(Lba >> 32);
@@ -140,7 +137,6 @@ WriteSectors ( Status = Controller->Passthru.PassThru (
&Controller->Passthru,
Device->NamespaceId,
- 0,
&CommandPacket,
NULL
);
@@ -281,30 +277,28 @@ NvmeFlush ( )
{
NVME_CONTROLLER_PRIVATE_DATA *Controller;
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
Controller = Device->Controller;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_FLUSH_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Controller->Cid[1]++;
CommandPacket.NvmeCmd->Nsid = Device->NamespaceId;
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
+ CommandPacket.QueueType = NVME_IO_QUEUE;
Status = Controller->Passthru.PassThru (
&Controller->Passthru,
Device->NamespaceId,
- 0,
&CommandPacket,
NULL
);
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf index 91d40cf368..f73d6af8af 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf @@ -4,7 +4,7 @@ # NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
# NVM Express specification.
#
-# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -45,7 +45,6 @@ NvmExpressHci.c
NvmExpressHci.h
NvmExpressPassthru.c
- NvmExpressPassthru.h
[Packages]
MdePkg/MdePkg.dec
@@ -66,6 +65,7 @@ ## BY_START
## TO_START
gEfiDevicePathProtocolGuid
+ gEfiNvmExpressPassThruProtocolGuid ## BY_START
gEfiBlockIoProtocolGuid ## BY_START
gEfiDiskInfoProtocolGuid ## BY_START
gEfiDriverSupportedEfiVersionProtocolGuid ## PRODUCES
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c index ac09fc2bd8..0e35694c39 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c @@ -2,7 +2,7 @@ NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
NVM Express specification.
- Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -509,13 +509,12 @@ NvmeEnableController ( UINT8 Timeout;
//
- // Enable the controller
+ // Enable the controller.
+ // CC.AMS, CC.MPS and CC.CSS are all set to 0.
//
ZeroMem (&Cc, sizeof (NVME_CC));
- Cc.En = 1;
- Cc.Iosqes = 6;
- Cc.Iocqes = 4;
- Status = WriteNvmeControllerConfiguration (Private, &Cc);
+ Cc.En = 1;
+ Status = WriteNvmeControllerConfiguration (Private, &Cc);
if (EFI_ERROR(Status)) {
return Status;
@@ -572,17 +571,16 @@ NvmeIdentifyController ( IN VOID *Buffer
)
{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_OPC;
- Command.Cdw0.Cid = Private->Cid[0]++;
//
// According to Nvm Express 1.1 spec Figure 38, When not used, the field shall be cleared to 0h.
// For the Identify command, the Namespace Identifier is only used for the Namespace data structure.
@@ -590,11 +588,11 @@ NvmeIdentifyController ( Command.Nsid = 0;
CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCompletion = &Completion;
CommandPacket.TransferBuffer = Buffer;
CommandPacket.TransferLength = sizeof (NVME_ADMIN_CONTROLLER_DATA);
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_ADMIN_QUEUE;
+ CommandPacket.QueueType = NVME_ADMIN_QUEUE;
//
// Set bit 0 (Cns bit) to 1 to identify a controller
//
@@ -604,7 +602,6 @@ NvmeIdentifyController ( Status = Private->Passthru.PassThru (
&Private->Passthru,
NVME_CONTROLLER_ID,
- 0,
&CommandPacket,
NULL
);
@@ -630,25 +627,24 @@ NvmeIdentifyNamespace ( IN VOID *Buffer
)
{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_OPC;
- Command.Cdw0.Cid = Private->Cid[0]++;
Command.Nsid = NamespaceId;
CommandPacket.TransferBuffer = Buffer;
CommandPacket.TransferLength = sizeof (NVME_ADMIN_NAMESPACE_DATA);
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_ADMIN_QUEUE;
+ CommandPacket.QueueType = NVME_ADMIN_QUEUE;
//
// Set bit 0 (Cns bit) to 1 to identify a namespace
//
@@ -658,7 +654,6 @@ NvmeIdentifyNamespace ( Status = Private->Passthru.PassThru (
&Private->Passthru,
NamespaceId,
- 0,
&CommandPacket,
NULL
);
@@ -680,26 +675,25 @@ NvmeCreateIoCompletionQueue ( IN NVME_CONTROLLER_PRIVATE_DATA *Private
)
{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
NVME_ADMIN_CRIOCQ CrIoCq;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
ZeroMem (&CrIoCq, sizeof(NVME_ADMIN_CRIOCQ));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
Command.Cdw0.Opcode = NVME_ADMIN_CRIOCQ_OPC;
- Command.Cdw0.Cid = Private->Cid[0]++;
CommandPacket.TransferBuffer = Private->CqBufferPciAddr[1];
CommandPacket.TransferLength = EFI_PAGE_SIZE;
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_ADMIN_QUEUE;
+ CommandPacket.QueueType = NVME_ADMIN_QUEUE;
CrIoCq.Qid = NVME_IO_QUEUE;
CrIoCq.Qsize = NVME_CCQ_SIZE;
@@ -710,7 +704,6 @@ NvmeCreateIoCompletionQueue ( Status = Private->Passthru.PassThru (
&Private->Passthru,
0,
- 0,
&CommandPacket,
NULL
);
@@ -732,26 +725,25 @@ NvmeCreateIoSubmissionQueue ( IN NVME_CONTROLLER_PRIVATE_DATA *Private
)
{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
EFI_STATUS Status;
NVME_ADMIN_CRIOSQ CrIoSq;
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
+ ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
ZeroMem (&CrIoSq, sizeof(NVME_ADMIN_CRIOSQ));
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
+ CommandPacket.NvmeCmd = &Command;
+ CommandPacket.NvmeCompletion = &Completion;
Command.Cdw0.Opcode = NVME_ADMIN_CRIOSQ_OPC;
- Command.Cdw0.Cid = Private->Cid[0]++;
CommandPacket.TransferBuffer = Private->SqBufferPciAddr[1];
CommandPacket.TransferLength = EFI_PAGE_SIZE;
CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_ADMIN_QUEUE;
+ CommandPacket.QueueType = NVME_ADMIN_QUEUE;
CrIoSq.Qid = NVME_IO_QUEUE;
CrIoSq.Qsize = NVME_CSQ_SIZE;
@@ -764,7 +756,6 @@ NvmeCreateIoSubmissionQueue ( Status = Private->Passthru.PassThru (
&Private->Passthru,
0,
- 0,
&CommandPacket,
NULL
);
@@ -930,22 +921,6 @@ NvmeControllerInit ( }
//
- // Create one I/O completion queue.
- //
- Status = NvmeCreateIoCompletionQueue (Private);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- //
- // Create one I/O Submission queue.
- //
- Status = NvmeCreateIoSubmissionQueue (Private);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- //
// Allocate buffer for Identify Controller data
//
Private->ControllerData = (NVME_ADMIN_CONTROLLER_DATA *)AllocateZeroPool (sizeof(NVME_ADMIN_CONTROLLER_DATA));
@@ -983,6 +958,22 @@ NvmeControllerInit ( DEBUG ((EFI_D_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes));
DEBUG ((EFI_D_INFO, " NN : 0x%x\n", Private->ControllerData->Nn));
+ //
+ // Create one I/O completion queue.
+ //
+ Status = NvmeCreateIoCompletionQueue (Private);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Create one I/O Submission queue.
+ //
+ Status = NvmeCreateIoSubmissionQueue (Private);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c index 2fc4df0a43..d37194a910 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c @@ -16,23 +16,6 @@ #include "NvmExpress.h"
-//
-// Page size should be set in the Controller Configuration register
-// during controller init, and the controller configuration save in
-// the controller's private data. The Max and Min supported page sizes
-// for the controller are specified in the Controller Capabilities register.
-//
-
-GLOBAL_REMOVE_IF_UNREFERENCED NVM_EXPRESS_PASS_THRU_MODE gNvmExpressPassThruMode = {
- 0,
- NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL | NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVME,
- sizeof (UINTN),
- 0x10000,
- 0,
- 0
-};
-
-
/**
Dump the execution status from a given completion queue entry.
@@ -335,21 +318,19 @@ EXIT: /**
Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
- both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
+ both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, and the non-blocking
I/O functionality is optional.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
- @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
- A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
- ID specifies that the command packet should be sent to all valid namespaces.
- @param[in] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
- A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
- UUID specifies that the command packet should be sent to all valid namespaces.
- @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
- by NamespaceId.
- @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
- If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O
- is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM
+
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] NamespaceId A 32 bit namespace ID as defined in the NVMe specification to which the NVM Express Command
+ Packet will be sent. A value of 0 denotes the NVM Express controller, a value of all 0xFF's
+ (all bytes are 0xFF) in the namespace ID specifies that the command packet should be sent to
+ all valid namespaces.
+ @param[in,out] Packet A pointer to the NVM Express Command Packet.
+ @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking I/O is performed.
+ If Event is NULL, then blocking I/O is performed. If Event is not NULL and non-blocking I/O
+ is supported, then non-blocking I/O is performed, and Event will be signaled when the NVM
Express Command Packet completes.
@retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
@@ -359,20 +340,20 @@ EXIT: @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
may retry again later.
@retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
- @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
+ @retval EFI_INVALID_PARAMETER NamespaceId or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
Express Command Packet was not sent, so no additional status information is available.
- @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
- The NVM Express Command Packet was not sent, so no additional status information is available.
+ @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the NVM Express
+ controller. The NVM Express Command Packet was not sent so no additional status information
+ is available.
@retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.
**/
EFI_STATUS
EFIAPI
NvmExpressPassThru (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
- IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
+ IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
IN EFI_EVENT Event OPTIONAL
)
{
@@ -381,7 +362,7 @@ NvmExpressPassThru ( EFI_PCI_IO_PROTOCOL *PciIo;
NVME_SQ *Sq;
NVME_CQ *Cq;
- UINT8 Qid;
+ UINT8 QueueType;
UINT32 Bytes;
UINT16 Offset;
EFI_EVENT TimerEvent;
@@ -403,11 +384,11 @@ NvmExpressPassThru ( return EFI_INVALID_PARAMETER;
}
- if ((Packet->NvmeCmd == NULL) || (Packet->NvmeResponse == NULL)) {
+ if ((Packet->NvmeCmd == NULL) || (Packet->NvmeCompletion == NULL)) {
return EFI_INVALID_PARAMETER;
}
- if (Packet->QueueId != NVME_ADMIN_QUEUE && Packet->QueueId != NVME_IO_QUEUE) {
+ if (Packet->QueueType != NVME_ADMIN_QUEUE && Packet->QueueType != NVME_IO_QUEUE) {
return EFI_INVALID_PARAMETER;
}
@@ -422,18 +403,18 @@ NvmExpressPassThru ( TimerEvent = NULL;
Status = EFI_SUCCESS;
- Qid = Packet->QueueId;
- Sq = Private->SqBuffer[Qid] + Private->SqTdbl[Qid].Sqt;
- Cq = Private->CqBuffer[Qid] + Private->CqHdbl[Qid].Cqh;
+ QueueType = Packet->QueueType;
+ Sq = Private->SqBuffer[QueueType] + Private->SqTdbl[QueueType].Sqt;
+ Cq = Private->CqBuffer[QueueType] + Private->CqHdbl[QueueType].Cqh;
if (Packet->NvmeCmd->Nsid != NamespaceId) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (Sq, sizeof (NVME_SQ));
- Sq->Opc = Packet->NvmeCmd->Cdw0.Opcode;
- Sq->Fuse = Packet->NvmeCmd->Cdw0.FusedOperation;
- Sq->Cid = Packet->NvmeCmd->Cdw0.Cid;
+ Sq->Opc = (UINT8)Packet->NvmeCmd->Cdw0.Opcode;
+ Sq->Fuse = (UINT8)Packet->NvmeCmd->Cdw0.FusedOperation;
+ Sq->Cid = Private->Cid[QueueType]++;
Sq->Nsid = Packet->NvmeCmd->Nsid;
//
@@ -519,6 +500,12 @@ NvmExpressPassThru ( Sq->Prp[1] = (Sq->Prp[0] + EFI_PAGE_SIZE) & ~(EFI_PAGE_SIZE - 1);
}
+ if(Packet->NvmeCmd->Flags & CDW2_VALID) {
+ Sq->Rsvd2 = (UINT64)Packet->NvmeCmd->Cdw2;
+ }
+ if(Packet->NvmeCmd->Flags & CDW3_VALID) {
+ Sq->Rsvd2 |= LShiftU64 ((UINT64)Packet->NvmeCmd->Cdw3, 32);
+ }
if(Packet->NvmeCmd->Flags & CDW10_VALID) {
Sq->Payload.Raw.Cdw10 = Packet->NvmeCmd->Cdw10;
}
@@ -541,13 +528,13 @@ NvmExpressPassThru ( //
// Ring the submission queue doorbell.
//
- Private->SqTdbl[Qid].Sqt ^= 1;
- Data = ReadUnaligned32 ((UINT32*)&Private->SqTdbl[Qid]);
+ Private->SqTdbl[QueueType].Sqt ^= 1;
+ Data = ReadUnaligned32 ((UINT32*)&Private->SqTdbl[QueueType]);
PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
- NVME_SQTDBL_OFFSET(Qid, Private->Cap.Dstrd),
+ NVME_SQTDBL_OFFSET(QueueType, Private->Cap.Dstrd),
1,
&Data
);
@@ -566,7 +553,6 @@ NvmExpressPassThru ( Status = gBS->SetTimer(TimerEvent, TimerRelative, Packet->CommandTimeout);
if (EFI_ERROR(Status)) {
- Packet->ControllerStatus = NVM_EXPRESS_STATUS_CONTROLLER_DEVICE_ERROR;
goto EXIT;
}
@@ -574,23 +560,21 @@ NvmExpressPassThru ( // Wait for completion queue to get filled in.
//
Status = EFI_TIMEOUT;
- Packet->ControllerStatus = NVM_EXPRESS_STATUS_CONTROLLER_TIMEOUT_COMMAND;
while (EFI_ERROR (gBS->CheckEvent (TimerEvent))) {
- if (Cq->Pt != Private->Pt[Qid]) {
+ if (Cq->Pt != Private->Pt[QueueType]) {
Status = EFI_SUCCESS;
- Packet->ControllerStatus = NVM_EXPRESS_STATUS_CONTROLLER_READY;
break;
}
}
- if ((Private->CqHdbl[Qid].Cqh ^= 1) == 0) {
- Private->Pt[Qid] ^= 1;
+ if ((Private->CqHdbl[QueueType].Cqh ^= 1) == 0) {
+ Private->Pt[QueueType] ^= 1;
}
//
// Copy the Respose Queue entry for this command to the callers response buffer
//
- CopyMem(Packet->NvmeResponse, Cq, sizeof(NVM_EXPRESS_RESPONSE));
+ CopyMem(Packet->NvmeCompletion, Cq, sizeof(EFI_NVM_EXPRESS_COMPLETION));
//
// Dump every completion entry status for debugging.
@@ -599,12 +583,12 @@ NvmExpressPassThru ( NvmeDumpStatus(Cq);
DEBUG_CODE_END();
- Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[Qid]);
+ Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueType]);
PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
- NVME_CQHDBL_OFFSET(Qid, Private->Cap.Dstrd),
+ NVME_CQHDBL_OFFSET(QueueType, Private->Cap.Dstrd),
1,
&Data
);
@@ -642,47 +626,43 @@ EXIT: }
/**
- Used to retrieve the list of namespaces defined on an NVM Express controller.
+ Used to retrieve the next namespace ID for this NVM Express controller.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces
- defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the
- namespace buffer, then the first namespace defined on the NVM Express controller is returned in
- NamespaceID, and a status of EFI_SUCCESS is returned.
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid
+ namespace ID on this NVM Express controller.
- If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),
- then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller
- is returned in NamespaceId, and EFI_SUCCESS is returned.
+ If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace
+ ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId
+ and a status of EFI_SUCCESS is returned.
- If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to
- GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.
+ If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,
+ then EFI_INVALID_PARAMETER is returned.
- If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then
- EFI_NOT_FOUND is returned
+ If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid
+ namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,
+ and EFI_SUCCESS is returned.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM
+ Express controller, then EFI_NOT_FOUND is returned.
+
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
namespace present on the NVM Express controller. On output, a
pointer to the next NamespaceId of an NVM Express namespace on
an NVM Express controller. An input value of 0xFFFFFFFF retrieves
the first NamespaceId for an NVM Express namespace present on an
NVM Express controller.
- @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID
- is defined for that NamespaceId, otherwise, zero is returned in
- this parameter. If the caller does not require a UUID, then a NULL
- pointer may be passed.
- @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.
+ @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.
@retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
- @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned
- on a previous call to GetNextNamespace().
+ @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.
**/
EFI_STATUS
EFIAPI
NvmExpressGetNextNamespace (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid OPTIONAL
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT32 *NamespaceId
)
{
NVME_CONTROLLER_PRIVATE_DATA *Private;
@@ -721,9 +701,6 @@ NvmExpressGetNextNamespace ( }
*NamespaceId = NextNamespaceId;
- if (NamespaceUuid != NULL) {
- *NamespaceUuid = NamespaceData->Eui64;
- }
} else {
if (*NamespaceId >= Private->ControllerData->Nn) {
return EFI_INVALID_PARAMETER;
@@ -744,9 +721,6 @@ NvmExpressGetNextNamespace ( }
*NamespaceId = NextNamespaceId;
- if (NamespaceUuid != NULL) {
- *NamespaceUuid = NamespaceData->Eui64;
- }
}
Done:
@@ -758,41 +732,40 @@ Done: }
/**
- Used to translate a device path node to a Namespace ID and Namespace UUID.
+ Used to translate a device path node to a namespace ID.
+
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the
+ namespace described by DevicePath.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID
- associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type
- that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate
- the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID
- and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.
+ If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express
+ Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned
+
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
the NVM Express controller.
@param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
- @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.
- @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.
- @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER
- is returned.
+ @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.
+ @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.
@retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
supports, then EFI_UNSUPPORTED is returned.
- @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver
- supports, but there is not a valid translation from DevicePath to a NamespaceID
- and NamespaceUuid, then EFI_NOT_FOUND is returned.
+ @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver
+ supports, but there is not a valid translation from DevicePath to a namespace ID,
+ then EFI_NOT_FOUND is returned.
**/
EFI_STATUS
EFIAPI
NvmExpressGetNamespace (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid
+ OUT UINT32 *NamespaceId
)
{
NVME_NAMESPACE_DEVICE_PATH *Node;
- if ((This == NULL) || (DevicePath == NULL) || (NamespaceId == NULL) || (NamespaceUuid == NULL)) {
+ if ((This == NULL) || (DevicePath == NULL) || (NamespaceId == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -807,8 +780,7 @@ NvmExpressGetNamespace ( return EFI_NOT_FOUND;
}
- *NamespaceId = Node->NamespaceId;
- *NamespaceUuid = Node->NamespaceUuid;
+ *NamespaceId = Node->NamespaceId;
return EFI_SUCCESS;
} else {
@@ -819,10 +791,10 @@ NvmExpressGetNamespace ( /**
Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
+ The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
path node for the NVM Express namespace specified by NamespaceId.
- If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.
+ If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.
If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
@@ -831,12 +803,10 @@ NvmExpressGetNamespace ( Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
+ @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
@param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
allocated and built. Caller must set the NamespaceId to zero if the
device path node will contain a valid UUID.
- @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
- allocated and built. UUID will only be valid of the Namespace ID is zero.
@param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
namespace specified by NamespaceId. This function is responsible for
allocating the buffer DevicePath with the boot service AllocatePool().
@@ -844,8 +814,7 @@ NvmExpressGetNamespace ( is finished with DevicePath.
@retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
by NamespaceId was allocated and returned in DevicePath.
- @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the
- NVM Express controller.
+ @retval EFI_NOT_FOUND The NamespaceId is not valid.
@retval EFI_INVALID_PARAMETER DevicePath is NULL.
@retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
@@ -853,13 +822,15 @@ NvmExpressGetNamespace ( EFI_STATUS
EFIAPI
NvmExpressBuildDevicePath (
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
+ IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
NVME_NAMESPACE_DEVICE_PATH *Node;
+ NVME_CONTROLLER_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ NVME_ADMIN_NAMESPACE_DATA *NamespaceData;
//
// Validate parameters
@@ -872,8 +843,10 @@ NvmExpressBuildDevicePath ( return EFI_NOT_FOUND;
}
- Node = (NVME_NAMESPACE_DEVICE_PATH *)AllocateZeroPool (sizeof (NVME_NAMESPACE_DEVICE_PATH));
+ Status = EFI_SUCCESS;
+ Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);
+ Node = (NVME_NAMESPACE_DEVICE_PATH *)AllocateZeroPool (sizeof (NVME_NAMESPACE_DEVICE_PATH));
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -882,9 +855,43 @@ NvmExpressBuildDevicePath ( Node->Header.SubType = MSG_NVME_NAMESPACE_DP;
SetDevicePathNodeLength (&Node->Header, sizeof (NVME_NAMESPACE_DEVICE_PATH));
Node->NamespaceId = NamespaceId;
- Node->NamespaceUuid = NamespaceUuid;
+
+ //
+ // Allocate a buffer for Identify Namespace data.
+ //
+ NamespaceData = NULL;
+ NamespaceData = AllocateZeroPool(sizeof (NVME_ADMIN_NAMESPACE_DATA));
+ if(NamespaceData == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ //
+ // Get UUID from specified Identify Namespace data.
+ //
+ Status = NvmeIdentifyNamespace (
+ Private,
+ NamespaceId,
+ (VOID *)NamespaceData
+ );
+
+ if (EFI_ERROR(Status)) {
+ goto Exit;
+ }
+
+ Node->NamespaceUuid = NamespaceData->Eui64;
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;
- return EFI_SUCCESS;
+
+Exit:
+ if(NamespaceData != NULL) {
+ FreePool (NamespaceData);
+ }
+
+ if (EFI_ERROR (Status)) {
+ FreePool (Node);
+ }
+
+ return Status;
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.h b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.h deleted file mode 100644 index cf05bffb84..0000000000 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.h +++ /dev/null @@ -1,299 +0,0 @@ -/** @file
- NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
- NVM Express specification.
-
- Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _NVM_EXPRESS_PASS_THRU_H_
-#define _NVM_EXPRESS_PASS_THRU_H_
-
-#define NVM_EXPRESS_PASS_THRU_PROTOCOL_GUID \
- { \
- 0xec51ef5c, 0x2cf3, 0x4a55, {0xbf, 0x85, 0xb6, 0x3c, 0xa3, 0xb1, 0x3f, 0x44 } \
- }
-
-typedef struct _NVM_EXPRESS_PASS_THRU_PROTOCOL NVM_EXPRESS_PASS_THRU_PROTOCOL;
-
-typedef struct {
- UINT32 AdapterId;
- UINT32 Attributes;
- UINT32 IoAlign;
- UINT32 HciVersion;
- UINT64 Timeout;
- UINT32 MaxNamespace;
-} NVM_EXPRESS_PASS_THRU_MODE;
-
-//
-// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for directly addressable namespaces.
-//
-#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
-//
-// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for a single volume logical namespace
-// comprised of multiple namespaces.
-//
-#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
-//
-// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports non blocking I/O.
-//
-#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
-//
-// If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports NVM command set commands.
-//
-#define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVME 0x0008
-
-//
-// QueueId
-//
-#define NVME_ADMIN_QUEUE 0x00
-#define NVME_IO_QUEUE 0x01
-
-//
-// ControllerStatus
-//
-#define NVM_EXPRESS_STATUS_CONTROLLER_READY 0x00
-#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ERROR 0x01
-#define NVM_EXPRESS_STATUS_CONTROLLER_FATAL 0x02
-#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_DATA_ERROR 0x04
-#define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ABORT 0x05
-#define NVM_EXPRESS_STATUS_CONTROLLER_DEVICE_ERROR 0x06
-#define NVM_EXPRESS_STATUS_CONTROLLER_TIMEOUT_COMMAND 0x09
-#define NVM_EXPRESS_STATUS_CONTROLLER_INVALID_NAMESPACE 0x0B
-#define NVM_EXPRESS_STATUS_CONTROLLER_NOT_READY 0x0C
-#define NVM_EXPRESS_STATUS_CONTROLLER_OTHER 0x7F
-
-typedef struct {
- UINT8 Opcode;
- UINT8 FusedOperation;
- #define NORMAL_CMD 0x00
- #define FUSED_FIRST_CMD 0x01
- #define FUSED_SECOND_CMD 0x02
- UINT16 Cid;
-} NVME_CDW0;
-
-typedef struct {
- NVME_CDW0 Cdw0;
- UINT8 Flags;
- #define CDW10_VALID 0x01
- #define CDW11_VALID 0x02
- #define CDW12_VALID 0x04
- #define CDW13_VALID 0x08
- #define CDW14_VALID 0x10
- #define CDW15_VALID 0x20
- UINT32 Nsid;
- UINT32 Cdw10;
- UINT32 Cdw11;
- UINT32 Cdw12;
- UINT32 Cdw13;
- UINT32 Cdw14;
- UINT32 Cdw15;
-} NVM_EXPRESS_COMMAND;
-
-typedef struct {
- UINT32 Cdw0;
- UINT32 Cdw1;
- UINT32 Cdw2;
- UINT32 Cdw3;
-} NVM_EXPRESS_RESPONSE;
-
-typedef struct {
- UINT64 CommandTimeout;
- VOID *TransferBuffer;
- UINT32 TransferLength;
- VOID *MetadataBuffer;
- UINT32 MetadataLength;
- UINT8 QueueId;
- NVM_EXPRESS_COMMAND *NvmeCmd;
- NVM_EXPRESS_RESPONSE *NvmeResponse;
- UINT8 ControllerStatus;
-} NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;
-
-//
-// Protocol funtion prototypes
-//
-/**
- Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
- both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
- I/O functionality is optional.
-
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
- @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
- A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
- ID specifies that the command packet should be sent to all valid namespaces.
- @param[in] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
- A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
- UUID specifies that the command packet should be sent to all valid namespaces.
- @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
- by NamespaceId.
- @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
- If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O
- is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM
- Express Command Packet completes.
-
- @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
- to, or from DataBuffer.
- @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred
- is returned in TransferLength.
- @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
- may retry again later.
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
- @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
- Express Command Packet was not sent, so no additional status information is available.
- @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
- The NVM Express Command Packet was not sent, so no additional status information is available.
- @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *NVM_EXPRESS_PASS_THRU_PASSTHRU)(
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
- IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
- );
-
-/**
- Used to retrieve the list of namespaces defined on an NVM Express controller.
-
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces
- defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the
- namespace buffer, then the first namespace defined on the NVM Express controller is returned in
- NamespaceID, and a status of EFI_SUCCESS is returned.
-
- If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),
- then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller
- is returned in NamespaceId, and EFI_SUCCESS is returned.
-
- If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to
- GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.
-
- If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then
- EFI_NOT_FOUND is returned
-
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
- @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
- namespace present on the NVM Express controller. On output, a
- pointer to the next NamespaceId of an NVM Express namespace on
- an NVM Express controller. An input value of 0xFFFFFFFF retrieves
- the first NamespaceId for an NVM Express namespace present on an
- NVM Express controller.
- @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID
- is defined for that NamespaceId, otherwise, zero is returned in
- this parameter. If the caller does not require a UUID, then a NULL
- pointer may be passed.
-
- @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.
- @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
- @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned
- on a previous call to GetNextNamespace().
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE)(
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid OPTIONAL
- );
-
-/**
- Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
-
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
- path node for the NVM Express namespace specified by NamespaceId.
-
- If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.
-
- If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
-
- If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
-
- Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
- initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
-
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
- @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
- allocated and built. Caller must set the NamespaceId to zero if the
- device path node will contain a valid UUID.
- @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
- allocated and built. UUID will only be valid of the Namespace ID is zero.
- @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
- namespace specified by NamespaceId. This function is responsible for
- allocating the buffer DevicePath with the boot service AllocatePool().
- It is the caller's responsibility to free DevicePath when the caller
- is finished with DevicePath.
- @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
- by NamespaceId was allocated and returned in DevicePath.
- @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the
- NVM Express controller.
- @retval EFI_INVALID_PARAMETER DevicePath is NULL.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH)(
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN UINT32 NamespaceId,
- IN UINT64 NamespaceUuid,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- );
-
-/**
- Used to translate a device path node to a Namespace ID and Namespace UUID.
-
- The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID
- associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type
- that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate
- the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID
- and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.
-
- @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
- @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
- the NVM Express controller.
- @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
- @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.
-
- @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.
- @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER
- is returned.
- @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
- supports, then EFI_UNSUPPORTED is returned.
- @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver
- supports, but there is not a valid translation from DevicePath to a NamespaceID
- and NamespaceUuid, then EFI_NOT_FOUND is returned.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *NVM_EXPRESS_PASS_THRU_GET_NAMESPACE)(
- IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT32 *NamespaceId,
- OUT UINT64 *NamespaceUuid
- );
-
-//
-// Protocol Interface Structure
-//
-struct _NVM_EXPRESS_PASS_THRU_PROTOCOL {
- NVM_EXPRESS_PASS_THRU_MODE *Mode;
- NVM_EXPRESS_PASS_THRU_PASSTHRU PassThru;
- NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE GetNextNamespace;
- NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
- NVM_EXPRESS_PASS_THRU_GET_NAMESPACE GetNamespace;
-};
-
-//extern EFI_GUID gNvmExpressPassThruProtocolGuid;
-
-#endif
-
|