Home | History | Annotate | Line # | Download | only in tables
tbinstal.c revision 1.3
      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.3  christos  * Copyright (C) 2000 - 2014, 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 #define __TBINSTAL_C__
     45  1.1    jruoho 
     46  1.1    jruoho #include "acpi.h"
     47  1.1    jruoho #include "accommon.h"
     48  1.1    jruoho #include "actables.h"
     49  1.1    jruoho 
     50  1.1    jruoho #define _COMPONENT          ACPI_TABLES
     51  1.1    jruoho         ACPI_MODULE_NAME    ("tbinstal")
     52  1.1    jruoho 
     53  1.3  christos /* Local prototypes */
     54  1.3  christos 
     55  1.3  christos static BOOLEAN
     56  1.3  christos AcpiTbCompareTables (
     57  1.3  christos     ACPI_TABLE_DESC         *TableDesc,
     58  1.3  christos     UINT32                  TableIndex);
     59  1.3  christos 
     60  1.1    jruoho 
     61  1.3  christos /*******************************************************************************
     62  1.1    jruoho  *
     63  1.3  christos  * FUNCTION:    AcpiTbCompareTables
     64  1.1    jruoho  *
     65  1.3  christos  * PARAMETERS:  TableDesc           - Table 1 descriptor to be compared
     66  1.3  christos  *              TableIndex          - Index of table 2 to be compared
     67  1.1    jruoho  *
     68  1.3  christos  * RETURN:      TRUE if both tables are identical.
     69  1.1    jruoho  *
     70  1.3  christos  * DESCRIPTION: This function compares a table with another table that has
     71  1.3  christos  *              already been installed in the root table list.
     72  1.1    jruoho  *
     73  1.3  christos  ******************************************************************************/
     74  1.1    jruoho 
     75  1.3  christos static BOOLEAN
     76  1.3  christos AcpiTbCompareTables (
     77  1.3  christos     ACPI_TABLE_DESC         *TableDesc,
     78  1.3  christos     UINT32                  TableIndex)
     79  1.1    jruoho {
     80  1.1    jruoho     ACPI_STATUS             Status = AE_OK;
     81  1.3  christos     BOOLEAN                 IsIdentical;
     82  1.3  christos     ACPI_TABLE_HEADER       *Table;
     83  1.3  christos     UINT32                  TableLength;
     84  1.3  christos     UINT8                   TableFlags;
     85  1.1    jruoho 
     86  1.1    jruoho 
     87  1.3  christos     Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex],
     88  1.3  christos                 &Table, &TableLength, &TableFlags);
     89  1.3  christos     if (ACPI_FAILURE (Status))
     90  1.1    jruoho     {
     91  1.3  christos         return (FALSE);
     92  1.1    jruoho     }
     93  1.1    jruoho 
     94  1.3  christos     /*
     95  1.3  christos      * Check for a table match on the entire table length,
     96  1.3  christos      * not just the header.
     97  1.3  christos      */
     98  1.3  christos     IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength ||
     99  1.3  christos         ACPI_MEMCMP (TableDesc->Pointer, Table, TableLength)) ?
    100  1.3  christos         FALSE : TRUE);
    101  1.1    jruoho 
    102  1.3  christos     /* Release the acquired table */
    103  1.1    jruoho 
    104  1.3  christos     AcpiTbReleaseTable (Table, TableLength, TableFlags);
    105  1.3  christos     return (IsIdentical);
    106  1.1    jruoho }
    107  1.1    jruoho 
    108  1.1    jruoho 
    109  1.1    jruoho /*******************************************************************************
    110  1.1    jruoho  *
    111  1.3  christos  * FUNCTION:    AcpiTbInstallTableWithOverride
    112  1.1    jruoho  *
    113  1.3  christos  * PARAMETERS:  TableIndex              - Index into root table array
    114  1.3  christos  *              NewTableDesc            - New table descriptor to install
    115  1.3  christos  *              Override                - Whether override should be performed
    116  1.1    jruoho  *
    117  1.3  christos  * RETURN:      None
    118  1.1    jruoho  *
    119  1.3  christos  * DESCRIPTION: Install an ACPI table into the global data structure. The
    120  1.3  christos  *              table override mechanism is called to allow the host
    121  1.3  christos  *              OS to replace any table before it is installed in the root
    122  1.3  christos  *              table array.
    123  1.1    jruoho  *
    124  1.1    jruoho  ******************************************************************************/
    125  1.1    jruoho 
    126  1.3  christos void
    127  1.3  christos AcpiTbInstallTableWithOverride (
    128  1.3  christos     UINT32                  TableIndex,
    129  1.3  christos     ACPI_TABLE_DESC         *NewTableDesc,
    130  1.3  christos     BOOLEAN                 Override)
    131  1.1    jruoho {
    132  1.1    jruoho 
    133  1.3  christos     if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
    134  1.1    jruoho     {
    135  1.3  christos         return;
    136  1.1    jruoho     }
    137  1.1    jruoho 
    138  1.1    jruoho     /*
    139  1.3  christos      * ACPI Table Override:
    140  1.2  christos      *
    141  1.3  christos      * Before we install the table, let the host OS override it with a new
    142  1.3  christos      * one if desired. Any table within the RSDT/XSDT can be replaced,
    143  1.3  christos      * including the DSDT which is pointed to by the FADT.
    144  1.1    jruoho      */
    145  1.3  christos     if (Override)
    146  1.2  christos     {
    147  1.3  christos         AcpiTbOverrideTable (NewTableDesc);
    148  1.2  christos     }
    149  1.1    jruoho 
    150  1.3  christos     AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[TableIndex],
    151  1.3  christos         NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer);
    152  1.1    jruoho 
    153  1.3  christos     AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer);
    154  1.1    jruoho 
    155  1.3  christos     /* Set the global integer width (based upon revision of the DSDT) */
    156  1.1    jruoho 
    157  1.3  christos     if (TableIndex == ACPI_TABLE_INDEX_DSDT)
    158  1.1    jruoho     {
    159  1.3  christos         AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision);
    160  1.1    jruoho     }
    161  1.1    jruoho }
    162  1.1    jruoho 
    163  1.1    jruoho 
    164  1.1    jruoho /*******************************************************************************
    165  1.1    jruoho  *
    166  1.3  christos  * FUNCTION:    AcpiTbInstallFixedTable
    167  1.2  christos  *
    168  1.3  christos  * PARAMETERS:  Address                 - Physical address of DSDT or FACS
    169  1.3  christos  *              Signature               - Table signature, NULL if no need to
    170  1.3  christos  *                                        match
    171  1.3  christos  *              TableIndex              - Index into root table array
    172  1.3  christos  *
    173  1.3  christos  * RETURN:      Status
    174  1.2  christos  *
    175  1.3  christos  * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data
    176  1.3  christos  *              structure.
    177  1.2  christos  *
    178  1.2  christos  ******************************************************************************/
    179  1.2  christos 
    180  1.3  christos ACPI_STATUS
    181  1.3  christos AcpiTbInstallFixedTable (
    182  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address,
    183  1.3  christos     const char              *Signature,
    184  1.3  christos     UINT32                  TableIndex)
    185  1.2  christos {
    186  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    187  1.2  christos     ACPI_STATUS             Status;
    188  1.2  christos 
    189  1.2  christos 
    190  1.3  christos     ACPI_FUNCTION_TRACE (TbInstallFixedTable);
    191  1.3  christos 
    192  1.2  christos 
    193  1.3  christos     if (!Address)
    194  1.2  christos     {
    195  1.3  christos         ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
    196  1.3  christos             Signature));
    197  1.3  christos         return (AE_NO_MEMORY);
    198  1.2  christos     }
    199  1.2  christos 
    200  1.3  christos     /* Fill a table descriptor for validation */
    201  1.2  christos 
    202  1.3  christos     Status = AcpiTbAcquireTempTable (&NewTableDesc, Address,
    203  1.3  christos                 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
    204  1.3  christos     if (ACPI_FAILURE (Status))
    205  1.2  christos     {
    206  1.3  christos         ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p",
    207  1.3  christos             ACPI_CAST_PTR (void, Address)));
    208  1.3  christos         return_ACPI_STATUS (Status);
    209  1.3  christos     }
    210  1.2  christos 
    211  1.3  christos     /* Validate and verify a table before installation */
    212  1.2  christos 
    213  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature);
    214  1.3  christos     if (ACPI_FAILURE (Status))
    215  1.3  christos     {
    216  1.3  christos         goto ReleaseAndExit;
    217  1.2  christos     }
    218  1.2  christos 
    219  1.3  christos     AcpiTbInstallTableWithOverride (TableIndex, &NewTableDesc, TRUE);
    220  1.2  christos 
    221  1.3  christos ReleaseAndExit:
    222  1.2  christos 
    223  1.3  christos     /* Release the temporary table descriptor */
    224  1.2  christos 
    225  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    226  1.3  christos     return_ACPI_STATUS (Status);
    227  1.2  christos }
    228  1.2  christos 
    229  1.2  christos 
    230  1.2  christos /*******************************************************************************
    231  1.2  christos  *
    232  1.3  christos  * FUNCTION:    AcpiTbInstallStandardTable
    233  1.1    jruoho  *
    234  1.3  christos  * PARAMETERS:  Address             - Address of the table (might be a virtual
    235  1.3  christos  *                                    address depending on the TableFlags)
    236  1.3  christos  *              Flags               - Flags for the table
    237  1.3  christos  *              Reload              - Whether reload should be performed
    238  1.3  christos  *              Override            - Whether override should be performed
    239  1.3  christos  *              TableIndex          - Where the table index is returned
    240  1.1    jruoho  *
    241  1.1    jruoho  * RETURN:      Status
    242  1.1    jruoho  *
    243  1.3  christos  * DESCRIPTION: This function is called to install an ACPI table that is
    244  1.3  christos  *              neither DSDT nor FACS (a "standard" table.)
    245  1.3  christos  *              When this function is called by "Load" or "LoadTable" opcodes,
    246  1.3  christos  *              or by AcpiLoadTable() API, the "Reload" parameter is set.
    247  1.3  christos  *              After sucessfully returning from this function, table is
    248  1.3  christos  *              "INSTALLED" but not "VALIDATED".
    249  1.1    jruoho  *
    250  1.1    jruoho  ******************************************************************************/
    251  1.1    jruoho 
    252  1.1    jruoho ACPI_STATUS
    253  1.3  christos AcpiTbInstallStandardTable (
    254  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address,
    255  1.3  christos     UINT8                   Flags,
    256  1.3  christos     BOOLEAN                 Reload,
    257  1.3  christos     BOOLEAN                 Override,
    258  1.3  christos     UINT32                  *TableIndex)
    259  1.1    jruoho {
    260  1.3  christos     UINT32                  i;
    261  1.3  christos     ACPI_STATUS             Status = AE_OK;
    262  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    263  1.1    jruoho 
    264  1.1    jruoho 
    265  1.3  christos     ACPI_FUNCTION_TRACE (TbInstallStandardTable);
    266  1.1    jruoho 
    267  1.1    jruoho 
    268  1.3  christos     /* Acquire a temporary table descriptor for validation */
    269  1.1    jruoho 
    270  1.3  christos     Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags);
    271  1.3  christos     if (ACPI_FAILURE (Status))
    272  1.1    jruoho     {
    273  1.3  christos         ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p",
    274  1.3  christos             ACPI_CAST_PTR (void, Address)));
    275  1.3  christos         return_ACPI_STATUS (Status);
    276  1.1    jruoho     }
    277  1.1    jruoho 
    278  1.3  christos     /*
    279  1.3  christos      * Optionally do not load any SSDTs from the RSDT/XSDT. This can
    280  1.3  christos      * be useful for debugging ACPI problems on some machines.
    281  1.3  christos      */
    282  1.3  christos     if (!Reload &&
    283  1.3  christos         AcpiGbl_DisableSsdtTableInstall &&
    284  1.3  christos         ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT))
    285  1.2  christos     {
    286  1.3  christos         ACPI_INFO ((AE_INFO, "Ignoring installation of %4.4s at %p",
    287  1.3  christos             NewTableDesc.Signature.Ascii, ACPI_CAST_PTR (void, Address)));
    288  1.3  christos         goto ReleaseAndExit;
    289  1.2  christos     }
    290  1.3  christos 
    291  1.3  christos     /* Validate and verify a table before installation */
    292  1.3  christos 
    293  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
    294  1.3  christos     if (ACPI_FAILURE (Status))
    295  1.2  christos     {
    296  1.3  christos         goto ReleaseAndExit;
    297  1.2  christos     }
    298  1.2  christos 
    299  1.3  christos     if (Reload)
    300  1.1    jruoho     {
    301  1.3  christos         /*
    302  1.3  christos          * Validate the incoming table signature.
    303  1.3  christos          *
    304  1.3  christos          * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
    305  1.3  christos          * 2) We added support for OEMx tables, signature "OEM".
    306  1.3  christos          * 3) Valid tables were encountered with a null signature, so we just
    307  1.3  christos          *    gave up on validating the signature, (05/2008).
    308  1.3  christos          * 4) We encountered non-AML tables such as the MADT, which caused
    309  1.3  christos          *    interpreter errors and kernel faults. So now, we once again allow
    310  1.3  christos          *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
    311  1.3  christos          */
    312  1.3  christos         if ((NewTableDesc.Signature.Ascii[0] != 0x00) &&
    313  1.3  christos            (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) &&
    314  1.3  christos            (ACPI_STRNCMP (NewTableDesc.Signature.Ascii, "OEM", 3)))
    315  1.3  christos         {
    316  1.3  christos             ACPI_BIOS_ERROR ((AE_INFO,
    317  1.3  christos                 "Table has invalid signature [%4.4s] (0x%8.8X), "
    318  1.3  christos                 "must be SSDT or OEMx",
    319  1.3  christos                 AcpiUtValidAcpiName (NewTableDesc.Signature.Ascii) ?
    320  1.3  christos                     NewTableDesc.Signature.Ascii : "????",
    321  1.3  christos                 NewTableDesc.Signature.Integer));
    322  1.3  christos 
    323  1.3  christos             Status = AE_BAD_SIGNATURE;
    324  1.3  christos             goto ReleaseAndExit;
    325  1.3  christos         }
    326  1.3  christos 
    327  1.3  christos         /* Check if table is already registered */
    328  1.3  christos 
    329  1.3  christos         for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
    330  1.3  christos         {
    331  1.3  christos             /*
    332  1.3  christos              * Check for a table match on the entire table length,
    333  1.3  christos              * not just the header.
    334  1.3  christos              */
    335  1.3  christos             if (!AcpiTbCompareTables (&NewTableDesc, i))
    336  1.3  christos             {
    337  1.3  christos                 continue;
    338  1.3  christos             }
    339  1.1    jruoho 
    340  1.3  christos             /*
    341  1.3  christos              * Note: the current mechanism does not unregister a table if it is
    342  1.3  christos              * dynamically unloaded. The related namespace entries are deleted,
    343  1.3  christos              * but the table remains in the root table list.
    344  1.3  christos              *
    345  1.3  christos              * The assumption here is that the number of different tables that
    346  1.3  christos              * will be loaded is actually small, and there is minimal overhead
    347  1.3  christos              * in just keeping the table in case it is needed again.
    348  1.3  christos              *
    349  1.3  christos              * If this assumption changes in the future (perhaps on large
    350  1.3  christos              * machines with many table load/unload operations), tables will
    351  1.3  christos              * need to be unregistered when they are unloaded, and slots in the
    352  1.3  christos              * root table list should be reused when empty.
    353  1.3  christos              */
    354  1.3  christos             if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
    355  1.3  christos             {
    356  1.3  christos                 /* Table is still loaded, this is an error */
    357  1.1    jruoho 
    358  1.3  christos                 Status = AE_ALREADY_EXISTS;
    359  1.3  christos                 goto ReleaseAndExit;
    360  1.3  christos             }
    361  1.3  christos             else
    362  1.3  christos             {
    363  1.3  christos                 /*
    364  1.3  christos                  * Table was unloaded, allow it to be reloaded.
    365  1.3  christos                  * As we are going to return AE_OK to the caller, we should
    366  1.3  christos                  * take the responsibility of freeing the input descriptor.
    367  1.3  christos                  * Refill the input descriptor to ensure
    368  1.3  christos                  * AcpiTbInstallTableWithOverride() can be called again to
    369  1.3  christos                  * indicate the re-installation.
    370  1.3  christos                  */
    371  1.3  christos                 AcpiTbUninstallTable (&NewTableDesc);
    372  1.3  christos                 *TableIndex = i;
    373  1.3  christos                (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
    374  1.3  christos                 return_ACPI_STATUS (AE_OK);
    375  1.3  christos             }
    376  1.1    jruoho         }
    377  1.1    jruoho     }
    378  1.1    jruoho 
    379  1.3  christos     /* Add the table to the global root table list */
    380  1.1    jruoho 
    381  1.3  christos     Status = AcpiTbGetNextRootIndex (&i);
    382  1.3  christos     if (ACPI_FAILURE (Status))
    383  1.1    jruoho     {
    384  1.3  christos         goto ReleaseAndExit;
    385  1.1    jruoho     }
    386  1.1    jruoho 
    387  1.3  christos     *TableIndex = i;
    388  1.3  christos     AcpiTbInstallTableWithOverride (i, &NewTableDesc, Override);
    389  1.1    jruoho 
    390  1.3  christos ReleaseAndExit:
    391  1.1    jruoho 
    392  1.3  christos     /* Release the temporary table descriptor */
    393  1.1    jruoho 
    394  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    395  1.3  christos     return_ACPI_STATUS (Status);
    396  1.1    jruoho }
    397  1.1    jruoho 
    398  1.1    jruoho 
    399  1.1    jruoho /*******************************************************************************
    400  1.1    jruoho  *
    401  1.3  christos  * FUNCTION:    AcpiTbOverrideTable
    402  1.1    jruoho  *
    403  1.3  christos  * PARAMETERS:  OldTableDesc        - Validated table descriptor to be
    404  1.3  christos  *                                    overridden
    405  1.1    jruoho  *
    406  1.1    jruoho  * RETURN:      None
    407  1.1    jruoho  *
    408  1.3  christos  * DESCRIPTION: Attempt table override by calling the OSL override functions.
    409  1.3  christos  *              Note: If the table is overridden, then the entire new table
    410  1.3  christos  *              is acquired and returned by this function.
    411  1.3  christos  *              Before/after invocation, the table descriptor is in a state
    412  1.3  christos  *              that is "VALIDATED".
    413  1.1    jruoho  *
    414  1.1    jruoho  ******************************************************************************/
    415  1.1    jruoho 
    416  1.1    jruoho void
    417  1.3  christos AcpiTbOverrideTable (
    418  1.3  christos     ACPI_TABLE_DESC         *OldTableDesc)
    419  1.1    jruoho {
    420  1.3  christos     ACPI_STATUS             Status;
    421  1.3  christos     const char              *OverrideType;
    422  1.3  christos     ACPI_TABLE_DESC         NewTableDesc;
    423  1.3  christos     ACPI_TABLE_HEADER       *Table;
    424  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address;
    425  1.3  christos     UINT32                  Length;
    426  1.1    jruoho 
    427  1.1    jruoho 
    428  1.3  christos     /* (1) Attempt logical override (returns a logical address) */
    429  1.1    jruoho 
    430  1.3  christos     Status = AcpiOsTableOverride (OldTableDesc->Pointer, &Table);
    431  1.3  christos     if (ACPI_SUCCESS (Status) && Table)
    432  1.1    jruoho     {
    433  1.3  christos         AcpiTbAcquireTempTable (&NewTableDesc, ACPI_PTR_TO_PHYSADDR (Table),
    434  1.3  christos             ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL);
    435  1.3  christos         OverrideType = "Logical";
    436  1.3  christos         goto FinishOverride;
    437  1.1    jruoho     }
    438  1.1    jruoho 
    439  1.3  christos     /* (2) Attempt physical override (returns a physical address) */
    440  1.1    jruoho 
    441  1.3  christos     Status = AcpiOsPhysicalTableOverride (OldTableDesc->Pointer,
    442  1.3  christos         &Address, &Length);
    443  1.3  christos     if (ACPI_SUCCESS (Status) && Address && Length)
    444  1.3  christos     {
    445  1.3  christos         AcpiTbAcquireTempTable (&NewTableDesc, Address,
    446  1.3  christos             ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
    447  1.3  christos         OverrideType = "Physical";
    448  1.3  christos         goto FinishOverride;
    449  1.1    jruoho     }
    450  1.1    jruoho 
    451  1.3  christos     return; /* There was no override */
    452  1.1    jruoho 
    453  1.1    jruoho 
    454  1.3  christos FinishOverride:
    455  1.2  christos 
    456  1.3  christos     /* Validate and verify a table before overriding */
    457  1.1    jruoho 
    458  1.3  christos     Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL);
    459  1.1    jruoho     if (ACPI_FAILURE (Status))
    460  1.1    jruoho     {
    461  1.3  christos         return;
    462  1.1    jruoho     }
    463  1.1    jruoho 
    464  1.3  christos     ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
    465  1.3  christos         " %s table override, new table: " ACPI_PRINTF_UINT,
    466  1.3  christos         OldTableDesc->Signature.Ascii,
    467  1.3  christos         ACPI_FORMAT_TO_UINT (OldTableDesc->Address),
    468  1.3  christos         OverrideType, ACPI_FORMAT_TO_UINT (NewTableDesc.Address)));
    469  1.1    jruoho 
    470  1.3  christos     /* We can now uninstall the original table */
    471  1.1    jruoho 
    472  1.3  christos     AcpiTbUninstallTable (OldTableDesc);
    473  1.1    jruoho 
    474  1.1    jruoho     /*
    475  1.3  christos      * Replace the original table descriptor and keep its state as
    476  1.3  christos      * "VALIDATED".
    477  1.1    jruoho      */
    478  1.3  christos     AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address,
    479  1.3  christos         NewTableDesc.Flags, NewTableDesc.Pointer);
    480  1.3  christos     AcpiTbValidateTempTable (OldTableDesc);
    481  1.1    jruoho 
    482  1.3  christos     /* Release the temporary table descriptor */
    483  1.1    jruoho 
    484  1.3  christos     AcpiTbReleaseTempTable (&NewTableDesc);
    485  1.1    jruoho }
    486  1.1    jruoho 
    487  1.1    jruoho 
    488  1.1    jruoho /*******************************************************************************
    489  1.1    jruoho  *
    490  1.3  christos  * FUNCTION:    AcpiTbStoreTable
    491  1.1    jruoho  *
    492  1.3  christos  * PARAMETERS:  Address             - Table address
    493  1.3  christos  *              Table               - Table header
    494  1.3  christos  *              Length              - Table length
    495  1.3  christos  *              Flags               - Install flags
    496  1.3  christos  *              TableIndex          - Where the table index is returned
    497  1.1    jruoho  *
    498  1.3  christos  * RETURN:      Status and table index.
    499  1.1    jruoho  *
    500  1.3  christos  * DESCRIPTION: Add an ACPI table to the global table list
    501  1.1    jruoho  *
    502  1.1    jruoho  ******************************************************************************/
    503  1.1    jruoho 
    504  1.1    jruoho ACPI_STATUS
    505  1.3  christos AcpiTbStoreTable (
    506  1.3  christos     ACPI_PHYSICAL_ADDRESS   Address,
    507  1.3  christos     ACPI_TABLE_HEADER       *Table,
    508  1.3  christos     UINT32                  Length,
    509  1.3  christos     UINT8                   Flags,
    510  1.3  christos     UINT32                  *TableIndex)
    511  1.1    jruoho {
    512  1.3  christos     ACPI_STATUS             Status;
    513  1.3  christos     ACPI_TABLE_DESC         *TableDesc;
    514  1.1    jruoho 
    515  1.1    jruoho 
    516  1.3  christos     Status = AcpiTbGetNextRootIndex (TableIndex);
    517  1.3  christos     if (ACPI_FAILURE (Status))
    518  1.1    jruoho     {
    519  1.3  christos         return (Status);
    520  1.1    jruoho     }
    521  1.1    jruoho 
    522  1.3  christos     /* Initialize added table */
    523  1.1    jruoho 
    524  1.3  christos     TableDesc = &AcpiGbl_RootTableList.Tables[*TableIndex];
    525  1.3  christos     AcpiTbInitTableDescriptor (TableDesc, Address, Flags, Table);
    526  1.3  christos     TableDesc->Pointer = Table;
    527  1.3  christos     return (AE_OK);
    528  1.1    jruoho }
    529  1.1    jruoho 
    530  1.1    jruoho 
    531  1.1    jruoho /*******************************************************************************
    532  1.1    jruoho  *
    533  1.3  christos  * FUNCTION:    AcpiTbUninstallTable
    534  1.1    jruoho  *
    535  1.3  christos  * PARAMETERS:  TableDesc           - Table descriptor
    536  1.1    jruoho  *
    537  1.3  christos  * RETURN:      None
    538  1.1    jruoho  *
    539  1.3  christos  * DESCRIPTION: Delete one internal ACPI table
    540  1.1    jruoho  *
    541  1.1    jruoho  ******************************************************************************/
    542  1.1    jruoho 
    543  1.3  christos void
    544  1.3  christos AcpiTbUninstallTable (
    545  1.3  christos     ACPI_TABLE_DESC         *TableDesc)
    546  1.1    jruoho {
    547  1.1    jruoho 
    548  1.3  christos     ACPI_FUNCTION_TRACE (TbUninstallTable);
    549  1.1    jruoho 
    550  1.1    jruoho 
    551  1.3  christos     /* Table must be installed */
    552  1.1    jruoho 
    553  1.3  christos     if (!TableDesc->Address)
    554  1.1    jruoho     {
    555  1.3  christos         return_VOID;
    556  1.1    jruoho     }
    557  1.1    jruoho 
    558  1.3  christos     AcpiTbInvalidateTable (TableDesc);
    559  1.1    jruoho 
    560  1.3  christos     if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
    561  1.3  christos         ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL)
    562  1.1    jruoho     {
    563  1.3  christos         ACPI_FREE (ACPI_CAST_PTR (void, TableDesc->Address));
    564  1.1    jruoho     }
    565  1.1    jruoho 
    566  1.3  christos     TableDesc->Address = ACPI_PTR_TO_PHYSADDR (NULL);
    567  1.3  christos     return_VOID;
    568  1.1    jruoho }
    569