Skip to content

Commit

Permalink
Tables: Add AcpiUninstallTable() to remove ACPI tables
Browse files Browse the repository at this point in the history
There are existing internal functions that allow the removal of ACPI
tables, but they are not exposed to OS in any useful way.

Introduce AcpiUninstallTable() which allows table states to be
"UNINSTALLED" in the global table list, resulting in failures of subsequent
calls to AcpiGetTable() for those tables.

The rationale for this change is the ability to remove the BGRT table
during kexec boot. The BGRT table refers to memory regions that are no
longer reserved by the firmware once the kexec kernel boots, having been
released for general allocation by the previous kernel.

Note that AcpiTbUninstallTable() is designed with limitation that it must
only be called after an AcpiTbInstallTable() call as it doesn't handle
table reference count synchronizations. So it is only safe in a
single-threaded early booting environment.

Original-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Feb 25, 2016
1 parent 6b2c3cd commit 8a0321d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
44 changes: 41 additions & 3 deletions source/components/tables/tbxfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ AcpiTbLoadNamespace (
* PARAMETERS: Address - Address of the ACPI table to be installed.
* Physical - Whether the address is a physical table
* address or not
* OutIndex - Where the table index is returned
*
* RETURN: Status
*
Expand All @@ -381,11 +382,11 @@ AcpiTbLoadNamespace (
ACPI_STATUS
AcpiInstallTable (
ACPI_PHYSICAL_ADDRESS Address,
BOOLEAN Physical)
BOOLEAN Physical,
UINT32 *OutIndex)
{
ACPI_STATUS Status;
UINT8 Flags;
UINT32 TableIndex;


ACPI_FUNCTION_TRACE (AcpiInstallTable);
Expand All @@ -401,14 +402,51 @@ AcpiInstallTable (
}

Status = AcpiTbVerifyAndInstallTable (Address, Flags,
FALSE, FALSE, &TableIndex);
FALSE, FALSE, OutIndex);

return_ACPI_STATUS (Status);
}

ACPI_EXPORT_SYMBOL_INIT (AcpiInstallTable)


/*******************************************************************************
*
* FUNCTION: AcpiUninstallTable
*
* PARAMETERS: TableIndex - Table index
*
* RETURN: None
*
* DESCRIPTION: Dynamically uninstall an ACPI table.
* Note: This function should only be invoked after
* AcpiInitializeTables() and before AcpiLoadTables().
*
******************************************************************************/

void
AcpiUninstallTable (
UINT32 TableIndex)
{

ACPI_FUNCTION_TRACE (AcpiUninstallTable);


/*
* This function can only be used during early stage, so the table mutex
* isn't required to be held.
*/
if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
{
AcpiTbUninstallTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
}

return_VOID;
}

ACPI_EXPORT_SYMBOL_INIT (AcpiUninstallTable)


/*******************************************************************************
*
* FUNCTION: AcpiLoadTable
Expand Down
8 changes: 7 additions & 1 deletion source/include/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,13 @@ ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
AcpiInstallTable (
ACPI_PHYSICAL_ADDRESS Address,
BOOLEAN Physical))
BOOLEAN Physical,
UINT32 *OutIndex))

ACPI_EXTERNAL_RETURN_VOID (
void
AcpiUninstallTable (
UINT32 TableIndex))

ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
Expand Down

0 comments on commit 8a0321d

Please sign in to comment.