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