]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / AcpiTableDxe / AcpiSdt.c
index 6146a1a309aacf519076cc54548bad8a2f3f6fcc..aae529ea0a66671ab81346e24ca43b78c8faf6a3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   ACPI Sdt Protocol Driver\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2010 - 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
@@ -19,7 +19,7 @@
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED\r
 EFI_ACPI_SDT_PROTOCOL  mAcpiSdtProtocolTemplate = {\r
-  EFI_ACPI_TABLE_VERSION_NONE | EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0 | EFI_ACPI_TABLE_VERSION_4_0,\r
+  EFI_ACPI_TABLE_VERSION_NONE,\r
   GetAcpiTable2,\r
   RegisterNotify,\r
   Open,\r
@@ -196,7 +196,7 @@ SdtNotifyAcpiList (
 \r
 /**\r
   Returns a requested ACPI table.\r
-  \r
+\r
   The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated\r
   with the Index that was input. The following structures are not considered elements in the list of\r
   ACPI tables:\r
@@ -204,19 +204,21 @@ SdtNotifyAcpiList (
   - Root System Description Table (RSDT)\r
   - Extended System Description Table (XSDT)\r
   Version is updated with a bit map containing all the versions of ACPI of which the table is a\r
-  member.\r
-  \r
+  member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,\r
+  the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.\r
+\r
   @param[in]    Index       The zero-based index of the table to retrieve.\r
   @param[out]   Table       Pointer for returning the table buffer.\r
   @param[out]   Version     On return, updated with the ACPI versions to which this table belongs. Type\r
                             EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the\r
-                            EFI_ACPI_SDT_PROTOCOL.    \r
-  @param[out]   TableKey    On return, points to the table key for the specified ACPI system definition table. This\r
-                            is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.  \r
-                            \r
+                            EFI_ACPI_SDT_PROTOCOL.\r
+  @param[out]   TableKey    On return, points to the table key for the specified ACPI system definition table.\r
+                            This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.\r
+                            The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()\r
+                            to uninstall the table.\r
   @retval EFI_SUCCESS       The function completed successfully.\r
-  @retval EFI_NOT_FOUND     The requested index is too large and a table was not found.                                  \r
-**/  \r
+  @retval EFI_NOT_FOUND     The requested index is too large and a table was not found.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GetAcpiTable2 (\r
@@ -276,9 +278,9 @@ GetAcpiTable2 (
 \r
 /**\r
   Register a callback when an ACPI table is installed.\r
-  \r
+\r
   This function registers a function which will be called whenever a new ACPI table is installed.\r
-  \r
+\r
   @param[in]  Notification               Points to the callback function to be registered\r
 **/\r
 VOID\r
@@ -316,13 +318,13 @@ SdtRegisterNotify (
 \r
 /**\r
   Unregister a callback when an ACPI table is installed.\r
-  \r
+\r
   This function unregisters a function which will be called whenever a new ACPI table is installed.\r
-  \r
+\r
   @param[in]  Notification               Points to the callback function to be unregistered.\r
-  \r
+\r
   @retval EFI_SUCCESS           Callback successfully unregistered.\r
-  @retval EFI_INVALID_PARAMETER Notification does not match a known registration function.                        \r
+  @retval EFI_INVALID_PARAMETER Notification does not match a known registration function.\r
 **/\r
 EFI_STATUS\r
 SdtUnregisterNotify (\r
@@ -369,17 +371,17 @@ SdtUnregisterNotify (
 \r
 /**\r
   Register or unregister a callback when an ACPI table is installed.\r
-  \r
+\r
   This function registers or unregisters a function which will be called whenever a new ACPI table is\r
   installed.\r
-  \r
+\r
   @param[in]    Register        If TRUE, then the specified function will be registered. If FALSE, then the specified\r
                                 function will be unregistered.\r
   @param[in]    Notification    Points to the callback function to be registered or unregistered.\r
-  \r
+\r
   @retval EFI_SUCCESS           Callback successfully registered or unregistered.\r
   @retval EFI_INVALID_PARAMETER Notification is NULL\r
-  @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.                        \r
+  @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -411,12 +413,12 @@ RegisterNotify (
 \r
 /**\r
   Create a handle for the first ACPI opcode in an ACPI system description table.\r
-  \r
+\r
   @param[in]    TableKey    The table key for the ACPI table, as returned by GetTable().\r
   @param[out]   Handle      On return, points to the newly created ACPI handle.\r
 \r
   @retval EFI_SUCCESS       Handle created successfully.\r
-  @retval EFI_NOT_FOUND     TableKey does not refer to a valid ACPI table.  \r
+  @retval EFI_NOT_FOUND     TableKey does not refer to a valid ACPI table.\r
 **/\r
 EFI_STATUS\r
 SdtOpenSdtTable (\r
@@ -464,12 +466,12 @@ SdtOpenSdtTable (
 \r
 /**\r
   Create a handle for the first ACPI opcode in an ACPI system description table.\r
-  \r
+\r
   @param[in]    TableKey    The table key for the ACPI table, as returned by GetTable().\r
   @param[out]   Handle      On return, points to the newly created ACPI handle.\r
 \r
   @retval EFI_SUCCESS       Handle created successfully.\r
-  @retval EFI_NOT_FOUND     TableKey does not refer to a valid ACPI table.  \r
+  @retval EFI_NOT_FOUND     TableKey does not refer to a valid ACPI table.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -487,21 +489,21 @@ OpenSdt (
 \r
 /**\r
   Create a handle from an ACPI opcode\r
-  \r
+\r
   @param[in]  Buffer                 Points to the ACPI opcode.\r
   @param[in]  BufferSize             Max buffer size.\r
   @param[out] Handle                 Upon return, holds the handle.\r
-  \r
+\r
   @retval   EFI_SUCCESS             Success\r
   @retval   EFI_INVALID_PARAMETER   Buffer is NULL or Handle is NULL or Buffer points to an\r
                                     invalid opcode.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 SdtOpenEx (\r
   IN    VOID            *Buffer,\r
   IN    UINTN           BufferSize,\r
-  OUT   EFI_ACPI_HANDLE *Handle \r
+  OUT   EFI_ACPI_HANDLE *Handle\r
   )\r
 {\r
   AML_BYTE_ENCODING   *AmlByteEncoding;\r
@@ -524,7 +526,7 @@ SdtOpenEx (
   //\r
   AmlHandle = AllocatePool (sizeof(*AmlHandle));\r
   ASSERT (AmlHandle != NULL);\r
-  \r
+\r
   AmlHandle->Signature       = EFI_AML_HANDLE_SIGNATURE;\r
   AmlHandle->Buffer          = Buffer;\r
   AmlHandle->AmlByteEncoding = AmlByteEncoding;\r
@@ -543,20 +545,20 @@ SdtOpenEx (
 \r
 /**\r
   Create a handle from an ACPI opcode\r
-  \r
+\r
   @param[in]  Buffer                 Points to the ACPI opcode.\r
   @param[out] Handle                 Upon return, holds the handle.\r
-  \r
+\r
   @retval   EFI_SUCCESS             Success\r
   @retval   EFI_INVALID_PARAMETER   Buffer is NULL or Handle is NULL or Buffer points to an\r
                                     invalid opcode.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 Open (\r
   IN    VOID            *Buffer,\r
-  OUT   EFI_ACPI_HANDLE *Handle \r
+  OUT   EFI_ACPI_HANDLE *Handle\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -581,11 +583,11 @@ Open (
 \r
 /**\r
   Close an ACPI handle.\r
-  \r
+\r
   @param[in] Handle Returns the handle.\r
-  \r
+\r
   @retval EFI_SUCCESS           Success\r
-  @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.  \r
+  @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -626,7 +628,7 @@ Close (
 \r
 /**\r
   Retrieve information about an ACPI object.\r
-  \r
+\r
   @param[in]    Handle      ACPI object handle.\r
   @param[in]    Index       Index of the data to retrieve from the object. In general, indexes read from left-to-right\r
                             in the ACPI encoding, with index 0 always being the ACPI opcode.\r
@@ -634,7 +636,7 @@ Close (
                             for the specified index.\r
   @param[out]   Data        Upon return, points to the pointer to the data.\r
   @param[out]   DataSize    Upon return, points to the size of Data.\r
-  \r
+\r
   @retval       EFI_SUCCESS           Success.\r
   @retval       EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.\r
 **/\r
@@ -690,7 +692,7 @@ GetOption (
 \r
 /**\r
   Change information about an ACPI object.\r
-  \r
+\r
   @param[in]  Handle    ACPI object handle.\r
   @param[in]  Index     Index of the data to retrieve from the object. In general, indexes read from left-to-right\r
                         in the ACPI encoding, with index 0 always being the ACPI opcode.\r
@@ -767,14 +769,14 @@ SetOption (
 \r
 /**\r
   Return the child ACPI objects.\r
-  \r
+\r
   @param[in]        ParentHandle    Parent handle.\r
   @param[in, out]   Handle          On entry, points to the previously returned handle or NULL to start with the first\r
                                     handle. On return, points to the next returned ACPI handle or NULL if there are no\r
                                     child objects.\r
 \r
   @retval EFI_SUCCESS               Success\r
-  @retval EFI_INVALID_PARAMETER     ParentHandle is NULL or does not refer to a valid ACPI object.                                \r
+  @retval EFI_INVALID_PARAMETER     ParentHandle is NULL or does not refer to a valid ACPI object.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -832,14 +834,14 @@ GetChild (
 \r
 /**\r
   Returns the handle of the ACPI object representing the specified ACPI path\r
-  \r
+\r
   @param[in]    HandleIn    Points to the handle of the object representing the starting point for the path search.\r
   @param[in]    AmlPath     Points to the AML path.\r
   @param[out]   HandleOut   On return, points to the ACPI object which represents AcpiPath, relative to\r
                             HandleIn.\r
-                            \r
+\r
   @retval EFI_SUCCESS           Success\r
-  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.                            \r
+  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.\r
 **/\r
 EFI_STATUS\r
 SdtFindPathFromNonRoot (\r
@@ -852,6 +854,7 @@ SdtFindPathFromNonRoot (
   VOID                *Buffer;\r
   EFI_STATUS          Status;\r
 \r
+  Buffer = NULL;\r
   AmlHandle = (EFI_AML_HANDLE *)HandleIn;\r
 \r
   //\r
@@ -870,9 +873,9 @@ SdtFindPathFromNonRoot (
 \r
 /**\r
   Duplicate AML handle.\r
-  \r
+\r
   @param[in]    AmlHandle   Handle to be duplicated.\r
-                            \r
+\r
   @return Duplicated AML handle.\r
 **/\r
 EFI_AML_HANDLE *\r
@@ -891,14 +894,14 @@ SdtDuplicateHandle (
 \r
 /**\r
   Returns the handle of the ACPI object representing the specified ACPI path\r
-  \r
+\r
   @param[in]    HandleIn    Points to the handle of the object representing the starting point for the path search.\r
   @param[in]    AmlPath     Points to the AML path.\r
   @param[out]   HandleOut   On return, points to the ACPI object which represents AcpiPath, relative to\r
                             HandleIn.\r
-                            \r
+\r
   @retval EFI_SUCCESS           Success\r
-  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.                            \r
+  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.\r
 **/\r
 EFI_STATUS\r
 SdtFindPathFromRoot (\r
@@ -912,6 +915,7 @@ SdtFindPathFromRoot (
   EFI_STATUS          Status;\r
   VOID                *Buffer;\r
 \r
+  Buffer = NULL;\r
   AmlHandle = (EFI_AML_HANDLE *)HandleIn;\r
 \r
   //\r
@@ -973,14 +977,14 @@ SdtFindPathFromRoot (
 \r
 /**\r
   Returns the handle of the ACPI object representing the specified ACPI path\r
-  \r
+\r
   @param[in]    HandleIn    Points to the handle of the object representing the starting point for the path search.\r
   @param[in]    AcpiPath    Points to the ACPI path, which conforms to the ACPI encoded path format.\r
   @param[out]   HandleOut   On return, points to the ACPI object which represents AcpiPath, relative to\r
                             HandleIn.\r
-                            \r
+\r
   @retval EFI_SUCCESS           Success\r
-  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.                            \r
+  @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1002,7 +1006,7 @@ FindPath (
   }\r
 \r
   AmlHandle = (EFI_AML_HANDLE *)HandleIn;\r
-  \r
+\r
   //\r
   // Convert ASL path to AML path\r
   //\r
@@ -1036,54 +1040,6 @@ FindPath (
   return Status;\r
 }\r
 \r
-/**\r
-  ExitPmAuth Protocol notification event handler.\r
-\r
-  @param[in] Event    Event whose notification function is being invoked.\r
-  @param[in] Context  Pointer to the notification function's context.\r
-**/\r
-VOID\r
-EFIAPI\r
-ExitPmAuthNotification (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-  VOID       *DxeSmmReadyToLock;\r
-\r
-  //\r
-  // Add more check to locate protocol after got event, because\r
-  // the library will signal this event immediately once it is register\r
-  // just in case it is already installed.\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiDxeSmmReadyToLockProtocolGuid,\r
-                  NULL,\r
-                  &DxeSmmReadyToLock\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Uninstall ACPI SDT protocol, so that we can make sure no one update ACPI table from API level.\r
-  //\r
-  Status = gBS->UninstallProtocolInterface (\r
-                  mHandle,\r
-                  &gEfiAcpiSdtProtocolGuid,\r
-                  &mPrivateData->AcpiSdtProtocol\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Close event, so it will not be invoked again.\r
-  //\r
-  gBS->CloseEvent (Event);\r
-\r
-  return ;\r
-}\r
-\r
 /**\r
   This function initializes AcpiSdt protocol in ACPI table instance.\r
 \r
@@ -1094,21 +1050,10 @@ SdtAcpiTableAcpiSdtConstructor (
   IN EFI_ACPI_TABLE_INSTANCE   *AcpiTableInstance\r
   )\r
 {\r
-  VOID *Registration;\r
 \r
   InitializeListHead (&AcpiTableInstance->NotifyList);\r
   CopyMem (&AcpiTableInstance->AcpiSdtProtocol, &mAcpiSdtProtocolTemplate, sizeof(mAcpiSdtProtocolTemplate));\r
-\r
-  //\r
-  // Register event for ExitPmAuth, so that we can uninstall ACPI SDT protocol after ExitPmAuth.\r
-  //\r
-  EfiCreateProtocolNotifyEvent (\r
-    &gEfiDxeSmmReadyToLockProtocolGuid,\r
-    TPL_CALLBACK,\r
-    ExitPmAuthNotification,\r
-    NULL,\r
-    &Registration\r
-    );\r
+  AcpiTableInstance->AcpiSdtProtocol.AcpiVersion = (EFI_ACPI_TABLE_VERSION)PcdGet32 (PcdAcpiExposedTableVersions);\r
 \r
   return ;\r
 }\r