Home | History | Annotate | Line # | Download | only in tables
tbinstal.c revision 1.8
      1  1.1    jruoho /******************************************************************************
      2  1.1    jruoho  *
      3  1.1    jruoho  * Module Name: tbinstal - ACPI table installation and removal
      4  1.1    jruoho  *
      5  1.1    jruoho  *****************************************************************************/
      6  1.1    jruoho 
      7  1.2  christos /*
      8  1.7  christos  * Copyright (C) 2000 - 2016, Intel Corp.
      9  1.1    jruoho  * All rights reserved.
     10  1.1    jruoho  *
     11  1.2  christos  * Redistribution and use in source and binary forms, with or without
     12  1.2  christos  * modification, are permitted provided that the following conditions
     13  1.2  christos  * are met:
     14  1.2  christos  * 1. Redistributions of source code must retain the above copyright
     15  1.2  christos  *    notice, this list of conditions, and the following disclaimer,
     16  1.2  christos  *    without modification.
     17  1.2  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.2  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.2  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.2  christos  *    including a substantially similar Disclaimer requirement for further
     21  1.2  christos  *    binary redistribution.
     22  1.2  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.2  christos  *    of any contributors may be used to endorse or promote products derived
     24  1.2  christos  *    from this software without specific prior written permission.
     25  1.2  christos  *
     26  1.2  christos  * Alternatively, this software may be distributed under the terms of the
     27  1.2  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.2  christos  * Software Foundation.
     29  1.2  christos  *
     30  1.2  christos  * NO WARRANTY
     31  1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.2  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.2  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.2  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.2  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.2  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.2  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.2  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.2  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.2  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.2  christos  * POSSIBILITY OF SUCH DAMAGES.
     42  1.2  christos  */
     43  1.1    jruoho 
     44  1.1    jruoho #include "acpi.h"
     45  1.1    jruoho #include "accommon.h"
     46  1.1    jruoho #include "actables.h"
     47  1.1    jruoho 
     48  1.1    jruoho #define _COMPONENT          ACPI_TABLES
     49  1.1    jruoho         ACPI_MODULE_NAME    ("tbinstal")
     50  1.1    jruoho 
     51  1.3  christos /* Local prototypes */
     52  1.3  christos 
     53  1.3  christos static BOOLEAN
     54  1.3  christos AcpiTbCompareTables (
     55  1.3  christos     ACPI_TABLE_DESC         *TableDesc,
     56  1.3  christos     UINT32                  TableIndex);
     57  1.3  christos 
     58  1.1    jruoho 
     59  1.3  christos /*******************************************************************************
     60  1.1    jruoho  *
     61  1.3  christos  * FUNCTION:    AcpiTbCompareTables
     62  1.1    jruoho  *
     63  1.3  christos  * PARAMETERS:  TableDesc           - Table 1 descriptor to be compared
     64  1.3  christos  *              TableIndex          - Index of table 2 to be compared
     65  1.1    jruoho  *
     66  1.3  christos  * RETURN:      TRUE if both tables are identical.
     67  1.1    jruoho  *
     68  1.3  christos  * DESCRIPTION: This function compares a table with another table that has
     69  1.3  christos  *              already been installed in the root table list.
     70  1.1    jruoho  *
     71  1.3  christos  ******************************************************************************/
     72  1.1    jruoho 
     73  1.3  christos static BOOLEAN
     74  1.3  christos AcpiTbCompareTables (
     75  1.3  christos     ACPI_TABLE_DESC         *TableDesc,
     76  1.3  christos     UINT32                  TableIndex)
     77  1.1    jruoho {
     78  1.1    jruoho     ACPI_STATUS             Status = AE_OK;
     79  1.3  christos     BOOLEAN                 IsIdentical;
     80  1.3  christos     ACPI_TABLE_HEADER       *Table;
     81  1.3  christos     UINT32                  TableLength;
     82  1.3  christos     UINT8                   TableFlags;
     83  1.1    jruoho 
     84  1.1    jruoho 
     85  1.3  christos     Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex],
     86  1.7  christos         &Table, &TableLength, &TableFlags);
     87  1.3  christos     if (ACPI_FAILURE (Status))
     88  1.1    jruoho     {
     89  1.3  christos         return (FALSE);
     90  1.1    jruoho     }
     91  1.1    jruoho 
     92  1.3  christos     /*
     93  1.3  christos      * Check for a table match on the entire table length,
     94  1.3  christos      * not just the header.
     95  1.3  christos      */
     96  1.3  christos     IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength ||
     97  1.6  christos         memcmp (TableDesc->Pointer, Table, TableLength)) ?
     98  1.3  christos         FALSE : TRUE);
     99  1.1    jruoho 
    100  1.3  christos     /* Release the acquired table */
    101  1.1    jruoho 
    102  1.3  christos     AcpiTbReleaseTable (Table, TableLength, TableFlags);
    103  1.3  christos     return (IsIdentical);
    104  1.1    jruoho }
    105  1.1    jruoho 
    106  1.1    jruoho 
    107  1.1    jruoho /*******************************************************************************
    108  1.1    jruoho  *
    109  1.3  christos  * FUNCTION:    AcpiTbInstallTableWithOverride
    110  1.1    jruoho  *
    111  1.7  christos  * PARAMETERS:  NewTableDesc            - New table descriptor to install
    112  1.3  christos  *              Override                - Whether override should be performed
    113  1.7  christos  *              TableIndex              - Where the table index is returned
    114  1.1    jruoho  *
    115  1.3  christos  * RETURN:      None
    116  1.1    jruoho  *
    117  1.3  christos  * DESCRIPTION: Install an ACPI table into the global data structure. The
    118  1.3  christos  *              table override mechanism is called to allow the host
    119  1.3  christos  *              OS to replace any table before it is installed in the root
    120  1.3  christos  *              table array.
    121  1.1    jruoho  *
    122  1.1    jruoho  ******************************************************************************/
    123  1.1    jruoho 
    124  1.3  christos void
    125  1.3  christos AcpiTbInstallTableWithOverride (
    126  1.3  christos     ACPI_TABLE_DESC         *NewTableDesc,
    127  1.7  christos     BOOLEAN                 Override,
    128  1.7  christos     UINT32                  *TableIndex)
    129  1.1    jruoho {
    130  1.7  christos     UINT32                  i;
    131  1.7  christos     ACPI_STATUS             Status;
    132  1.7  christos 
    133  1.1    jruoho 
    134  1.7  christos     Status = AcpiTbGetNextTableDescriptor (&i, NULL);
    135  1.7  christos     if (ACPI_FAILURE (Status))
    136  1.1    jruoho     {
    137  1.3  christos         return;
    138  1.1    jruoho     }
    139  1.1    jruoho 
    140  1.1    jruoho     /*
    141  1.3  christos      * ACPI Table Override:
    142  1.2  christos      *
    143  1.3  christos      * Before we install the table, let the host OS override it with a new
    144  1.3  christos      * one if desired. Any table within the RSDT/XSDT can be replaced,
    145  1.3  christos      * including the DSDT which is pointed to by the FADT.
    146  1.1    jruoho      */
    147  1.3  christos     if (Override)
    148  1.2  christos     {
    149  1.3  christos         AcpiTbOverrideTable (NewTableDesc);
    150  1.2  christos     }
    151  1.1    jruoho 
    152  1.7  christos     AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[i],
    153  1.3  christos         NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer);
    154  1.1    jruoho 
    155  1.3  christos     AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer);
    156  1.1    jruoho 
    157  1.7  christos     /* This synchronizes AcpiGbl_DsdtIndex */
    158  1.7  christos 
    159  1.7  christos     *TableIndex = i;
    160  1.7  christos 
    161  1.3  christos     /* Set the global integer width (based upon revision of the DSDT) */
    162  1.1    jruoho 
    163  1.7  christos     if (i == AcpiGbl_DsdtIndex)
    164  1.1    jruoho     {
    165  1.3  christos         AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision);
    166  1.1    jruoho     }
    167  1.1    jruoho }
    168  1.1    jruoho 
    169  1.1    jruoho 
    170  1.1    jruoho /*******************************************************************************
    171  1.1    jruoho  *
    172  1.3  christos  * FUNCTION:    AcpiTbInstallFixedTable
    173  1.2  christos  *
    174  1.3  christos  * PARAMETERS:  Address                 - Physical address of DSDT or FACS
    175  1.3  christos  *              Signature               - Table signature, NULL if no need to
    176  1.3  christos  *                                        match
    177  1.7  christos  *              TableIndex              - Where the table index is returned
    178  1.3  christos  *
    179  1.3  christos  * RETURN:      Status
    180  1.2  christos  *
    181  1.3  christos  * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data
    182  1.3  christos  *              structure.
    183  1.2  christos  *
    184  1.2  christos  ******************************************************************************/
    185  1.2  christos 
    186  1.3  christos ACPI_STATUS
    187  1.3  christos AcpiTbInstallFixedTable (
    188  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address,
    189  1.3  christos     const char              *Signature,
    190  1.7  christos     UINT32                  *TableIndex)
    191  1.2  christos {
    192  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    193  1.2  christos     ACPI_STATUS             Status;
    194  1.2  christos 
    195  1.2  christos 
    196  1.3  christos     ACPI_FUNCTION_TRACE (TbInstallFixedTable);
    197  1.3  christos 
    198  1.2  christos 
    199  1.3  christos     if (!Address)
    200  1.2  christos     {
    201  1.3  christos         ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
    202  1.3  christos             Signature));
    203  1.3  christos         return (AE_NO_MEMORY);
    204  1.2  christos     }
    205  1.2  christos 
    206  1.3  christos     /* Fill a table descriptor for validation */
    207  1.2  christos 
    208  1.3  christos     Status = AcpiTbAcquireTempTable (&NewTableDesc, Address,
    209  1.7  christos         ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
    210  1.3  christos     if (ACPI_FAILURE (Status))
    211  1.2  christos     {
    212  1.4  christos         ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X",
    213  1.4  christos             ACPI_FORMAT_UINT64 (Address)));
    214  1.3  christos         return_ACPI_STATUS (Status);
    215  1.3  christos     }
    216  1.2  christos 
    217  1.3  christos     /* Validate and verify a table before installation */
    218  1.2  christos 
    219  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature);
    220  1.3  christos     if (ACPI_FAILURE (Status))
    221  1.3  christos     {
    222  1.3  christos         goto ReleaseAndExit;
    223  1.2  christos     }
    224  1.2  christos 
    225  1.7  christos     /* Add the table to the global root table list */
    226  1.7  christos 
    227  1.7  christos     AcpiTbInstallTableWithOverride (&NewTableDesc, TRUE, TableIndex);
    228  1.2  christos 
    229  1.3  christos ReleaseAndExit:
    230  1.2  christos 
    231  1.3  christos     /* Release the temporary table descriptor */
    232  1.2  christos 
    233  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    234  1.3  christos     return_ACPI_STATUS (Status);
    235  1.2  christos }
    236  1.2  christos 
    237  1.2  christos 
    238  1.2  christos /*******************************************************************************
    239  1.2  christos  *
    240  1.3  christos  * FUNCTION:    AcpiTbInstallStandardTable
    241  1.1    jruoho  *
    242  1.3  christos  * PARAMETERS:  Address             - Address of the table (might be a virtual
    243  1.3  christos  *                                    address depending on the TableFlags)
    244  1.3  christos  *              Flags               - Flags for the table
    245  1.3  christos  *              Reload              - Whether reload should be performed
    246  1.3  christos  *              Override            - Whether override should be performed
    247  1.3  christos  *              TableIndex          - Where the table index is returned
    248  1.1    jruoho  *
    249  1.1    jruoho  * RETURN:      Status
    250  1.1    jruoho  *
    251  1.3  christos  * DESCRIPTION: This function is called to install an ACPI table that is
    252  1.3  christos  *              neither DSDT nor FACS (a "standard" table.)
    253  1.3  christos  *              When this function is called by "Load" or "LoadTable" opcodes,
    254  1.3  christos  *              or by AcpiLoadTable() API, the "Reload" parameter is set.
    255  1.3  christos  *              After sucessfully returning from this function, table is
    256  1.3  christos  *              "INSTALLED" but not "VALIDATED".
    257  1.1    jruoho  *
    258  1.1    jruoho  ******************************************************************************/
    259  1.1    jruoho 
    260  1.1    jruoho ACPI_STATUS
    261  1.3  christos AcpiTbInstallStandardTable (
    262  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address,
    263  1.3  christos     UINT8                   Flags,
    264  1.3  christos     BOOLEAN                 Reload,
    265  1.3  christos     BOOLEAN                 Override,
    266  1.3  christos     UINT32                  *TableIndex)
    267  1.1    jruoho {
    268  1.3  christos     UINT32                  i;
    269  1.3  christos     ACPI_STATUS             Status = AE_OK;
    270  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    271  1.1    jruoho 
    272  1.1    jruoho 
    273  1.3  christos     ACPI_FUNCTION_TRACE (TbInstallStandardTable);
    274  1.1    jruoho 
    275  1.1    jruoho 
    276  1.3  christos     /* Acquire a temporary table descriptor for validation */
    277  1.1    jruoho 
    278  1.3  christos     Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags);
    279  1.3  christos     if (ACPI_FAILURE (Status))
    280  1.1    jruoho     {
    281  1.7  christos         ACPI_ERROR ((AE_INFO,
    282  1.7  christos             "Could not acquire table length at %8.8X%8.8X",
    283  1.4  christos             ACPI_FORMAT_UINT64 (Address)));
    284  1.3  christos         return_ACPI_STATUS (Status);
    285  1.1    jruoho     }
    286  1.1    jruoho 
    287  1.3  christos     /*
    288  1.3  christos      * Optionally do not load any SSDTs from the RSDT/XSDT. This can
    289  1.3  christos      * be useful for debugging ACPI problems on some machines.
    290  1.3  christos      */
    291  1.3  christos     if (!Reload &&
    292  1.3  christos         AcpiGbl_DisableSsdtTableInstall &&
    293  1.3  christos         ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT))
    294  1.2  christos     {
    295  1.8  christos         ACPI_INFO ((
    296  1.7  christos             "Ignoring installation of %4.4s at %8.8X%8.8X",
    297  1.4  christos             NewTableDesc.Signature.Ascii, ACPI_FORMAT_UINT64 (Address)));
    298  1.3  christos         goto ReleaseAndExit;
    299  1.2  christos     }
    300  1.3  christos 
    301  1.3  christos     /* Validate and verify a table before installation */
    302  1.3  christos 
    303  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
    304  1.3  christos     if (ACPI_FAILURE (Status))
    305  1.2  christos     {
    306  1.3  christos         goto ReleaseAndExit;
    307  1.2  christos     }
    308  1.2  christos 
    309  1.3  christos     if (Reload)
    310  1.1    jruoho     {
    311  1.3  christos         /*
    312  1.3  christos          * Validate the incoming table signature.
    313  1.3  christos          *
    314  1.3  christos          * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
    315  1.3  christos          * 2) We added support for OEMx tables, signature "OEM".
    316  1.3  christos          * 3) Valid tables were encountered with a null signature, so we just
    317  1.3  christos          *    gave up on validating the signature, (05/2008).
    318  1.3  christos          * 4) We encountered non-AML tables such as the MADT, which caused
    319  1.3  christos          *    interpreter errors and kernel faults. So now, we once again allow
    320  1.3  christos          *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
    321  1.3  christos          */
    322  1.3  christos         if ((NewTableDesc.Signature.Ascii[0] != 0x00) &&
    323  1.3  christos            (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) &&
    324  1.6  christos            (strncmp (NewTableDesc.Signature.Ascii, "OEM", 3)))
    325  1.3  christos         {
    326  1.3  christos             ACPI_BIOS_ERROR ((AE_INFO,
    327  1.3  christos                 "Table has invalid signature [%4.4s] (0x%8.8X), "
    328  1.3  christos                 "must be SSDT or OEMx",
    329  1.8  christos                 AcpiUtValidNameseg (NewTableDesc.Signature.Ascii) ?
    330  1.3  christos                     NewTableDesc.Signature.Ascii : "????",
    331  1.3  christos                 NewTableDesc.Signature.Integer));
    332  1.3  christos 
    333  1.3  christos             Status = AE_BAD_SIGNATURE;
    334  1.3  christos             goto ReleaseAndExit;
    335  1.3  christos         }
    336  1.3  christos 
    337  1.3  christos         /* Check if table is already registered */
    338  1.3  christos 
    339  1.3  christos         for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
    340  1.3  christos         {
    341  1.3  christos             /*
    342  1.3  christos              * Check for a table match on the entire table length,
    343  1.3  christos              * not just the header.
    344  1.3  christos              */
    345  1.3  christos             if (!AcpiTbCompareTables (&NewTableDesc, i))
    346  1.3  christos             {
    347  1.3  christos                 continue;
    348  1.3  christos             }
    349  1.1    jruoho 
    350  1.3  christos             /*
    351  1.3  christos              * Note: the current mechanism does not unregister a table if it is
    352  1.3  christos              * dynamically unloaded. The related namespace entries are deleted,
    353  1.3  christos              * but the table remains in the root table list.
    354  1.3  christos              *
    355  1.3  christos              * The assumption here is that the number of different tables that
    356  1.3  christos              * will be loaded is actually small, and there is minimal overhead
    357  1.3  christos              * in just keeping the table in case it is needed again.
    358  1.3  christos              *
    359  1.3  christos              * If this assumption changes in the future (perhaps on large
    360  1.3  christos              * machines with many table load/unload operations), tables will
    361  1.3  christos              * need to be unregistered when they are unloaded, and slots in the
    362  1.3  christos              * root table list should be reused when empty.
    363  1.3  christos              */
    364  1.7  christos             if (AcpiGbl_RootTableList.Tables[i].Flags &
    365  1.7  christos                 ACPI_TABLE_IS_LOADED)
    366  1.3  christos             {
    367  1.3  christos                 /* Table is still loaded, this is an error */
    368  1.1    jruoho 
    369  1.3  christos                 Status = AE_ALREADY_EXISTS;
    370  1.3  christos                 goto ReleaseAndExit;
    371  1.3  christos             }
    372  1.3  christos             else
    373  1.3  christos             {
    374  1.3  christos                 /*
    375  1.3  christos                  * Table was unloaded, allow it to be reloaded.
    376  1.3  christos                  * As we are going to return AE_OK to the caller, we should
    377  1.3  christos                  * take the responsibility of freeing the input descriptor.
    378  1.3  christos                  * Refill the input descriptor to ensure
    379  1.3  christos                  * AcpiTbInstallTableWithOverride() can be called again to
    380  1.3  christos                  * indicate the re-installation.
    381  1.3  christos                  */
    382  1.3  christos                 AcpiTbUninstallTable (&NewTableDesc);
    383  1.3  christos                 *TableIndex = i;
    384  1.3  christos                 return_ACPI_STATUS (AE_OK);
    385  1.3  christos             }
    386  1.1    jruoho         }
    387  1.1    jruoho     }
    388  1.1    jruoho 
    389  1.3  christos     /* Add the table to the global root table list */
    390  1.1    jruoho 
    391  1.7  christos     AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex);
    392  1.1    jruoho 
    393  1.3  christos ReleaseAndExit:
    394  1.1    jruoho 
    395  1.3  christos     /* Release the temporary table descriptor */
    396  1.1    jruoho 
    397  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    398  1.3  christos     return_ACPI_STATUS (Status);
    399  1.1    jruoho }
    400  1.1    jruoho 
    401  1.1    jruoho 
    402  1.1    jruoho /*******************************************************************************
    403  1.1    jruoho  *
    404  1.3  christos  * FUNCTION:    AcpiTbOverrideTable
    405  1.1    jruoho  *
    406  1.3  christos  * PARAMETERS:  OldTableDesc        - Validated table descriptor to be
    407  1.3  christos  *                                    overridden
    408  1.1    jruoho  *
    409  1.1    jruoho  * RETURN:      None
    410  1.1    jruoho  *
    411  1.3  christos  * DESCRIPTION: Attempt table override by calling the OSL override functions.
    412  1.3  christos  *              Note: If the table is overridden, then the entire new table
    413  1.3  christos  *              is acquired and returned by this function.
    414  1.3  christos  *              Before/after invocation, the table descriptor is in a state
    415  1.3  christos  *              that is "VALIDATED".
    416  1.1    jruoho  *
    417  1.1    jruoho  ******************************************************************************/
    418  1.1    jruoho 
    419  1.1    jruoho void
    420  1.3  christos AcpiTbOverrideTable (
    421  1.3  christos     ACPI_TABLE_DESC         *OldTableDesc)
    422  1.1    jruoho {
    423  1.3  christos     ACPI_STATUS             Status;
    424  1.3  christos     const char              *OverrideType;
    425  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    426  1.3  christos     ACPI_TABLE_HEADER       *Table;
    427  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address;
    428  1.3  christos     UINT32                  Length;
    429  1.1    jruoho 
    430  1.1    jruoho 
    431  1.3  christos     /* (1) Attempt logical override (returns a logical address) */
    432  1.1    jruoho 
    433  1.3  christos     Status = AcpiOsTableOverride (OldTableDesc->Pointer, &Table);
    434  1.3  christos     if (ACPI_SUCCESS (Status) && Table)
    435  1.1    jruoho     {
    436  1.3  christos         AcpiTbAcquireTempTable (&NewTableDesc, ACPI_PTR_TO_PHYSADDR (Table),
    437  1.3  christos             ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL);
    438  1.3  christos         OverrideType = "Logical";
    439  1.3  christos         goto FinishOverride;
    440  1.1    jruoho     }
    441  1.1    jruoho 
    442  1.3  christos     /* (2) Attempt physical override (returns a physical address) */
    443  1.1    jruoho 
    444  1.3  christos     Status = AcpiOsPhysicalTableOverride (OldTableDesc->Pointer,
    445  1.3  christos         &Address, &Length);
    446  1.3  christos     if (ACPI_SUCCESS (Status) && Address && Length)
    447  1.3  christos     {
    448  1.3  christos         AcpiTbAcquireTempTable (&NewTableDesc, Address,
    449  1.3  christos             ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
    450  1.3  christos         OverrideType = "Physical";
    451  1.3  christos         goto FinishOverride;
    452  1.1    jruoho     }
    453  1.1    jruoho 
    454  1.3  christos     return; /* There was no override */
    455  1.1    jruoho 
    456  1.1    jruoho 
    457  1.3  christos FinishOverride:
    458  1.2  christos 
    459  1.3  christos     /* Validate and verify a table before overriding */
    460  1.1    jruoho 
    461  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
    462  1.1    jruoho     if (ACPI_FAILURE (Status))
    463  1.1    jruoho     {
    464  1.3  christos         return;
    465  1.1    jruoho     }
    466  1.1    jruoho 
    467  1.8  christos     ACPI_INFO (("%4.4s 0x%8.8X%8.8X"
    468  1.4  christos         " %s table override, new table: 0x%8.8X%8.8X",
    469  1.3  christos         OldTableDesc->Signature.Ascii,
    470  1.4  christos         ACPI_FORMAT_UINT64 (OldTableDesc->Address),
    471  1.4  christos         OverrideType, ACPI_FORMAT_UINT64 (NewTableDesc.Address)));
    472  1.1    jruoho 
    473  1.3  christos     /* We can now uninstall the original table */
    474  1.1    jruoho 
    475  1.3  christos     AcpiTbUninstallTable (OldTableDesc);
    476  1.1    jruoho 
    477  1.1    jruoho     /*
    478  1.3  christos      * Replace the original table descriptor and keep its state as
    479  1.3  christos      * "VALIDATED".
    480  1.1    jruoho      */
    481  1.3  christos     AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address,
    482  1.3  christos         NewTableDesc.Flags, NewTableDesc.Pointer);
    483  1.3  christos     AcpiTbValidateTempTable (OldTableDesc);
    484  1.1    jruoho 
    485  1.3  christos     /* Release the temporary table descriptor */
    486  1.1    jruoho 
    487  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    488  1.1    jruoho }
    489  1.1    jruoho 
    490  1.1    jruoho 
    491  1.1    jruoho /*******************************************************************************
    492  1.1    jruoho  *
    493  1.3  christos  * FUNCTION:    AcpiTbUninstallTable
    494  1.1    jruoho  *
    495  1.3  christos  * PARAMETERS:  TableDesc           - Table descriptor
    496  1.1    jruoho  *
    497  1.3  christos  * RETURN:      None
    498  1.1    jruoho  *
    499  1.3  christos  * DESCRIPTION: Delete one internal ACPI table
    500  1.1    jruoho  *
    501  1.1    jruoho  ******************************************************************************/
    502  1.1    jruoho 
    503  1.3  christos void
    504  1.3  christos AcpiTbUninstallTable (
    505  1.3  christos     ACPI_TABLE_DESC         *TableDesc)
    506  1.1    jruoho {
    507  1.1    jruoho 
    508  1.3  christos     ACPI_FUNCTION_TRACE (TbUninstallTable);
    509  1.1    jruoho 
    510  1.1    jruoho 
    511  1.3  christos     /* Table must be installed */
    512  1.1    jruoho 
    513  1.3  christos     if (!TableDesc->Address)
    514  1.1    jruoho     {
    515  1.3  christos         return_VOID;
    516  1.1    jruoho     }
    517  1.1    jruoho 
    518  1.3  christos     AcpiTbInvalidateTable (TableDesc);
    519  1.1    jruoho 
    520  1.3  christos     if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
    521  1.3  christos         ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL)
    522  1.1    jruoho     {
    523  1.5  christos 	void *ptr = ACPI_PHYSADDR_TO_PTR (TableDesc->Address);
    524  1.5  christos 	if (ptr)
    525  1.5  christos 	{
    526  1.5  christos 		ACPI_FREE (ptr);
    527  1.5  christos 	}
    528  1.1    jruoho     }
    529  1.1    jruoho 
    530  1.3  christos     TableDesc->Address = ACPI_PTR_TO_PHYSADDR (NULL);
    531  1.3  christos     return_VOID;
    532  1.1    jruoho }
    533