TianoCore EDK2 master
Loading...
Searching...
No Matches
UfsDevConfigProtocol.c
Go to the documentation of this file.
1
9#include "UfsPassThru.h"
10
35EFIAPI
38 IN BOOLEAN Read,
39 IN UINT8 DescId,
40 IN UINT8 Index,
41 IN UINT8 Selector,
42 IN OUT UINT8 *Descriptor,
43 IN OUT UINT32 *DescSize
44 )
45{
46 EFI_STATUS Status;
48
49 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_DEV_CONFIG (This);
50
51 if ((This == NULL) || (Descriptor == NULL) || (DescSize == NULL)) {
52 return EFI_INVALID_PARAMETER;
53 }
54
55 Status = UfsRwDeviceDesc (
56 Private,
57 Read,
58 DescId,
59 Index,
60 Selector,
61 Descriptor,
62 DescSize
63 );
64 if (Status == EFI_TIMEOUT) {
65 Status = EFI_DEVICE_ERROR;
66 }
67
68 return Status;
69}
70
90EFIAPI
93 IN BOOLEAN Read,
94 IN UINT8 FlagId,
95 IN OUT UINT8 *Flag
96 )
97{
98 EFI_STATUS Status;
100
101 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_DEV_CONFIG (This);
102
103 if ((This == NULL) || (Flag == NULL)) {
104 return EFI_INVALID_PARAMETER;
105 }
106
107 Status = UfsRwFlags (Private, Read, FlagId, Flag);
108 if (Status == EFI_TIMEOUT) {
109 Status = EFI_DEVICE_ERROR;
110 }
111
112 return Status;
113}
114
139EFIAPI
142 IN BOOLEAN Read,
143 IN UINT8 AttrId,
144 IN UINT8 Index,
145 IN UINT8 Selector,
146 IN OUT UINT8 *Attribute,
147 IN OUT UINT32 *AttrSize
148 )
149{
150 EFI_STATUS Status;
152 UINT32 Attribute32;
153
154 Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_DEV_CONFIG (This);
155 Attribute32 = 0;
156
157 if ((This == NULL) || (Attribute == NULL) || (AttrSize == NULL)) {
158 return EFI_INVALID_PARAMETER;
159 }
160
161 //
162 // According to UFS Version 2.1 Spec (JESD220C) Section 14.3, the size of a attribute will not
163 // exceed 32-bit.
164 //
165 if (*AttrSize > 4) {
166 return EFI_INVALID_PARAMETER;
167 }
168
169 if (!Read) {
170 CopyMem (&Attribute32, Attribute, *AttrSize);
171 }
172
173 Status = UfsRwAttributes (
174 Private,
175 Read,
176 AttrId,
177 Index,
178 Selector,
179 &Attribute32
180 );
181 if (!EFI_ERROR (Status)) {
182 if (Read) {
183 CopyMem (Attribute, &Attribute32, *AttrSize);
184 }
185 } else {
186 *AttrSize = 0;
187 if (Status == EFI_TIMEOUT) {
188 Status = EFI_DEVICE_ERROR;
189 }
190 }
191
192 return Status;
193}
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
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)
Definition: UfsHci.c:960
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)
Definition: UfsHci.c:1014
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 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 UfsRwFlags(IN UFS_PEIM_HC_PRIVATE_DATA *Private, IN BOOLEAN Read, IN UINT8 FlagId, IN OUT UINT8 *Value)
Definition: UfsHci.c:1060