TianoCore EDK2 master
|
#include "UfsBlockIoPei.h"
Go to the source code of this file.
Copyright (c) 2014 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file UfsHci.c.
VOID DumpQueryResponseResult | ( | IN UINT8 | Result | ) |
EFI_STATUS UfsControllerInit | ( | IN EDKII_UFS_HC_PLATFORM_PPI * | UfsHcPlatformPpi, |
IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ||
) |
Initialize the UFS host controller.
[in] | UfsHcPlatformPpi | The pointer to the EDKII_UFS_HC_PLATFORM_PPI data structure. // APTIOV_OVERRIDE |
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
EFI_SUCCESS | The Ufs Host Controller is initialized successfully. |
Others | A device error occurred while initializing the controller. |
EFI_STATUS UfsControllerStop | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ) |
EFI_STATUS UfsCreateDMCommandDesc | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UFS_DEVICE_MANAGEMENT_REQUEST_PACKET * | Packet, | ||
IN UTP_TRD * | Trd | ||
) |
Allocate QUERY REQUEST/QUERY RESPONSE UPIU for filling UTP TRD's command descriptor field.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Packet | The pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET data structure. |
[in] | Trd | The pointer to the UTP Transfer Request Descriptor. |
EFI_SUCCESS | The creation succeed. |
EFI_DEVICE_ERROR | The creation failed. |
EFI_OUT_OF_RESOURCES | The memory resource is insufficient. |
EFI_INVALID_PARAMETER | The parameter passed in is invalid. |
EFI_STATUS UfsCreateNopCommandDesc | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UTP_TRD * | Trd | ||
) |
Allocate NOP IN and NOP OUT UPIU for filling UTP TRD's command descriptor field.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Trd | The pointer to the UTP Transfer Request Descriptor. |
EFI_SUCCESS | The creation succeed. |
EFI_DEVICE_ERROR | The creation failed. |
EFI_OUT_OF_RESOURCES | The memory resource is insufficient. |
EFI_STATUS UfsCreateScsiCommandDesc | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | Lun, | ||
IN UFS_SCSI_REQUEST_PACKET * | Packet, | ||
IN UTP_TRD * | Trd, | ||
OUT VOID ** | BufferMap | ||
) |
Allocate COMMAND/RESPONSE UPIU for filling UTP TRD's command descriptor field.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Lun | The Lun on which the SCSI command is executed. |
[in] | Packet | The pointer to the UFS_SCSI_REQUEST_PACKET data structure. |
[in] | Trd | The pointer to the UTP Transfer Request Descriptor. |
[out] | BufferMap | A resulting value, if not NULL, to pass to IoMmuUnmap(). |
EFI_SUCCESS | The creation succeed. |
EFI_DEVICE_ERROR | The creation failed. |
EFI_OUT_OF_RESOURCES | The memory resource is insufficient. |
EFI_STATUS UfsDeviceDetection | ( | IN EDKII_UFS_HC_PLATFORM_PPI * | UfsHcPlatformPpi, |
IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ||
) |
Detect if a UFS device attached.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
EFI_SUCCESS | The UFS device detection was executed successfully. |
EFI_NOT_FOUND | Not found a UFS device attached. |
EFI_DEVICE_ERROR | A device error occurred while detecting the UFS device. |
EFI_STATUS UfsEnableHostController | ( | IN EDKII_UFS_HC_PLATFORM_PPI * | UfsHcPlatformPpi, |
IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ||
) |
Enable the UFS host controller for accessing.
[in] | UfsHcPlatformPpi | The pointer to the EDKII_UFS_HC_PLATFORM_PPI data structure |
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
EFI_SUCCESS | The UFS host controller enabling was executed successfully. |
EFI_DEVICE_ERROR | A device error occurred while enabling the UFS host controller. |
EFI_STATUS UfsExecNopCmds | ( | IN UFS_PEIM_HC_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.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
EFI_SUCCESS | The NOP IN command was sent by the host. The NOP OUT response was received successfully. |
EFI_DEVICE_ERROR | A device error occurred while attempting to execute NOP IN command. |
EFI_OUT_OF_RESOURCES | The resource for transfer is not available. |
EFI_TIMEOUT | A timeout occurred while waiting for the NOP IN command to execute. |
EFI_STATUS UfsExecScsiCmds | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | Lun, | ||
IN OUT UFS_SCSI_REQUEST_PACKET * | Packet | ||
) |
Sends a UFS-supported SCSI Request Packet to a UFS device that is attached to the UFS host controller.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Lun | The LUN of the UFS device to send the SCSI Request Packet. |
[in,out] | Packet | A pointer to the SCSI Request Packet to send to a specified Lun of the UFS device. |
EFI_SUCCESS | The 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_ERROR | A device error occurred while attempting to send the SCSI Request Packet. |
EFI_OUT_OF_RESOURCES | The resource for transfer is not available. |
EFI_TIMEOUT | A timeout occurred while waiting for the SCSI Request Packet to execute. |
EFI_STATUS UfsExecUicCommands | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | UicOpcode, | ||
IN UINT32 | Arg1, | ||
IN UINT32 | Arg2, | ||
IN UINT32 | Arg3 | ||
) |
Sent UIC DME_LINKSTARTUP command to start the link startup procedure.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | UicOpcode | The opcode of the UIC command. |
[in] | Arg1 | The value for 1st argument of the UIC command. |
[in] | Arg2 | The value for 2nd argument of the UIC command. |
[in] | Arg3 | The value for 3rd argument of the UIC command. |
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.
[in,out] | TsfBase | The base address of TSF field of QUERY REQUEST UPIU. |
[in] | Opcode | The opcode of request. |
[in] | DescId | The descriptor ID of request. |
[in] | Index | The index of request. |
[in] | Selector | The selector of request. |
[in] | Length | The length of transferred data. The maximum is 4. |
[in] | Value | The value of transferred data. |
EFI_STATUS UfsFindAvailableSlotInTrl | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
OUT UINT8 * | Slot | ||
) |
EFI_STATUS UfsGetReturnDataFromQueryResponse | ( | IN OUT UFS_DEVICE_MANAGEMENT_REQUEST_PACKET * | Packet, |
IN UTP_QUERY_RESP_UPIU * | QueryResp | ||
) |
Extracts return data from query response upiu.
[in,out] | Packet | Pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET. |
[in] | QueryResp | Pointer to the query response. |
EFI_INVALID_PARAMETER | Packet or QueryResp are empty or opcode is invalid. |
EFI_DEVICE_ERROR | Data returned from device is invalid. |
EFI_SUCCESS | Data extracted. |
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.
[in,out] | Command | The base address of COMMAND UPIU. |
[in] | Lun | The Lun on which the SCSI command is executed. |
[in] | TaskTag | The task tag of request. |
[in] | Cdb | The cdb buffer containing SCSI command. |
[in] | CdbLength | The cdb length. |
[in] | DataDirection | The direction of data transfer. |
[in] | ExpDataTranLen | The expected transfer data length. |
EFI_SUCCESS | The initialization succeed. |
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.
[in,out] | QueryReq | The base address of QUERY REQUEST UPIU. |
[in] | TaskTag | The task tag of request. |
[in] | Opcode | The opcode of request. |
[in] | DescId | The descriptor ID of request. |
[in] | Index | The index of request. |
[in] | Selector | The selector of request. |
[in] | DataSize | The data size to be read or written. |
[in] | Data | The buffer to be read or written. |
EFI_SUCCESS | The initialization succeed. |
EFI_STATUS UfsInitTaskManagementRequestList | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ) |
Initialize UFS task management request list related h/w context.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
EFI_SUCCESS | The UFS task management list was initialzed successfully. |
EFI_DEVICE_ERROR | The initialization fails. |
EFI_STATUS UfsInitTransferRequestList | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private | ) |
EFI_STATUS UfsInitUtpPrdt | ( | IN UTP_TR_PRD * | Prdt, |
IN VOID * | Buffer, | ||
IN UINT32 | BufferSize | ||
) |
EFI_STATUS UfsReadFlag | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | FlagId, | ||
OUT UINT8 * | Value | ||
) |
Read specified flag from a UFS device.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | FlagId | The ID of flag to be read. |
[out] | Value | The flag's value. |
EFI_SUCCESS | The flag was read successfully. |
EFI_DEVICE_ERROR | A device error occurred while attempting to read the flag. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of reading the flag. |
EFI_STATUS UfsRwAttributes | ( | IN UFS_PEIM_HC_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.
[in] | Private | The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure. |
[in] | Read | The boolean variable to show r/w direction. |
[in] | AttrId | The ID of Attribute. |
[in] | Index | The Index of Attribute. |
[in] | Selector | The Selector of Attribute. |
[in,out] | Attributes | The value of Attribute to be read or written. |
EFI_SUCCESS | The Attribute was read/written successfully. |
EFI_INVALID_PARAMETER | AttrId, Index and Selector are invalid combination to point to a type of UFS device descriptor. |
EFI_DEVICE_ERROR | A device error occurred while attempting to r/w the Attribute. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of r/w the Attribute. |
EFI_STATUS UfsRwDeviceDesc | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN BOOLEAN | Read, | ||
IN UINT8 | DescId, | ||
IN UINT8 | Index, | ||
IN UINT8 | Selector, | ||
IN OUT VOID * | Descriptor, | ||
IN UINT32 | DescSize | ||
) |
Read or write specified device descriptor of a UFS device.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Read | The boolean variable to show r/w direction. |
[in] | DescId | The ID of device descriptor. |
[in] | Index | The Index of device descriptor. |
[in] | Selector | The Selector of device descriptor. |
[in,out] | Descriptor | The buffer of device descriptor to be read or written. |
[in] | DescSize | The size of device descriptor buffer. |
EFI_SUCCESS | The device descriptor was read/written successfully. |
EFI_DEVICE_ERROR | A device error occurred while attempting to r/w the device descriptor. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of r/w the device descriptor. |
EFI_STATUS UfsRwFlags | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN BOOLEAN | Read, | ||
IN UINT8 | FlagId, | ||
IN OUT UINT8 * | Value | ||
) |
Read or write specified flag of a UFS device.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | Read | The boolean variable to show r/w direction. |
[in] | FlagId | The ID of flag to be read or written. |
[in,out] | Value | The value to set or clear flag. |
EFI_SUCCESS | The flag was read/written successfully. |
EFI_DEVICE_ERROR | A device error occurred while attempting to r/w the flag. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of r/w the flag. |
EFI_STATUS UfsSendDmRequest | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN OUT UFS_DEVICE_MANAGEMENT_REQUEST_PACKET * | Packet | ||
) |
Sends Query Request to the device. Query is sent until device responds correctly or counter runs out.
[in] | Private | Pointer to the UFS_PEIM_HC_PRIVATE_DATA. |
[in,out] | Packet | Pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET. |
EFI_SUCCESS | The device responded correctly to the Query request. |
EFI_INVALID_PARAMETER | The DescId, Index and Selector fields in Packet are invalid combination to point to a type of UFS device descriptor. |
EFI_DEVICE_ERROR | A device error occurred while waiting for the response from the device. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of the operation. |
EFI_STATUS UfsSendDmRequestRetry | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN OUT UFS_DEVICE_MANAGEMENT_REQUEST_PACKET * | Packet | ||
) |
Creates Transfer Request descriptor and sends Query Request to the device.
[in] | Private | Pointer to the UFS_PEIM_HC_PRIVATE_DATA. |
[in,out] | Packet | Pointer to the UFS_DEVICE_MANAGEMENT_REQUEST_PACKET. |
EFI_SUCCESS | The device descriptor was read/written successfully. |
EFI_INVALID_PARAMETER | The DescId, Index and Selector fields in Packet are invalid combination to point to a type of UFS device descriptor. |
EFI_DEVICE_ERROR | A device error occurred while attempting to r/w the device descriptor. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of r/w the device descriptor. |
EFI_STATUS UfsSetFlag | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | FlagId | ||
) |
Set specified flag to 1 on a UFS device.
[in] | Private | The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure. |
[in] | FlagId | The ID of flag to be set. |
EFI_SUCCESS | The flag was set successfully. |
EFI_DEVICE_ERROR | A device error occurred while attempting to set the flag. |
EFI_TIMEOUT | A timeout occurred while waiting for the completion of setting the flag. |
VOID UfsStartExecCmd | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | Slot | ||
) |
VOID UfsStopExecCmd | ( | IN UFS_PEIM_HC_PRIVATE_DATA * | Private, |
IN UINT8 | Slot | ||
) |
EFI_STATUS EFIAPI UfsWaitMemSet | ( | IN UINTN | Address, |
IN UINT32 | MaskValue, | ||
IN UINT32 | TestValue, | ||
IN UINT64 | Timeout | ||
) |
Wait for the value of the specified system memory set to the test value.
Address | The system memory address to test. |
MaskValue | The mask value of memory. |
TestValue | The test value of memory. |
Timeout | The time out value for wait memory set, uses 100ns as a unit. |
EFI_TIMEOUT | The system memory setting is time out. |
EFI_SUCCESS | The system memory is correct set. |