\r
#include "HiiDatabase.h"\r
\r
-#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
-\r
/**\r
Calculate the number of Unicode characters of the incoming Configuration string,\r
not including NULL terminator.\r
Length /= 2;\r
*DevicePath = (UINT8 *) AllocateZeroPool (Length);\r
if (*DevicePath == NULL) {\r
- SafeFreePool (DevicePathString);\r
+ FreePool (DevicePathString);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- HexStringToBuffer (*DevicePath, &Length, DevicePathString);\r
+ HexStringToBufInReverseOrder (*DevicePath, &Length, DevicePathString);\r
\r
- SafeFreePool (DevicePathString);\r
+ FreePool (DevicePathString);\r
\r
return EFI_SUCCESS;\r
\r
);\r
}\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (HandleBuffer);\r
+ if (HandleBuffer != NULL) {\r
+ FreePool (HandleBuffer);\r
+ }\r
return Status;\r
}\r
\r
Status = HiiExportPackageLists (HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
}\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (HandleBuffer);\r
- SafeFreePool (HiiPackageList);\r
+ FreePool (HandleBuffer);\r
+ FreePool (HiiPackageList);\r
return Status;\r
}\r
\r
\r
Status = HiiGetPackageListHandle (HiiDatabase, HiiHandle, &DriverHandle);\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (HandleBuffer);\r
- SafeFreePool (HiiPackageList);\r
- SafeFreePool (Storage);\r
+ FreePool (HandleBuffer);\r
+ FreePool (HiiPackageList);\r
+ FreePool (Storage);\r
return Status;\r
}\r
Storage->DriverHandle = DriverHandle;\r
}\r
}\r
\r
- SafeFreePool (HiiPackageList);\r
+ FreePool (HiiPackageList);\r
}\r
\r
- SafeFreePool (HandleBuffer);\r
+ FreePool (HandleBuffer);\r
\r
return EFI_SUCCESS;\r
}\r
\r
switch (Flag) {\r
case 1:\r
- Status = BufferToHexString (StringHeader, (UINT8 *) Buffer, BufferLen);\r
+ Status = BufInReverseOrderToHexString (StringHeader, (UINT8 *) Buffer, BufferLen);\r
break;\r
case 2:\r
Status = UnicodeToConfigString (StringHeader, &Length, (CHAR16 *) Buffer);\r
}\r
\r
\r
-#endif\r
-\r
/**\r
Adjusts the size of a previously allocated buffer.\r
\r
Status = EFI_SUCCESS;\r
\r
Exit:\r
- SafeFreePool (Str);\r
+ if (Str != NULL) {\r
+ FreePool (Str);\r
+ }\r
return Status;\r
}\r
\r
OUT EFI_STRING *Results\r
)\r
{\r
-#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
-\r
HII_DATABASE_PRIVATE_DATA *Private;\r
EFI_STRING StringPtr;\r
EFI_STRING ConfigRequest;\r
EFI_STATUS Status;\r
LIST_ENTRY *Link;\r
HII_DATABASE_RECORD *Database;\r
+ UINT8 *DevicePathPkg;\r
UINT8 *CurrentDevicePath;\r
EFI_HANDLE DriverHandle;\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
UINTN RemainSize;\r
EFI_STRING TmpPtr;\r
\r
+ //\r
+ // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
+ // as FALSE. But this renders the system to not 100% compliant with\r
+ // UEFI 2.1. Use this with caution.\r
+ //\r
+ if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
if (This == NULL || Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
Status = GetDevicePath (ConfigRequest, (UINT8 **) &DevicePath);\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (ConfigRequest);\r
+ FreePool (ConfigRequest);\r
return Status;\r
}\r
\r
Link = Link->ForwardLink\r
) {\r
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);\r
- CurrentDevicePath = Database->PackageList->DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if (CurrentDevicePath != NULL) {\r
+ \r
+ if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
+ CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
if (CompareMem (\r
DevicePath,\r
CurrentDevicePath,\r
}\r
}\r
\r
- SafeFreePool (DevicePath);\r
+ FreePool (DevicePath);\r
\r
if (DriverHandle == NULL) {\r
//\r
// Set Progress to the 'G' in "GUID" of the routing header.\r
//\r
*Progress = StringPtr;\r
- SafeFreePool (ConfigRequest);\r
+ FreePool (ConfigRequest);\r
return EFI_NOT_FOUND;\r
}\r
\r
for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);\r
*Progress = TmpPtr;\r
\r
- SafeFreePool (ConfigRequest);\r
+ FreePool (ConfigRequest);\r
return Status;\r
}\r
\r
ASSERT (*AccessProgress == 0);\r
Status = AppendToMultiString (Results, AccessResults);\r
ASSERT_EFI_ERROR (Status);\r
- SafeFreePool (AccessResults);\r
+ FreePool (AccessResults);\r
AccessResults = NULL;\r
- SafeFreePool (ConfigRequest);\r
+ FreePool (ConfigRequest);\r
ConfigRequest = NULL;\r
\r
//\r
}\r
\r
return EFI_SUCCESS;\r
-#else\r
- return EFI_UNSUPPORTED;\r
-#endif\r
\r
}\r
\r
OUT EFI_STRING *Results\r
)\r
{\r
-#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
-\r
EFI_STATUS Status;\r
HII_DATABASE_PRIVATE_DATA *Private;\r
LIST_ENTRY StorageListHdr;\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
EFI_STRING AccessProgress;\r
EFI_STRING AccessResults;\r
- UINTN TmpSize;\r
+\r
+ //\r
+ // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
+ // as FALSE. But this renders the system to not 100% compliant with\r
+ // UEFI 2.1. Use this with caution.\r
+ //\r
+ if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
if (This == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
if (PathHdr == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- Status = BufferToHexString (PathHdr, (UINT8 *) DevicePath, Length);\r
+ Status = BufInReverseOrderToHexString (PathHdr, (UINT8 *) DevicePath, Length);\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Generate a <ConfigRequest> with one <ConfigHdr> and zero <RequestElement>.\r
// It means extract all possible configurations from this specific driver.\r
//\r
- TmpSize = StrLen (L"GUID=&NAME=&PATH=");\r
- RequestSize = (TmpSize + 32 + StrLen (Storage->Name) * 4)\r
- * sizeof (CHAR16) + PathHdrSize;\r
+ RequestSize = (StrLen (L"GUID=&NAME=&PATH=") + 32) * sizeof (CHAR16) + PathHdrSize;\r
+ if (Storage->Name != NULL) {\r
+ RequestSize += StrLen (Storage->Name) * 4 * sizeof (CHAR16);\r
+ }\r
+ \r
ConfigRequest = (EFI_STRING) AllocateZeroPool (RequestSize);\r
if (ConfigRequest == NULL) {\r
- SafeFreePool (PathHdr);\r
+ FreePool (PathHdr);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
StrnCpy (StringPtr, L"GUID=", StrLen (L"GUID="));\r
StringPtr += StrLen (L"GUID=");\r
\r
- Status = BufferToHexString (StringPtr, (UINT8 *) (&Storage->Guid), sizeof (EFI_GUID));\r
+ Status = BufInReverseOrderToHexString (StringPtr, (UINT8 *) (&Storage->Guid), sizeof (EFI_GUID));\r
ASSERT_EFI_ERROR (Status);\r
\r
StringPtr += 32;\r
StrnCpy (StringPtr, L"NAME=", StrLen (L"NAME="));\r
StringPtr += StrLen (L"NAME=");\r
\r
- Length = (StrLen (Storage->Name) * 4 + 1) * sizeof (CHAR16);\r
- Status = UnicodeToConfigString (StringPtr, &Length, Storage->Name);\r
- ASSERT_EFI_ERROR (Status);\r
- StringPtr += StrLen (Storage->Name) * 4;\r
+ if (Storage->Name != NULL) {\r
+ Length = (StrLen (Storage->Name) * 4 + 1) * sizeof (CHAR16);\r
+ Status = UnicodeToConfigString (StringPtr, &Length, Storage->Name);\r
+ ASSERT_EFI_ERROR (Status);\r
+ StringPtr += StrLen (Storage->Name) * 4;\r
+ }\r
\r
*StringPtr = L'&';\r
StringPtr++;\r
StringPtr += StrLen (L"PATH=");\r
StrCpy (StringPtr, PathHdr);\r
\r
- SafeFreePool (PathHdr);\r
+ FreePool (PathHdr);\r
PathHdr = NULL;\r
\r
//\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ AccessProgress = NULL;\r
+ AccessResults = NULL;\r
Status = ConfigAccess->ExtractConfig (\r
ConfigAccess,\r
ConfigRequest,\r
&AccessResults\r
);\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (ConfigRequest);\r
- SafeFreePool (AccessResults);\r
+ FreePool (ConfigRequest);\r
+ if (AccessProgress != NULL) {\r
+ FreePool (AccessProgress);\r
+ }\r
+ if (AccessResults != NULL) {\r
+ FreePool (AccessResults);\r
+ }\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
ASSERT (*AccessProgress == 0);\r
Status = AppendToMultiString (Results, AccessResults);\r
ASSERT_EFI_ERROR (Status);\r
- SafeFreePool (AccessResults);\r
+ FreePool (AccessResults);\r
AccessResults = NULL;\r
- SafeFreePool (ConfigRequest);\r
+ FreePool (ConfigRequest);\r
ConfigRequest = NULL;\r
\r
}\r
HII_FORMSET_STORAGE_SIGNATURE\r
);\r
RemoveEntryList (&Storage->Entry);\r
- SafeFreePool (Storage->Name);\r
- SafeFreePool (Storage);\r
+ FreePool (Storage->Name);\r
+ FreePool (Storage);\r
}\r
\r
return EFI_SUCCESS;\r
-#else\r
- return EFI_UNSUPPORTED;\r
-#endif\r
}\r
\r
\r
OUT EFI_STRING *Progress\r
)\r
{\r
-#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
-\r
HII_DATABASE_PRIVATE_DATA *Private;\r
EFI_STRING StringPtr;\r
EFI_STRING ConfigResp;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
LIST_ENTRY *Link;\r
HII_DATABASE_RECORD *Database;\r
+ UINT8 *DevicePathPkg;\r
UINT8 *CurrentDevicePath;\r
EFI_HANDLE DriverHandle;\r
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
UINTN RemainSize;\r
EFI_STRING TmpPtr;\r
\r
+ //\r
+ // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
+ // as FALSE. But this renders the system to not 100% compliant with\r
+ // UEFI 2.1. Use this with caution.\r
+ //\r
+ if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
if (This == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
Status = GetDevicePath (ConfigResp, (UINT8 **) &DevicePath);\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (ConfigResp);\r
+ FreePool (ConfigResp);\r
return Status;\r
}\r
\r
Link = Link->ForwardLink\r
) {\r
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);\r
- CurrentDevicePath = Database->PackageList->DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
- if (CurrentDevicePath != NULL) {\r
+\r
+ if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {\r
+ CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);\r
if (CompareMem (\r
DevicePath,\r
CurrentDevicePath,\r
}\r
}\r
\r
- SafeFreePool (DevicePath);\r
+ FreePool (DevicePath);\r
\r
if (DriverHandle == NULL) {\r
//\r
// Set Progress to the 'G' in "GUID" of the routing header.\r
//\r
*Progress = StringPtr;\r
- SafeFreePool (ConfigResp);\r
+ FreePool (ConfigResp);\r
return EFI_NOT_FOUND;\r
}\r
\r
for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);\r
*Progress = TmpPtr;\r
\r
- SafeFreePool (ConfigResp);\r
+ FreePool (ConfigResp);\r
return Status;\r
}\r
\r
- SafeFreePool (ConfigResp);\r
+ FreePool (ConfigResp);\r
ConfigResp = NULL;\r
\r
//\r
}\r
\r
return EFI_SUCCESS;\r
-#else\r
- return EFI_UNSUPPORTED;\r
-#endif\r
}\r
\r
\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
- while (*StringPtr++ != L'&');\r
+\r
+ while (*StringPtr != L'&' && *StringPtr != 0) {\r
+ StringPtr++;\r
+ }\r
+ if (*StringPtr == 0) {\r
+ *Progress = StringPtr;\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Exit;\r
+ }\r
+ //\r
+ // Skip '&'\r
+ //\r
+ StringPtr++;\r
\r
//\r
// Copy <ConfigHdr> and an additional '&' to <ConfigResp>\r
TmpBuffer,\r
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
);\r
- SafeFreePool (TmpBuffer);\r
+ FreePool (TmpBuffer);\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
TmpBuffer,\r
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
);\r
- SafeFreePool (TmpBuffer);\r
+ FreePool (TmpBuffer);\r
\r
StringPtr += Length;\r
if (*StringPtr != 0 && *StringPtr != L'&') {\r
ASSERT_EFI_ERROR (Status);\r
ToLower (ValueStr);\r
\r
- SafeFreePool (Value);\r
+ FreePool (Value);\r
Value = NULL;\r
\r
//\r
\r
AppendToMultiString (Config, ConfigElement);\r
\r
- SafeFreePool (ConfigElement);\r
- SafeFreePool (ValueStr);\r
+ FreePool (ConfigElement);\r
+ FreePool (ValueStr);\r
ConfigElement = NULL;\r
ValueStr = NULL;\r
\r
return EFI_SUCCESS;\r
\r
Exit:\r
-\r
- SafeFreePool (*Config);\r
- SafeFreePool (ValueStr);\r
- SafeFreePool (Value);\r
- SafeFreePool (ConfigElement);\r
+ FreePool (*Config);\r
+ if (ValueStr != NULL) {\r
+ FreePool (ValueStr);\r
+ }\r
+ if (Value != NULL) {\r
+ FreePool (Value);\r
+ }\r
+ if (ConfigElement) {\r
+ FreePool (ConfigElement);\r
+ }\r
\r
return Status;\r
\r
Status = EFI_INVALID_PARAMETER;\r
goto Exit;\r
}\r
- while (*StringPtr++ != L'&');\r
+\r
+ while (*StringPtr != L'&' && *StringPtr != 0) {\r
+ StringPtr++;\r
+ }\r
+ if (*StringPtr == 0) {\r
+ *Progress = StringPtr;\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Exit;\r
+ }\r
+ //\r
+ // Skip '&'\r
+ //\r
+ StringPtr++;\r
\r
//\r
// Parse each <ConfigElement> if exists\r
TmpBuffer,\r
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
);\r
- SafeFreePool (TmpBuffer);\r
+ FreePool (TmpBuffer);\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {\r
TmpBuffer,\r
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)\r
);\r
- SafeFreePool (TmpBuffer);\r
+ FreePool (TmpBuffer);\r
\r
StringPtr += Length;\r
if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) {\r
CopyMem (Block + Offset, Value, Width);\r
*BlockSize = Offset + Width - 1;\r
\r
- SafeFreePool (Value);\r
+ FreePool (Value);\r
Value = NULL;\r
\r
//\r
\r
Exit:\r
\r
- SafeFreePool (Value);\r
+ if (Value != NULL) {\r
+ FreePool (Value);\r
+ }\r
return Status;\r
}\r
\r
OUT EFI_STRING *AltCfgResp\r
)\r
{\r
-#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
-\r
EFI_STATUS Status;\r
EFI_STRING StringPtr;\r
EFI_STRING HdrStart;\r
BOOLEAN NameFlag;\r
BOOLEAN PathFlag;\r
\r
+ //\r
+ // For size reduction, please define PcdSupportFullConfigRoutingProtocol \r
+ // as FALSE. But this renders the system to not 100% compliant with\r
+ // UEFI 2.1. Use this with caution.\r
+ //\r
+ if (!FeaturePcdGet (PcdSupportFullConfigRoutingProtocol)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
HdrStart = NULL;\r
HdrEnd = NULL;\r
GuidStr = NULL;\r
}\r
}\r
\r
- SafeFreePool (GuidStr);\r
- SafeFreePool (NameStr);\r
- SafeFreePool (PathStr);\r
- SafeFreePool (AltIdStr);\r
- SafeFreePool (Result);\r
+ if (GuidStr != NULL) {\r
+ FreePool (GuidStr);\r
+ }\r
+ if (NameStr != NULL) {\r
+ FreePool (NameStr);\r
+ }\r
+ if (PathStr != NULL) {\r
+ FreePool (PathStr);\r
+ }\r
+ if (AltIdStr != NULL) {\r
+ FreePool (AltIdStr);\r
+ }\r
+ if (Result != NULL) {\r
+ FreePool (Result);\r
+ }\r
\r
return Status;\r
\r
-#else\r
- return EFI_UNSUPPORTED;\r
-#endif\r
-\r
}\r
\r
\r