diff options
Diffstat (limited to 'MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c')
-rw-r--r-- | MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c | 388 |
1 files changed, 202 insertions, 186 deletions
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c index 0633f8197f..d37367823d 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c @@ -8,31 +8,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatVarCleanup.h"
-VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR;
-EDKII_VAR_CHECK_PROTOCOL *mVarCheck = NULL;
+VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR;
+EDKII_VAR_CHECK_PROTOCOL *mVarCheck = NULL;
///
/// The flag to indicate whether the platform has left the DXE phase of execution.
///
-BOOLEAN mEndOfDxe = FALSE;
+BOOLEAN mEndOfDxe = FALSE;
-EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL;
+EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL;
-LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
-UINT16 mUserVariableCount = 0;
-UINT16 mMarkedUserVariableCount = 0;
+LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
+UINT16 mUserVariableCount = 0;
+UINT16 mMarkedUserVariableCount = 0;
-EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID;
-CHAR16 mVarStoreName[] = L"VariableCleanup";
+EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID;
+CHAR16 mVarStoreName[] = L"VariableCleanup";
-HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = {
+HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
VARIABLE_CLEANUP_HII_GUID
@@ -41,8 +41,8 @@ HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = { END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) ((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
+ (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
}
}
};
@@ -58,11 +58,11 @@ InternalGetVarErrorFlag ( VOID
)
{
- EFI_STATUS Status;
- UINTN Size;
- VAR_ERROR_FLAG ErrorFlag;
+ EFI_STATUS Status;
+ UINTN Size;
+ VAR_ERROR_FLAG ErrorFlag;
- Size = sizeof (ErrorFlag);
+ Size = sizeof (ErrorFlag);
Status = gRT->GetVariable (
VAR_ERROR_FLAG_NAME,
&gEdkiiVarErrorFlagGuid,
@@ -74,6 +74,7 @@ InternalGetVarErrorFlag ( DEBUG ((DEBUG_INFO, "%s - not found\n", VAR_ERROR_FLAG_NAME));
return VAR_ERROR_FLAG_NO_ERROR;
}
+
return ErrorFlag;
}
@@ -89,20 +90,21 @@ InternalGetVarErrorFlag ( **/
BOOLEAN
IsUserVariable (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid
)
{
- EFI_STATUS Status;
- VAR_CHECK_VARIABLE_PROPERTY Property;
+ EFI_STATUS Status;
+ VAR_CHECK_VARIABLE_PROPERTY Property;
if (mVarCheck == NULL) {
gBS->LocateProtocol (
&gEdkiiVarCheckProtocolGuid,
NULL,
- (VOID **) &mVarCheck
+ (VOID **)&mVarCheck
);
}
+
ASSERT (mVarCheck != NULL);
ZeroMem (&Property, sizeof (Property));
@@ -119,12 +121,12 @@ IsUserVariable ( return TRUE;
}
-// DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name));
-// DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", Property.Revision));
-// DEBUG ((DEBUG_INFO, " Property - 0x%04x\n", Property.Property));
-// DEBUG ((DEBUG_INFO, " Attribute - 0x%08x\n", Property.Attributes));
-// DEBUG ((DEBUG_INFO, " MinSize - 0x%x\n", Property.MinSize));
-// DEBUG ((DEBUG_INFO, " MaxSize - 0x%x\n", Property.MaxSize));
+ // DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name));
+ // DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", Property.Revision));
+ // DEBUG ((DEBUG_INFO, " Property - 0x%04x\n", Property.Property));
+ // DEBUG ((DEBUG_INFO, " Attribute - 0x%08x\n", Property.Attributes));
+ // DEBUG ((DEBUG_INFO, " MinSize - 0x%x\n", Property.MinSize));
+ // DEBUG ((DEBUG_INFO, " MaxSize - 0x%x\n", Property.MaxSize));
return FALSE;
}
@@ -139,15 +141,16 @@ IsUserVariable ( **/
USER_VARIABLE_NODE *
FindUserVariableNodeByGuid (
- IN EFI_GUID *Guid
+ IN EFI_GUID *Guid
)
{
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
if (CompareGuid (Guid, &UserVariableNode->Guid)) {
@@ -185,56 +188,57 @@ CreateUserVariableNode ( VOID
)
{
- EFI_STATUS Status;
- EFI_STATUS GetVariableStatus;
- CHAR16 *VarName;
- UINTN MaxVarNameSize;
- UINTN VarNameSize;
- UINTN MaxDataSize;
- UINTN DataSize;
- VOID *Data;
- UINT32 Attributes;
- EFI_GUID Guid;
- USER_VARIABLE_NODE *UserVariableNode;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- UINT16 Index;
- UINTN StringSize;
+ EFI_STATUS Status;
+ EFI_STATUS GetVariableStatus;
+ CHAR16 *VarName;
+ UINTN MaxVarNameSize;
+ UINTN VarNameSize;
+ UINTN MaxDataSize;
+ UINTN DataSize;
+ VOID *Data;
+ UINT32 Attributes;
+ EFI_GUID Guid;
+ USER_VARIABLE_NODE *UserVariableNode;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ UINT16 Index;
+ UINTN StringSize;
//
// Initialize 128 * sizeof (CHAR16) variable name size.
//
MaxVarNameSize = 128 * sizeof (CHAR16);
- VarName = AllocateZeroPool (MaxVarNameSize);
+ VarName = AllocateZeroPool (MaxVarNameSize);
ASSERT (VarName != NULL);
//
// Initialize 0x1000 variable data size.
//
MaxDataSize = 0x1000;
- Data = AllocateZeroPool (MaxDataSize);
+ Data = AllocateZeroPool (MaxDataSize);
ASSERT (Data != NULL);
Index = 0;
do {
VarNameSize = MaxVarNameSize;
- Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
+ Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
if (Status == EFI_BUFFER_TOO_SMALL) {
VarName = ReallocatePool (MaxVarNameSize, VarNameSize, VarName);
ASSERT (VarName != NULL);
MaxVarNameSize = VarNameSize;
- Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
+ Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
}
if (!EFI_ERROR (Status)) {
if (IsUserVariable (VarName, &Guid)) {
- DataSize = MaxDataSize;
+ DataSize = MaxDataSize;
GetVariableStatus = gRT->GetVariable (VarName, &Guid, &Attributes, &DataSize, Data);
if (GetVariableStatus == EFI_BUFFER_TOO_SMALL) {
Data = ReallocatePool (MaxDataSize, DataSize, Data);
ASSERT (Data != NULL);
- MaxDataSize = DataSize;
+ MaxDataSize = DataSize;
GetVariableStatus = gRT->GetVariable (VarName, &Guid, &Attributes, &DataSize, Data);
}
+
ASSERT_EFI_ERROR (GetVariableStatus);
if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
@@ -246,23 +250,23 @@ CreateUserVariableNode ( //
UserVariableNameNode = AllocateZeroPool (sizeof (*UserVariableNameNode));
ASSERT (UserVariableNameNode != NULL);
- UserVariableNameNode->Signature = USER_VARIABLE_NAME_NODE_SIGNATURE;
- UserVariableNameNode->Name = AllocateCopyPool (VarNameSize, VarName);
+ UserVariableNameNode->Signature = USER_VARIABLE_NAME_NODE_SIGNATURE;
+ UserVariableNameNode->Name = AllocateCopyPool (VarNameSize, VarName);
UserVariableNameNode->Attributes = Attributes;
- UserVariableNameNode->DataSize = DataSize;
- UserVariableNameNode->Index = Index;
- UserVariableNameNode->QuestionId = (EFI_QUESTION_ID) (USER_VARIABLE_QUESTION_ID + Index);
+ UserVariableNameNode->DataSize = DataSize;
+ UserVariableNameNode->Index = Index;
+ UserVariableNameNode->QuestionId = (EFI_QUESTION_ID)(USER_VARIABLE_QUESTION_ID + Index);
//
// 2 space * sizeof (CHAR16) + StrSize.
//
- StringSize = 2 * sizeof (CHAR16) + StrSize (UserVariableNameNode->Name);
+ StringSize = 2 * sizeof (CHAR16) + StrSize (UserVariableNameNode->Name);
UserVariableNameNode->PromptString = AllocatePool (StringSize);
ASSERT (UserVariableNameNode->PromptString != NULL);
UnicodeSPrint (UserVariableNameNode->PromptString, StringSize, L" %s", UserVariableNameNode->Name);
//
// (33 chars of "Attribtues = 0x and DataSize = 0x" + 1 terminator + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16).
//
- StringSize = (33 + 1 + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16);
+ StringSize = (33 + 1 + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16);
UserVariableNameNode->HelpString = AllocatePool (StringSize);
ASSERT (UserVariableNameNode->HelpString != NULL);
UnicodeSPrint (UserVariableNameNode->HelpString, StringSize, L"Attribtues = 0x%08x and DataSize = 0x%x", UserVariableNameNode->Attributes, UserVariableNameNode->DataSize);
@@ -291,19 +295,19 @@ DestroyUserVariableNode ( VOID
)
{
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
while (mUserVariableList.ForwardLink != &mUserVariableList) {
- Link = mUserVariableList.ForwardLink;
+ Link = mUserVariableList.ForwardLink;
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
RemoveEntryList (&UserVariableNode->Link);
while (UserVariableNode->NameLink.ForwardLink != &UserVariableNode->NameLink) {
- NameLink = UserVariableNode->NameLink.ForwardLink;
+ NameLink = UserVariableNode->NameLink.ForwardLink;
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
RemoveEntryList (&UserVariableNameNode->Link);
@@ -339,19 +343,19 @@ DestroyUserVariableNode ( **/
EFI_STATUS
CreateTimeBasedPayload (
- IN OUT UINTN *DataSize,
- IN OUT UINT8 **Data
+ IN OUT UINTN *DataSize,
+ IN OUT UINT8 **Data
)
{
- EFI_STATUS Status;
- UINT8 *NewData;
- UINT8 *Payload;
- UINTN PayloadSize;
- EFI_VARIABLE_AUTHENTICATION_2 *DescriptorData;
- UINTN DescriptorSize;
- EFI_TIME Time;
-
- if (Data == NULL || DataSize == NULL) {
+ EFI_STATUS Status;
+ UINT8 *NewData;
+ UINT8 *Payload;
+ UINTN PayloadSize;
+ EFI_VARIABLE_AUTHENTICATION_2 *DescriptorData;
+ UINTN DescriptorSize;
+ EFI_TIME Time;
+
+ if ((Data == NULL) || (DataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -365,7 +369,7 @@ CreateTimeBasedPayload ( PayloadSize = *DataSize;
DescriptorSize = OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData);
- NewData = (UINT8 *) AllocateZeroPool (DescriptorSize + PayloadSize);
+ NewData = (UINT8 *)AllocateZeroPool (DescriptorSize + PayloadSize);
if (NewData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -374,7 +378,7 @@ CreateTimeBasedPayload ( CopyMem (NewData + DescriptorSize, Payload, PayloadSize);
}
- DescriptorData = (EFI_VARIABLE_AUTHENTICATION_2 *) (NewData);
+ DescriptorData = (EFI_VARIABLE_AUTHENTICATION_2 *)(NewData);
ZeroMem (&Time, sizeof (EFI_TIME));
Status = gRT->GetTime (&Time, NULL);
@@ -382,6 +386,7 @@ CreateTimeBasedPayload ( FreePool (NewData);
return Status;
}
+
Time.Pad1 = 0;
Time.Nanosecond = 0;
Time.TimeZone = 0;
@@ -423,19 +428,19 @@ CreateTimeBasedPayload ( **/
EFI_STATUS
CreateCounterBasedPayload (
- IN OUT UINTN *DataSize,
- IN OUT UINT8 **Data
+ IN OUT UINTN *DataSize,
+ IN OUT UINT8 **Data
)
{
- EFI_STATUS Status;
- UINT8 *NewData;
- UINT8 *Payload;
- UINTN PayloadSize;
- EFI_VARIABLE_AUTHENTICATION *DescriptorData;
- UINTN DescriptorSize;
- UINT64 MonotonicCount;
-
- if (Data == NULL || DataSize == NULL) {
+ EFI_STATUS Status;
+ UINT8 *NewData;
+ UINT8 *Payload;
+ UINTN PayloadSize;
+ EFI_VARIABLE_AUTHENTICATION *DescriptorData;
+ UINTN DescriptorSize;
+ UINT64 MonotonicCount;
+
+ if ((Data == NULL) || (DataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -451,7 +456,7 @@ CreateCounterBasedPayload ( DescriptorSize = (OFFSET_OF (EFI_VARIABLE_AUTHENTICATION, AuthInfo)) + \
(OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)) + \
sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256);
- NewData = (UINT8 *) AllocateZeroPool (DescriptorSize + PayloadSize);
+ NewData = (UINT8 *)AllocateZeroPool (DescriptorSize + PayloadSize);
if (NewData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -460,13 +465,14 @@ CreateCounterBasedPayload ( CopyMem (NewData + DescriptorSize, Payload, PayloadSize);
}
- DescriptorData = (EFI_VARIABLE_AUTHENTICATION *) (NewData);
+ DescriptorData = (EFI_VARIABLE_AUTHENTICATION *)(NewData);
Status = gBS->GetNextMonotonicCount (&MonotonicCount);
if (EFI_ERROR (Status)) {
FreePool (NewData);
return Status;
}
+
DescriptorData->MonotonicCount = MonotonicCount;
DescriptorData->AuthInfo.Hdr.dwLength = OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData) + sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256);
@@ -496,38 +502,40 @@ DeleteUserVariable ( IN VARIABLE_CLEANUP_DATA *VariableCleanupData OPTIONAL
)
{
- EFI_STATUS Status;
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
- UINTN DataSize;
- UINT8 *Data;
+ EFI_STATUS Status;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
+ UINTN DataSize;
+ UINT8 *Data;
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
for (NameLink = UserVariableNode->NameLink.ForwardLink
- ;NameLink != &UserVariableNode->NameLink
- ;NameLink = NameLink->ForwardLink) {
+ ; NameLink != &UserVariableNode->NameLink
+ ; NameLink = NameLink->ForwardLink)
+ {
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
if (!UserVariableNameNode->Deleted && (DeleteAll || ((VariableCleanupData != NULL) && (VariableCleanupData->UserVariable[UserVariableNameNode->Index] == TRUE)))) {
DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Delete variable: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name));
if ((UserVariableNameNode->Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
DataSize = 0;
- Data = NULL;
- Status = CreateTimeBasedPayload (&DataSize, &Data);
+ Data = NULL;
+ Status = CreateTimeBasedPayload (&DataSize, &Data);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, UserVariableNameNode->Attributes, DataSize, Data);
FreePool (Data);
}
} else if ((UserVariableNameNode->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
DataSize = 0;
- Data = NULL;
- Status = CreateCounterBasedPayload (&DataSize, &Data);
+ Data = NULL;
+ Status = CreateCounterBasedPayload (&DataSize, &Data);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, UserVariableNameNode->Attributes, DataSize, Data);
FreePool (Data);
@@ -535,6 +543,7 @@ DeleteUserVariable ( } else {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, 0, 0, NULL);
}
+
if (!EFI_ERROR (Status)) {
UserVariableNameNode->Deleted = TRUE;
} else {
@@ -569,21 +578,21 @@ DeleteUserVariable ( EFI_STATUS
EFIAPI
VariableCleanupHiiExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- EFI_STATUS Status;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- UINTN BufferSize;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- BOOLEAN AllocatedRequest;
- UINTN Size;
-
- if (Progress == NULL || Results == NULL) {
+ EFI_STATUS Status;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ UINTN BufferSize;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
+
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -601,7 +610,7 @@ VariableCleanupHiiExtractConfig ( //
// Convert buffer data to <ConfigResp> by helper function BlockToConfig().
//
- BufferSize = sizeof (VARIABLE_CLEANUP_DATA);
+ BufferSize = sizeof (VARIABLE_CLEANUP_DATA);
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
@@ -614,7 +623,7 @@ VariableCleanupHiiExtractConfig ( mVarStoreName,
Private->DriverHandle
);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
@@ -625,7 +634,7 @@ VariableCleanupHiiExtractConfig ( Status = Private->ConfigRouting->BlockToConfig (
Private->ConfigRouting,
ConfigRequest,
- (UINT8 *) &Private->VariableCleanupData,
+ (UINT8 *)&Private->VariableCleanupData,
BufferSize,
Results,
Progress
@@ -639,6 +648,7 @@ VariableCleanupHiiExtractConfig ( FreePool (ConfigRequest);
ConfigRequest = NULL;
}
+
//
// Set Progress string to the original request string or the string's null terminator.
//
@@ -662,17 +672,17 @@ UpdateUserVariableForm ( IN VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private
)
{
- EFI_STRING_ID PromptStringToken;
- EFI_STRING_ID HelpStringToken;
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- EFI_IFR_GUID_LABEL *EndLabel;
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
- BOOLEAN Created;
+ EFI_STRING_ID PromptStringToken;
+ EFI_STRING_ID HelpStringToken;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
+ BOOLEAN Created;
//
// Init OpCode Handle.
@@ -686,16 +696,16 @@ UpdateUserVariableForm ( //
// Create Hii Extend Label OpCode as the start opcode.
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- StartLabel->Number = LABEL_START;
+ StartLabel->Number = LABEL_START;
//
// Create Hii Extend Label OpCode as the end opcode.
//
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- EndLabel->Number = LABEL_END;
+ EndLabel->Number = LABEL_END;
HiiUpdateForm (
Private->HiiHandle,
@@ -706,8 +716,9 @@ UpdateUserVariableForm ( );
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
//
@@ -715,8 +726,9 @@ UpdateUserVariableForm ( //
Created = FALSE;
for (NameLink = UserVariableNode->NameLink.ForwardLink
- ;NameLink != &UserVariableNode->NameLink
- ;NameLink = NameLink->ForwardLink) {
+ ; NameLink != &UserVariableNode->NameLink
+ ; NameLink = NameLink->ForwardLink)
+ {
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
if (!UserVariableNameNode->Deleted) {
@@ -733,12 +745,12 @@ UpdateUserVariableForm ( // Only create opcode for the non-deleted variables.
//
PromptStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->PromptString, NULL);
- HelpStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->HelpString, NULL);
+ HelpStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->HelpString, NULL);
HiiCreateCheckBoxOpCode (
StartOpCodeHandle,
UserVariableNameNode->QuestionId,
VARIABLE_CLEANUP_VARSTORE_ID,
- (UINT16) (USER_VARIABLE_VAR_OFFSET + UserVariableNameNode->Index),
+ (UINT16)(USER_VARIABLE_VAR_OFFSET + UserVariableNameNode->Index),
PromptStringToken,
HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -826,18 +838,19 @@ UpdateUserVariableForm ( EFI_STATUS
EFIAPI
VariableCleanupHiiRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- EFI_STATUS Status;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ UINTN BufferSize;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Configuration;
if (Configuration == NULL) {
@@ -861,19 +874,19 @@ VariableCleanupHiiRouteConfig ( // Convert <ConfigResp> to buffer data by helper function ConfigToBlock().
//
Status = Private->ConfigRouting->ConfigToBlock (
- Private->ConfigRouting,
- Configuration,
- (UINT8 *) &Private->VariableCleanupData,
- &BufferSize,
- Progress
- );
+ Private->ConfigRouting,
+ Configuration,
+ (UINT8 *)&Private->VariableCleanupData,
+ &BufferSize,
+ Progress
+ );
ASSERT_EFI_ERROR (Status);
DeleteUserVariable (FALSE, &Private->VariableCleanupData);
//
// For "F10" hotkey to refresh the form.
//
-// UpdateUserVariableForm (Private);
+ // UpdateUserVariableForm (Private);
return EFI_SUCCESS;
}
@@ -905,16 +918,16 @@ VariableCleanupHiiRouteConfig ( EFI_STATUS
EFIAPI
VariableCleanupHiiCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- VARIABLE_CLEANUP_DATA *VariableCleanupData;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ VARIABLE_CLEANUP_DATA *VariableCleanupData;
Private = VARIABLE_CLEANUP_HII_PRIVATE_FROM_THIS (This);
@@ -929,7 +942,7 @@ VariableCleanupHiiCallback ( // Retrieve uncommitted data from Form Browser.
//
VariableCleanupData = &Private->VariableCleanupData;
- HiiGetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *) VariableCleanupData);
+ HiiGetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *)VariableCleanupData);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (Value == NULL) {
return EFI_INVALID_PARAMETER;
@@ -938,8 +951,9 @@ VariableCleanupHiiCallback ( if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
if ((QuestionId >= USER_VARIABLE_QUESTION_ID) && (QuestionId < USER_VARIABLE_QUESTION_ID + MAX_USER_VARIABLE_COUNT)) {
- if (Value->b){
+ if (Value->b) {
//
// Means one user variable checkbox is marked to delete but not press F10 or "Commit Changes and Exit" menu.
//
@@ -964,7 +978,7 @@ VariableCleanupHiiCallback ( } else {
switch (QuestionId) {
case SELECT_ALL_QUESTION_ID:
- if (Value->b){
+ if (Value->b) {
//
// Means the SelectAll checkbox is marked to delete all user variables but not press F10 or "Commit Changes and Exit" menu.
//
@@ -977,6 +991,7 @@ VariableCleanupHiiCallback ( SetMem (VariableCleanupData->UserVariable, sizeof (VariableCleanupData->UserVariable), FALSE);
mMarkedUserVariableCount = 0;
}
+
break;
case SAVE_AND_EXIT_QUESTION_ID:
DeleteUserVariable (FALSE, VariableCleanupData);
@@ -999,7 +1014,7 @@ VariableCleanupHiiCallback ( //
// Pass changed uncommitted data back to Form Browser.
//
- HiiSetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *) VariableCleanupData, NULL);
+ HiiSetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *)VariableCleanupData, NULL);
return EFI_SUCCESS;
}
@@ -1022,13 +1037,13 @@ VariableCleanupHiiCallback ( EFI_STATUS
EFIAPI
PlatformVarCleanup (
- IN VAR_ERROR_FLAG Flag,
- IN VAR_CLEANUP_TYPE Type
+ IN VAR_ERROR_FLAG Flag,
+ IN VAR_CLEANUP_TYPE Type
)
{
- EFI_STATUS Status;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
if (!mEndOfDxe) {
//
@@ -1037,7 +1052,7 @@ PlatformVarCleanup ( return EFI_UNSUPPORTED;
}
- if ((Type >= VarCleanupMax) || ((Flag & ((VAR_ERROR_FLAG) (VAR_ERROR_FLAG_SYSTEM_ERROR & VAR_ERROR_FLAG_USER_ERROR))) == 0)) {
+ if ((Type >= VarCleanupMax) || ((Flag & ((VAR_ERROR_FLAG)(VAR_ERROR_FLAG_SYSTEM_ERROR & VAR_ERROR_FLAG_USER_ERROR))) == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -1048,7 +1063,7 @@ PlatformVarCleanup ( return EFI_SUCCESS;
}
- if ((Flag & (~((VAR_ERROR_FLAG) VAR_ERROR_FLAG_SYSTEM_ERROR))) == 0) {
+ if ((Flag & (~((VAR_ERROR_FLAG)VAR_ERROR_FLAG_SYSTEM_ERROR))) == 0) {
//
// This sample does not support system variables cleanup.
//
@@ -1080,7 +1095,7 @@ PlatformVarCleanup ( //
// Locate FormBrowser2 protocol.
//
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&FormBrowser2);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1090,7 +1105,7 @@ PlatformVarCleanup ( return EFI_OUT_OF_RESOURCES;
}
- Private->Signature = VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE;
+ Private->Signature = VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE;
Private->ConfigAccess.ExtractConfig = VariableCleanupHiiExtractConfig;
Private->ConfigAccess.RouteConfig = VariableCleanupHiiRouteConfig;
Private->ConfigAccess.Callback = VariableCleanupHiiCallback;
@@ -1098,7 +1113,7 @@ PlatformVarCleanup ( Status = gBS->LocateProtocol (
&gEfiHiiConfigRoutingProtocolGuid,
NULL,
- (VOID **) &Private->ConfigRouting
+ (VOID **)&Private->ConfigRouting
);
if (EFI_ERROR (Status)) {
goto Done;
@@ -1163,6 +1178,7 @@ Done: NULL
);
}
+
if (Private->HiiHandle != NULL) {
HiiRemovePackages (Private->HiiHandle);
}
@@ -1225,11 +1241,11 @@ PlatformVarCleanupEndOfDxeEvent ( EFI_STATUS
EFIAPI
PlatformVarCleanupLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mLastVarErrorFlag = InternalGetVarErrorFlag ();
DEBUG ((DEBUG_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag));
@@ -1262,11 +1278,11 @@ PlatformVarCleanupLibConstructor ( EFI_STATUS
EFIAPI
PlatformVarCleanupLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Close the End of DXE event.
|