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