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