MdeModulePkg/UfsPassThruDxe: Add impl of UFS Device Config Protocol

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Hao Wu
2017-06-19 10:53:34 +08:00
parent 59d3fad32e
commit 32c9049de1
5 changed files with 383 additions and 14 deletions

View File

@@ -17,6 +17,7 @@
#include <Uefi.h>
#include <Protocol/ScsiPassThruExt.h>
#include <Protocol/UfsDeviceConfig.h>
#include <Protocol/UfsHostController.h>
#include <Library/DebugLib.h>
@@ -63,6 +64,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA {
EFI_HANDLE Handle;
EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
EFI_UFS_DEVICE_CONFIG_PROTOCOL UfsDevConfig;
EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;
UINTN UfsHcBase;
UINT32 Capabilities;
@@ -120,6 +122,13 @@ typedef struct {
UFS_PASS_THRU_SIG \
)
#define UFS_PASS_THRU_PRIVATE_DATA_FROM_DEV_CONFIG(a) \
CR (a, \
UFS_PASS_THRU_PRIVATE_DATA, \
UfsDevConfig, \
UFS_PASS_THRU_SIG \
)
typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {
UINT64 Timeout;
VOID *DataBuffer;
@@ -732,6 +741,27 @@ UfsReadFlag (
OUT UINT8 *Value
);
/**
Read or write specified flag of a UFS device.
@param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
@param[in] Read The boolean variable to show r/w direction.
@param[in] FlagId The ID of flag to be read or written.
@param[in, out] Value The value to set or clear flag.
@retval EFI_SUCCESS The flag was read/written successfully.
@retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the flag.
@retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the flag.
**/
EFI_STATUS
UfsRwFlags (
IN UFS_PASS_THRU_PRIVATE_DATA *Private,
IN BOOLEAN Read,
IN UINT8 FlagId,
IN OUT UINT8 *Value
);
/**
Read or write specified device descriptor of a UFS device.
@@ -741,7 +771,9 @@ UfsReadFlag (
@param[in] Index The Index of device descriptor.
@param[in] Selector The Selector of device descriptor.
@param[in, out] Descriptor The buffer of device descriptor to be read or written.
@param[in] DescSize The size of device descriptor buffer.
@param[in, out] DescSize The 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.
@retval EFI_SUCCESS The device descriptor was read/written successfully.
@retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.
@@ -756,7 +788,7 @@ UfsRwDeviceDesc (
IN UINT8 Index,
IN UINT8 Selector,
IN OUT VOID *Descriptor,
IN UINT32 DescSize
IN OUT UINT32 *DescSize
);
/**
@@ -833,6 +865,103 @@ SignalCallerEvent (
IN UFS_PASS_THRU_TRANS_REQ *TransReq
);
/**
Read or write specified device descriptor of a UFS device.
The function is used to read/write UFS device descriptors. The consumer of this API is
responsible for allocating the data buffer pointed by Descriptor.
@param[in] This The pointer to the EFI_UFS_DEVICE_CONFIG_PROTOCOL instance.
@param[in] Read The boolean variable to show r/w direction.
@param[in] DescId The ID of device descriptor.
@param[in] Index The Index of device descriptor.
@param[in] Selector The Selector of device descriptor.
@param[in, out] Descriptor The buffer of device descriptor to be read or written.
@param[in, out] DescSize The 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.
@retval EFI_SUCCESS The device descriptor is read/written successfully.
@retval EFI_INVALID_PARAMETER This is NULL or Descriptor is NULL or DescSize is NULL.
DescId, Index and Selector are invalid combination to point to a
type of UFS device descriptor.
@retval EFI_DEVICE_ERROR The device descriptor is not read/written successfully.
**/
EFI_STATUS
EFIAPI
UfsRwUfsDescriptor (
IN EFI_UFS_DEVICE_CONFIG_PROTOCOL *This,
IN BOOLEAN Read,
IN UINT8 DescId,
IN UINT8 Index,
IN UINT8 Selector,
IN OUT UINT8 *Descriptor,
IN OUT UINT32 *DescSize
);
/**
Read or write specified flag of a UFS device.
The function is used to read/write UFS flag descriptors. The consumer of this API is responsible
for allocating the buffer pointed by Flag. The buffer size is 1 byte as UFS flag descriptor is
just a single Boolean value that represents a TRUE or FALSE, '0' or '1', ON or OFF type of value.
@param[in] This The pointer to the EFI_UFS_DEVICE_CONFIG_PROTOCOL instance.
@param[in] Read The boolean variable to show r/w direction.
@param[in] FlagId The ID of flag to be read or written.
@param[in, out] Flag The buffer to set or clear flag.
@retval EFI_SUCCESS The flag descriptor is set/clear successfully.
@retval EFI_INVALID_PARAMETER This is NULL or Flag is NULL.
FlagId is an invalid UFS flag ID.
@retval EFI_DEVICE_ERROR The flag is not set/clear successfully.
**/
EFI_STATUS
EFIAPI
UfsRwUfsFlag (
IN EFI_UFS_DEVICE_CONFIG_PROTOCOL *This,
IN BOOLEAN Read,
IN UINT8 FlagId,
IN OUT UINT8 *Flag
);
/**
Read or write specified attribute of a UFS device.
The function is used to read/write UFS attributes. The consumer of this API is responsible for
allocating the data buffer pointed by Attribute.
@param[in] This The pointer to the EFI_UFS_DEVICE_CONFIG_PROTOCOL instance.
@param[in] Read The boolean variable to show r/w direction.
@param[in] AttrId The ID of Attribute.
@param[in] Index The Index of Attribute.
@param[in] Selector The Selector of Attribute.
@param[in, out] Attribute The buffer of Attribute to be read or written.
@param[in, out] AttrSize The size of Attribute buffer. On input, the size, in bytes, of the
data buffer specified by Attribute. On output, the number of bytes
that were actually transferred.
@retval EFI_SUCCESS The attribute is read/written successfully.
@retval EFI_INVALID_PARAMETER This is NULL or Attribute is NULL or AttrSize is NULL.
AttrId, Index and Selector are invalid combination to point to a
type of UFS attribute.
@retval EFI_DEVICE_ERROR The attribute is not read/written successfully.
**/
EFI_STATUS
EFIAPI
UfsRwUfsAttribute (
IN EFI_UFS_DEVICE_CONFIG_PROTOCOL *This,
IN BOOLEAN Read,
IN UINT8 AttrId,
IN UINT8 Index,
IN UINT8 Selector,
IN OUT UINT8 *Attribute,
IN OUT UINT32 *AttrSize
);
extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;