TianoCore EDK2 master
Loading...
Searching...
No Matches
NvmExpressHci.c File Reference
#include "NvmExpress.h"
#include <Guid/NVMeEventGroup.h>

Go to the source code of this file.

Macros

#define NVME_SHUTDOWN_PROCESS_TIMEOUT   45
 

Functions

EFI_STATUS ReadNvmeControllerCapabilities (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_CAP *Cap)
 
EFI_STATUS ReadNvmeControllerConfiguration (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_CC *Cc)
 
EFI_STATUS WriteNvmeControllerConfiguration (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_CC *Cc)
 
EFI_STATUS ReadNvmeControllerStatus (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_CSTS *Csts)
 
EFI_STATUS WriteNvmeAdminQueueAttributes (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_AQA *Aqa)
 
EFI_STATUS WriteNvmeAdminSubmissionQueueBaseAddress (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_ASQ *Asq)
 
EFI_STATUS WriteNvmeAdminCompletionQueueBaseAddress (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN NVME_ACQ *Acq)
 
EFI_STATUS NvmeDisableController (IN NVME_CONTROLLER_PRIVATE_DATA *Private)
 
EFI_STATUS NvmeEnableController (IN NVME_CONTROLLER_PRIVATE_DATA *Private)
 
EFI_STATUS NvmeIdentifyController (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN VOID *Buffer)
 
EFI_STATUS NvmeIdentifyNamespace (IN NVME_CONTROLLER_PRIVATE_DATA *Private, IN UINT32 NamespaceId, IN VOID *Buffer)
 
EFI_STATUS NvmeCreateIoCompletionQueue (IN NVME_CONTROLLER_PRIVATE_DATA *Private)
 
EFI_STATUS NvmeCreateIoSubmissionQueue (IN NVME_CONTROLLER_PRIVATE_DATA *Private)
 
EFI_STATUS NvmeControllerInit (IN NVME_CONTROLLER_PRIVATE_DATA *Private)
 
VOID EFIAPI NvmeShutdownAllControllers (IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
 
VOID NvmeRegisterShutdownNotification (VOID)
 
VOID NvmeUnregisterShutdownNotification (VOID)
 

Variables

UINTN mNvmeControllerNumber = 0
 

Detailed Description

NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows NVM Express specification.

Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file NvmExpressHci.c.

Macro Definition Documentation

◆ NVME_SHUTDOWN_PROCESS_TIMEOUT

#define NVME_SHUTDOWN_PROCESS_TIMEOUT   45

Definition at line 13 of file NvmExpressHci.c.

Function Documentation

◆ NvmeControllerInit()

EFI_STATUS NvmeControllerInit ( IN NVME_CONTROLLER_PRIVATE_DATA Private)

Initialize the Nvm Express controller.

Parameters
[in]PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe NVM Express Controller is initialized successfully.
OthersA device error occurred while initializing the controller.

Definition at line 723 of file NvmExpressHci.c.

◆ NvmeCreateIoCompletionQueue()

EFI_STATUS NvmeCreateIoCompletionQueue ( IN NVME_CONTROLLER_PRIVATE_DATA Private)

Create io completion queue.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
Returns
EFI_SUCCESS Successfully create io completion queue.
EFI_DEVICE_ERROR Fail to create io completion queue.

Definition at line 577 of file NvmExpressHci.c.

◆ NvmeCreateIoSubmissionQueue()

EFI_STATUS NvmeCreateIoSubmissionQueue ( IN NVME_CONTROLLER_PRIVATE_DATA Private)

Create io submission queue.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
Returns
EFI_SUCCESS Successfully create io submission queue.
EFI_DEVICE_ERROR Fail to create io submission queue.

Definition at line 649 of file NvmExpressHci.c.

◆ NvmeDisableController()

EFI_STATUS NvmeDisableController ( IN NVME_CONTROLLER_PRIVATE_DATA Private)

Disable the Nvm Express controller.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
Returns
EFI_SUCCESS Successfully disable the controller.
EFI_DEVICE_ERROR Fail to disable the controller.

Definition at line 314 of file NvmExpressHci.c.

◆ NvmeEnableController()

EFI_STATUS NvmeEnableController ( IN NVME_CONTROLLER_PRIVATE_DATA Private)

Enable the Nvm Express controller.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
Returns
EFI_SUCCESS Successfully enable the controller.
EFI_DEVICE_ERROR Fail to enable the controller.
EFI_TIMEOUT Fail to enable the controller in given time slot.

Definition at line 393 of file NvmExpressHci.c.

◆ NvmeIdentifyController()

EFI_STATUS NvmeIdentifyController ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN VOID *  Buffer 
)

Get identify controller data.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
BufferThe buffer used to store the identify controller data.
Returns
EFI_SUCCESS Successfully get the identify controller data.
EFI_DEVICE_ERROR Fail to get the identify controller data.

Definition at line 472 of file NvmExpressHci.c.

◆ NvmeIdentifyNamespace()

EFI_STATUS NvmeIdentifyNamespace ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN UINT32  NamespaceId,
IN VOID *  Buffer 
)

Get specified identify namespace data.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
NamespaceIdThe specified namespace identifier.
BufferThe buffer used to store the identify namespace data.
Returns
EFI_SUCCESS Successfully get the identify namespace data.
EFI_DEVICE_ERROR Fail to get the identify namespace data.

Definition at line 527 of file NvmExpressHci.c.

◆ NvmeRegisterShutdownNotification()

VOID NvmeRegisterShutdownNotification ( VOID  )

Register the shutdown notification through the ResetNotification protocol.

Register the shutdown notification when mNvmeControllerNumber increased from 0 to 1.

Definition at line 1070 of file NvmExpressHci.c.

◆ NvmeShutdownAllControllers()

VOID EFIAPI NvmeShutdownAllControllers ( IN EFI_RESET_TYPE  ResetType,
IN EFI_STATUS  ResetStatus,
IN UINTN  DataSize,
IN VOID *ResetData  OPTIONAL 
)

This routine is called to properly shutdown the Nvm Express controller per NVMe spec.

Parameters
[in]ResetTypeThe type of reset to perform.
[in]ResetStatusThe status code for the reset.
[in]DataSizeThe size, in bytes, of ResetData.
[in]ResetDataFor a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further indicate the reason for the system reset. For a ResetType of EfiResetPlatformSpecific the data buffer also starts with a Null-terminated string that is followed by an EFI_GUID that describes the specific type of reset to perform.

Definition at line 956 of file NvmExpressHci.c.

◆ NvmeUnregisterShutdownNotification()

VOID NvmeUnregisterShutdownNotification ( VOID  )

Unregister the shutdown notification through the ResetNotification protocol.

Unregister the shutdown notification when mNvmeControllerNumber decreased from 1 to 0.

Definition at line 1095 of file NvmExpressHci.c.

◆ ReadNvmeControllerCapabilities()

EFI_STATUS ReadNvmeControllerCapabilities ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_CAP Cap 
)

Read Nvm Express controller capability register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
CapThe buffer used to store capability register content.
Returns
EFI_SUCCESS Successfully read the controller capability register content.
EFI_DEVICE_ERROR Fail to read the controller capability register.

Definition at line 32 of file NvmExpressHci.c.

◆ ReadNvmeControllerConfiguration()

EFI_STATUS ReadNvmeControllerConfiguration ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_CC Cc 
)

Read Nvm Express controller configuration register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
CcThe buffer used to store configuration register content.
Returns
EFI_SUCCESS Successfully read the controller configuration register content.
EFI_DEVICE_ERROR Fail to read the controller configuration register.

Definition at line 70 of file NvmExpressHci.c.

◆ ReadNvmeControllerStatus()

EFI_STATUS ReadNvmeControllerStatus ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_CSTS Csts 
)

Read Nvm Express controller status register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
CstsThe buffer used to store status register content.
Returns
EFI_SUCCESS Successfully read the controller status register content.
EFI_DEVICE_ERROR Fail to read the controller status register.

Definition at line 154 of file NvmExpressHci.c.

◆ WriteNvmeAdminCompletionQueueBaseAddress()

EFI_STATUS WriteNvmeAdminCompletionQueueBaseAddress ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_ACQ *  Acq 
)

Write Nvm Express admin completion queue base address register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
AcqThe buffer used to store the content to be written into admin completion queue base address register.
Returns
EFI_SUCCESS Successfully write data into the admin completion queue base address register.
EFI_DEVICE_ERROR Fail to write data into the admin completion queue base address register.

Definition at line 274 of file NvmExpressHci.c.

◆ WriteNvmeAdminQueueAttributes()

EFI_STATUS WriteNvmeAdminQueueAttributes ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_AQA Aqa 
)

Write Nvm Express admin queue attributes register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
AqaThe buffer used to store the content to be written into admin queue attributes register.
Returns
EFI_SUCCESS Successfully write data into the admin queue attributes register.
EFI_DEVICE_ERROR Fail to write data into the admin queue attributes register.

Definition at line 192 of file NvmExpressHci.c.

◆ WriteNvmeAdminSubmissionQueueBaseAddress()

EFI_STATUS WriteNvmeAdminSubmissionQueueBaseAddress ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_ASQ *  Asq 
)

Write Nvm Express admin submission queue base address register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
AsqThe buffer used to store the content to be written into admin submission queue base address register.
Returns
EFI_SUCCESS Successfully write data into the admin submission queue base address register.
EFI_DEVICE_ERROR Fail to write data into the admin submission queue base address register.

Definition at line 233 of file NvmExpressHci.c.

◆ WriteNvmeControllerConfiguration()

EFI_STATUS WriteNvmeControllerConfiguration ( IN NVME_CONTROLLER_PRIVATE_DATA Private,
IN NVME_CC Cc 
)

Write Nvm Express controller configuration register.

Parameters
PrivateThe pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
CcThe buffer used to store the content to be written into configuration register.
Returns
EFI_SUCCESS Successfully write data into the controller configuration register.
EFI_DEVICE_ERROR Fail to write data into the controller configuration register.

Definition at line 108 of file NvmExpressHci.c.

Variable Documentation

◆ mNvmeControllerNumber

UINTN mNvmeControllerNumber = 0

Definition at line 19 of file NvmExpressHci.c.