]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiLib.c
INF extension reviewed
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLib.c
index 53a46106e158bd5d6364438e24433b1bfbb78706..e515c1235716720e5c1cfc212d441dc9682977ff 100644 (file)
@@ -5,7 +5,7 @@
   EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, \r
   and print messages on the console output and standard error devices.\r
 \r
-  Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
   All rights reserved. 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
@@ -280,18 +280,16 @@ EfiNamedEventSignal (
   return Status;\r
 }\r
 \r
-/**\r
+/** \r
   Returns the current TPL.\r
 \r
-  This function returns the current TPL.  There is no EFI service to directly\r
-  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise\r
-  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level\r
-  can then immediately be restored back to the current TPL level with a call\r
+  This function returns the current TPL.  There is no EFI service to directly \r
+  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level \r
+  can then immediately be restored back to the current TPL level with a call \r
   to RestoreTPL().\r
 \r
-  @param  VOID\r
-\r
-  @retval EFI_TPL              The current TPL.\r
+  @return The current TPL.\r
 \r
 **/\r
 EFI_TPL\r
@@ -368,11 +366,12 @@ EfiAcquireLock (
 }\r
 \r
 /**\r
-  Acquires ownership of a lock.  If the lock is already owned , then an error is returned.\r
+  Acquires ownership of a lock.\r
 \r
-  This function raises the system's current task priority level to the task \r
-  priority level of the mutual exclusion lock.  Then, it attempts to place the \r
-  lock in the acquired state.\r
+  This function raises the system's current task priority level to the task priority\r
+  level of the mutual exclusion lock.  Then, it attempts to place the lock in the acquired state.\r
+  If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r
+  Otherwise, EFI_SUCCESS is returned.\r
   If Lock is NULL, then ASSERT().\r
   If Lock is not initialized, then ASSERT().\r
 \r
@@ -444,7 +443,7 @@ EfiReleaseLock (
   currently managing the controller specified by ControllerHandle.  This test\r
   is performed by evaluating if the the protocol specified by ProtocolGuid is\r
   present on ControllerHandle and is was opened by DriverBindingHandle with an\r
-  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.\r
+  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
   If ProtocolGuid is NULL, then ASSERT().\r
 \r
   @param  ControllerHandle     A handle for a controller to test.\r
@@ -507,10 +506,10 @@ EfiTestManagedDevice (
   ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
   If ProtocolGuid is NULL, then ASSERT().\r
 \r
-  @param  ControllerHandle     A handle for a (parent) controller to test.\r
+  @param  ControllerHandle     A handle for a (parent) controller to test. \r
   @param  ChildHandle          A child handle to test.\r
   @param  ProtocolGuid         Supplies the protocol that the child controller\r
-                               opens on its parent controller.\r
+                               opens on its parent controller. \r
 \r
   @retval EFI_SUCCESS          ChildHandle is a child of the ControllerHandle.\r
   @retval EFI_UNSUPPORTED      ChildHandle is not a child of the\r
@@ -565,7 +564,7 @@ EfiTestChildHandle (
 /**\r
   This function looks up a Unicode string in UnicodeStringTable.\r
 \r
-  If Language is   a member of SupportedLanguages and a Unicode string is found in\r
+  If Language is a member of SupportedLanguages and a Unicode string is found in\r
   UnicodeStringTable that matches the language code specified by Language, then it\r
   is returned in UnicodeString.\r
 \r
@@ -651,52 +650,45 @@ LookupUnicodeString (
 \r
 /**\r
   This function looks up a Unicode string in UnicodeStringTable.\r
-  If Language is a member of SupportedLanguages and a Unicode\r
-  string is found in UnicodeStringTable that matches the\r
-  language code specified by Language, then it is returned in\r
-  UnicodeString.\r
-\r
-  @param  Language                A pointer to the ISO 639-2 or\r
-                                  RFC 3066 language code for the\r
-                                  Unicode string to look up and\r
-                                  return.  \r
-  @param  SupportedLanguages      A pointer to the set of ISO\r
-                                  639-2 or RFC 3066 language\r
-                                  codes that the Unicode string\r
-                                  table supports. Language must\r
-                                  be a member of this set.  \r
-  @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.  \r
-  @param  UnicodeString           A pointer to the Unicode\r
-                                  string from UnicodeStringTable\r
-                                  that matches the language\r
-                                  specified by Language.\r
-  @param  Iso639Language          Specify the language code\r
-                                  format supported. If true,\r
-                                  then the format follow ISO\r
-                                  639-2. If false, then it\r
-                                  follows RFC3066.\r
-  @retval  EFI_SUCCESS            The Unicode string that\r
-                                  matches the language specified\r
-                                  by Language was found in the\r
-                                  table of Unicoide strings\r
-                                  UnicodeStringTable, and it was\r
-                                  returned in UnicodeString.\r
-  \r
+\r
+  If Language is a member of SupportedLanguages and a Unicode string is found in\r
+  UnicodeStringTable that matches the language code specified by Language, then\r
+  it is returned in UnicodeString.\r
+\r
+  @param  Language             A pointer to an ASCII string containing the ISO 639-2 or the\r
+                               RFC 4646 language code for the Unicode string to look up and\r
+                               return. If Iso639Language is TRUE, then this ASCII string is\r
+                               not assumed to be Null-terminated, and only the first three\r
+                               chacters are used. If Iso639Language is FALSE, then this ASCII\r
+                               string must be Null-terminated. \r
+  @param  SupportedLanguages   A pointer to a Null-terminated ASCII string that contains a\r
+                               set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
+                               string table supports.  Language must be a member of this set.\r
+                               If Iso639Language is TRUE, then this string contains one or more\r
+                               ISO 639-2 language codes with no separator characters. If Iso639Language\r
+                               is FALSE, then is string contains one or more RFC 4646 language\r
+                               codes separated by ';'.\r
+  @param  UnicodeStringTable   A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
+                               is defined in "Related Definitions".\r
+  @param  UnicodeString        A pointer to the Null-terminated Unicode string from UnicodeStringTable\r
+                               that matches the language specified by Language.\r
+  @param  Iso639Language       Specifies the supported language code format. If it is TRUE, then\r
+                               Language and SupportedLanguages follow ISO 639-2 language code format.\r
+                               Otherwise, they follow RFC 4646 language code format.\r
+\r
+\r
+  @retval  EFI_SUCCESS            The Unicode string that matches the language specified by Language\r
+                                  was found in the table of Unicode strings UnicodeStringTable, and\r
+                                  it was returned in UnicodeString.\r
   @retval  EFI_INVALID_PARAMETER  Language is NULL.  \r
   @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.  \r
   @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.  \r
-  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.\r
-  @retval  EFI_UNSUPPORTED        The language specified by\r
-                                  Language is not a member\r
-                                  ofSupportedLanguages.  \r
-  @retval EFI_UNSUPPORTED         The language specified by\r
-                                  Language is not supported by\r
-                                  UnicodeStringTable.\r
+  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.  \r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not a member of SupportedLanguages.  \r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not supported by UnicodeStringTable.\r
 \r
 **/\r
 EFI_STATUS\r
-\r
 EFIAPI\r
 LookupUnicodeString2 (\r
   IN CONST CHAR8                     *Language,\r
@@ -944,52 +936,45 @@ AddUnicodeString (
 \r
 \r
 /**\r
-  This function adds a Unicode string to UnicodeStringTable.\r
-\r
-  If Language is a member of SupportedLanguages then\r
-  UnicodeString is added to UnicodeStringTable.  New buffers are\r
-  allocated for both Language and UnicodeString.  The contents\r
-  of Language and UnicodeString are copied into these new\r
-  buffers.  These buffers are automatically freed when\r
-  FreeUnicodeStringTable() is called.\r
-\r
-  @param  Language                A pointer to the ISO 639-2 or\r
-                                  RFC 3066 language code for the\r
-                                  Unicode string to add.  \r
-  @param  SupportedLanguages      A pointer to the set of ISO\r
-                                  639-2 or RFC 3066 language\r
-                                  codes that the Unicode string\r
-                                  table supports. Language must\r
-                                  be a member of this set.  \r
-  @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.  \r
-  @param  UnicodeString           A pointer to the Unicode\r
-                                  string to add.  \r
-  @param  Iso639Language          Specify the language code\r
-                                  format supported. If true,\r
-                                  then the format follow ISO\r
-                                  639-2. If false, then it\r
-                                  follows RFC3066.\r
-  @retval EFI_SUCCESS             The Unicode string that\r
-                                  matches the language specified\r
-                                  by Language was found in the\r
-                                  table of Unicode strings\r
-                                  UnicodeStringTable, and it was\r
-                                  returned in UnicodeString.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   Language is NULL.  \r
-  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.  \r
-  @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.  \r
-  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.  \r
-  @retval EFI_ALREADY_STARTED     A Unicode string with language\r
-                                  Language is already present in\r
-                                  UnicodeStringTable.  \r
-  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to\r
-                                  add another Unicode string to\r
-                                  UnicodeStringTable.  \r
-  @retval EFI_UNSUPPORTED         The language specified by\r
-                                  Language is not a member of\r
-                                  SupportedLanguages.\r
+  This function adds the Null-terminated Unicode string specified by UnicodeString\r
+  to UnicodeStringTable.\r
+\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to\r
+  UnicodeStringTable.  New buffers are allocated for both Language and UnicodeString.\r
+  The contents of Language and UnicodeString are copied into these new buffers.\r
+  These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.\r
+\r
+  @param  Language            A pointer to an ASCII string containing the ISO 639-2 or\r
+                              the RFC 4646 language code for the Unicode string to add.\r
+                              If Iso639Language is TRUE, then this ASCII string is not\r
+                              assumed to be Null-terminated, and only the first three\r
+                              chacters are used. If Iso639Language is FALSE, then this\r
+                              ASCII string must be Null-terminated.\r
+  @param  SupportedLanguages  A pointer to a Null-terminated ASCII string that contains\r
+                              a set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
+                              string table supports.  Language must be a member of this set.\r
+                              If Iso639Language is TRUE, then this string contains one or more\r
+                              ISO 639-2 language codes with no separator characters.\r
+                              If Iso639Language is FALSE, then is string contains one or more\r
+                              RFC 4646 language codes separated by ';'.\r
+  @param  UnicodeStringTable  A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
+                              is defined in "Related Definitions".\r
+  @param  UnicodeString       A pointer to the Unicode string to add.  \r
+  @param  Iso639Language      Specifies the supported language code format. If it is TRUE,\r
+                              then Language and SupportedLanguages follow ISO 639-2 language code format.\r
+                              Otherwise, they follow RFC 4646 language code format.\r
+\r
+  @retval EFI_SUCCESS            The Unicode string that matches the language specified by\r
+                                 Language was found in the table of Unicode strings UnicodeStringTable,\r
+                                 and it was returned in UnicodeString.  \r
+  @retval EFI_INVALID_PARAMETER  Language is NULL.  \r
+  @retval EFI_INVALID_PARAMETER  UnicodeString is NULL.  \r
+  @retval EFI_INVALID_PARAMETER  UnicodeString is an empty string.  \r
+  @retval EFI_UNSUPPORTED        SupportedLanguages is NULL.  \r
+  @retval EFI_ALREADY_STARTED    A Unicode string with language Language is already present in\r
+                                 UnicodeStringTable.  \r
+  @retval EFI_OUT_OF_RESOURCES   There is not enough memory to add another Unicode string UnicodeStringTable.  \r
+  @retval EFI_UNSUPPORTED        The language specified by Language is not a member of SupportedLanguages.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1202,50 +1187,3 @@ FreeUnicodeStringTable (
 \r
   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 a valid RFC 3066\r
-                 language string. If "PlatformLang" is not set in the system, the default\r
-                 language specifed by PcdUefiVariableDefaultPlatformLang 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