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