167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: tbinstal - ACPI table installation and removal
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
7217365Sjkim/*
8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp.
970243Smsmith * All rights reserved.
1067754Smsmith *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
2567754Smsmith *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
2967754Smsmith *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
4367754Smsmith
44193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
45193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
46193341Sjkim#include <contrib/dev/acpica/include/actables.h>
4767754Smsmith
4877424Smsmith#define _COMPONENT          ACPI_TABLES
4991116Smsmith        ACPI_MODULE_NAME    ("tbinstal")
5067754Smsmith
51281075Sdim/* Local prototypes */
5267754Smsmith
53281075Sdimstatic BOOLEAN
54281075SdimAcpiTbCompareTables (
55281075Sdim    ACPI_TABLE_DESC         *TableDesc,
56281075Sdim    UINT32                  TableIndex);
57281075Sdim
58281075Sdim
59281075Sdim/*******************************************************************************
6067754Smsmith *
61281075Sdim * FUNCTION:    AcpiTbCompareTables
6291116Smsmith *
63281075Sdim * PARAMETERS:  TableDesc           - Table 1 descriptor to be compared
64281075Sdim *              TableIndex          - Index of table 2 to be compared
6591116Smsmith *
66281075Sdim * RETURN:      TRUE if both tables are identical.
6791116Smsmith *
68281075Sdim * DESCRIPTION: This function compares a table with another table that has
69281075Sdim *              already been installed in the root table list.
7091116Smsmith *
71281075Sdim ******************************************************************************/
7291116Smsmith
73281075Sdimstatic BOOLEAN
74281075SdimAcpiTbCompareTables (
75281075Sdim    ACPI_TABLE_DESC         *TableDesc,
76281075Sdim    UINT32                  TableIndex)
7791116Smsmith{
78167802Sjkim    ACPI_STATUS             Status = AE_OK;
79281075Sdim    BOOLEAN                 IsIdentical;
80281075Sdim    ACPI_TABLE_HEADER       *Table;
81281075Sdim    UINT32                  TableLength;
82281075Sdim    UINT8                   TableFlags;
8391116Smsmith
8491116Smsmith
85281075Sdim    Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex],
86306536Sjkim        &Table, &TableLength, &TableFlags);
87281075Sdim    if (ACPI_FAILURE (Status))
8891116Smsmith    {
89281075Sdim        return (FALSE);
90167802Sjkim    }
9191116Smsmith
92281075Sdim    /*
93281075Sdim     * Check for a table match on the entire table length,
94281075Sdim     * not just the header.
95281075Sdim     */
96281075Sdim    IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength ||
97306536Sjkim        memcmp (TableDesc->Pointer, Table, TableLength)) ?
98281075Sdim        FALSE : TRUE);
9991116Smsmith
100281075Sdim    /* Release the acquired table */
10191116Smsmith
102281075Sdim    AcpiTbReleaseTable (Table, TableLength, TableFlags);
103281075Sdim    return (IsIdentical);
10491116Smsmith}
10591116Smsmith
10691116Smsmith
10791116Smsmith/*******************************************************************************
10891116Smsmith *
109281075Sdim * FUNCTION:    AcpiTbInstallTableWithOverride
11067754Smsmith *
111306536Sjkim * PARAMETERS:  NewTableDesc            - New table descriptor to install
112281075Sdim *              Override                - Whether override should be performed
113306536Sjkim *              TableIndex              - Where the table index is returned
11467754Smsmith *
115281075Sdim * RETURN:      None
11667754Smsmith *
117281075Sdim * DESCRIPTION: Install an ACPI table into the global data structure. The
118281075Sdim *              table override mechanism is called to allow the host
119281075Sdim *              OS to replace any table before it is installed in the root
120281075Sdim *              table array.
12167754Smsmith *
12267754Smsmith ******************************************************************************/
12367754Smsmith
124281075Sdimvoid
125281075SdimAcpiTbInstallTableWithOverride (
126281075Sdim    ACPI_TABLE_DESC         *NewTableDesc,
127306536Sjkim    BOOLEAN                 Override,
128306536Sjkim    UINT32                  *TableIndex)
12967754Smsmith{
130306536Sjkim    UINT32                  i;
131306536Sjkim    ACPI_STATUS             Status;
13267754Smsmith
133306536Sjkim
134306536Sjkim    Status = AcpiTbGetNextTableDescriptor (&i, NULL);
135306536Sjkim    if (ACPI_FAILURE (Status))
136167802Sjkim    {
137281075Sdim        return;
138167802Sjkim    }
13967754Smsmith
140193267Sjkim    /*
141281075Sdim     * ACPI Table Override:
142222544Sjkim     *
143281075Sdim     * Before we install the table, let the host OS override it with a new
144281075Sdim     * one if desired. Any table within the RSDT/XSDT can be replaced,
145281075Sdim     * including the DSDT which is pointed to by the FADT.
146193267Sjkim     */
147281075Sdim    if (Override)
148222544Sjkim    {
149281075Sdim        AcpiTbOverrideTable (NewTableDesc);
150222544Sjkim    }
151222544Sjkim
152306536Sjkim    AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[i],
153281075Sdim        NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer);
154167802Sjkim
155281075Sdim    AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer);
156167802Sjkim
157306536Sjkim    /* This synchronizes AcpiGbl_DsdtIndex */
158306536Sjkim
159306536Sjkim    *TableIndex = i;
160306536Sjkim
161281075Sdim    /* Set the global integer width (based upon revision of the DSDT) */
162167802Sjkim
163306536Sjkim    if (i == AcpiGbl_DsdtIndex)
164100966Siwasaki    {
165281075Sdim        AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision);
166100966Siwasaki    }
16767754Smsmith}
16867754Smsmith
16967754Smsmith
17067754Smsmith/*******************************************************************************
17167754Smsmith *
172281075Sdim * FUNCTION:    AcpiTbInstallFixedTable
173231844Sjkim *
174281075Sdim * PARAMETERS:  Address                 - Physical address of DSDT or FACS
175281075Sdim *              Signature               - Table signature, NULL if no need to
176281075Sdim *                                        match
177306536Sjkim *              TableIndex              - Where the table index is returned
178231844Sjkim *
179281075Sdim * RETURN:      Status
180231844Sjkim *
181281075Sdim * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data
182281075Sdim *              structure.
183231844Sjkim *
184231844Sjkim ******************************************************************************/
185231844Sjkim
186281075SdimACPI_STATUS
187281075SdimAcpiTbInstallFixedTable (
188281075Sdim    ACPI_PHYSICAL_ADDRESS   Address,
189281075Sdim    char                    *Signature,
190306536Sjkim    UINT32                  *TableIndex)
191231844Sjkim{
192281075Sdim    ACPI_TABLE_DESC         NewTableDesc;
193231844Sjkim    ACPI_STATUS             Status;
194231844Sjkim
195231844Sjkim
196281075Sdim    ACPI_FUNCTION_TRACE (TbInstallFixedTable);
197231844Sjkim
198281075Sdim
199281075Sdim    if (!Address)
200231844Sjkim    {
201281075Sdim        ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
202281075Sdim            Signature));
203281075Sdim        return (AE_NO_MEMORY);
204231844Sjkim    }
205231844Sjkim
206281075Sdim    /* Fill a table descriptor for validation */
207231844Sjkim
208281075Sdim    Status = AcpiTbAcquireTempTable (&NewTableDesc, Address,
209306536Sjkim        ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
210281075Sdim    if (ACPI_FAILURE (Status))
211231844Sjkim    {
212281687Sjkim        ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X",
213281687Sjkim            ACPI_FORMAT_UINT64 (Address)));
214281075Sdim        return_ACPI_STATUS (Status);
215281075Sdim    }
216231844Sjkim
217281075Sdim    /* Validate and verify a table before installation */
218231844Sjkim
219281075Sdim    Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature);
220281075Sdim    if (ACPI_FAILURE (Status))
221281075Sdim    {
222281075Sdim        goto ReleaseAndExit;
223231844Sjkim    }
224231844Sjkim
225306536Sjkim    /* Add the table to the global root table list */
226231844Sjkim
227306536Sjkim    AcpiTbInstallTableWithOverride (&NewTableDesc, TRUE, TableIndex);
228306536Sjkim
229281075SdimReleaseAndExit:
230231844Sjkim
231281075Sdim    /* Release the temporary table descriptor */
232231844Sjkim
233281075Sdim    AcpiTbReleaseTempTable (&NewTableDesc);
234281075Sdim    return_ACPI_STATUS (Status);
235231844Sjkim}
236231844Sjkim
237231844Sjkim
238231844Sjkim/*******************************************************************************
239231844Sjkim *
240281075Sdim * FUNCTION:    AcpiTbInstallStandardTable
24167754Smsmith *
242281075Sdim * PARAMETERS:  Address             - Address of the table (might be a virtual
243281075Sdim *                                    address depending on the TableFlags)
244281075Sdim *              Flags               - Flags for the table
245281075Sdim *              Reload              - Whether reload should be performed
246281075Sdim *              Override            - Whether override should be performed
247281075Sdim *              TableIndex          - Where the table index is returned
24867754Smsmith *
24967754Smsmith * RETURN:      Status
25067754Smsmith *
251281075Sdim * DESCRIPTION: This function is called to install an ACPI table that is
252281075Sdim *              neither DSDT nor FACS (a "standard" table.)
253281075Sdim *              When this function is called by "Load" or "LoadTable" opcodes,
254281075Sdim *              or by AcpiLoadTable() API, the "Reload" parameter is set.
255281075Sdim *              After sucessfully returning from this function, table is
256281075Sdim *              "INSTALLED" but not "VALIDATED".
25767754Smsmith *
25867754Smsmith ******************************************************************************/
25967754Smsmith
26067754SmsmithACPI_STATUS
261281075SdimAcpiTbInstallStandardTable (
262281075Sdim    ACPI_PHYSICAL_ADDRESS   Address,
263281075Sdim    UINT8                   Flags,
264281075Sdim    BOOLEAN                 Reload,
265281075Sdim    BOOLEAN                 Override,
266281075Sdim    UINT32                  *TableIndex)
26767754Smsmith{
268281075Sdim    UINT32                  i;
269281075Sdim    ACPI_STATUS             Status = AE_OK;
270281075Sdim    ACPI_TABLE_DESC         NewTableDesc;
27167754Smsmith
27267754Smsmith
273281075Sdim    ACPI_FUNCTION_TRACE (TbInstallStandardTable);
27467754Smsmith
27567754Smsmith
276281075Sdim    /* Acquire a temporary table descriptor for validation */
27767754Smsmith
278281075Sdim    Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags);
279281075Sdim    if (ACPI_FAILURE (Status))
28067754Smsmith    {
281306536Sjkim        ACPI_ERROR ((AE_INFO,
282306536Sjkim            "Could not acquire table length at %8.8X%8.8X",
283281687Sjkim            ACPI_FORMAT_UINT64 (Address)));
284281075Sdim        return_ACPI_STATUS (Status);
28567754Smsmith    }
28667754Smsmith
287281075Sdim    /*
288281075Sdim     * Optionally do not load any SSDTs from the RSDT/XSDT. This can
289281075Sdim     * be useful for debugging ACPI problems on some machines.
290281075Sdim     */
291281075Sdim    if (!Reload &&
292281075Sdim        AcpiGbl_DisableSsdtTableInstall &&
293281075Sdim        ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT))
294240716Sjkim    {
295306536Sjkim        ACPI_INFO ((
296306536Sjkim            "Ignoring installation of %4.4s at %8.8X%8.8X",
297281687Sjkim            NewTableDesc.Signature.Ascii, ACPI_FORMAT_UINT64 (Address)));
298281075Sdim        goto ReleaseAndExit;
299240716Sjkim    }
300240716Sjkim
301281075Sdim    /* Validate and verify a table before installation */
302281075Sdim
303281075Sdim    Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
304281075Sdim    if (ACPI_FAILURE (Status))
30567754Smsmith    {
306281075Sdim        goto ReleaseAndExit;
30799146Siwasaki    }
30891116Smsmith
309281075Sdim    if (Reload)
31099146Siwasaki    {
311281075Sdim        /*
312281075Sdim         * Validate the incoming table signature.
313281075Sdim         *
314281075Sdim         * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
315281075Sdim         * 2) We added support for OEMx tables, signature "OEM".
316281075Sdim         * 3) Valid tables were encountered with a null signature, so we just
317281075Sdim         *    gave up on validating the signature, (05/2008).
318281075Sdim         * 4) We encountered non-AML tables such as the MADT, which caused
319281075Sdim         *    interpreter errors and kernel faults. So now, we once again allow
320281075Sdim         *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
321281075Sdim         */
322281075Sdim        if ((NewTableDesc.Signature.Ascii[0] != 0x00) &&
323281075Sdim           (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) &&
324306536Sjkim           (strncmp (NewTableDesc.Signature.Ascii, "OEM", 3)))
325281075Sdim        {
326281075Sdim            ACPI_BIOS_ERROR ((AE_INFO,
327281075Sdim                "Table has invalid signature [%4.4s] (0x%8.8X), "
328281075Sdim                "must be SSDT or OEMx",
329306536Sjkim                AcpiUtValidNameseg (NewTableDesc.Signature.Ascii) ?
330281075Sdim                    NewTableDesc.Signature.Ascii : "????",
331281075Sdim                NewTableDesc.Signature.Integer));
332167802Sjkim
333281075Sdim            Status = AE_BAD_SIGNATURE;
334281075Sdim            goto ReleaseAndExit;
335167802Sjkim        }
33691116Smsmith
337281075Sdim        /* Check if table is already registered */
33899146Siwasaki
339281075Sdim        for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
340281075Sdim        {
341281075Sdim            /*
342281075Sdim             * Check for a table match on the entire table length,
343281075Sdim             * not just the header.
344281075Sdim             */
345281075Sdim            if (!AcpiTbCompareTables (&NewTableDesc, i))
346281075Sdim            {
347281075Sdim                continue;
348281075Sdim            }
34967754Smsmith
350281075Sdim            /*
351281075Sdim             * Note: the current mechanism does not unregister a table if it is
352281075Sdim             * dynamically unloaded. The related namespace entries are deleted,
353281075Sdim             * but the table remains in the root table list.
354281075Sdim             *
355281075Sdim             * The assumption here is that the number of different tables that
356281075Sdim             * will be loaded is actually small, and there is minimal overhead
357281075Sdim             * in just keeping the table in case it is needed again.
358281075Sdim             *
359281075Sdim             * If this assumption changes in the future (perhaps on large
360281075Sdim             * machines with many table load/unload operations), tables will
361281075Sdim             * need to be unregistered when they are unloaded, and slots in the
362281075Sdim             * root table list should be reused when empty.
363281075Sdim             */
364306536Sjkim            if (AcpiGbl_RootTableList.Tables[i].Flags &
365306536Sjkim                ACPI_TABLE_IS_LOADED)
366281075Sdim            {
367281075Sdim                /* Table is still loaded, this is an error */
36867754Smsmith
369281075Sdim                Status = AE_ALREADY_EXISTS;
370281075Sdim                goto ReleaseAndExit;
371281075Sdim            }
372281075Sdim            else
373281075Sdim            {
374281075Sdim                /*
375281075Sdim                 * Table was unloaded, allow it to be reloaded.
376281075Sdim                 * As we are going to return AE_OK to the caller, we should
377281075Sdim                 * take the responsibility of freeing the input descriptor.
378281075Sdim                 * Refill the input descriptor to ensure
379281075Sdim                 * AcpiTbInstallTableWithOverride() can be called again to
380281075Sdim                 * indicate the re-installation.
381281075Sdim                 */
382281075Sdim                AcpiTbUninstallTable (&NewTableDesc);
383281075Sdim                *TableIndex = i;
384281075Sdim                return_ACPI_STATUS (AE_OK);
385281075Sdim            }
386167802Sjkim        }
387117521Snjl    }
388117521Snjl
389281075Sdim    /* Add the table to the global root table list */
390207344Sjkim
391306536Sjkim    AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex);
39267754Smsmith
393281075SdimReleaseAndExit:
39467754Smsmith
395281075Sdim    /* Release the temporary table descriptor */
396250838Sjkim
397281075Sdim    AcpiTbReleaseTempTable (&NewTableDesc);
398281075Sdim    return_ACPI_STATUS (Status);
39967754Smsmith}
40067754Smsmith
40167754Smsmith
40267754Smsmith/*******************************************************************************
40367754Smsmith *
404281075Sdim * FUNCTION:    AcpiTbOverrideTable
40567754Smsmith *
406281075Sdim * PARAMETERS:  OldTableDesc        - Validated table descriptor to be
407281075Sdim *                                    overridden
40867754Smsmith *
409167802Sjkim * RETURN:      None
41067754Smsmith *
411281075Sdim * DESCRIPTION: Attempt table override by calling the OSL override functions.
412281075Sdim *              Note: If the table is overridden, then the entire new table
413281075Sdim *              is acquired and returned by this function.
414281075Sdim *              Before/after invocation, the table descriptor is in a state
415281075Sdim *              that is "VALIDATED".
41667754Smsmith *
41767754Smsmith ******************************************************************************/
41867754Smsmith
41967754Smsmithvoid
420281075SdimAcpiTbOverrideTable (
421281075Sdim    ACPI_TABLE_DESC         *OldTableDesc)
42267754Smsmith{
423281075Sdim    ACPI_STATUS             Status;
424281075Sdim    char                    *OverrideType;
425281075Sdim    ACPI_TABLE_DESC         NewTableDesc;
426281075Sdim    ACPI_TABLE_HEADER       *Table;
427281075Sdim    ACPI_PHYSICAL_ADDRESS   Address;
428281075Sdim    UINT32                  Length;
42967754Smsmith
43067754Smsmith
431281075Sdim    /* (1) Attempt logical override (returns a logical address) */
432167802Sjkim
433281075Sdim    Status = AcpiOsTableOverride (OldTableDesc->Pointer, &Table);
434281075Sdim    if (ACPI_SUCCESS (Status) && Table)
435167802Sjkim    {
436281075Sdim        AcpiTbAcquireTempTable (&NewTableDesc, ACPI_PTR_TO_PHYSADDR (Table),
437281075Sdim            ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL);
438281075Sdim        OverrideType = "Logical";
439281075Sdim        goto FinishOverride;
440167802Sjkim    }
441167802Sjkim
442281075Sdim    /* (2) Attempt physical override (returns a physical address) */
443281075Sdim
444281075Sdim    Status = AcpiOsPhysicalTableOverride (OldTableDesc->Pointer,
445281075Sdim        &Address, &Length);
446281075Sdim    if (ACPI_SUCCESS (Status) && Address && Length)
44767754Smsmith    {
448281075Sdim        AcpiTbAcquireTempTable (&NewTableDesc, Address,
449281075Sdim            ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
450281075Sdim        OverrideType = "Physical";
451281075Sdim        goto FinishOverride;
45267754Smsmith    }
453167802Sjkim
454281075Sdim    return; /* There was no override */
455167802Sjkim
456241973Sjkim
457281075SdimFinishOverride:
45867754Smsmith
459281075Sdim    /* Validate and verify a table before overriding */
46067754Smsmith
461281075Sdim    Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
462193267Sjkim    if (ACPI_FAILURE (Status))
46367754Smsmith    {
464281075Sdim        return;
46567754Smsmith    }
466193267Sjkim
467306536Sjkim    ACPI_INFO (("%4.4s 0x%8.8X%8.8X"
468281687Sjkim        " %s table override, new table: 0x%8.8X%8.8X",
469281075Sdim        OldTableDesc->Signature.Ascii,
470281687Sjkim        ACPI_FORMAT_UINT64 (OldTableDesc->Address),
471281687Sjkim        OverrideType, ACPI_FORMAT_UINT64 (NewTableDesc.Address)));
472193267Sjkim
473281075Sdim    /* We can now uninstall the original table */
47467754Smsmith
475281075Sdim    AcpiTbUninstallTable (OldTableDesc);
476193267Sjkim
477193267Sjkim    /*
478281075Sdim     * Replace the original table descriptor and keep its state as
479281075Sdim     * "VALIDATED".
480193267Sjkim     */
481281075Sdim    AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address,
482281075Sdim        NewTableDesc.Flags, NewTableDesc.Pointer);
483281075Sdim    AcpiTbValidateTempTable (OldTableDesc);
484193267Sjkim
485281075Sdim    /* Release the temporary table descriptor */
486193267Sjkim
487281075Sdim    AcpiTbReleaseTempTable (&NewTableDesc);
488167802Sjkim}
48967754Smsmith
49067754Smsmith
491167802Sjkim/*******************************************************************************
492167802Sjkim *
493281075Sdim * FUNCTION:    AcpiTbUninstallTable
49467754Smsmith *
495281075Sdim * PARAMETERS:  TableDesc           - Table descriptor
49667754Smsmith *
497281075Sdim * RETURN:      None
49867754Smsmith *
499281075Sdim * DESCRIPTION: Delete one internal ACPI table
50067754Smsmith *
50167754Smsmith ******************************************************************************/
50267754Smsmith
503281075Sdimvoid
504281075SdimAcpiTbUninstallTable (
505281075Sdim    ACPI_TABLE_DESC         *TableDesc)
50667754Smsmith{
50767754Smsmith
508281075Sdim    ACPI_FUNCTION_TRACE (TbUninstallTable);
50967754Smsmith
51067754Smsmith
511281075Sdim    /* Table must be installed */
51267754Smsmith
513281075Sdim    if (!TableDesc->Address)
51467754Smsmith    {
515281075Sdim        return_VOID;
51667754Smsmith    }
51767754Smsmith
518281075Sdim    AcpiTbInvalidateTable (TableDesc);
51967754Smsmith
520281075Sdim    if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
521281075Sdim        ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL)
52267754Smsmith    {
523281687Sjkim        ACPI_FREE (ACPI_PHYSADDR_TO_PTR (TableDesc->Address));
52467754Smsmith    }
52567754Smsmith
526281075Sdim    TableDesc->Address = ACPI_PTR_TO_PHYSADDR (NULL);
527281075Sdim    return_VOID;
528167802Sjkim}
529