and print messages on the console output and standard error devices.\r
\r
Copyright (c) 2006 - 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
- http://opensource.org/licenses/bsd-license.php.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
-\r
#include "UefiLibInternal.h"\r
\r
/**\r
UINT32 Name1;\r
UINT32 Name2;\r
\r
- Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
- Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
+ Name1 = ReadUnaligned24 ((CONST UINT32 *)Language1);\r
+ Name2 = ReadUnaligned24 ((CONST UINT32 *)Language2);\r
\r
- return (BOOLEAN) (Name1 == Name2);\r
+ return (BOOLEAN)(Name1 == Name2);\r
}\r
\r
/**\r
ASSERT (Table != NULL);\r
\r
SystemTable = gST;\r
- *Table = NULL;\r
+ *Table = NULL;\r
for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {\r
if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {\r
*Table = SystemTable->ConfigurationTable[Index].VendorTable;\r
**/\r
EFI_EVENT\r
EFIAPI\r
-EfiCreateProtocolNotifyEvent(\r
+EfiCreateProtocolNotifyEvent (\r
IN EFI_GUID *ProtocolGuid,\r
IN EFI_TPL NotifyTpl,\r
IN EFI_EVENT_NOTIFY NotifyFunction,\r
- IN VOID *NotifyContext, OPTIONAL\r
+ IN VOID *NotifyContext OPTIONAL,\r
OUT VOID **Registration\r
)\r
{\r
IN CONST EFI_GUID *Name,\r
IN EFI_TPL NotifyTpl,\r
IN EFI_EVENT_NOTIFY NotifyFunction,\r
- IN CONST VOID *NotifyContext, OPTIONAL\r
+ IN CONST VOID *NotifyContext OPTIONAL,\r
OUT VOID *Registration OPTIONAL\r
)\r
{\r
EVT_NOTIFY_SIGNAL,\r
NotifyTpl,\r
NotifyFunction,\r
- (VOID *) NotifyContext,\r
+ (VOID *)NotifyContext,\r
&Event\r
);\r
ASSERT_EFI_ERROR (Status);\r
//\r
\r
Status = gBS->RegisterProtocolNotify (\r
- (EFI_GUID *) Name,\r
+ (EFI_GUID *)Name,\r
Event,\r
RegistrationLocal\r
);\r
EFI_STATUS Status;\r
EFI_HANDLE Handle;\r
\r
- ASSERT(Name != NULL);\r
+ ASSERT (Name != NULL);\r
\r
Handle = NULL;\r
Status = gBS->InstallProtocolInterface (\r
&Handle,\r
- (EFI_GUID *) Name,\r
+ (EFI_GUID *)Name,\r
EFI_NATIVE_INTERFACE,\r
NULL\r
);\r
\r
Status = gBS->UninstallProtocolInterface (\r
Handle,\r
- (EFI_GUID *) Name,\r
+ (EFI_GUID *)Name,\r
NULL\r
);\r
ASSERT_EFI_ERROR (Status);\r
EFI_STATUS\r
EFIAPI\r
EfiEventGroupSignal (\r
- IN CONST EFI_GUID *EventGroup\r
+ IN CONST EFI_GUID *EventGroup\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_EVENT Event;\r
+ EFI_STATUS Status;\r
+ EFI_EVENT Event;\r
\r
if (EventGroup == NULL) {\r
return EFI_INVALID_PARAMETER;\r
VOID\r
EFIAPI\r
EfiEventEmptyFunction (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
)\r
{\r
}\r
VOID\r
)\r
{\r
- EFI_TPL Tpl;\r
+ EFI_TPL Tpl;\r
\r
Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
gBS->RestoreTPL (Tpl);\r
return Tpl;\r
}\r
\r
-\r
/**\r
Initializes a basic mutual exclusion lock.\r
\r
EFIAPI\r
EfiInitializeLock (\r
IN OUT EFI_LOCK *Lock,\r
- IN EFI_TPL Priority\r
+ IN EFI_TPL Priority\r
)\r
{\r
ASSERT (Lock != NULL);\r
ASSERT (Priority <= TPL_HIGH_LEVEL);\r
\r
- Lock->Tpl = Priority;\r
- Lock->OwnerTpl = TPL_APPLICATION;\r
- Lock->Lock = EfiLockReleased ;\r
+ Lock->Tpl = Priority;\r
+ Lock->OwnerTpl = TPL_APPLICATION;\r
+ Lock->Lock = EfiLockReleased;\r
return Lock;\r
}\r
\r
IN EFI_LOCK *Lock\r
)\r
{\r
-\r
ASSERT (Lock != NULL);\r
ASSERT (Lock->Lock != EfiLockUninitialized);\r
\r
IN EFI_LOCK *Lock\r
)\r
{\r
- EFI_TPL Tpl;\r
+ EFI_TPL Tpl;\r
\r
ASSERT (Lock != NULL);\r
ASSERT (Lock->Lock == EfiLockAcquired);\r
EFI_STATUS\r
EFIAPI\r
EfiTestManagedDevice (\r
- IN CONST EFI_HANDLE ControllerHandle,\r
- IN CONST EFI_HANDLE DriverBindingHandle,\r
- IN CONST EFI_GUID *ProtocolGuid\r
+ IN CONST EFI_HANDLE ControllerHandle,\r
+ IN CONST EFI_HANDLE DriverBindingHandle,\r
+ IN CONST EFI_GUID *ProtocolGuid\r
)\r
{\r
- EFI_STATUS Status;\r
- VOID *ManagedInterface;\r
+ EFI_STATUS Status;\r
+ VOID *ManagedInterface;\r
\r
ASSERT (ProtocolGuid != NULL);\r
\r
Status = gBS->OpenProtocol (\r
ControllerHandle,\r
- (EFI_GUID *) ProtocolGuid,\r
+ (EFI_GUID *)ProtocolGuid,\r
&ManagedInterface,\r
DriverBindingHandle,\r
ControllerHandle,\r
if (!EFI_ERROR (Status)) {\r
gBS->CloseProtocol (\r
ControllerHandle,\r
- (EFI_GUID *) ProtocolGuid,\r
+ (EFI_GUID *)ProtocolGuid,\r
DriverBindingHandle,\r
ControllerHandle\r
);\r
EFI_STATUS\r
EFIAPI\r
EfiTestChildHandle (\r
- IN CONST EFI_HANDLE ControllerHandle,\r
- IN CONST EFI_HANDLE ChildHandle,\r
- IN CONST EFI_GUID *ProtocolGuid\r
+ IN CONST EFI_HANDLE ControllerHandle,\r
+ IN CONST EFI_HANDLE ChildHandle,\r
+ IN CONST EFI_GUID *ProtocolGuid\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
- UINTN EntryCount;\r
- UINTN Index;\r
+ EFI_STATUS Status;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+ UINTN EntryCount;\r
+ UINTN Index;\r
\r
ASSERT (ProtocolGuid != NULL);\r
\r
//\r
Status = gBS->OpenProtocolInformation (\r
ControllerHandle,\r
- (EFI_GUID *) ProtocolGuid,\r
+ (EFI_GUID *)ProtocolGuid,\r
&OpenInfoBuffer,\r
&EntryCount\r
);\r
Status = EFI_UNSUPPORTED;\r
for (Index = 0; Index < EntryCount; Index++) {\r
if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) &&\r
- (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+ ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0))\r
+ {\r
Status = EFI_SUCCESS;\r
break;\r
}\r
return Status;\r
}\r
\r
+/**\r
+ This function checks the supported languages list for a target language,\r
+ This only supports RFC 4646 Languages.\r
+\r
+ @param SupportedLanguages The supported languages\r
+ @param TargetLanguage The target language\r
+\r
+ @retval Returns EFI_SUCCESS if the language is supported,\r
+ EFI_UNSUPPORTED otherwise\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IsLanguageSupported (\r
+ IN CONST CHAR8 *SupportedLanguages,\r
+ IN CONST CHAR8 *TargetLanguage\r
+ )\r
+{\r
+ UINTN Index;\r
+\r
+ while (*SupportedLanguages != 0) {\r
+ for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++) {\r
+ }\r
+\r
+ if ((AsciiStrnCmp (SupportedLanguages, TargetLanguage, Index) == 0) && (TargetLanguage[Index] == 0)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ SupportedLanguages += Index;\r
+ for ( ; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++) {\r
+ }\r
+ }\r
+\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
/**\r
This function looks up a Unicode string in UnicodeStringTable.\r
\r
//\r
// Make sure the parameters are valid\r
//\r
- if (Language == NULL || UnicodeString == NULL) {\r
+ if ((Language == NULL) || (UnicodeString == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// If there are no supported languages, or the Unicode String Table is empty, then the\r
// Unicode String specified by Language is not supported by this Unicode String Table\r
//\r
- if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+ if ((SupportedLanguages == NULL) || (UnicodeStringTable == NULL)) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
//\r
while (*SupportedLanguages != 0) {\r
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
-\r
//\r
// Search the Unicode String Table for the matching Language specifier\r
//\r
while (UnicodeStringTable->Language != NULL) {\r
if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {\r
-\r
//\r
// A matching string was found, so return it\r
//\r
return EFI_UNSUPPORTED;\r
}\r
\r
-\r
-\r
/**\r
This function looks up a Unicode string in UnicodeStringTable.\r
\r
IN BOOLEAN Iso639Language\r
)\r
{\r
- BOOLEAN Found;\r
- UINTN Index;\r
- CHAR8 *LanguageString;\r
+ BOOLEAN Found;\r
+ UINTN Index;\r
+ CHAR8 *LanguageString;\r
\r
//\r
// Make sure the parameters are valid\r
//\r
- if (Language == NULL || UnicodeString == NULL) {\r
+ if ((Language == NULL) || (UnicodeString == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// If there are no supported languages, or the Unicode String Table is empty, then the\r
// Unicode String specified by Language is not supported by this Unicode String Table\r
//\r
- if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+ if ((SupportedLanguages == NULL) || (UnicodeStringTable == NULL)) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
// Make sure Language is in the set of Supported Languages\r
//\r
Found = FALSE;\r
- while (*SupportedLanguages != 0) {\r
- if (Iso639Language) {\r
+ if (Iso639Language) {\r
+ while (*SupportedLanguages != 0) {\r
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
Found = TRUE;\r
break;\r
}\r
+\r
SupportedLanguages += 3;\r
- } else {\r
- for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
- if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
- Found = TRUE;\r
- break;\r
- }\r
- SupportedLanguages += Index;\r
- for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
}\r
+ } else {\r
+ Found = !IsLanguageSupported (SupportedLanguages, Language);\r
}\r
\r
//\r
while (UnicodeStringTable->Language != NULL) {\r
LanguageString = UnicodeStringTable->Language;\r
while (0 != *LanguageString) {\r
- for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
- if (AsciiStrnCmp(LanguageString, Language, Index) == 0) {\r
+ for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++) {\r
+ }\r
+\r
+ if (AsciiStrnCmp (LanguageString, Language, Index) == 0) {\r
*UnicodeString = UnicodeStringTable->UnicodeString;\r
return EFI_SUCCESS;\r
}\r
+\r
LanguageString += Index;\r
- for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++);\r
+ for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++) {\r
+ }\r
}\r
+\r
UnicodeStringTable++;\r
}\r
\r
return EFI_UNSUPPORTED;\r
}\r
\r
-\r
/**\r
This function adds a Unicode string to UnicodeStringTable.\r
\r
//\r
// Make sure the parameter are valid\r
//\r
- if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+ if ((Language == NULL) || (UnicodeString == NULL) || (UnicodeStringTable == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
//\r
while (*SupportedLanguages != 0) {\r
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
-\r
//\r
// Determine the size of the Unicode String Table by looking for a NULL Language entry\r
//\r
//\r
if (*UnicodeStringTable != NULL) {\r
CopyMem (\r
- NewUnicodeStringTable,\r
- *UnicodeStringTable,\r
- NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
- );\r
+ NewUnicodeStringTable,\r
+ *UnicodeStringTable,\r
+ NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
+ );\r
}\r
\r
//\r
//\r
// Compute the length of the Unicode String\r
//\r
- for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)\r
- ;\r
+ for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) {\r
+ }\r
\r
//\r
// Allocate space for a copy of the Unicode String\r
//\r
NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (\r
- (UnicodeStringLength + 1) * sizeof (CHAR16),\r
- UnicodeString\r
- );\r
+ (UnicodeStringLength + 1) * sizeof (CHAR16),\r
+ UnicodeString\r
+ );\r
if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
FreePool (NewUnicodeStringTable);\r
//\r
// Mark the end of the Unicode String Table\r
//\r
- NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
- NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
+ NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
+ NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
\r
//\r
// Free the old Unicode String Table\r
return EFI_UNSUPPORTED;\r
}\r
\r
-\r
/**\r
This function adds the Null-terminated Unicode string specified by UnicodeString\r
to UnicodeStringTable.\r
//\r
// Make sure the parameter are valid\r
//\r
- if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+ if ((Language == NULL) || (UnicodeString == NULL) || (UnicodeStringTable == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// Make sure Language is a member of SupportedLanguages\r
//\r
Found = FALSE;\r
- while (*SupportedLanguages != 0) {\r
- if (Iso639Language) {\r
+ if (Iso639Language) {\r
+ while (*SupportedLanguages != 0) {\r
if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
Found = TRUE;\r
break;\r
}\r
+\r
SupportedLanguages += 3;\r
- } else {\r
- for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
- if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {\r
- Found = TRUE;\r
- break;\r
- }\r
- SupportedLanguages += Index;\r
- for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
}\r
+ } else {\r
+ Found = !IsLanguageSupported (SupportedLanguages, Language);\r
}\r
\r
//\r
LanguageString = OldUnicodeStringTable->Language;\r
\r
while (*LanguageString != 0) {\r
- for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
+ for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++) {\r
+ }\r
\r
if (AsciiStrnCmp (Language, LanguageString, Index) == 0) {\r
return EFI_ALREADY_STARTED;\r
}\r
+\r
LanguageString += Index;\r
- for (; *LanguageString != 0 && *LanguageString == ';'; LanguageString++);\r
+ for ( ; *LanguageString != 0 && *LanguageString == ';'; LanguageString++) {\r
+ }\r
}\r
+\r
OldUnicodeStringTable++;\r
NumberOfEntries++;\r
}\r
//\r
// Allocate space for a copy of the Language specifier\r
//\r
- NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize(Language), Language);\r
+ NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language);\r
if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
FreePool (NewUnicodeStringTable);\r
return EFI_OUT_OF_RESOURCES;\r
//\r
// Compute the length of the Unicode String\r
//\r
- for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++);\r
+ for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) {\r
+ }\r
\r
//\r
// Allocate space for a copy of the Unicode String\r
//\r
// Mark the end of the Unicode String Table\r
//\r
- NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
- NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
+ NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
+ NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
\r
//\r
// Free the old Unicode String Table\r
IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable\r
)\r
{\r
- UINTN Index;\r
+ UINTN Index;\r
\r
//\r
// If the Unicode String Table is NULL, then it is already freed\r
// Loop through the Unicode String Table until we reach the end of table marker\r
//\r
for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {\r
-\r
//\r
// Free the Language string from the Unicode String Table\r
//\r
return EFI_SUCCESS;\r
}\r
\r
-#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
-\r
-/**\r
- [ATTENTION] This function will be deprecated for security reason.\r
-\r
- Returns a pointer to an allocated buffer that contains the contents of a\r
- variable retrieved through the UEFI Runtime Service GetVariable(). The\r
- returned buffer is allocated using AllocatePool(). The caller is responsible\r
- for freeing this buffer with FreePool().\r
-\r
- If Name is NULL, then ASSERT().\r
- If Guid is NULL, then ASSERT().\r
-\r
- @param[in] Name The pointer to a Null-terminated Unicode string.\r
- @param[in] Guid The pointer to an EFI_GUID structure\r
-\r
- @retval NULL The variable could not be retrieved.\r
- @retval NULL There are not enough resources available for the variable contents.\r
- @retval Other A pointer to allocated buffer containing the variable contents.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-GetVariable (\r
- IN CONST CHAR16 *Name,\r
- IN CONST EFI_GUID *Guid\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- VOID *Value;\r
-\r
- ASSERT (Name != NULL);\r
- ASSERT (Guid != NULL);\r
-\r
- //\r
- // Try to get the variable size.\r
- //\r
- Value = NULL;\r
- Size = 0;\r
- Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &Size, Value);\r
- if (Status != EFI_BUFFER_TOO_SMALL) {\r
- return NULL;\r
- }\r
-\r
- //\r
- // Allocate buffer to get the variable.\r
- //\r
- Value = AllocatePool (Size);\r
- if (Value == NULL) {\r
- return NULL;\r
- }\r
-\r
- //\r
- // Get the variable data.\r
- //\r
- Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &Size, Value);\r
- if (EFI_ERROR (Status)) {\r
- FreePool(Value);\r
- return NULL;\r
- }\r
-\r
- return Value;\r
-}\r
-\r
-/**\r
- [ATTENTION] This function will be deprecated for security reason.\r
-\r
- Returns a pointer to an allocated buffer that contains the contents of a\r
- variable retrieved through the UEFI Runtime Service GetVariable(). This\r
- function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.\r
- The returned buffer is allocated using AllocatePool(). The caller is\r
- responsible for freeing this buffer with FreePool().\r
-\r
- If Name is NULL, then ASSERT().\r
-\r
- @param[in] Name The pointer to a Null-terminated Unicode string.\r
-\r
- @retval NULL The variable could not be retrieved.\r
- @retval NULL There are not enough resources available for the variable contents.\r
- @retval Other A pointer to allocated buffer containing the variable contents.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-GetEfiGlobalVariable (\r
- IN CONST CHAR16 *Name\r
- )\r
-{\r
- return GetVariable (Name, &gEfiGlobalVariableGuid);\r
-}\r
-#endif\r
-\r
/**\r
Returns the status whether get the variable success. The function retrieves\r
variable through the UEFI Runtime Service GetVariable(). The\r
BufferSize = 0;\r
*Value = NULL;\r
if (Size != NULL) {\r
- *Size = 0;\r
+ *Size = 0;\r
}\r
\r
- Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);\r
+ Status = gRT->GetVariable ((CHAR16 *)Name, (EFI_GUID *)Guid, NULL, &BufferSize, *Value);\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r
return Status;\r
}\r
//\r
// Get the variable data.\r
//\r
- Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);\r
+ Status = gRT->GetVariable ((CHAR16 *)Name, (EFI_GUID *)Guid, NULL, &BufferSize, *Value);\r
if (EFI_ERROR (Status)) {\r
- FreePool(*Value);\r
+ FreePool (*Value);\r
*Value = NULL;\r
}\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
-GetVariable3(\r
- IN CONST CHAR16 *Name,\r
- IN CONST EFI_GUID *Guid,\r
- OUT VOID **Value,\r
- OUT UINTN *Size OPTIONAL,\r
- OUT UINT32 *Attr OPTIONAL\r
+GetVariable3 (\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST EFI_GUID *Guid,\r
+ OUT VOID **Value,\r
+ OUT UINTN *Size OPTIONAL,\r
+ OUT UINT32 *Attr OPTIONAL\r
)\r
{\r
EFI_STATUS Status;\r
UINTN BufferSize;\r
\r
- ASSERT(Name != NULL && Guid != NULL && Value != NULL);\r
+ ASSERT (Name != NULL && Guid != NULL && Value != NULL);\r
\r
//\r
// Try to get the variable size.\r
//\r
BufferSize = 0;\r
- *Value = NULL;\r
+ *Value = NULL;\r
if (Size != NULL) {\r
*Size = 0;\r
}\r
*Attr = 0;\r
}\r
\r
- Status = gRT->GetVariable((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &BufferSize, *Value);\r
+ Status = gRT->GetVariable ((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &BufferSize, *Value);\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r
return Status;\r
}\r
//\r
// Allocate buffer to get the variable.\r
//\r
- *Value = AllocatePool(BufferSize);\r
- ASSERT(*Value != NULL);\r
+ *Value = AllocatePool (BufferSize);\r
+ ASSERT (*Value != NULL);\r
if (*Value == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
//\r
// Get the variable data.\r
//\r
- Status = gRT->GetVariable((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &BufferSize, *Value);\r
- if (EFI_ERROR(Status)) {\r
- FreePool(*Value);\r
+ Status = gRT->GetVariable ((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &BufferSize, *Value);\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (*Value);\r
*Value = NULL;\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
GetEfiGlobalVariable2 (\r
- IN CONST CHAR16 *Name,\r
- OUT VOID **Value,\r
- OUT UINTN *Size OPTIONAL\r
+ IN CONST CHAR16 *Name,\r
+ OUT VOID **Value,\r
+ OUT UINTN *Size OPTIONAL\r
)\r
{\r
return GetVariable2 (Name, &gEfiGlobalVariableGuid, Value, Size);\r
// If in RFC 4646 mode, then determine the length of the first RFC 4646 language code in Language\r
//\r
if (Iso639Language == 0) {\r
- for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++);\r
+ for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++) {\r
+ }\r
}\r
\r
//\r
//\r
// Skip ';' characters in Supported\r
//\r
- for (; *Supported != '\0' && *Supported == ';'; Supported++);\r
+ for ( ; *Supported != '\0' && *Supported == ';'; Supported++) {\r
+ }\r
+\r
//\r
// Determine the length of the next language code in Supported\r
//\r
- for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++);\r
+ for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++) {\r
+ }\r
+\r
//\r
// If Language is longer than the Supported, then skip to the next language\r
//\r
continue;\r
}\r
}\r
+\r
//\r
// See if the first LanguageLength characters in Supported match Language\r
//\r
if (BestLanguage == NULL) {\r
return NULL;\r
}\r
+\r
return CopyMem (BestLanguage, Supported, CompareLength);\r
}\r
}\r
//\r
// If RFC 4646 mode, then trim Language from the right to the next '-' character\r
//\r
- for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);\r
+ for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--) {\r
+ }\r
}\r
}\r
}\r
+\r
VA_END (Args);\r
\r
//\r
//\r
// Check input parameters\r
//\r
- if (Protocol == NULL || NoProtocols == NULL || Buffer == NULL) {\r
+ if ((Protocol == NULL) || (NoProtocols == NULL) || (Buffer == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// Initialze output parameters\r
//\r
*NoProtocols = 0;\r
- *Buffer = NULL;\r
+ *Buffer = NULL;\r
\r
//\r
// Retrieve the array of handles that support Protocol\r
gBS->FreePool (HandleBuffer);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
ZeroMem (*Buffer, NoHandles * sizeof (VOID *));\r
\r
//\r
IN UINT64 Attributes\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_HANDLE FileSystemHandle;\r
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem;\r
- EFI_FILE_PROTOCOL *LastFile;\r
- FILEPATH_DEVICE_PATH *FilePathNode;\r
- CHAR16 *AlignedPathName;\r
- CHAR16 *PathName;\r
- EFI_FILE_PROTOCOL *NextFile;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE FileSystemHandle;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem;\r
+ EFI_FILE_PROTOCOL *LastFile;\r
+ FILEPATH_DEVICE_PATH *FilePathNode;\r
+ CHAR16 *AlignedPathName;\r
+ CHAR16 *PathName;\r
+ EFI_FILE_PROTOCOL *NextFile;\r
\r
if (File == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
+\r
*File = NULL;\r
\r
if (FilePath == NULL) {\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
Status = gBS->OpenProtocol (\r
FileSystemHandle,\r
&gEfiSimpleFileSystemProtocolGuid,\r
// Traverse the device path nodes relative to the filesystem.\r
//\r
while (!IsDevicePathEnd (*FilePath)) {\r
- if (DevicePathType (*FilePath) != MEDIA_DEVICE_PATH ||\r
- DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP) {\r
+ if ((DevicePathType (*FilePath) != MEDIA_DEVICE_PATH) ||\r
+ (DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP))\r
+ {\r
Status = EFI_INVALID_PARAMETER;\r
goto CloseLastFile;\r
}\r
+\r
FilePathNode = (FILEPATH_DEVICE_PATH *)*FilePath;\r
\r
//\r
//\r
if ((UINTN)FilePathNode->PathName % sizeof *FilePathNode->PathName == 0) {\r
AlignedPathName = NULL;\r
- PathName = FilePathNode->PathName;\r
+ PathName = FilePathNode->PathName;\r
} else {\r
AlignedPathName = AllocateCopyPool (\r
(DevicePathNodeLength (FilePathNode) -\r
Status = EFI_OUT_OF_RESOURCES;\r
goto CloseLastFile;\r
}\r
+\r
PathName = AlignedPathName;\r
}\r
\r
if (AlignedPathName != NULL) {\r
FreePool (AlignedPathName);\r
}\r
+\r
if (EFI_ERROR (Status)) {\r
goto CloseLastFile;\r
}\r
// Advance to the next device path node.\r
//\r
LastFile->Close (LastFile);\r
- LastFile = NextFile;\r
+ LastFile = NextFile;\r
*FilePath = NextDevicePathNode (FilePathNode);\r
}\r
\r