TianoCore EDK2 master
Loading...
Searching...
No Matches
UfsPassThru.h
Go to the documentation of this file.
1
9#ifndef _UFS_PASS_THRU_H_
10#define _UFS_PASS_THRU_H_
11
12#include <Uefi.h>
13
18
19#include <Library/DebugLib.h>
21#include <Library/BaseLib.h>
22#include <Library/UefiLib.h>
27#include <Library/PcdLib.h>
28#include <Library/TimerLib.h>
29
30#include "UfsPassThruHci.h"
31
32#define UFS_PASS_THRU_SIG SIGNATURE_32 ('U', 'F', 'S', 'P')
33
34//
35// Lun 0~7 is for 8 common luns.
36// Lun 8~11 is for those 4 well known luns (Refer to UFS 2.0 spec Table 10.58 for details):
37// Lun 8: REPORT LUNS
38// Lun 9: UFS DEVICE
39// Lun 10: BOOT
40// Lun 11: RPMB
41//
42#define UFS_MAX_LUNS 12
43#define UFS_WLUN_PREFIX 0xC1
44
45typedef struct {
46 UINT8 Lun[UFS_MAX_LUNS];
47 UINT16 BitMask : 12; // Bit 0~7 is 1/1 mapping to common luns. Bit 8~11 is 1/1 mapping to well-known luns.
48 UINT16 Rsvd : 4;
50
52 UINT32 Signature;
53 EFI_HANDLE Handle;
54 EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
55 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
57 EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;
58 UINTN UfsHcBase;
59 EDKII_UFS_HC_INFO UfsHcInfo;
60 EDKII_UFS_HC_DRIVER_INTERFACE UfsHcDriverInterface;
61
62 UINT8 TaskTag;
63
64 VOID *UtpTrlBase;
65 UINT8 Nutrs;
66 VOID *TrlMapping;
67 VOID *UtpTmrlBase;
68 UINT8 Nutmrs;
69 VOID *TmrlMapping;
70
72
73 //
74 // For Non-blocking operation.
75 //
76 EFI_EVENT TimerEvent;
77 LIST_ENTRY Queue;
79
80#define UFS_PASS_THRU_TRANS_REQ_SIG SIGNATURE_32 ('U', 'F', 'S', 'T')
81
82typedef struct {
83 UINT32 Signature;
84 LIST_ENTRY TransferList;
85
86 UINT8 Slot;
87 UTP_TRD *Trd;
88 UINT32 CmdDescSize;
89 VOID *CmdDescHost;
90 VOID *CmdDescMapping;
91 VOID *AlignedDataBuf;
92 UINTN AlignedDataBufSize;
93 VOID *DataBufMapping;
94
96 UINT64 TimeoutRemain;
97 EFI_EVENT CallerEvent;
99
100#define UFS_PASS_THRU_TRANS_REQ_FROM_THIS(a) \
101 CR(a, UFS_PASS_THRU_TRANS_REQ, TransferList, UFS_PASS_THRU_TRANS_REQ_SIG)
102
103#define UFS_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
104#define UFS_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS(1)
105
106#define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)
107
108#define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
109 CR (a, \
110 UFS_PASS_THRU_PRIVATE_DATA, \
111 ExtScsiPassThru, \
112 UFS_PASS_THRU_SIG \
113 )
114
115#define UFS_PASS_THRU_PRIVATE_DATA_FROM_DEV_CONFIG(a) \
116 CR (a, \
117 UFS_PASS_THRU_PRIVATE_DATA, \
118 UfsDevConfig, \
119 UFS_PASS_THRU_SIG \
120 )
121
122#define UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF(a) \
123 CR (a, \
124 UFS_PASS_THRU_PRIVATE_DATA, \
125 UfsHcDriverInterface, \
126 UFS_PASS_THRU_SIG \
127 )
128
130 UINT64 Timeout;
131 VOID *DataBuffer;
132 UINT8 Opcode;
133 UINT8 DescId;
134 UINT8 Index;
135 UINT8 Selector;
136 UINT32 TransferLength;
137 UINT8 DataDirection;
139
140//
141// function prototype
142//
143
187EFIAPI
190 IN EFI_HANDLE Controller,
191 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
192 );
193
230EFIAPI
233 IN EFI_HANDLE Controller,
234 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
235 );
236
264EFIAPI
267 IN EFI_HANDLE Controller,
268 IN UINTN NumberOfChildren,
269 IN EFI_HANDLE *ChildHandleBuffer
270 );
271
272//
273// EFI Component Name Functions
274//
275
316EFIAPI
319 IN CHAR8 *Language,
320 OUT CHAR16 **DriverName
321 );
322
392EFIAPI
395 IN EFI_HANDLE ControllerHandle,
396 IN EFI_HANDLE ChildHandle OPTIONAL,
397 IN CHAR8 *Language,
398 OUT CHAR16 **ControllerName
399 );
400
443EFIAPI
446 IN UINT8 *Target,
447 IN UINT64 Lun,
449 IN EFI_EVENT Event OPTIONAL
450 );
451
479EFIAPI
482 IN OUT UINT8 **Target,
483 IN OUT UINT64 *Lun
484 );
485
514EFIAPI
517 IN UINT8 *Target,
518 IN UINT64 Lun,
519 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
520 );
521
542EFIAPI
545 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
546 OUT UINT8 **Target,
547 OUT UINT64 *Lun
548 );
549
562EFIAPI
565 );
566
587EFIAPI
590 IN UINT8 *Target,
591 IN UINT64 Lun
592 );
593
617EFIAPI
620 IN OUT UINT8 **Target
621 );
622
650 IN UINT8 Lun,
652 IN EFI_EVENT Event OPTIONAL
653 );
654
667 );
668
681 );
682
700 IN UINTN Size,
701 OUT VOID **CmdDescHost,
702 OUT EFI_PHYSICAL_ADDRESS *CmdDescPhyAddr,
703 OUT VOID **CmdDescMapping
704 );
705
720 IN UINT8 FlagId
721 );
722
738 IN UINT8 FlagId,
739 OUT UINT8 *Value
740 );
741
758 IN BOOLEAN Read,
759 IN UINT8 FlagId,
760 IN OUT UINT8 *Value
761 );
762
784 IN BOOLEAN Read,
785 IN UINT8 DescId,
786 IN UINT8 Index,
787 IN UINT8 Selector,
788 IN OUT VOID *Descriptor,
789 IN OUT UINT32 *DescSize
790 );
791
810 IN BOOLEAN Read,
811 IN UINT8 AttrId,
812 IN UINT8 Index,
813 IN UINT8 Selector,
814 IN OUT UINT32 *Attributes
815 );
816
833 );
834
842VOID
843EFIAPI
845 IN EFI_EVENT Event,
846 IN VOID *Context
847 );
848
859VOID
860EFIAPI
864 );
865
890EFIAPI
893 IN BOOLEAN Read,
894 IN UINT8 DescId,
895 IN UINT8 Index,
896 IN UINT8 Selector,
897 IN OUT UINT8 *Descriptor,
898 IN OUT UINT32 *DescSize
899 );
900
920EFIAPI
923 IN BOOLEAN Read,
924 IN UINT8 FlagId,
925 IN OUT UINT8 *Flag
926 );
927
952EFIAPI
955 IN BOOLEAN Read,
956 IN UINT8 AttrId,
957 IN UINT8 Index,
958 IN UINT8 Selector,
959 IN OUT UINT8 *Attribute,
960 IN OUT UINT32 *AttrSize
961 );
962
974EFIAPI
977 IN OUT EDKII_UIC_COMMAND *UicCommand
978 );
979
991 );
992
993extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;
994extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;
995extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;
996extern EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform;
997
998#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_STATUS EFIAPI UfsPassThruGetNextTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
Definition: UfsPassThru.c:254
EFI_STATUS EFIAPI UfsPassThruResetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun)
Definition: UfsPassThru.c:576
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 EFIAPI UfsPassThruPassThru(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
Definition: UfsPassThru.c:142
EFI_STATUS EFIAPI UfsPassThruBuildDevicePath(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
Definition: UfsPassThru.c:384
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)
EFI_STATUS EFIAPI UfsPassThruComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: ComponentName.c:90
EFI_STATUS EFIAPI UfsPassThruGetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT8 **Target, OUT UINT64 *Lun)
Definition: UfsPassThru.c:462
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 EFIAPI UfsPassThruComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
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 GetUfsHcInfo(IN UFS_PASS_THRU_PRIVATE_DATA *Private)
EFI_STATUS UfsExecNopCmds(IN UFS_PASS_THRU_PRIVATE_DATA *Private)
EFI_STATUS EFIAPI UfsHcDriverInterfaceExecUicCommand(IN EDKII_UFS_HC_DRIVER_INTERFACE *This, IN OUT EDKII_UIC_COMMAND *UicCommand)
EFI_STATUS UfsRwFlags(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN BOOLEAN Read, IN UINT8 FlagId, IN OUT UINT8 *Value)
EFI_STATUS UfsReadFlag(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 FlagId, OUT UINT8 *Value)
EFI_STATUS EFIAPI UfsPassThruGetNextTarget(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target)
Definition: UfsPassThru.c:612
EFI_STATUS EFIAPI UfsPassThruDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UfsPassThru.c:828
VOID EFIAPI SignalCallerEvent(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
EFI_STATUS EFIAPI UfsPassThruResetChannel(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This)
Definition: UfsPassThru.c:545
EFI_STATUS EFIAPI UfsPassThruDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UfsPassThru.c:1117
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)
VOID EFIAPI ProcessAsyncTaskList(IN EFI_EVENT Event, IN VOID *Context)
Definition: NvmExpress.c:567
EFI_STATUS EFIAPI UfsPassThruDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UfsPassThru.c:674
EFI_STATUS UfsControllerStop(IN UFS_PASS_THRU_PRIVATE_DATA *Private)
EFI_STATUS EFIAPI UfsRwUfsFlag(IN EFI_UFS_DEVICE_CONFIG_PROTOCOL *This, IN BOOLEAN Read, IN UINT8 FlagId, IN OUT UINT8 *Flag)
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)
EFI_STATUS UfsControllerInit(IN UFS_PASS_THRU_PRIVATE_DATA *Private)
EFI_STATUS UfsSetFlag(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UINT8 FlagId)