X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FUefiLib%2FUefiLib.c;h=1acccb052261acc766ed630df300ff9fa701ffca;hb=f8d18bada5af6d1f89cfc3cd50580d590a641e50;hp=12a717aa270b35dbb90f294ef503362229fe6574;hpb=1c280088ec83160a5f190b3d0ba796b224ee23b3;p=mirror_edk2.git diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c index 12a717aa27..1acccb0522 100644 --- a/MdePkg/Library/UefiLib/UefiLib.c +++ b/MdePkg/Library/UefiLib/UefiLib.c @@ -12,9 +12,7 @@ **/ -// -// Include common header file for this module. -// + #include "UefiLibInternal.h" /** @@ -27,7 +25,6 @@ @retval FALSE Language 1 and language 2 are not the same. **/ -STATIC BOOLEAN CompareIso639LanguageCode ( IN CONST CHAR8 *Language1, @@ -48,6 +45,8 @@ CompareIso639LanguageCode ( Table for a table with a GUID that matches TableGuid. If a match is found, then a pointer to the configuration table is returned in Table, and EFI_SUCCESS is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + If TableGuid is NULL, then ASSERT(). + If Table is NULL, then ASSERT(). @param TableGuid Pointer to table's GUID type.. @param Table Pointer to the table associated with TableGuid in the EFI System Table. @@ -147,6 +146,9 @@ EfiCreateProtocolNotifyEvent( This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. This event is signaled with EfiNamedEventSignal(). This provide the ability for one or more listeners on the same event named by the GUID specified by Name. + If Name is NULL, then ASSERT(). + If NotifyTpl is not a legal TPL value, then ASSERT(). + If NotifyFunction is NULL, then ASSERT(). @param Name Supplies GUID name of the event. @param NotifyTpl Supplies the task priority level of the event notifications. @@ -172,6 +174,10 @@ EfiNamedEventListen ( EFI_EVENT Event; VOID *RegistrationLocal; + ASSERT (Name != NULL); + ASSERT (NotifyFunction != NULL); + ASSERT (NotifyTpl <= TPL_HIGH_LEVEL); + // // Create event // @@ -205,7 +211,7 @@ EfiNamedEventListen ( ); ASSERT_EFI_ERROR (Status); - return EFI_SUCCESS; + return Status; } /** @@ -243,7 +249,7 @@ EfiNamedEventSignal ( ); ASSERT_EFI_ERROR (Status); - return EFI_SUCCESS; + return Status; } /** @@ -257,7 +263,7 @@ EfiNamedEventSignal ( @param VOID - @retvale EFI_TPL The current TPL. + @retval EFI_TPL The current TPL. **/ EFI_TPL @@ -280,6 +286,8 @@ EfiGetCurrentTpl ( and returns the lock. Each lock provides mutual exclusion access at its task priority level. Since there is no preemption or multiprocessor support in EFI, acquiring the lock only consists of raising to the locks TPL. + If Lock is NULL, then ASSERT(). + If Priority is not a valid TPL value, then ASSERT(). @param Lock A pointer to the lock data structure to initialize. @param Priority EFI TPL associated with the lock. @@ -307,8 +315,11 @@ EfiInitializeLock ( This function raises the system's current task priority level to the task priority level of the mutual exclusion lock. Then, it places the lock in the acquired state. + If Lock is NULL, then ASSERT(). + If Lock is not initialized, then ASSERT(). + If Lock is already in the acquired state, then ASSERT(). - @param Priority The task priority level of the lock. + @param Lock The task lock with priority level. **/ VOID @@ -457,7 +468,7 @@ EfiTestManagedDevice ( @param ControllerHandle A handle for a (parent) controller to test. @param ChildHandle A child handle to test. - @param ConsumsedGuid Supplies the protocol that the child controller + @param ProtocolGuid Supplies the protocol that the child controller opens on its parent controller. @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. @@ -672,6 +683,7 @@ LookupUnicodeString ( **/ EFI_STATUS + EFIAPI LookupUnicodeString2 ( IN CONST CHAR8 *Language, @@ -713,7 +725,7 @@ LookupUnicodeString2 ( SupportedLanguages += 3; } else { for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++); - if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) { + if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) { Found = TRUE; break; } @@ -1076,7 +1088,7 @@ AddUnicodeString2 ( while (OldUnicodeStringTable->Language != NULL) { LanguageString = OldUnicodeStringTable->Language; - while (*LanguageString) { + while (*LanguageString != 0) { for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++); if (AsciiStrnCmp (Language, LanguageString, Index) == 0) { @@ -1209,4 +1221,50 @@ FreeUnicodeStringTable ( return EFI_SUCCESS; } +/** + Determine what is the current language setting. The space reserved for Lang + must be at least RFC_3066_ENTRY_SIZE bytes; + + If Lang is NULL, then ASSERT. + + @param Lang Pointer of system language. Lang will always be filled with + a valid RFC 3066 language string. If "PlatformLang" is not + set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang + is returned. + + @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang. + @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang. + +**/ +EFI_STATUS +EFIAPI +GetCurrentLanguage ( + OUT CHAR8 *Lang + ) +{ + EFI_STATUS Status; + UINTN Size; + + ASSERT (Lang != NULL); + + // + // Get current language setting + // + Size = RFC_3066_ENTRY_SIZE; + Status = gRT->GetVariable ( + L"PlatformLang", + &gEfiGlobalVariableGuid, + NULL, + &Size, + Lang + ); + + if (EFI_ERROR (Status)) { + AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang)); + } + + return Status; +} + +