12#ifndef _EFI_NVM_EXPRESS_H_
13#define _EFI_NVM_EXPRESS_H_
61#define PCI_CLASS_MASS_STORAGE_NVM 0x08
62#define PCI_IF_NVMHCI 0x02
64#define NVME_ASQ_SIZE 1
65#define NVME_ACQ_SIZE 1
67#define NVME_CSQ_SIZE 1
68#define NVME_CCQ_SIZE 1
74#define NVME_ASYNC_CSQ_SIZE 63
79#define NVME_ASYNC_CCQ_SIZE 255
81#define NVME_MAX_QUEUES 3
86#define NVME_LBA_FORMATNVM_LBAF_MASK 0xF
91#define NVME_CQE_STATUS_FIELD_MASK 0xFFFF0000
92#define NVME_CQE_STATUS_FIELD_OFFSET 16
93#define NVME_CQE_STATUS_FIELD_SCT_MASK 0x0E00
94#define NVME_CQE_STATUS_FIELD_SCT_OFFSET 0x9
95#define NVME_CQE_STATUS_FIELD_SC_MASK 0x1FE
96#define NVME_CQE_STATUS_FIELD_SC_OFFSET 0x01
97#define NVME_CQE_SCT_GENERIC_CMD_STATUS 0x0
98#define NVME_CQE_SCT_CMD_SPECIFIC_STATUS 0x1
99#define NVME_CQE_SCT_MEDIA_DATA_INTEGRITY_ERRORS_STATUS 0x2
100#define NVME_CQE_SCT_PATH_RELATED_STATUS 0x3
101#define NVME_CQE_SC_SUCCESSFUL_COMPLETION 0x00
102#define NVME_CQE_SC_INVALID_CMD_OPCODE 0x01
103#define NVME_CQE_SC_INVALID_FIELD_IN_CMD 0x02
105#define NVME_ALL_NAMESPACES 0xFFFFFFFF
107#define NVME_CONTROLLER_ID 0
112#define NVME_GENERIC_TIMEOUT EFI_TIMER_PERIOD_SECONDS (5)
117#define NVME_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS (1)
122#define NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N','V','M','E')
135 UINT64 PciAttributes;
157 UINT8 *BufferPciAddr;
162 NVME_SQ *SqBuffer[NVME_MAX_QUEUES];
163 NVME_CQ *CqBuffer[NVME_MAX_QUEUES];
164 NVME_SQ *SqBufferPciAddr[NVME_MAX_QUEUES];
165 NVME_CQ *CqBufferPciAddr[NVME_MAX_QUEUES];
177 BOOLEAN CreateIoQueue;
179 UINT8 Pt[NVME_MAX_QUEUES];
180 UINT16 Cid[NVME_MAX_QUEUES];
197#define NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU(a) \
199 NVME_CONTROLLER_PRIVATE_DATA, \
201 NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE \
207#define NVME_DEVICE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X','S','S','D')
224 UINT64 NamespaceUuid;
238 CHAR16 ModelName[80];
247#define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO(a) \
249 NVME_DEVICE_PRIVATE_DATA, \
251 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
254#define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO2(a) \
256 NVME_DEVICE_PRIVATE_DATA, \
258 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
261#define NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO(a) \
263 NVME_DEVICE_PRIVATE_DATA, \
265 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
268#define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a) \
270 NVME_DEVICE_PRIVATE_DATA, \
272 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
275#define NVME_DEVICE_PRIVATE_DATA_FROM_MEDIA_SANITIZE(a) \
277 NVME_DEVICE_PRIVATE_DATA, \
279 NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
285#define NVME_BLKIO2_REQUEST_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'R')
292 UINTN UnsubmittedSubtaskNum;
293 BOOLEAN LastSubtaskSubmitted;
300#define NVME_BLKIO2_REQUEST_FROM_LINK(a) \
301 CR (a, NVME_BLKIO2_REQUEST, Link, NVME_BLKIO2_REQUEST_SIGNATURE)
303#define NVME_BLKIO2_SUBTASK_SIGNATURE SIGNATURE_32 ('N', 'B', '2', 'S')
319#define NVME_BLKIO2_SUBTASK_FROM_LINK(a) \
320 CR (a, NVME_BLKIO2_SUBTASK, Link, NVME_BLKIO2_SUBTASK_SIGNATURE)
325#define NVME_PASS_THRU_ASYNC_REQ_SIG SIGNATURE_32 ('N', 'P', 'A', 'R')
341#define NVME_PASS_THRU_ASYNC_REQ_FROM_THIS(a) \
343 NVME_PASS_THRU_ASYNC_REQ, \
345 NVME_PASS_THRU_ASYNC_REQ_SIG \
392 OUT CHAR16 **DriverName
470 OUT CHAR16 **ControllerName
635 IN UINT32 NamespaceId,
677 IN OUT UINT32 *NamespaceId
709 OUT UINT32 *NamespaceId
747 IN UINT32 NamespaceId,
EFI_STATUS EFIAPI NvmExpressComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
EFI_STATUS EFIAPI NvmExpressPassThru(IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This, IN UINT32 NamespaceId, IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI NvmExpressDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI NvmExpressGetNamespace(IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT32 *NamespaceId)
EFI_STATUS EFIAPI NvmExpressBuildDevicePath(IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This, IN UINT32 NamespaceId, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
VOID NvmeRegisterShutdownNotification(VOID)
EFI_STATUS EFIAPI NvmExpressComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_STATUS EFIAPI NvmExpressDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
VOID NvmeDumpStatus(IN NVME_CQ *Cq)
EFI_STATUS EFIAPI NvmExpressDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI NvmExpressGetNextNamespace(IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This, IN OUT UINT32 *NamespaceId)
VOID NvmeUnregisterShutdownNotification(VOID)