Skip to content

Commit

Permalink
Tables: Add AcpiUnloadTable() to unload definition block tables
Browse files Browse the repository at this point in the history
This patch adds AcpiUnloadTable() API and adds parameter in
AcpiLoadTable() to be used for the new AcpiUnloadTable() API.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Apr 5, 2016
1 parent c16e132 commit b5fda3c
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 35 deletions.
2 changes: 1 addition & 1 deletion source/components/debugger/dbfileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ AcpiDbLoadTables (
{
Table = TableListHead->Table;

Status = AcpiLoadTable (Table);
Status = AcpiLoadTable (Table, NULL);
if (ACPI_FAILURE (Status))
{
if (Status == AE_ALREADY_EXISTS)
Expand Down
110 changes: 81 additions & 29 deletions source/components/tables/tbxfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ ACPI_EXPORT_SYMBOL_INIT (AcpiUninstallTable)
*
* PARAMETERS: Table - Pointer to a buffer containing the ACPI
* table to be loaded.
* OutTableIndex - Where the table index is returned
*
* RETURN: Status
*
Expand All @@ -465,7 +466,8 @@ ACPI_EXPORT_SYMBOL_INIT (AcpiUninstallTable)

ACPI_STATUS
AcpiLoadTable (
ACPI_TABLE_HEADER *Table)
ACPI_TABLE_HEADER *Table,
UINT32 *OutTableIndex)
{
ACPI_STATUS Status;
UINT32 TableIndex;
Expand All @@ -476,6 +478,10 @@ AcpiLoadTable (

/* Parameter validation */

if (OutTableIndex)
{
*OutTableIndex = ACPI_INVALID_TABLE_INDEX;
}
if (!Table)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
Expand Down Expand Up @@ -526,6 +532,10 @@ AcpiLoadTable (
}

UnlockAndExit:
if (OutTableIndex && ACPI_SUCCESS (Status))
{
*OutTableIndex = TableIndex;
}
(void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
return_ACPI_STATUS (Status);
}
Expand Down Expand Up @@ -612,42 +622,84 @@ AcpiUnloadParentTable (
break;
}

/* Ensure the table is actually loaded */
(void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
Status = AcpiUnloadTable (i);
(void) AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
break;
}

if (!AcpiTbIsTableLoaded (i))
{
Status = AE_NOT_EXIST;
break;
}
(void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
return_ACPI_STATUS (Status);
}

/* Invoke table handler if present */
ACPI_EXPORT_SYMBOL (AcpiUnloadParentTable)

if (AcpiGbl_TableHandler)
{
(void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD,
AcpiGbl_RootTableList.Tables[i].Pointer,
AcpiGbl_TableHandlerContext);
}

/*
* Delete all namespace objects owned by this table. Note that
* these objects can appear anywhere in the namespace by virtue
* of the AML "Scope" operator. Thus, we need to track ownership
* by an ID, not simply a position within the hierarchy.
*/
Status = AcpiTbDeleteNamespaceByOwner (i);
if (ACPI_FAILURE (Status))
{
break;
}
/*******************************************************************************
*
* FUNCTION: AcpiUnloadTable
*
* PARAMETERS: TableIndex - The table index
*
* RETURN: Status
*
* DESCRIPTION: Unload a definition block table.
*
******************************************************************************/

Status = AcpiTbReleaseOwnerId (i);
AcpiTbSetTableLoadedFlag (i, FALSE);
break;
ACPI_STATUS
AcpiUnloadTable (
UINT32 TableIndex)
{
ACPI_STATUS Status;


ACPI_FUNCTION_TRACE (AcpiUnloadTable);


/* Must acquire the interpreter lock during this operation */

Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}

/* Ensure the table is actually loaded */

if (!AcpiTbIsTableLoaded (TableIndex))
{
Status = AE_NOT_EXIST;
goto ErrorExit;
}

/* Invoke table handler if present */

if (AcpiGbl_TableHandler)
{
(void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD,
AcpiGbl_RootTableList.Tables[TableIndex].Pointer,
AcpiGbl_TableHandlerContext);
}

/*
* Delete all namespace objects owned by this table. Note that
* these objects can appear anywhere in the namespace by virtue
* of the AML "Scope" operator. Thus, we need to track ownership
* by an ID, not simply a position within the hierarchy.
*/
Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}

Status = AcpiTbReleaseOwnerId (TableIndex);
AcpiTbSetTableLoadedFlag (TableIndex, FALSE);

ErrorExit:
(void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
return_ACPI_STATUS (Status);
}

ACPI_EXPORT_SYMBOL (AcpiUnloadParentTable)
ACPI_EXPORT_SYMBOL (AcpiUnloadTable)
8 changes: 7 additions & 1 deletion source/include/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,13 @@ AcpiUninstallTable (
ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
AcpiLoadTable (
ACPI_TABLE_HEADER *Table))
ACPI_TABLE_HEADER *Table,
UINT32 *OutTableIndex))

ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
AcpiUnloadTable (
UINT32 TableInde))

ACPI_EXTERNAL_RETURN_STATUS (
ACPI_STATUS
Expand Down
8 changes: 4 additions & 4 deletions source/tools/acpiexec/aeexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ AeMiscellaneousTests (

/* Load and unload SSDT4 */

Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code, NULL);
ACPI_CHECK_OK (AcpiLoadTable, Status);

Status = AcpiGetHandle (NULL, "\\_T96", &Handle);
Expand All @@ -715,7 +715,7 @@ AeMiscellaneousTests (

/* Re-load SSDT4 */

Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code, NULL);
ACPI_CHECK_OK (AcpiLoadTable, Status);

/* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */
Expand All @@ -726,12 +726,12 @@ AeMiscellaneousTests (
Status = AcpiUnloadParentTable (Handle);
ACPI_CHECK_OK (AcpiUnloadParentTable, Status);

Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code);
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code, NULL);
ACPI_CHECK_OK (AcpiLoadTable, Status);

/* Load OEM9 table (causes table override) */

Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code);
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code, NULL);
ACPI_CHECK_OK (AcpiLoadTable, Status);
}

Expand Down

0 comments on commit b5fda3c

Please sign in to comment.