/** @file\r
Utility routines used by boot maintenance modules.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
#include "BootMaint.h"\r
\r
-/**\r
-\r
- Find the first instance of this Protocol\r
- in the system and return it's interface.\r
-\r
-\r
- @param ProtocolGuid Provides the protocol to search for\r
- @param Interface On return, a pointer to the first interface\r
- that matches ProtocolGuid\r
-\r
- @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found\r
- @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibLocateProtocol (\r
- IN EFI_GUID *ProtocolGuid,\r
- OUT VOID **Interface\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = gBS->LocateProtocol (\r
- ProtocolGuid,\r
- NULL,\r
- (VOID **) Interface\r
- );\r
- return Status;\r
-}\r
-\r
/**\r
\r
Function opens and returns a file handle to the root directory of a volume.\r
\r
@param VarName A Null-terminated Unicode string that is\r
the name of the vendor's variable.\r
- \r
+\r
@param VarGuid A unique identifier for the vendor.\r
\r
@retval EFI_SUCCESS The variable was found and removed\r
//\r
// Delete variable from Storage\r
//\r
- Status = gRT->SetVariable (VarName, VarGuid, VAR_FLAG, 0, NULL);\r
- ASSERT (!EFI_ERROR (Status));\r
+ Status = gRT->SetVariable (\r
+ VarName,\r
+ VarGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ 0,\r
+ NULL\r
+ );\r
+ //\r
+ // Deleting variable with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
FreePool (VarBuf);\r
}\r
\r
return Count;\r
}\r
\r
-/**\r
- Adjusts the size of a previously allocated buffer.\r
\r
+/**\r
+ Get a string from the Data Hub record based on\r
+ a device path.\r
\r
- @param OldPool - A pointer to the buffer whose size is being adjusted.\r
- @param OldSize - The size of the current buffer.\r
- @param NewSize - The size of the new buffer.\r
+ @param DevPath The device Path.\r
\r
- @return The newly allocated buffer.\r
- @retval NULL Allocation failed.\r
+ @return A string located from the Data Hub records based on\r
+ the device path.\r
+ @retval NULL If failed to get the String from Data Hub.\r
\r
**/\r
-VOID *\r
-EfiReallocatePool (\r
- IN VOID *OldPool,\r
- IN UINTN OldSize,\r
- IN UINTN NewSize\r
+UINT16 *\r
+EfiLibStrFromDatahub (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
)\r
{\r
- VOID *NewPool;\r
-\r
- NewPool = NULL;\r
- if (NewSize != 0) {\r
- NewPool = AllocateZeroPool (NewSize);\r
- }\r
-\r
- if (OldPool != NULL) {\r
- if (NewPool != NULL) {\r
- CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
- }\r
-\r
- FreePool (OldPool);\r
- }\r
-\r
- return NewPool;\r
+ return NULL;\r
}\r
\r
/**\r
- Compare two EFI_TIME data.\r
\r
+ Find the first instance of this Protocol\r
+ in the system and return it's interface.\r
\r
- @param FirstTime - A pointer to the first EFI_TIME data.\r
- @param SecondTime - A pointer to the second EFI_TIME data.\r
\r
- @retval TRUE The FirstTime is not later than the SecondTime.\r
- @retval FALSE The FirstTime is later than the SecondTime.\r
+ @param ProtocolGuid Provides the protocol to search for\r
+ @param Interface On return, a pointer to the first interface\r
+ that matches ProtocolGuid\r
+\r
+ @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found\r
+ @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid\r
\r
**/\r
-BOOLEAN\r
-TimeCompare (\r
- IN EFI_TIME *FirstTime,\r
- IN EFI_TIME *SecondTime\r
+EFI_STATUS\r
+EfiLibLocateProtocol (\r
+ IN EFI_GUID *ProtocolGuid,\r
+ OUT VOID **Interface\r
)\r
{\r
- if (FirstTime->Year != SecondTime->Year) {\r
- return (BOOLEAN) (FirstTime->Year < SecondTime->Year);\r
- } else if (FirstTime->Month != SecondTime->Month) {\r
- return (BOOLEAN) (FirstTime->Month < SecondTime->Month);\r
- } else if (FirstTime->Day != SecondTime->Day) {\r
- return (BOOLEAN) (FirstTime->Day < SecondTime->Day);\r
- } else if (FirstTime->Hour != SecondTime->Hour) {\r
- return (BOOLEAN) (FirstTime->Hour < SecondTime->Hour);\r
- } else if (FirstTime->Minute != SecondTime->Minute) {\r
- return (BOOLEAN) (FirstTime->Minute < FirstTime->Minute);\r
- } else if (FirstTime->Second != SecondTime->Second) {\r
- return (BOOLEAN) (FirstTime->Second < SecondTime->Second);\r
- }\r
+ EFI_STATUS Status;\r
\r
- return (BOOLEAN) (FirstTime->Nanosecond <= SecondTime->Nanosecond);\r
+ Status = gBS->LocateProtocol (\r
+ ProtocolGuid,\r
+ NULL,\r
+ (VOID **) Interface\r
+ );\r
+ return Status;\r
}\r
\r
-/**\r
- Get a string from the Data Hub record based on \r
- a device path.\r
-\r
- @param DevPath The device Path.\r
-\r
- @return A string located from the Data Hub records based on\r
- the device path.\r
- @retval NULL If failed to get the String from Data Hub.\r
-\r
-**/\r
-UINT16 *\r
-EfiLibStrFromDatahub (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
- )\r
-{\r
- return NULL;\r
-}\r