]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiLib.c
Code and comments have been checked with spec.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLib.c
index 1e960174abc54c16ca99d081183ade929e72da2c..53a46106e158bd5d6364438e24433b1bfbb78706 100644 (file)
@@ -45,10 +45,13 @@ CompareIso639LanguageCode (
 }\r
 \r
 /**\r
-  This function searches the list of configuration tables stored in the EFI System\r
-  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
+  Retrieves a pointer to the system configuration table from the EFI System Table\r
+  based on a specified GUID.\r
+  \r
+  This function searches the list of configuration tables stored in the EFI System Table\r
+  for a table with a GUID that matches TableGuid.  If a match is found, then a pointer to\r
+  the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID\r
+  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
@@ -85,16 +88,26 @@ EfiGetSystemConfigurationTable (
 }\r
 \r
 /**\r
-  This function causes the notification function to be executed for every protocol\r
-  of type ProtocolGuid instance that exists in the system when this function is\r
-  invoked.  In addition, every time a protocol of type ProtocolGuid instance is\r
-  installed or reinstalled, the notification function is also executed.\r
+  Creates and returns a notification event and registers that event with all the protocol\r
+  instances specified by ProtocolGuid.\r
+\r
+  This function causes the notification function to be executed for every protocol of type\r
+  ProtocolGuid instance that exists in the system when this function is invoked.\r
+  In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled,\r
+  the notification function is also executed.  This function returns the notification event\r
+  that was created. \r
+  If ProtocolGuid is NULL, then ASSERT().\r
+  If NotifyTpl is not a legal TPL value, then ASSERT().\r
+  If NotifyFunction is NULL, then ASSERT().\r
+  If Registration is NULL, then ASSERT().\r
 \r
   @param  ProtocolGuid    Supplies GUID of the protocol upon whose installation the event is fired.\r
   @param  NotifyTpl       Supplies the task priority level of the event notifications.\r
   @param  NotifyFunction  Supplies the function to notify when the event is signaled.\r
   @param  NotifyContext   The context parameter to pass to NotifyFunction.\r
   @param  Registration    A pointer to a memory location to receive the registration value.\r
+                          This value is passed to LocateHandle() to obtain new handles that\r
+                          have been added that support the ProtocolGuid-specified protocol. \r
 \r
   @return The notification event that was created.\r
 \r
@@ -112,6 +125,10 @@ EfiCreateProtocolNotifyEvent(
   EFI_STATUS  Status;\r
   EFI_EVENT   Event;\r
 \r
+  ASSERT (ProtocolGuid != NULL);\r
+  ASSERT (NotifyFunction != NULL);\r
+  ASSERT (Registration != NULL);\r
+\r
   //\r
   // Create the event\r
   //\r
@@ -147,9 +164,11 @@ EfiCreateProtocolNotifyEvent(
 }\r
 \r
 /**\r
+  Creates a named event that can be signaled with EfiNamedEventSignal().\r
+\r
   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
+  This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more\r
+  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
@@ -157,7 +176,7 @@ EfiCreateProtocolNotifyEvent(
   @param  Name                  Supplies GUID name of the event.\r
   @param  NotifyTpl             Supplies the task priority level of the event notifications.\r
   @param  NotifyFunction        Supplies the function to notify when the event is signaled.\r
-  @param  NotifyContext         The context parameter to pass to NotifyFunction.\r
+  @param  NotifyContext         The context parameter to pass to NotifyFunction. \r
   @param  Registration          A pointer to a memory location to receive the registration value.\r
 \r
   @retval EFI_SUCCESS           A named event was created.\r
@@ -219,8 +238,11 @@ EfiNamedEventListen (
 }\r
 \r
 /**\r
-  This function signals the named event specified by Name.  The named event must\r
-  have been created with EfiNamedEventListen().\r
+  Signals a named event created with EfiNamedEventListen().\r
+\r
+  This function signals the named event specified by Name. The named event must have been\r
+  created with EfiNamedEventListen().\r
+  If Name is NULL, then ASSERT().\r
 \r
   @param  Name                  Supplies GUID name of the event.\r
 \r
@@ -237,6 +259,8 @@ EfiNamedEventSignal (
   EFI_STATUS  Status;\r
   EFI_HANDLE  Handle;\r
 \r
+  ASSERT(Name != NULL);\r
+\r
   Handle = NULL;\r
   Status = gBS->InstallProtocolInterface (\r
                   &Handle,\r
@@ -286,8 +310,10 @@ EfiGetCurrentTpl (
 \r
 \r
 /**\r
-  This function initializes a basic mutual exclusion lock to the released state\r
-  and returns the lock.  Each lock provides mutual exclusion access at its task\r
+  Initializes a basic mutual exclusion lock.\r
+\r
+  This function initializes a basic mutual exclusion lock to the released state \r
+  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
@@ -316,14 +342,16 @@ EfiInitializeLock (
 }\r
 \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 places the lock in the\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 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  Lock   The task lock with priority level.\r
+  @param  Lock              A pointer to the lock to acquire.\r
 \r
 **/\r
 VOID\r
@@ -340,9 +368,13 @@ EfiAcquireLock (
 }\r
 \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
+  Acquires ownership of a lock.  If the lock is already owned , then an error is returned.\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
+  If Lock is NULL, then ASSERT().\r
+  If Lock is not initialized, then ASSERT().\r
 \r
   @param  Lock              A pointer to the lock to acquire.\r
 \r
@@ -375,9 +407,14 @@ EfiAcquireLockOrFail (
 }\r
 \r
 /**\r
-  This function transitions a mutual exclusion lock from the acquired state to\r
-  the released state, and restores the system's task priority level to its\r
+  Releases ownership of a lock.\r
+\r
+  This function transitions a mutual exclusion lock from the acquired state to \r
+  the released state, and restores the system's task priority level to its \r
   previous level.\r
+  If Lock is NULL, then ASSERT().\r
+  If Lock is not initialized, then ASSERT().\r
+  If Lock is already in the released state, then ASSERT().\r
 \r
   @param  Lock  A pointer to the lock to release.\r
 \r
@@ -527,50 +564,32 @@ EfiTestChildHandle (
 \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\r
-                                  language code for the Unicode\r
-                                  string to look up and return.\r
-  \r
-  @param  SupportedLanguages      A pointer to the set of ISO\r
-                                  639-2language\r
-                                  codes that the Unicode string\r
-                                  table supports. Language must\r
-                                  be a member of this set.\r
-  \r
-  @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.\r
-  \r
-  @param  UnicodeString           A pointer to the Unicode\r
-                                  string from UnicodeStringTable\r
-                                  that matches the language\r
-                                  specified by Language.\r
 \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
-  @retval  EFI_INVALID_PARAMETER  Language is NULL.\r
-  \r
-  @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.\r
-  @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.\r
-  \r
-  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.\r
-  \r
-  @retval  EFI_UNSUPPORTED        The language specified by\r
-                                  Language is not a member\r
-                                  ofSupportedLanguages.\r
-  \r
-  @retval EFI_UNSUPPORTED         The language specified by\r
-                                  Language is not supported by\r
-                                  UnicodeStringTable.\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
+  @param  Language                A pointer to the ISO 639-2 language code for the \r
+                                  Unicode string to look up and return.\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes \r
+                                  that the Unicode string table supports.  Language \r
+                                  must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string from UnicodeStringTable\r
+                                  that matches the language specified by Language.\r
+\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found\r
+                                  in the table of Unicoide 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_UNSUPPORTED         SupportedLanguages is NULL.\r
+  @retval EFI_UNSUPPORTED         UnicodeStringTable is NULL.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not \r
+                                  supported by UnicodeStringTable.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -640,28 +659,23 @@ LookupUnicodeString (
   @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
-  \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
-  \r
+                                  be a member of this set.  \r
   @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.\r
-  \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
-\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
-\r
   @retval  EFI_SUCCESS            The Unicode string that\r
                                   matches the language specified\r
                                   by Language was found in the\r
@@ -669,18 +683,13 @@ LookupUnicodeString (
                                   UnicodeStringTable, and it was\r
                                   returned in UnicodeString.\r
   \r
-  @retval  EFI_INVALID_PARAMETER  Language is NULL.\r
-  \r
-  @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.\r
-  \r
-  @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.\r
-  \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
-  \r
   @retval  EFI_UNSUPPORTED        The language specified by\r
                                   Language is not a member\r
-                                  ofSupportedLanguages.\r
-  \r
+                                  ofSupportedLanguages.  \r
   @retval EFI_UNSUPPORTED         The language specified by\r
                                   Language is not supported by\r
                                   UnicodeStringTable.\r
@@ -767,57 +776,36 @@ LookupUnicodeString2 (
 \r
 \r
 /**\r
-  \r
   This function adds a Unicode string to UnicodeStringTable.\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
+\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to \r
+  UnicodeStringTable.  New buffers are allocated for both Language and \r
+  UnicodeString.  The contents of Language and UnicodeString are copied into \r
+  these new buffers.  These buffers are automatically freed when \r
   FreeUnicodeStringTable() is called.\r
 \r
-  @param  Language                A pointer to the ISO 639-2\r
-                                  language code for the Unicode\r
+  @param  Language                A pointer to the ISO 639-2 language code for the Unicode \r
                                   string to add.\r
-  \r
-  @param  SupportedLanguages      A pointer to the set of ISO\r
-                                  639-2 language codes that the\r
-                                  Unicode string table supports.\r
-                                  Language must be a member of\r
-                                  this set.\r
-  \r
-  @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.\r
-  \r
-  @param  UnicodeString           A pointer to the Unicode\r
-                                  string to add.\r
-\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
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes\r
+                                  that the Unicode string table supports.\r
+                                  Language must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string to add.\r
+\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found in the table of \r
+                                  Unicode strings UnicodeStringTable, and it was \r
                                   returned in UnicodeString.\r
-  \r
   @retval EFI_INVALID_PARAMETER   Language is NULL.\r
-  \r
   @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
-  \r
   @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.\r
-  \r
   @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
-  \r
-  @retval EFI_ALREADY_STARTED     A Unicode string with language\r
-                                  Language is already present in\r
-                                  UnicodeStringTable.\r
-  \r
-  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to\r
-                                  add another Unicode string to\r
-                                  UnicodeStringTable.\r
-  \r
-  @retval EFI_UNSUPPORTED         The language specified by\r
-                                  Language is not a member of\r
-                                  SupportedLanguages.\r
+  @retval EFI_ALREADY_STARTED     A Unicode string with language Language is \r
+                                  already present in UnicodeStringTable.\r
+  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to add another \r
+                                  Unicode string to UnicodeStringTable.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -956,8 +944,8 @@ AddUnicodeString (
 \r
 \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
@@ -967,26 +955,21 @@ AddUnicodeString (
 \r
   @param  Language                A pointer to the ISO 639-2 or\r
                                   RFC 3066 language code for the\r
-                                  Unicode string to add.\r
-  \r
+                                  Unicode string to add.  \r
   @param  SupportedLanguages      A pointer to the set of ISO\r
-                                  639-2 or RFC 3.66 language\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
-  \r
+                                  be a member of this set.  \r
   @param  UnicodeStringTable      A pointer to the table of\r
-                                  Unicode strings.\r
-  \r
+                                  Unicode strings.  \r
   @param  UnicodeString           A pointer to the Unicode\r
-                                  string to add.\r
-  \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
-\r
   @retval EFI_SUCCESS             The Unicode string that\r
                                   matches the language specified\r
                                   by Language was found in the\r
@@ -994,22 +977,16 @@ AddUnicodeString (
                                   UnicodeStringTable, and it was\r
                                   returned in UnicodeString.\r
   \r
-  @retval EFI_INVALID_PARAMETER   Language is NULL.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.\r
-  \r
-  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\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
-  \r
+                                  UnicodeStringTable.  \r
   @retval EFI_OUT_OF_RESOURCES    There is not enough memory to\r
                                   add another Unicode string to\r
-                                  UnicodeStringTable.\r
-  \r
+                                  UnicodeStringTable.  \r
   @retval EFI_UNSUPPORTED         The language specified by\r
                                   Language is not a member of\r
                                   SupportedLanguages.\r
@@ -1175,6 +1152,7 @@ AddUnicodeString2 (
 \r
 /**\r
   This function frees the table of Unicode strings in UnicodeStringTable.\r
+\r
   If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
   Otherwise, each language code, and each Unicode string in the Unicode string \r
   table are freed, and EFI_SUCCESS is returned.\r
@@ -1231,10 +1209,9 @@ FreeUnicodeStringTable (
 \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
+  @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