TianoCore EDK2 master
Loading...
Searching...
No Matches
UfsPassThruHci.c File Reference
#include "UfsPassThru.h"

Go to the source code of this file.

Functions

EFI_STATUS UfsMmioRead32 (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINTN Offset, OUT UINT32 *Value)
 
EFI_STATUS UfsMmioWrite32 (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINTN Offset, IN UINT32 Value)
 
EFI_STATUS UfsWaitMemSet (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINTN Offset, IN UINT32 MaskValue, IN UINT32 TestValue, IN UINT64 Timeout)
 
VOID DumpUicCmdExecResult (IN UINT8 UicOpcode, IN UINT8 Result)
 
VOID DumpQueryResponseResult (IN UINT8 Result)
 
VOID SwapLittleEndianToBigEndian (IN OUT UINT8 *Buffer, IN UINT32 BufferSize)
 
VOID UfsFillTsfOfQueryReqUpiu (IN OUT UTP_UPIU_TSF *TsfBase, IN UINT8 Opcode, IN UINT8 DescId OPTIONAL, IN UINT8 Index OPTIONAL, IN UINT8 Selector OPTIONAL, IN UINT16 Length OPTIONAL, IN UINT32 Value OPTIONAL)
 
EFI_STATUS UfsInitCommandUpiu (IN OUT UTP_COMMAND_UPIU *Command, IN UINT8 Lun, IN UINT8 TaskTag, IN UINT8 *Cdb, IN UINT8 CdbLength, IN UFS_DATA_DIRECTION DataDirection, IN UINT32 ExpDataTranLen)
 
EFI_STATUS UfsInitUtpPrdt (IN UTP_TR_PRD *Prdt, IN VOID *Buffer, IN UINT32 BufferSize)
 
EFI_STATUS UfsInitQueryRequestUpiu (IN OUT UTP_QUERY_REQ_UPIU *QueryReq, IN UINT8 TaskTag, IN UINT8 Opcode, IN UINT8 DescId, IN UINT8 Index, IN UINT8 Selector, IN UINTN DataSize OPTIONAL, IN UINT8 *Data OPTIONAL)
 
EFI_STATUS UfsCreateScsiCommandDesc (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 Lun, IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN UTP_TRD *Trd, OUT VOID **CmdDescHost, OUT VOID **CmdDescMapping)
 
EFI_STATUS UfsCreateDMCommandDesc (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet, IN UTP_TRD *Trd, OUT VOID **CmdDescHost, OUT VOID **CmdDescMapping)
 
EFI_STATUS UfsCreateNopCommandDesc (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UTP_TRD *Trd, OUT VOID **CmdDescHost, OUT VOID **CmdDescMapping)
 
EFI_STATUS UfsFindAvailableSlotInTrl (IN UFS_PASS_THRU_PRIVATE_DATA *Private, OUT UINT8 *Slot)
 
EFI_STATUS UfsStartExecCmd (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 Slot)
 
EFI_STATUS UfsStopExecCmd (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 Slot)
 
EFI_STATUS UfsGetReturnDataFromQueryResponse (IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet, IN UTP_QUERY_RESP_UPIU *QueryResp)
 
EFI_STATUS UfsSendDmRequestRetry (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet)
 
EFI_STATUS UfsSendDmRequest (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET *Packet)
 
EFI_STATUS UfsRwDeviceDesc (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN BOOLEAN Read, IN UINT8 DescId, IN UINT8 Index, IN UINT8 Selector, IN OUT VOID *Descriptor, IN OUT UINT32 *DescSize)
 
EFI_STATUS UfsRwAttributes (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN BOOLEAN Read, IN UINT8 AttrId, IN UINT8 Index, IN UINT8 Selector, IN OUT UINT32 *Attributes)
 
EFI_STATUS UfsRwFlags (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN BOOLEAN Read, IN UINT8 FlagId, IN OUT UINT8 *Value)
 
EFI_STATUS UfsSetFlag (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 FlagId)
 
EFI_STATUS UfsReadFlag (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 FlagId, OUT UINT8 *Value)
 
EFI_STATUS UfsExecNopCmds (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
VOID UfsReconcileDataTransferBuffer (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
 
EFI_STATUS UfsPrepareDataTransferBuffer (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN OUT UFS_PASS_THRU_TRANS_REQ *TransReq)
 
EFI_STATUS UfsExecScsiCmds (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 Lun, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
 
EFI_STATUS UfsExecUicCommands (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN OUT EDKII_UIC_COMMAND *UicCommand)
 
EFI_STATUS UfsAllocateAlignCommonBuffer (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINTN Size, OUT VOID **CmdDescHost, OUT EFI_PHYSICAL_ADDRESS *CmdDescPhyAddr, OUT VOID **CmdDescMapping)
 
EFI_STATUS UfsEnableHostController (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
EFI_STATUS UfsDeviceDetection (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
EFI_STATUS UfsInitTaskManagementRequestList (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
EFI_STATUS UfsInitTransferRequestList (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
EFI_STATUS UfsControllerInit (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
EFI_STATUS UfsControllerStop (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 
VOID EFIAPI SignalCallerEvent (IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
 
VOID EFIAPI ProcessAsyncTaskList (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI UfsHcDriverInterfaceExecUicCommand (IN EDKII_UFS_HC_DRIVER_INTERFACE *This, IN OUT EDKII_UIC_COMMAND *UicCommand)
 
EFI_STATUS GetUfsHcInfo (IN UFS_PASS_THRU_PRIVATE_DATA *Private)
 

Detailed Description

UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface for upper layer application to execute UFS-supported SCSI cmds.

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

Definition in file UfsPassThruHci.c.

Function Documentation

◆ DumpQueryResponseResult()

VOID DumpQueryResponseResult ( IN UINT8  Result)

Dump QUERY RESPONSE UPIU result for debugging.

Parameters
[in]ResultThe result to be parsed.

Definition at line 208 of file UfsPassThruHci.c.

◆ DumpUicCmdExecResult()

VOID DumpUicCmdExecResult ( IN UINT8  UicOpcode,
IN UINT8  Result 
)

Dump UIC command execution result for debugging.

Parameters
[in]UicOpcodeThe executed UIC opcode.
[in]ResultThe result to be parsed.

Definition at line 144 of file UfsPassThruHci.c.

◆ GetUfsHcInfo()

EFI_STATUS GetUfsHcInfo ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Initializes UfsHcInfo field in private data.

Parameters
[in]PrivatePointer to host controller private data.
Return values
EFI_SUCCESSUfsHcInfo initialized successfully.
OthersFailed to initalize UfsHcInfo.

Definition at line 2438 of file UfsPassThruHci.c.

◆ ProcessAsyncTaskList()

VOID EFIAPI ProcessAsyncTaskList ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Call back function when the timer event is signaled.

Parameters
[in]EventThe Event this notify function registered to.
[in]ContextPointer to the context data registered to the Event.

Definition at line 2279 of file UfsPassThruHci.c.

◆ SignalCallerEvent()

VOID EFIAPI SignalCallerEvent ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UFS_PASS_THRU_TRANS_REQ TransReq 
)

Internal helper function which will signal the caller event and clean up resources.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]TransReqThe pointer to the UFS_PASS_THRU_TRANS_REQ data structure.

Definition at line 2231 of file UfsPassThruHci.c.

◆ SwapLittleEndianToBigEndian()

VOID SwapLittleEndianToBigEndian ( IN OUT UINT8 *  Buffer,
IN UINT32  BufferSize 
)

Swap little endian to big endian.

Parameters
[in,out]BufferThe data buffer. In input, it contains little endian data. In output, it will become big endian.
[in]BufferSizeThe length of converted data.

Definition at line 258 of file UfsPassThruHci.c.

◆ UfsAllocateAlignCommonBuffer()

EFI_STATUS UfsAllocateAlignCommonBuffer ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINTN  Size,
OUT VOID **  CmdDescHost,
OUT EFI_PHYSICAL_ADDRESS CmdDescPhyAddr,
OUT VOID **  CmdDescMapping 
)

Allocate common buffer for host and UFS bus master access simultaneously.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]SizeThe length of buffer to be allocated.
[out]CmdDescHostA pointer to store the base system memory address of the allocated range.
[out]CmdDescPhyAddrThe resulting map address for the UFS bus master to use to access the hosts CmdDescHost.
[out]CmdDescMappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSThe common buffer was allocated successfully.
EFI_DEVICE_ERRORThe allocation fails.
EFI_OUT_OF_RESOURCESThe memory resource is insufficient.

Definition at line 1763 of file UfsPassThruHci.c.

◆ UfsControllerInit()

EFI_STATUS UfsControllerInit ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Initialize the UFS host controller.

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

Definition at line 2122 of file UfsPassThruHci.c.

◆ UfsControllerStop()

EFI_STATUS UfsControllerStop ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Stop the UFS host controller.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe Ufs Host Controller is stopped successfully.
OthersA device error occurred while stopping the controller.

Definition at line 2166 of file UfsPassThruHci.c.

◆ UfsCreateDMCommandDesc()

EFI_STATUS UfsCreateDMCommandDesc ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet,
IN UTP_TRD Trd,
OUT VOID **  CmdDescHost,
OUT VOID **  CmdDescMapping 
)

Allocate QUERY REQUEST/QUERY RESPONSE UPIU for filling UTP TRD's command descriptor field.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]PacketThe pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET data structure.
[in]TrdThe pointer to the UTP Transfer Request Descriptor.
[out]CmdDescHostA pointer to store the base system memory address of the allocated range.
[out]CmdDescMappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSThe creation succeed.
EFI_DEVICE_ERRORThe creation failed.
EFI_OUT_OF_RESOURCESThe memory resource is insufficient.
EFI_INVALID_PARAMETERThe parameter passed in is invalid.

Definition at line 573 of file UfsPassThruHci.c.

◆ UfsCreateNopCommandDesc()

EFI_STATUS UfsCreateNopCommandDesc ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UTP_TRD Trd,
OUT VOID **  CmdDescHost,
OUT VOID **  CmdDescMapping 
)

Allocate NOP IN and NOP OUT UPIU for filling UTP TRD's command descriptor field.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]TrdThe pointer to the UTP Transfer Request Descriptor.
[out]CmdDescHostA pointer to store the base system memory address of the allocated range.
[out]CmdDescMappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSThe creation succeed.
EFI_DEVICE_ERRORThe creation failed.
EFI_OUT_OF_RESOURCESThe memory resource is insufficient.

Definition at line 667 of file UfsPassThruHci.c.

◆ UfsCreateScsiCommandDesc()

EFI_STATUS UfsCreateScsiCommandDesc ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  Lun,
IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet,
IN UTP_TRD Trd,
OUT VOID **  CmdDescHost,
OUT VOID **  CmdDescMapping 
)

Allocate COMMAND/RESPONSE UPIU for filling UTP TRD's command descriptor field.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]LunThe Lun on which the SCSI command is executed.
[in]PacketThe pointer to the EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET data structure.
[in]TrdThe pointer to the UTP Transfer Request Descriptor.
[out]CmdDescHostA pointer to store the base system memory address of the allocated range.
[out]CmdDescMappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSThe creation succeed.
EFI_DEVICE_ERRORThe creation failed.
EFI_OUT_OF_RESOURCESThe memory resource is insufficient.

Definition at line 495 of file UfsPassThruHci.c.

◆ UfsDeviceDetection()

EFI_STATUS UfsDeviceDetection ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Detect if a UFS device attached.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe UFS device detection was executed successfully.
EFI_NOT_FOUNDNot found a UFS device attached.
EFI_DEVICE_ERRORA device error occurred while detecting the UFS device.

Definition at line 1931 of file UfsPassThruHci.c.

◆ UfsEnableHostController()

EFI_STATUS UfsEnableHostController ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Enable the UFS host controller for accessing.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe UFS host controller enabling was executed successfully.
EFI_DEVICE_ERRORA device error occurred while enabling the UFS host controller.

Definition at line 1850 of file UfsPassThruHci.c.

◆ UfsExecNopCmds()

EFI_STATUS UfsExecNopCmds ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Sends NOP IN cmd to a UFS device for initialization process request. For more details, please refer to UFS 2.0 spec Figure 13.3.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe NOP IN command was sent by the host. The NOP OUT response was received successfully.
EFI_DEVICE_ERRORA device error occurred while attempting to execute NOP IN command.
EFI_OUT_OF_RESOURCESThe resource for transfer is not available.
EFI_TIMEOUTA timeout occurred while waiting for the NOP IN command to execute.

Definition at line 1254 of file UfsPassThruHci.c.

◆ UfsExecScsiCmds()

EFI_STATUS UfsExecScsiCmds ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  Lun,
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet,
IN EFI_EVENT Event  OPTIONAL 
)

Sends a UFS-supported SCSI Request Packet to a UFS device that is attached to the UFS host controller.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]LunThe LUN of the UFS device to send the SCSI Request Packet.
[in,out]PacketA pointer to the SCSI Request Packet to send to a specified Lun of the UFS device.
[in]EventIf nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed. If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O is supported, then nonblocking I/O is performed, and Event will be signaled when the SCSI Request Packet completes.
Return values
EFI_SUCCESSThe SCSI Request Packet was sent by the host. For bi-directional commands, InTransferLength bytes were transferred from InDataBuffer. For write and bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.
EFI_DEVICE_ERRORA device error occurred while attempting to send the SCSI Request Packet.
EFI_OUT_OF_RESOURCESThe resource for transfer is not available.
EFI_TIMEOUTA timeout occurred while waiting for the SCSI Request Packet to execute.

Definition at line 1492 of file UfsPassThruHci.c.

◆ UfsExecUicCommands()

EFI_STATUS UfsExecUicCommands ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN OUT EDKII_UIC_COMMAND UicCommand 
)

Send UIC command.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in,out]UicCommandUIC command descriptor. On exit contains UIC command results.
Returns
EFI_SUCCESS Successfully execute this UIC command and detect attached UFS device.
EFI_DEVICE_ERROR Fail to execute this UIC command and detect attached UFS device.

Definition at line 1661 of file UfsPassThruHci.c.

◆ UfsFillTsfOfQueryReqUpiu()

VOID UfsFillTsfOfQueryReqUpiu ( IN OUT UTP_UPIU_TSF TsfBase,
IN UINT8  Opcode,
IN UINT8 DescId  OPTIONAL,
IN UINT8 Index  OPTIONAL,
IN UINT8 Selector  OPTIONAL,
IN UINT16 Length  OPTIONAL,
IN UINT32 Value  OPTIONAL 
)

Fill TSF field of QUERY REQUEST UPIU.

Parameters
[in,out]TsfBaseThe base address of TSF field of QUERY REQUEST UPIU.
[in]OpcodeThe opcode of request.
[in]DescIdThe descriptor ID of request.
[in]IndexThe index of request.
[in]SelectorThe selector of request.
[in]LengthThe length of transferred data. The maximum is 4.
[in]ValueThe value of transferred data.

Definition at line 288 of file UfsPassThruHci.c.

◆ UfsFindAvailableSlotInTrl()

EFI_STATUS UfsFindAvailableSlotInTrl ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
OUT UINT8 *  Slot 
)

Find out available slot in transfer list of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[out]SlotThe available slot.
Return values
EFI_SUCCESSThe available slot was found successfully.
EFI_NOT_READYNo slot is available at this moment.

Definition at line 718 of file UfsPassThruHci.c.

◆ UfsGetReturnDataFromQueryResponse()

EFI_STATUS UfsGetReturnDataFromQueryResponse ( IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet,
IN UTP_QUERY_RESP_UPIU QueryResp 
)

Extracts return data from query response upiu.

Parameters
[in]PacketPointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET.
[in]QueryRespPointer to the query response.
Return values
EFI_INVALID_PARAMETERPacket or QueryResp are empty or opcode is invalid.
EFI_DEVICE_ERRORData returned from device is invalid.
EFI_SUCCESSData extracted.

Definition at line 831 of file UfsPassThruHci.c.

◆ UfsHcDriverInterfaceExecUicCommand()

EFI_STATUS EFIAPI UfsHcDriverInterfaceExecUicCommand ( IN EDKII_UFS_HC_DRIVER_INTERFACE This,
IN OUT EDKII_UIC_COMMAND UicCommand 
)

Execute UIC command.

Parameters
[in]ThisPointer to driver interface produced by the UFS controller.
[in,out]UicCommandDescriptor of the command that will be executed.
Return values
EFI_SUCCESSCommand executed successfully.
EFI_INVALID_PARAMETERThis or UicCommand is NULL.
OthersCommand failed to execute.

Definition at line 2413 of file UfsPassThruHci.c.

◆ UfsInitCommandUpiu()

EFI_STATUS UfsInitCommandUpiu ( IN OUT UTP_COMMAND_UPIU Command,
IN UINT8  Lun,
IN UINT8  TaskTag,
IN UINT8 *  Cdb,
IN UINT8  CdbLength,
IN UFS_DATA_DIRECTION  DataDirection,
IN UINT32  ExpDataTranLen 
)

Initialize COMMAND UPIU.

Parameters
[in,out]CommandThe base address of COMMAND UPIU.
[in]LunThe Lun on which the SCSI command is executed.
[in]TaskTagThe task tag of request.
[in]CdbThe cdb buffer containing SCSI command.
[in]CdbLengthThe cdb length.
[in]DataDirectionThe direction of data transfer.
[in]ExpDataTranLenThe expected transfer data length.
Return values
EFI_SUCCESSThe initialization succeed.

Definition at line 334 of file UfsPassThruHci.c.

◆ UfsInitQueryRequestUpiu()

EFI_STATUS UfsInitQueryRequestUpiu ( IN OUT UTP_QUERY_REQ_UPIU QueryReq,
IN UINT8  TaskTag,
IN UINT8  Opcode,
IN UINT8  DescId,
IN UINT8  Index,
IN UINT8  Selector,
IN UINTN DataSize  OPTIONAL,
IN UINT8 *Data  OPTIONAL 
)

Initialize QUERY REQUEST UPIU.

Parameters
[in,out]QueryReqThe base address of QUERY REQUEST UPIU.
[in]TaskTagThe task tag of request.
[in]OpcodeThe opcode of request.
[in]DescIdThe descriptor ID of request.
[in]IndexThe index of request.
[in]SelectorThe selector of request.
[in]DataSizeThe data size to be read or written.
[in]DataThe buffer to be read or written.
Return values
EFI_SUCCESSThe initialization succeed.

Definition at line 440 of file UfsPassThruHci.c.

◆ UfsInitTaskManagementRequestList()

EFI_STATUS UfsInitTaskManagementRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Initialize UFS task management request list related h/w context.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe UFS task management list was initialzed successfully.
EFI_DEVICE_ERRORThe initialization fails.

Definition at line 1990 of file UfsPassThruHci.c.

◆ UfsInitTransferRequestList()

EFI_STATUS UfsInitTransferRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA Private)

Initialize UFS transfer request list related h/w context.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
Return values
EFI_SUCCESSThe UFS transfer list was initialzed successfully.
EFI_DEVICE_ERRORThe initialization fails.

Definition at line 2056 of file UfsPassThruHci.c.

◆ UfsInitUtpPrdt()

EFI_STATUS UfsInitUtpPrdt ( IN UTP_TR_PRD Prdt,
IN VOID *  Buffer,
IN UINT32  BufferSize 
)

Initialize UTP PRDT for data transfer.

Parameters
[in]PrdtThe base address of PRDT.
[in]BufferThe buffer to be read or written.
[in]BufferSizeThe data size to be read or written.
Return values
EFI_SUCCESSThe initialization succeed.

Definition at line 386 of file UfsPassThruHci.c.

◆ UfsMmioRead32()

EFI_STATUS UfsMmioRead32 ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINTN  Offset,
OUT UINT32 *  Value 
)

Read 32bits data from specified UFS MMIO register.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]OffsetThe offset within the UFS Host Controller MMIO space to start the memory operation.
[out]ValueThe data buffer to store.
Return values
EFI_TIMEOUTThe operation is time out.
EFI_SUCCESSThe operation succeeds.
OthersThe operation fails.

Definition at line 27 of file UfsPassThruHci.c.

◆ UfsMmioWrite32()

EFI_STATUS UfsMmioWrite32 ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINTN  Offset,
IN UINT32  Value 
)

Write 32bits data to specified UFS MMIO register.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]OffsetThe offset within the UFS Host Controller MMIO space to start the memory operation.
[in]ValueThe data to write.
Return values
EFI_TIMEOUTThe operation is time out.
EFI_SUCCESSThe operation succeeds.
OthersThe operation fails.

Definition at line 57 of file UfsPassThruHci.c.

◆ UfsPrepareDataTransferBuffer()

EFI_STATUS UfsPrepareDataTransferBuffer ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN OUT UFS_PASS_THRU_TRANS_REQ TransReq 
)

Prepare data buffer for transfer.

Parameters
[in]PrivatePointer to the UFS_PASS_THRU_PRIVATE_DATA
[in,out]TransReqPointer to the transfer request
Return values
EFI_DEVICE_ERRORFailed to prepare buffer for transfer
EFI_SUCCESSBuffer ready for transfer

Definition at line 1375 of file UfsPassThruHci.c.

◆ UfsReadFlag()

EFI_STATUS UfsReadFlag ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  FlagId,
OUT UINT8 *  Value 
)

Read specified flag from a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]FlagIdThe ID of flag to be read.
[out]ValueThe flag's value.
Return values
EFI_SUCCESSThe flag was read successfully.
EFI_DEVICE_ERRORA device error occurred while attempting to read the flag.
EFI_TIMEOUTA timeout occurred while waiting for the completion of reading the flag.

Definition at line 1227 of file UfsPassThruHci.c.

◆ UfsReconcileDataTransferBuffer()

VOID UfsReconcileDataTransferBuffer ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UFS_PASS_THRU_TRANS_REQ TransReq 
)

Cleanup data buffers after data transfer. This function also takes care to copy all data to user memory pool for unaligned data transfers.

Parameters
[in]PrivatePointer to the UFS_PASS_THRU_PRIVATE_DATA
[in]TransReqPointer to the transfer request

Definition at line 1333 of file UfsPassThruHci.c.

◆ UfsRwAttributes()

EFI_STATUS UfsRwAttributes ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN BOOLEAN  Read,
IN UINT8  AttrId,
IN UINT8  Index,
IN UINT8  Selector,
IN OUT UINT32 *  Attributes 
)

Read or write specified attribute of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]ReadThe boolean variable to show r/w direction.
[in]AttrIdThe ID of Attribute.
[in]IndexThe Index of Attribute.
[in]SelectorThe Selector of Attribute.
[in,out]AttributesThe value of Attribute to be read or written.
Return values
EFI_SUCCESSThe Attribute was read/written successfully.
EFI_INVALID_PARAMETERAttrId, Index and Selector are invalid combination to point to a type of UFS device descriptor.
EFI_DEVICE_ERRORA device error occurred while attempting to r/w the Attribute.
EFI_TIMEOUTA timeout occurred while waiting for the completion of r/w the Attribute.

Definition at line 1104 of file UfsPassThruHci.c.

◆ UfsRwDeviceDesc()

EFI_STATUS UfsRwDeviceDesc ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN BOOLEAN  Read,
IN UINT8  DescId,
IN UINT8  Index,
IN UINT8  Selector,
IN OUT VOID *  Descriptor,
IN OUT UINT32 *  DescSize 
)

Read or write specified device descriptor of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]ReadThe boolean variable to show r/w direction.
[in]DescIdThe ID of device descriptor.
[in]IndexThe Index of device descriptor.
[in]SelectorThe Selector of device descriptor.
[in,out]DescriptorThe buffer of device descriptor to be read or written.
[in,out]DescSizeThe size of device descriptor buffer. On input, the size, in bytes, of the data buffer specified by Descriptor. On output, the number of bytes that were actually transferred.
Return values
EFI_SUCCESSThe device descriptor was read/written successfully.
EFI_INVALID_PARAMETERDescId, Index and Selector are invalid combination to point to a type of UFS device descriptor.
EFI_DEVICE_ERRORA device error occurred while attempting to r/w the device descriptor.
EFI_TIMEOUTA timeout occurred while waiting for the completion of r/w the device descriptor.

Definition at line 1042 of file UfsPassThruHci.c.

◆ UfsRwFlags()

EFI_STATUS UfsRwFlags ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN BOOLEAN  Read,
IN UINT8  FlagId,
IN OUT UINT8 *  Value 
)

Read or write specified flag of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]ReadThe boolean variable to show r/w direction.
[in]FlagIdThe ID of flag to be read or written.
[in,out]ValueThe value to set or clear flag.
Return values
EFI_SUCCESSThe flag was read/written successfully.
EFI_INVALID_PARAMETERFlagId is an invalid UFS flag ID.
EFI_DEVICE_ERRORA device error occurred while attempting to r/w the flag.
EFI_TIMEOUTA timeout occurred while waiting for the completion of r/w the flag.

Definition at line 1149 of file UfsPassThruHci.c.

◆ UfsSendDmRequest()

EFI_STATUS UfsSendDmRequest ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet 
)

Sends Query Request to the device. Query is sent until device responds correctly or counter runs out.

Parameters
[in]PrivatePointer to the UFS_PASS_THRU_PRIVATE_DATA.
[in]PacketPointer to the UFS_DEVICE_MANAGEMENT_PACKET.
Return values
EFI_SUCCESSThe device responded correctly to the Query request.
EFI_INVALID_PARAMETERThe DescId, Index and Selector fields in Packet are invalid combination to point to a type of UFS device descriptor.
EFI_DEVICE_ERRORA device error occurred while waiting for the response from the device.
EFI_TIMEOUTA timeout occurred while waiting for the completion of the operation.

Definition at line 1000 of file UfsPassThruHci.c.

◆ UfsSendDmRequestRetry()

EFI_STATUS UfsSendDmRequestRetry ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet 
)

Creates Transfer Request descriptor and sends Query Request to the device.

Parameters
[in]PrivatePointer to the UFS_PASS_THRU_PRIVATE_DATA.
[in]PacketPointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET.
Return values
EFI_SUCCESSThe device descriptor was read/written successfully.
EFI_INVALID_PARAMETERThe DescId, Index and Selector fields in Packet are invalid combination to point to a type of UFS device descriptor.
EFI_DEVICE_ERRORA device error occurred while attempting to r/w the device descriptor.
EFI_TIMEOUTA timeout occurred while waiting for the completion of r/w the device descriptor.

Definition at line 898 of file UfsPassThruHci.c.

◆ UfsSetFlag()

EFI_STATUS UfsSetFlag ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  FlagId 
)

Set specified flag to 1 on a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]FlagIdThe ID of flag to be set.
Return values
EFI_SUCCESSThe flag was set successfully.
EFI_DEVICE_ERRORA device error occurred while attempting to set the flag.
EFI_TIMEOUTA timeout occurred while waiting for the completion of setting the flag.

Definition at line 1200 of file UfsPassThruHci.c.

◆ UfsStartExecCmd()

EFI_STATUS UfsStartExecCmd ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  Slot 
)

Start specified slot in transfer list of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]SlotThe slot to be started.

Definition at line 755 of file UfsPassThruHci.c.

◆ UfsStopExecCmd()

EFI_STATUS UfsStopExecCmd ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINT8  Slot 
)

Stop specified slot in transfer list of a UFS device.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]SlotThe slot to be stop.

Definition at line 791 of file UfsPassThruHci.c.

◆ UfsWaitMemSet()

EFI_STATUS UfsWaitMemSet ( IN UFS_PASS_THRU_PRIVATE_DATA Private,
IN UINTN  Offset,
IN UINT32  MaskValue,
IN UINT32  TestValue,
IN UINT64  Timeout 
)

Wait for the value of the specified system memory set to the test value.

Parameters
[in]PrivateThe pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
[in]OffsetThe offset within the UFS Host Controller MMIO space to start the memory operation.
[in]MaskValueThe mask value of memory.
[in]TestValueThe test value of memory.
[in]TimeoutThe time out value for wait memory set, uses 100ns as a unit.
Return values
EFI_TIMEOUTThe system memory setting is time out.
EFI_SUCCESSThe system memory is correct set.
OthersThe operation fails.

Definition at line 89 of file UfsPassThruHci.c.