]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
d39b62e102de2ff72385259a59fd31023513982c
[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, 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/BlockIo.h>
30 #include <Protocol/DiskInfo.h>
31 #include <Protocol/DriverSupportedEfiVersion.h>
32
33 #include <Library/BaseLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/PrintLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/DevicePathLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/UefiBootServicesTableLib.h>
41 #include <Library/UefiDriverEntryPoint.h>
42
43 typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA;
44 typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;
45
46 #include "NvmExpressPassthru.h"
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 2 // Number of admin submission queue entries
60 #define NVME_ACQ_SIZE 2 // Number of admin completion queue entries
61
62 #define NVME_CSQ_SIZE 2 // Number of I/O submission queue entries
63 #define NVME_CCQ_SIZE 2 // Number of I/O completion queue entries
64
65 #define NVME_MAX_IO_QUEUES 2 // Number of I/O 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 NVM_EXPRESS_PASS_THRU_MODE PassThruMode;
95 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 submission queue #1.
106 // 3rd 4kB boundary is the start of the admin completion queue.
107 // 4th 4kB boundary is the start of 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_IO_QUEUES];
118 NVME_CQ *CqBuffer[NVME_MAX_IO_QUEUES];
119 NVME_SQ *SqBufferPciAddr[NVME_MAX_IO_QUEUES];
120 NVME_CQ *CqBufferPciAddr[NVME_MAX_IO_QUEUES];
121
122 //
123 // Submission and completion queue indices.
124 //
125 NVME_SQTDBL SqTdbl[NVME_MAX_IO_QUEUES];
126 NVME_CQHDBL CqHdbl[NVME_MAX_IO_QUEUES];
127
128 UINT8 Pt[2];
129 UINT16 Cid[2];
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 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] NamespaceUuid Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
461 A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace
462 UUID specifies that the command packet should be sent to all valid namespaces.
463 @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
464 by NamespaceId.
465 @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.
466 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O
467 is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM
468 Express Command Packet completes.
469
470 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
471 to, or from DataBuffer.
472 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred
473 is returned in TransferLength.
474 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller
475 may retry again later.
476 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.
477 @retval EFI_INVALID_PARAMETER Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
478 Express Command Packet was not sent, so no additional status information is available.
479 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.
480 The NVM Express Command Packet was not sent, so no additional status information is available.
481 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.
482
483 **/
484 EFI_STATUS
485 EFIAPI
486 NvmExpressPassThru (
487 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
488 IN UINT32 NamespaceId,
489 IN UINT64 NamespaceUuid,
490 IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,
491 IN EFI_EVENT Event OPTIONAL
492 );
493
494 /**
495 Used to retrieve the list of namespaces defined on an NVM Express controller.
496
497 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves a list of namespaces
498 defined on an NVM Express controller. If on input a NamespaceID is specified by all 0xFF in the
499 namespace buffer, then the first namespace defined on the NVM Express controller is returned in
500 NamespaceID, and a status of EFI_SUCCESS is returned.
501
502 If NamespaceId is a Namespace value that was returned on a previous call to GetNextNamespace(),
503 then the next valid NamespaceId for an NVM Express SSD namespace on the NVM Express controller
504 is returned in NamespaceId, and EFI_SUCCESS is returned.
505
506 If Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned on a previous call to
507 GetNextNamespace(), then EFI_INVALID_PARAMETER is returned.
508
509 If NamespaceId is the NamespaceId of the last SSD namespace on the NVM Express controller, then
510 EFI_NOT_FOUND is returned
511
512 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
513 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express
514 namespace present on the NVM Express controller. On output, a
515 pointer to the next NamespaceId of an NVM Express namespace on
516 an NVM Express controller. An input value of 0xFFFFFFFF retrieves
517 the first NamespaceId for an NVM Express namespace present on an
518 NVM Express controller.
519 @param[out] NamespaceUuid On output, the UUID associated with the next namespace, if a UUID
520 is defined for that NamespaceId, otherwise, zero is returned in
521 this parameter. If the caller does not require a UUID, then a NULL
522 pointer may be passed.
523
524 @retval EFI_SUCCESS The NamespaceId of the next Namespace was returned.
525 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.
526 @retval EFI_INVALID_PARAMETER Namespace array is not a 0xFFFFFFFF and NamespaceId was not returned
527 on a previous call to GetNextNamespace().
528
529 **/
530 EFI_STATUS
531 EFIAPI
532 NvmExpressGetNextNamespace (
533 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
534 IN OUT UINT32 *NamespaceId,
535 OUT UINT64 *NamespaceUuid OPTIONAL
536 );
537
538 /**
539 Used to translate a device path node to a Target ID and LUN.
540
541 The NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamwspace() function determines the Namespace ID and Namespace UUID
542 associated with the NVM Express SSD namespace described by DevicePath. If DevicePath is a device path node type
543 that the NVM Express Pass Thru driver supports, then the NVM Express Pass Thru driver will attempt to translate
544 the contents DevicePath into a Namespace ID and UUID. If this translation is successful, then that Namespace ID
545 and UUID are returned in NamespaceID and NamespaceUUID, and EFI_SUCCESS is returned.
546
547 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
548 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on
549 the NVM Express controller.
550 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.
551 @param[out] NamespaceUuid The NVM Express namespace contained in the device path node.
552
553 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId and NamespaceUuid.
554 @retval EFI_INVALID_PARAMETER If DevicePath, NamespaceId, or NamespaceUuid are NULL, then EFI_INVALID_PARAMETER
555 is returned.
556 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver
557 supports, then EFI_UNSUPPORTED is returned.
558 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the Nvm Express Pass Thru driver
559 supports, but there is not a valid translation from DevicePath to a NamespaceID
560 and NamespaceUuid, then EFI_NOT_FOUND is returned.
561 **/
562 EFI_STATUS
563 EFIAPI
564 NvmExpressGetNamespace (
565 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
566 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
567 OUT UINT32 *NamespaceId,
568 OUT UINT64 *NamespaceUuid
569 );
570
571 /**
572 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.
573
574 The NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device
575 path node for the NVM Express namespace specified by NamespaceId.
576
577 If the namespace device specified by NamespaceId is not valid , then EFI_NOT_FOUND is returned.
578
579 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.
580
581 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
582
583 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are
584 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.
585
586 @param[in] This A pointer to the NVM_EXPRESS_PASS_THRU_PROTOCOL instance.
587 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be
588 allocated and built. Caller must set the NamespaceId to zero if the
589 device path node will contain a valid UUID.
590 @param[in] NamespaceUuid The NVM Express namespace UUID for which a device path node is to be
591 allocated and built. UUID will only be valid of the Namespace ID is zero.
592 @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express
593 namespace specified by NamespaceId. This function is responsible for
594 allocating the buffer DevicePath with the boot service AllocatePool().
595 It is the caller's responsibility to free DevicePath when the caller
596 is finished with DevicePath.
597 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified
598 by NamespaceId was allocated and returned in DevicePath.
599 @retval EFI_NOT_FOUND The NVM Express namespace specified by NamespaceId does not exist on the
600 NVM Express controller.
601 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
602 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.
603
604 **/
605 EFI_STATUS
606 EFIAPI
607 NvmExpressBuildDevicePath (
608 IN NVM_EXPRESS_PASS_THRU_PROTOCOL *This,
609 IN UINT32 NamespaceId,
610 IN UINT64 NamespaceUuid,
611 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
612 );
613
614 #endif