Home | History | Annotate | Line # | Download | only in acpiexec
aetables.c revision 1.1
      1 /******************************************************************************
      2  *
      3  * Module Name: aetables - Miscellaneous ACPI tables for acpiexec utility
      4  *
      5  *****************************************************************************/
      6 
      7 /******************************************************************************
      8  *
      9  * 1. Copyright Notice
     10  *
     11  * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
     12  * All rights reserved.
     13  *
     14  * 2. License
     15  *
     16  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  * rights.  You may have additional license terms from the party that provided
     18  * you this software, covering your right to use that party's intellectual
     19  * property rights.
     20  *
     21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  * copy of the source code appearing in this file ("Covered Code") an
     23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  * make derivatives, distribute, use and display any portion of the Covered
     26  * Code in any form, with the right to sublicense such rights; and
     27  *
     28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  * license (with the right to sublicense), under only those claims of Intel
     30  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  * offer to sell, and import the Covered Code and derivative works thereof
     32  * solely to the minimum extent necessary to exercise the above copyright
     33  * license, and in no event shall the patent license extend to any additions
     34  * to or modifications of the Original Intel Code.  No other license or right
     35  * is granted directly or by implication, estoppel or otherwise;
     36  *
     37  * The above copyright and patent license is granted only if the following
     38  * conditions are met:
     39  *
     40  * 3. Conditions
     41  *
     42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  * Redistribution of source code of any substantial portion of the Covered
     44  * Code or modification with rights to further distribute source must include
     45  * the above Copyright Notice, the above License, this list of Conditions,
     46  * and the following Disclaimer and Export Compliance provision.  In addition,
     47  * Licensee must cause all Covered Code to which Licensee contributes to
     48  * contain a file documenting the changes Licensee made to create that Covered
     49  * Code and the date of any change.  Licensee must include in that file the
     50  * documentation of any changes made by any predecessor Licensee.  Licensee
     51  * must include a prominent statement that the modification is derived,
     52  * directly or indirectly, from Original Intel Code.
     53  *
     54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  * Redistribution of source code of any substantial portion of the Covered
     56  * Code or modification without rights to further distribute source must
     57  * include the following Disclaimer and Export Compliance provision in the
     58  * documentation and/or other materials provided with distribution.  In
     59  * addition, Licensee may not authorize further sublicense of source of any
     60  * portion of the Covered Code, and must include terms to the effect that the
     61  * license from Licensee to its licensee is limited to the intellectual
     62  * property embodied in the software Licensee provides to its licensee, and
     63  * not to intellectual property embodied in modifications its licensee may
     64  * make.
     65  *
     66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  * substantial portion of the Covered Code or modification must reproduce the
     68  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  * provision in the documentation and/or other materials provided with the
     70  * distribution.
     71  *
     72  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  * Intel Code.
     74  *
     75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  * other dealings in products derived from or relating to the Covered Code
     78  * without prior written authorization from Intel.
     79  *
     80  * 4. Disclaimer and Export Compliance
     81  *
     82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
     85  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
     86  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
     87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  * PARTICULAR PURPOSE.
     89  *
     90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
     96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  * LIMITED REMEDY.
     98  *
     99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  * software or system incorporating such software without first obtaining any
    101  * required license or other approval from the U. S. Department of Commerce or
    102  * any other agency or department of the United States Government.  In the
    103  * event Licensee exports any such software from the United States or
    104  * re-exports any such software from a foreign destination, Licensee shall
    105  * ensure that the distribution and export/re-export of the software is in
    106  * compliance with all laws, regulations, orders, or other restrictions of the
    107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  * any of its subsidiaries will export/re-export any technical data, process,
    109  * software, or service, directly or indirectly, to any country for which the
    110  * United States government or any agency thereof requires an export license,
    111  * other governmental approval, or letter of assurance, without first obtaining
    112  * such license, approval or letter.
    113  *
    114  *****************************************************************************/
    115 
    116 #include "aecommon.h"
    117 
    118 #define _COMPONENT          ACPI_TOOLS
    119         ACPI_MODULE_NAME    ("aetables")
    120 
    121 /* Local prototypes */
    122 
    123 void
    124 AeTableOverride (
    125     ACPI_TABLE_HEADER       *ExistingTable,
    126     ACPI_TABLE_HEADER       **NewTable);
    127 
    128 ACPI_PHYSICAL_ADDRESS
    129 AeLocalGetRootPointer (
    130     void);
    131 
    132 /*
    133  * Misc ACPI tables to be installed
    134  */
    135 
    136 /* Default DSDT. This will be replaced with the input DSDT */
    137 
    138 unsigned char DsdtCode[] =
    139 {
    140     0x44,0x53,0x44,0x54,0x24,0x00,0x00,0x00,  /* 00000000    "DSDT$..." */
    141     0x02,0x6F,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    ".oIntel." */
    142     0x4E,0x75,0x6C,0x6C,0x44,0x53,0x44,0x54,  /* 00000010    "NullDSDT" */
    143     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    144     0x04,0x12,0x08,0x20,
    145 };
    146 
    147 unsigned char LocalDsdtCode[] =
    148 {
    149     0x44,0x53,0x44,0x54,0x24,0x00,0x00,0x00,  /* 00000000    "DSDT$..." */
    150     0x02,0x2C,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    ".,Intel." */
    151     0x4C,0x6F,0x63,0x61,0x6C,0x00,0x00,0x00,  /* 00000010    "Local..." */
    152     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    153     0x30,0x07,0x09,0x20,
    154 };
    155 
    156 /* Several example SSDTs */
    157 
    158 unsigned char Ssdt1Code[] = /* Has method _T98 */
    159 {
    160     0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00,  /* 00000000    "SSDT0..." */
    161     0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    "..Intel." */
    162     0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00,  /* 00000010    "Many...." */
    163     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    164     0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54,  /* 00000020    "$.. .._T" */
    165     0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4,  /* 00000028    "98.p..`." */
    166 };
    167 
    168 unsigned char Ssdt2Code[] = /* Has method _T99 */
    169 {
    170     0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00,  /* 00000000    "SSDT0..." */
    171     0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    "..Intel." */
    172     0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00,  /* 00000010    "Many...." */
    173     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    174     0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54,  /* 00000020    "$.. .._T" */
    175     0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4,  /* 00000028    "99.p..`." */
    176 };
    177 
    178 unsigned char Ssdt3Code[] = /* Has method _T97 */
    179 {
    180     0x54,0x53,0x44,0x54,0x30,0x00,0x00,0x00,  /* 00000000    "TSDT0..." */
    181     0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    "..Intel." */
    182     0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00,  /* 00000010    "Many...." */
    183     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    184     0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54,  /* 00000020    "$.. .._T" */
    185     0x39,0x37,0x00,0x70,0x0A,0x04,0x60,0xA4,  /* 00000028    "97.p..`." */
    186 };
    187 
    188 /* Example OEM table */
    189 
    190 unsigned char Oem1Code[] =
    191 {
    192     0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00,  /* 00000000    "OEM18..." */
    193     0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    ".KIntel." */
    194     0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00,  /* 00000010    "Many...." */
    195     0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    196     0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54,  /* 00000020    "... ._XT" */
    197     0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54,  /* 00000028    "2...._XT" */
    198     0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32,  /* 00000030    "1.p._XT2" */
    199 };
    200 
    201 /* ASL source for this table is at the end of this file */
    202 
    203 unsigned char OemxCode[] =
    204 {
    205     0x4F,0x45,0x4D,0x58,0xB0,0x00,0x00,0x00,  /* 00000000    "OEMX...." */
    206     0x02,0x54,0x4D,0x79,0x4F,0x45,0x4D,0x00,  /* 00000008    ".TMyOEM." */
    207     0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x00,  /* 00000010    "Test...." */
    208     0x32,0x04,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "2...INTL" */
    209     0x31,0x03,0x10,0x20,0x14,0x1D,0x5F,0x49,  /* 00000020    "1.. .._I" */
    210     0x4E,0x49,0x00,0x70,0x0D,0x54,0x61,0x62,  /* 00000028    "NI.p.Tab" */
    211     0x6C,0x65,0x20,0x4F,0x45,0x4D,0x58,0x20,  /* 00000030    "le OEMX " */
    212     0x72,0x75,0x6E,0x6E,0x69,0x6E,0x67,0x00,  /* 00000038    "running." */
    213     0x5B,0x31,0x10,0x22,0x5C,0x5F,0x47,0x50,  /* 00000040    "[1."\_GP" */
    214     0x45,0x14,0x06,0x5F,0x45,0x30,0x37,0x00,  /* 00000048    "E.._E07." */
    215     0x14,0x06,0x5F,0x45,0x32,0x32,0x00,0x14,  /* 00000050    ".._E22.." */
    216     0x06,0x5F,0x4C,0x33,0x31,0x00,0x14,0x06,  /* 00000058    "._L31..." */
    217     0x5F,0x4C,0x36,0x36,0x00,0x5B,0x82,0x10,  /* 00000060    "_L66.[.." */
    218     0x4F,0x45,0x4D,0x31,0x08,0x5F,0x50,0x52,  /* 00000068    "OEM1._PR" */
    219     0x57,0x12,0x05,0x02,0x0A,0x07,0x00,0x5B,  /* 00000070    "W......[" */
    220     0x82,0x10,0x4F,0x45,0x4D,0x32,0x08,0x5F,  /* 00000078    "..OEM2._" */
    221     0x50,0x52,0x57,0x12,0x05,0x02,0x0A,0x66,  /* 00000080    "PRW....f" */
    222     0x00,0x10,0x26,0x5C,0x47,0x50,0x45,0x32,  /* 00000088    "..&\GPE2" */
    223     0x14,0x06,0x5F,0x4C,0x30,0x31,0x00,0x14,  /* 00000090    ".._L01.." */
    224     0x06,0x5F,0x45,0x30,0x37,0x00,0x08,0x5F,  /* 00000098    "._E07.._" */
    225     0x50,0x52,0x57,0x12,0x0C,0x02,0x12,0x08,  /* 000000A0    "PRW....." */
    226     0x02,0x5C,0x47,0x50,0x45,0x32,0x01,0x00   /* 000000A8    ".\GPE2.." */
    227 };
    228 
    229 /*
    230  * Example installable control method
    231  *
    232  * DefinitionBlock ("", "DSDT", 2, "Intel", "MTHDTEST", 0x20090512)
    233  * {
    234  *     Method (\_SI_._T97, 1, Serialized)
    235  *     {
    236  *         Store ("Example installed method", Debug)
    237  *         Store (Arg0, Debug)
    238  *         Return ()
    239  *     }
    240  * }
    241  *
    242  * Compiled byte code below.
    243  */
    244 unsigned char MethodCode[] =
    245 {
    246     0x44,0x53,0x44,0x54,0x53,0x00,0x00,0x00,  /* 00000000    "DSDTS..." */
    247     0x02,0xF9,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    "..Intel." */
    248     0x4D,0x54,0x48,0x44,0x54,0x45,0x53,0x54,  /* 00000010    "MTHDTEST" */
    249     0x12,0x05,0x09,0x20,0x49,0x4E,0x54,0x4C,  /* 00000018    "... INTL" */
    250     0x22,0x04,0x09,0x20,0x14,0x2E,0x2E,0x5F,  /* 00000020    "".. ..._" */
    251     0x54,0x49,0x5F,0x5F,0x54,0x39,0x37,0x09,  /* 00000028    "SI__T97." */
    252     0x70,0x0D,0x45,0x78,0x61,0x6D,0x70,0x6C,  /* 00000030    "p.Exampl" */
    253     0x65,0x20,0x69,0x6E,0x73,0x74,0x61,0x6C,  /* 00000038    "e instal" */
    254     0x6C,0x65,0x64,0x20,0x6D,0x65,0x74,0x68,  /* 00000040    "led meth" */
    255     0x6F,0x64,0x00,0x5B,0x31,0x70,0x68,0x5B,  /* 00000048    "od.[1ph[" */
    256     0x31,0xA4,0x00,
    257 };
    258 
    259 
    260 /*
    261  * We need a local FADT so that the hardware subcomponent will function,
    262  * even though the underlying OSD HW access functions don't do
    263  * anything.
    264  */
    265 ACPI_TABLE_HEADER           *DsdtToInstallOverride;
    266 ACPI_TABLE_RSDP             LocalRSDP;
    267 ACPI_TABLE_FADT             LocalFADT;
    268 ACPI_TABLE_FACS             LocalFACS;
    269 ACPI_TABLE_HEADER           LocalTEST;
    270 ACPI_TABLE_HEADER           LocalBADTABLE;
    271 ACPI_TABLE_RSDT             *LocalRSDT;
    272 
    273 #define BASE_RSDT_TABLES    7
    274 #define BASE_RSDT_SIZE      (sizeof (ACPI_TABLE_RSDT) + ((BASE_RSDT_TABLES -1) * sizeof (UINT32)))
    275 
    276 #define ACPI_MAX_INIT_TABLES (32)
    277 static ACPI_TABLE_DESC      Tables[ACPI_MAX_INIT_TABLES];
    278 
    279 
    280 /******************************************************************************
    281  *
    282  * FUNCTION:    AeTableOverride
    283  *
    284  * DESCRIPTION: Local implementation of AcpiOsTableOverride.
    285  *              Exercise the override mechanism
    286  *
    287  *****************************************************************************/
    288 
    289 void
    290 AeTableOverride (
    291     ACPI_TABLE_HEADER       *ExistingTable,
    292     ACPI_TABLE_HEADER       **NewTable)
    293 {
    294 
    295     /* This code exercises the table override mechanism in the core */
    296 
    297     if (ACPI_COMPARE_NAME (ExistingTable->Signature, ACPI_SIG_DSDT))
    298     {
    299         *NewTable = DsdtToInstallOverride;
    300     }
    301 
    302     /* This code tests override of dynamically loaded tables */
    303 
    304     else if (ACPI_COMPARE_NAME (ExistingTable->Signature, "TSDT"))
    305     {
    306         *NewTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Ssdt3Code);
    307     }
    308 }
    309 
    310 
    311 /******************************************************************************
    312  *
    313  * FUNCTION:    AeBuildLocalTables
    314  *
    315  * PARAMETERS:  TableCount      - Number of tables on the command line
    316  *              TableList       - List of actual tables from files
    317  *
    318  * RETURN:      Status
    319  *
    320  * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, RSDT,
    321  *              FADT, and several other test tables.
    322  *
    323  *****************************************************************************/
    324 
    325 ACPI_STATUS
    326 AeBuildLocalTables (
    327     UINT32                  TableCount,
    328     AE_TABLE_DESC           *TableList)
    329 {
    330     ACPI_PHYSICAL_ADDRESS   DsdtAddress = 0;
    331     UINT32                  RsdtSize;
    332     AE_TABLE_DESC           *NextTable;
    333     UINT32                  NextIndex;
    334     ACPI_TABLE_FADT         *ExternalFadt = NULL;
    335 
    336 
    337     /*
    338      * Update the table count. For DSDT, it is not put into the RSDT. For
    339      * FADT, this is already accounted for since we usually install a
    340      * local FADT.
    341      */
    342     NextTable = TableList;
    343     while (NextTable)
    344     {
    345         if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) ||
    346             ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
    347         {
    348             TableCount--;
    349         }
    350         NextTable = NextTable->Next;
    351     }
    352 
    353     RsdtSize = BASE_RSDT_SIZE + (TableCount * sizeof (UINT32));
    354 
    355     /* Build an RSDT */
    356 
    357     LocalRSDT = AcpiOsAllocate (RsdtSize);
    358     if (!LocalRSDT)
    359     {
    360         return AE_NO_MEMORY;
    361     }
    362 
    363     ACPI_MEMSET (LocalRSDT, 0, RsdtSize);
    364     ACPI_STRNCPY (LocalRSDT->Header.Signature, ACPI_SIG_RSDT, 4);
    365     LocalRSDT->Header.Length = RsdtSize;
    366 
    367     LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
    368     LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
    369     LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
    370 
    371     /* Install two SSDTs to test multiple table support */
    372 
    373     LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
    374     LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
    375 
    376     /* Install the OEM1 table to test LoadTable */
    377 
    378     LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
    379 
    380     /* Install the OEMx table to test LoadTable */
    381 
    382     LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&OemxCode);
    383 
    384     /*
    385      * Install the user tables. The DSDT must be installed in the FADT.
    386      * All other tables are installed directly into the RSDT.
    387      */
    388     NextIndex = BASE_RSDT_TABLES;
    389     NextTable = TableList;
    390     while (NextTable)
    391     {
    392         /*
    393          * Incoming DSDT or FADT are special cases. All other tables are
    394          * just immediately installed into the RSDT.
    395          */
    396         if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT))
    397         {
    398             if (DsdtAddress)
    399             {
    400                 printf ("Already found a DSDT, only one allowed\n");
    401                 return AE_ALREADY_EXISTS;
    402             }
    403 
    404             /* The incoming user table is a DSDT */
    405 
    406             DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode);
    407             DsdtToInstallOverride = NextTable->Table;
    408         }
    409         else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
    410         {
    411             ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table);
    412             LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
    413         }
    414         else
    415         {
    416             /* Install the table in the RSDT */
    417 
    418             LocalRSDT->TableOffsetEntry[NextIndex] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
    419             NextIndex++;
    420         }
    421 
    422         NextTable = NextTable->Next;
    423     }
    424 
    425     /* Build an RSDP */
    426 
    427     ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP));
    428     ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8);
    429     ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6);
    430     LocalRSDP.Revision = 1;
    431     LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT);
    432     LocalRSDP.Length = sizeof (ACPI_TABLE_RSDT);
    433 
    434     /* Set checksums for both RSDT and RSDP */
    435 
    436     LocalRSDT->Header.Checksum = (UINT8) -AcpiTbChecksum (
    437         (void *) LocalRSDT, LocalRSDT->Header.Length);
    438     LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum (
    439         (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH);
    440 
    441     if (!DsdtAddress)
    442     {
    443         /* Use the local DSDT because incoming table(s) are all SSDT(s) */
    444 
    445         DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode);
    446         DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode);
    447     }
    448 
    449     if (ExternalFadt)
    450     {
    451         /*
    452          * Use the external FADT, but we must update the DSDT/FACS addresses
    453          * as well as the checksum
    454          */
    455         ExternalFadt->Dsdt = DsdtAddress;
    456         ExternalFadt->Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    457 
    458         if (ExternalFadt->Header.Length > ACPI_PTR_DIFF (&ExternalFadt->XDsdt, ExternalFadt))
    459         {
    460             ExternalFadt->XDsdt = DsdtAddress;
    461             ExternalFadt->XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    462         }
    463         /* Complete the FADT with the checksum */
    464 
    465         ExternalFadt->Header.Checksum = 0;
    466         ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum (
    467             (void *) ExternalFadt, ExternalFadt->Header.Length);
    468     }
    469     else
    470     {
    471         /*
    472          * Build a local FADT so we can test the hardware/event init
    473          */
    474         ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
    475         ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4);
    476 
    477         /* Setup FADT header and DSDT/FACS addresses */
    478 
    479         LocalFADT.Dsdt = DsdtAddress;
    480         LocalFADT.Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    481 
    482         LocalFADT.XDsdt = DsdtAddress;
    483         LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    484 
    485         LocalFADT.Header.Revision = 3;
    486         LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT);
    487 
    488         /* Miscellaneous FADT fields */
    489 
    490         LocalFADT.Gpe0BlockLength = 16;
    491         LocalFADT.Gpe1BlockLength = 6;
    492         LocalFADT.Gpe1Base = 96;
    493 
    494         LocalFADT.Pm1EventLength = 4;
    495         LocalFADT.Pm1ControlLength = 2;
    496         LocalFADT.PmTimerLength  = 4;
    497 
    498         LocalFADT.Gpe0Block = 0x00001234;
    499         LocalFADT.Gpe1Block = 0x00005678;
    500 
    501         LocalFADT.Pm1aEventBlock = 0x00001aaa;
    502         LocalFADT.Pm1bEventBlock = 0x00001bbb;
    503         LocalFADT.PmTimerBlock = 0xA0;
    504         LocalFADT.Pm1aControlBlock = 0xB0;
    505 
    506         /* Setup one example X-64 field */
    507 
    508         LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
    509         LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock;
    510         LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength);
    511 
    512         /* Complete the FADT with the checksum */
    513 
    514         LocalFADT.Header.Checksum = 0;
    515         LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum (
    516             (void *) &LocalFADT, LocalFADT.Header.Length);
    517     }
    518 
    519     /* Build a FACS */
    520 
    521     ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
    522     ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4);
    523 
    524     LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
    525     LocalFACS.GlobalLock = 0x11AA0011;
    526 
    527     /* Build a fake table [TEST] so that we make sure that the CA core ignores it */
    528 
    529     ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
    530     ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
    531 
    532     LocalTEST.Revision = 1;
    533     LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
    534     LocalTEST.Checksum = (UINT8) -AcpiTbChecksum (
    535         (void *) &LocalTEST, LocalTEST.Length);
    536 
    537     /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */
    538 
    539     ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
    540     ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
    541 
    542     LocalBADTABLE.Revision = 1;
    543     LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
    544     LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum (
    545         (void *) &LocalBADTABLE, LocalBADTABLE.Length);
    546 
    547     return (AE_OK);
    548 }
    549 
    550 
    551 /******************************************************************************
    552  *
    553  * FUNCTION:    AeInstallTables
    554  *
    555  * PARAMETERS:  None
    556  *
    557  * RETURN:      Status
    558  *
    559  * DESCRIPTION: Install the various ACPI tables
    560  *
    561  *****************************************************************************/
    562 
    563 ACPI_STATUS
    564 AeInstallTables (
    565     void)
    566 {
    567     ACPI_STATUS             Status;
    568 
    569     Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE);
    570     Status = AcpiReallocateRootTable ();
    571     Status = AcpiLoadTables ();
    572 
    573     /*
    574      * Test run-time control method installation. Do it twice to test code
    575      * for an existing name.
    576      */
    577     Status = AcpiInstallMethod (MethodCode);
    578     if (ACPI_FAILURE (Status))
    579     {
    580         AcpiOsPrintf ("%s, Could not install method\n",
    581             AcpiFormatException (Status));
    582     }
    583 
    584     Status = AcpiInstallMethod (MethodCode);
    585     if (ACPI_FAILURE (Status))
    586     {
    587         AcpiOsPrintf ("%s, Could not install method\n",
    588             AcpiFormatException (Status));
    589     }
    590 
    591     return (AE_OK);
    592 }
    593 
    594 
    595 /******************************************************************************
    596  *
    597  * FUNCTION:    AeLocalGetRootPointer
    598  *
    599  * PARAMETERS:  Flags       - not used
    600  *              Address     - Where the root pointer is returned
    601  *
    602  * RETURN:      Status
    603  *
    604  * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
    605  *              standard ACPI mechanism.
    606  *
    607  *****************************************************************************/
    608 
    609 ACPI_PHYSICAL_ADDRESS
    610 AeLocalGetRootPointer (
    611     void)
    612 {
    613 
    614     return ((ACPI_PHYSICAL_ADDRESS) &LocalRSDP);
    615 }
    616 
    617 
    618 #if 0
    619 /******************************************************************************
    620  *
    621  * DESCRIPTION: ASL tables that are used in RSDT/XSDT, also used to test
    622  *              Load/LoadTable operators.
    623  *
    624  *****************************************************************************/
    625 
    626 DefinitionBlock ("", "OEMX", 2, "MyOEM", "Test", 0x00000432)
    627 {
    628     External (GPE2, DeviceObj)
    629 
    630     Method (_INI)
    631     {
    632         Store ("Table OEMX running", Debug)
    633     }
    634 
    635     Scope (\_GPE)
    636     {
    637         Method (_E07) {}
    638         Method (_E22) {}
    639         Method (_L31) {}
    640         Method (_L66) {}
    641     }
    642 
    643     Device (OEM1)
    644     {
    645         Name (_PRW, Package(){7,0})
    646     }
    647     Device (OEM2)
    648     {
    649         Name (_PRW, Package(){0x66,0})
    650     }
    651 
    652     Scope (\GPE2)
    653     {
    654         Method (_L01) {}
    655         Method (_E07) {}
    656 
    657         Name (_PRW, Package() {Package() {\GPE2, 1}, 0})
    658     }
    659 }
    660 
    661 /* Parent gr.asl file */
    662 
    663 DefinitionBlock ("", "DSDT", 2, "Intel", "Many", 0x00000001)
    664 {
    665     Name (BUF1, Buffer()
    666     {
    667         0x4F,0x45,0x4D,0x58,0xB0,0x00,0x00,0x00,  /* 00000000    "OEMX...." */
    668         0x02,0x54,0x4D,0x79,0x4F,0x45,0x4D,0x00,  /* 00000008    ".TMyOEM." */
    669         0x54,0x65,0x73,0x74,0x00,0x00,0x00,0x00,  /* 00000010    "Test...." */
    670         0x32,0x04,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "2...INTL" */
    671         0x31,0x03,0x10,0x20,0x14,0x1D,0x5F,0x49,  /* 00000020    "1.. .._I" */
    672         0x4E,0x49,0x00,0x70,0x0D,0x54,0x61,0x62,  /* 00000028    "NI.p.Tab" */
    673         0x6C,0x65,0x20,0x4F,0x45,0x4D,0x58,0x20,  /* 00000030    "le OEMX " */
    674         0x72,0x75,0x6E,0x6E,0x69,0x6E,0x67,0x00,  /* 00000038    "running." */
    675         0x5B,0x31,0x10,0x22,0x5C,0x5F,0x47,0x50,  /* 00000040    "[1."\_GP" */
    676         0x45,0x14,0x06,0x5F,0x45,0x30,0x37,0x00,  /* 00000048    "E.._E07." */
    677         0x14,0x06,0x5F,0x45,0x32,0x32,0x00,0x14,  /* 00000050    ".._E22.." */
    678         0x06,0x5F,0x4C,0x33,0x31,0x00,0x14,0x06,  /* 00000058    "._L31..." */
    679         0x5F,0x4C,0x36,0x36,0x00,0x5B,0x82,0x10,  /* 00000060    "_L66.[.." */
    680         0x4F,0x45,0x4D,0x31,0x08,0x5F,0x50,0x52,  /* 00000068    "OEM1._PR" */
    681         0x57,0x12,0x05,0x02,0x0A,0x07,0x00,0x5B,  /* 00000070    "W......[" */
    682         0x82,0x10,0x4F,0x45,0x4D,0x32,0x08,0x5F,  /* 00000078    "..OEM2._" */
    683         0x50,0x52,0x57,0x12,0x05,0x02,0x0A,0x66,  /* 00000080    "PRW....f" */
    684         0x00,0x10,0x26,0x5C,0x47,0x50,0x45,0x32,  /* 00000088    "..&\GPE2" */
    685         0x14,0x06,0x5F,0x4C,0x30,0x31,0x00,0x14,  /* 00000090    ".._L01.." */
    686         0x06,0x5F,0x45,0x30,0x37,0x00,0x08,0x5F,  /* 00000098    "._E07.._" */
    687         0x50,0x52,0x57,0x12,0x0C,0x02,0x12,0x08,  /* 000000A0    "PRW....." */
    688         0x02,0x5C,0x47,0x50,0x45,0x32,0x01,0x00   /* 000000A8    ".\GPE2.." */
    689     })
    690 
    691     Name (HNDL, 0)
    692     Method (LD)
    693     {
    694         Load (BUF1, HNDL)
    695         Store ("Load operator, handle:", Debug)
    696         Store (HNDL, Debug)
    697     }
    698 
    699     Method (MAIN, 0, NotSerialized)
    700     {
    701         Store ("Loading OEMX table", Debug)
    702         Store (LoadTable ("OEMX", "MyOEM", "Test"), Debug)
    703     }
    704 
    705     Scope (\_GPE)
    706     {
    707         Method (_L08) {}
    708         Method (_E08) {}
    709         Method (_L0B) {}
    710     }
    711 
    712     Device (DEV0)
    713     {
    714         Name (_PRW, Package() {0x11, 0})
    715     }
    716 
    717     Device (\GPE2)
    718     {
    719         Method (_L00) {}
    720     }
    721 }
    722 
    723 #endif
    724 
    725