2 NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
3 NVM Express specification.
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _NVM_EXPRESS_PASS_THRU_H_
17 #define _NVM_EXPRESS_PASS_THRU_H_
19 #define NVM_EXPRESS_PASS_THRU_PROTOCOL_GUID \
21 0xec51ef5c, 0x2cf3, 0x4a55, {0xbf, 0x85, 0xb6, 0x3c, 0xa3, 0xb1, 0x3f, 0x44 } \
24 typedef struct _NVM_EXPRESS_PASS_THRU_PROTOCOL NVM_EXPRESS_PASS_THRU_PROTOCOL
;
33 } NVM_EXPRESS_PASS_THRU_MODE
;
36 // If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for directly addressable namespaces.
38 #define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
40 // If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface is for a single volume logical namespace
41 // comprised of multiple namespaces.
43 #define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
45 // If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports non blocking I/O.
47 #define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
49 // If this bit is set, then the NVM_EXPRESS_PASS_THRU_PROTOCOL interface supports NVM command set commands.
51 #define NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVME 0x0008
56 #define NVME_ADMIN_QUEUE 0x00
57 #define NVME_IO_QUEUE 0x01
62 #define NVM_EXPRESS_STATUS_CONTROLLER_READY 0x00
63 #define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ERROR 0x01
64 #define NVM_EXPRESS_STATUS_CONTROLLER_FATAL 0x02
65 #define NVM_EXPRESS_STATUS_CONTROLLER_CMD_DATA_ERROR 0x04
66 #define NVM_EXPRESS_STATUS_CONTROLLER_CMD_ABORT 0x05
67 #define NVM_EXPRESS_STATUS_CONTROLLER_DEVICE_ERROR 0x06
68 #define NVM_EXPRESS_STATUS_CONTROLLER_TIMEOUT_COMMAND 0x09
69 #define NVM_EXPRESS_STATUS_CONTROLLER_INVALID_NAMESPACE 0x0B
70 #define NVM_EXPRESS_STATUS_CONTROLLER_NOT_READY 0x0C
71 #define NVM_EXPRESS_STATUS_CONTROLLER_OTHER 0x7F
76 #define NORMAL_CMD 0x00
77 #define FUSED_FIRST_CMD 0x01
78 #define FUSED_SECOND_CMD 0x02
85 #define CDW10_VALID 0x01
86 #define CDW11_VALID 0x02
87 #define CDW12_VALID 0x04
88 #define CDW13_VALID 0x08
89 #define CDW14_VALID 0x10
90 #define CDW15_VALID 0x20
98 } NVM_EXPRESS_COMMAND
;
105 } NVM_EXPRESS_RESPONSE
;
108 UINT64 CommandTimeout
;
109 VOID
*TransferBuffer
;
110 UINT32 TransferLength
;
111 VOID
*MetadataBuffer
;
112 UINT32 MetadataLength
;
114 NVM_EXPRESS_COMMAND
*NvmeCmd
;
115 NVM_EXPRESS_RESPONSE
*NvmeResponse
;
116 UINT8 ControllerStatus
;
117 } NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
;
120 // Protocol funtion prototypes
123 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
124 both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
125 I/O functionality is optional.
127 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
128 @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
129 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
130 ID specifies that the command packet should be sent to all valid namespaces.
131 @param[in] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
132 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
133 UUID specifies that the command packet should be sent to all valid namespaces.
134 @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
136 @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
137 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O
138 is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM
139 Express Command Packet completes.
141 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
142 to, or from DataBuffer.
143 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred
144 is returned in TransferLength.
145 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
146 may retry again later.
147 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
148 @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
149 Express Command Packet was not sent, so no additional status information is available.
150 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
151 The NVM Express Command Packet was not sent, so no additional status information is available.
152 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.
157 (EFIAPI
*NVM_EXPRESS_PASS_THRU_PASSTHRU
)(
158 IN NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
159 IN UINT32 NamespaceId
,
160 IN UINT64 NamespaceUuid
,
161 IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET
*Packet
,
162 IN EFI_EVENT Event OPTIONAL
166 Used to retrieve the list of namespaces defined on an NVM Express controller.
168 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces
169 defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the
170 namespace buffer, then the first namespace defined on the NVM Express controller is returned in
171 NamespaceID, and a status of EFI_SUCCESS is returned.
173 If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),
174 then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller
175 is returned in NamespaceId, and EFI_SUCCESS is returned.
177 If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to
178 GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.
180 If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then
181 EFI_NOT_FOUND is returned
183 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
184 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
185 namespace present on the NVM Express controller. On output, a
186 pointer to the next NamespaceId of an NVM Express namespace on
187 an NVM Express controller. An input value of 0xFFFFFFFF retrieves
188 the first NamespaceId for an NVM Express namespace present on an
189 NVM Express controller.
190 @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID
191 is defined for that NamespaceId, otherwise, zero is returned in
192 this parameter. If the caller does not require a UUID, then a NULL
193 pointer may be passed.
195 @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.
196 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
197 @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned
198 on a previous call to GetNextNamespace().
203 (EFIAPI
*NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE
)(
204 IN NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
205 IN OUT UINT32
*NamespaceId
,
206 OUT UINT64
*NamespaceUuid OPTIONAL
210 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
212 The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
213 path node for the NVM Express namespace specified by NamespaceId.
215 If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.
217 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
219 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
221 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
222 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
224 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
225 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
226 allocated and built. Caller must set the NamespaceId to zero if the
227 device path node will contain a valid UUID.
228 @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
229 allocated and built. UUID will only be valid of the Namespace ID is zero.
230 @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
231 namespace specified by NamespaceId. This function is responsible for
232 allocating the buffer DevicePath with the boot service AllocatePool().
233 It is the caller's responsibility to free DevicePath when the caller
234 is finished with DevicePath.
235 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
236 by NamespaceId was allocated and returned in DevicePath.
237 @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the
238 NVM Express controller.
239 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
240 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
245 (EFIAPI
*NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH
)(
246 IN NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
247 IN UINT32 NamespaceId
,
248 IN UINT64 NamespaceUuid
,
249 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
253 Used to translate a device path node to a Namespace ID and Namespace UUID.
255 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID
256 associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type
257 that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate
258 the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID
259 and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.
261 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
262 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
263 the NVM Express controller.
264 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
265 @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.
267 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.
268 @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER
270 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
271 supports, then EFI_UNSUPPORTED is returned.
272 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver
273 supports, but there is not a valid translation from DevicePath to a NamespaceID
274 and NamespaceUuid, then EFI_NOT_FOUND is returned.
278 (EFIAPI
*NVM_EXPRESS_PASS_THRU_GET_NAMESPACE
)(
279 IN NVM_EXPRESS_PASS_THRU_PROTOCOL
*This
,
280 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
281 OUT UINT32
*NamespaceId
,
282 OUT UINT64
*NamespaceUuid
286 // Protocol Interface Structure
288 struct _NVM_EXPRESS_PASS_THRU_PROTOCOL
{
289 NVM_EXPRESS_PASS_THRU_MODE
*Mode
;
290 NVM_EXPRESS_PASS_THRU_PASSTHRU PassThru
;
291 NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE GetNextNamespace
;
292 NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath
;
293 NVM_EXPRESS_PASS_THRU_GET_NAMESPACE GetNamespace
;
296 //extern EFI_GUID gNvmExpressPassThruProtocolGuid;