-/**\r
- This function adds, removes, or updates ACPI tables. If the address is not\r
- null and the handle value is null, the table is added. If both the address and \r
- handle are not null, the table at handle is updated with the table at address.\r
- If the address is null and the handle is not, the table at handle is deleted.\r
-\r
- @param AcpiTableInstance Instance of the protocol.\r
- @param Table Pointer to a table.\r
- @param Checksum Boolean indicating if the checksum should be calculated.\r
- @param Version Version(s) to set.\r
- @param Handle Handle of the table.\r
-\r
- @return EFI_SUCCESS The function completed successfully.\r
- @return EFI_INVALID_PARAMETER Both the Table and *Handle were NULL.\r
- @return EFI_ABORTED Could not complete the desired request.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SetAcpiTable (\r
- IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,\r
- IN VOID *Table OPTIONAL,\r
- IN BOOLEAN Checksum,\r
- IN EFI_ACPI_TABLE_VERSION Version,\r
- IN OUT UINTN *Handle\r
- )\r
-{\r
- UINTN SavedHandle;\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Check for invalid input parameters\r
- //\r
- ASSERT (Handle);\r
-\r
- //\r
- // Initialize locals\r
- //\r
- //\r
- // Determine desired action\r
- //\r
- if (*Handle == 0) {\r
- if (Table == NULL) {\r
- //\r
- // Invalid parameter combination\r
- //\r
- return EFI_INVALID_PARAMETER;\r
- } else {\r
- //\r
- // Add table\r
- //\r
- Status = AddTableToList (AcpiTableInstance, Table, Checksum, Version, Handle);\r
- }\r
- } else {\r
- if (Table != NULL) {\r
- //\r
- // Update table\r
- //\r
- //\r
- // Delete the table list entry\r
- //\r
- Status = RemoveTableFromList (AcpiTableInstance, Version, *Handle);\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Should not get an error here ever, but abort if we do.\r
- //\r
- return EFI_ABORTED;\r
- }\r
- //\r
- // Set the handle to replace the table at the same handle\r
- //\r
- SavedHandle = AcpiTableInstance->CurrentHandle;\r
- AcpiTableInstance->CurrentHandle = *Handle;\r
-\r
- //\r
- // Add the table\r
- //\r
- Status = AddTableToList (AcpiTableInstance, Table, Checksum, Version, Handle);\r
-\r
- //\r
- // Restore the saved current handle\r
- //\r
- AcpiTableInstance->CurrentHandle = SavedHandle;\r
- } else {\r
- //\r
- // Delete table\r
- //\r
- Status = RemoveTableFromList (AcpiTableInstance, Version, *Handle);\r
- }\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Should not get an error here ever, but abort if we do.\r
- //\r
- return EFI_ABORTED;\r
- }\r
- //\r
- // Done\r
- //\r
- return EFI_SUCCESS;\r
-}\r
-\r