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