Home | History | Annotate | Line # | Download | only in acpiexec
aetables.c revision 1.1.1.2.2.2
      1  1.1.1.2.2.2  bouyer /******************************************************************************
      2  1.1.1.2.2.2  bouyer  *
      3  1.1.1.2.2.2  bouyer  * Module Name: aetables - ACPI table setup/install for acpiexec utility
      4  1.1.1.2.2.2  bouyer  *
      5  1.1.1.2.2.2  bouyer  *****************************************************************************/
      6  1.1.1.2.2.2  bouyer 
      7  1.1.1.2.2.2  bouyer /*
      8  1.1.1.2.2.2  bouyer  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.1.1.2.2.2  bouyer  * All rights reserved.
     10  1.1.1.2.2.2  bouyer  *
     11  1.1.1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
     13  1.1.1.2.2.2  bouyer  * are met:
     14  1.1.1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2.2.2  bouyer  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2.2.2  bouyer  *    without modification.
     17  1.1.1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2.2.2  bouyer  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2.2.2  bouyer  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2.2.2  bouyer  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2.2.2  bouyer  *    binary redistribution.
     22  1.1.1.2.2.2  bouyer  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2.2.2  bouyer  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.1.1.2.2.2  bouyer  *
     26  1.1.1.2.2.2  bouyer  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2.2.2  bouyer  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2.2.2  bouyer  * Software Foundation.
     29  1.1.1.2.2.2  bouyer  *
     30  1.1.1.2.2.2  bouyer  * NO WARRANTY
     31  1.1.1.2.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2.2.2  bouyer  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2.2.2  bouyer  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2.2.2  bouyer  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2.2.2  bouyer  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2.2.2  bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2.2.2  bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2.2.2  bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2.2.2  bouyer  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2.2.2  bouyer  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2.2.2  bouyer  */
     43  1.1.1.2.2.2  bouyer 
     44  1.1.1.2.2.2  bouyer #include "aecommon.h"
     45  1.1.1.2.2.2  bouyer #include "aetables.h"
     46  1.1.1.2.2.2  bouyer 
     47  1.1.1.2.2.2  bouyer #define _COMPONENT          ACPI_TOOLS
     48  1.1.1.2.2.2  bouyer         ACPI_MODULE_NAME    ("aetables")
     49  1.1.1.2.2.2  bouyer 
     50  1.1.1.2.2.2  bouyer /* Local prototypes */
     51  1.1.1.2.2.2  bouyer 
     52  1.1.1.2.2.2  bouyer void
     53  1.1.1.2.2.2  bouyer AeTableOverride (
     54  1.1.1.2.2.2  bouyer     ACPI_TABLE_HEADER       *ExistingTable,
     55  1.1.1.2.2.2  bouyer     ACPI_TABLE_HEADER       **NewTable);
     56  1.1.1.2.2.2  bouyer 
     57  1.1.1.2.2.2  bouyer ACPI_PHYSICAL_ADDRESS
     58  1.1.1.2.2.2  bouyer AeLocalGetRootPointer (
     59  1.1.1.2.2.2  bouyer     void);
     60  1.1.1.2.2.2  bouyer 
     61  1.1.1.2.2.2  bouyer /* User table (DSDT) */
     62  1.1.1.2.2.2  bouyer 
     63  1.1.1.2.2.2  bouyer static ACPI_TABLE_HEADER        *DsdtToInstallOverride;
     64  1.1.1.2.2.2  bouyer 
     65  1.1.1.2.2.2  bouyer /* Non-AML tables that are constructed locally and installed */
     66  1.1.1.2.2.2  bouyer 
     67  1.1.1.2.2.2  bouyer static ACPI_TABLE_RSDP          LocalRSDP;
     68  1.1.1.2.2.2  bouyer static ACPI_TABLE_FACS          LocalFACS;
     69  1.1.1.2.2.2  bouyer static ACPI_TABLE_HEADER        LocalTEST;
     70  1.1.1.2.2.2  bouyer static ACPI_TABLE_HEADER        LocalBADTABLE;
     71  1.1.1.2.2.2  bouyer 
     72  1.1.1.2.2.2  bouyer /*
     73  1.1.1.2.2.2  bouyer  * We need a local FADT so that the hardware subcomponent will function,
     74  1.1.1.2.2.2  bouyer  * even though the underlying OSD HW access functions don't do anything.
     75  1.1.1.2.2.2  bouyer  */
     76  1.1.1.2.2.2  bouyer static ACPI_TABLE_FADT          LocalFADT;
     77  1.1.1.2.2.2  bouyer 
     78  1.1.1.2.2.2  bouyer /*
     79  1.1.1.2.2.2  bouyer  * Use XSDT so that both 32- and 64-bit versions of this utility will
     80  1.1.1.2.2.2  bouyer  * function automatically.
     81  1.1.1.2.2.2  bouyer  */
     82  1.1.1.2.2.2  bouyer static ACPI_TABLE_XSDT          *LocalXSDT;
     83  1.1.1.2.2.2  bouyer 
     84  1.1.1.2.2.2  bouyer #define BASE_XSDT_TABLES        7
     85  1.1.1.2.2.2  bouyer #define BASE_XSDT_SIZE          (sizeof (ACPI_TABLE_XSDT) + \
     86  1.1.1.2.2.2  bouyer                                     ((BASE_XSDT_TABLES -1) * sizeof (UINT64)))
     87  1.1.1.2.2.2  bouyer 
     88  1.1.1.2.2.2  bouyer #define ACPI_MAX_INIT_TABLES    (32)
     89  1.1.1.2.2.2  bouyer static ACPI_TABLE_DESC          Tables[ACPI_MAX_INIT_TABLES];
     90  1.1.1.2.2.2  bouyer 
     91  1.1.1.2.2.2  bouyer 
     92  1.1.1.2.2.2  bouyer /******************************************************************************
     93  1.1.1.2.2.2  bouyer  *
     94  1.1.1.2.2.2  bouyer  * FUNCTION:    AeTableOverride
     95  1.1.1.2.2.2  bouyer  *
     96  1.1.1.2.2.2  bouyer  * DESCRIPTION: Local implementation of AcpiOsTableOverride.
     97  1.1.1.2.2.2  bouyer  *              Exercise the override mechanism
     98  1.1.1.2.2.2  bouyer  *
     99  1.1.1.2.2.2  bouyer  *****************************************************************************/
    100  1.1.1.2.2.2  bouyer 
    101  1.1.1.2.2.2  bouyer void
    102  1.1.1.2.2.2  bouyer AeTableOverride (
    103  1.1.1.2.2.2  bouyer     ACPI_TABLE_HEADER       *ExistingTable,
    104  1.1.1.2.2.2  bouyer     ACPI_TABLE_HEADER       **NewTable)
    105  1.1.1.2.2.2  bouyer {
    106  1.1.1.2.2.2  bouyer 
    107  1.1.1.2.2.2  bouyer     /* This code exercises the table override mechanism in the core */
    108  1.1.1.2.2.2  bouyer 
    109  1.1.1.2.2.2  bouyer     if (ACPI_COMPARE_NAME (ExistingTable->Signature, ACPI_SIG_DSDT))
    110  1.1.1.2.2.2  bouyer     {
    111  1.1.1.2.2.2  bouyer         *NewTable = DsdtToInstallOverride;
    112  1.1.1.2.2.2  bouyer     }
    113  1.1.1.2.2.2  bouyer 
    114  1.1.1.2.2.2  bouyer     /* This code tests override of dynamically loaded tables */
    115  1.1.1.2.2.2  bouyer 
    116  1.1.1.2.2.2  bouyer     else if (ACPI_COMPARE_NAME (ExistingTable->Signature, "TSDT"))
    117  1.1.1.2.2.2  bouyer     {
    118  1.1.1.2.2.2  bouyer         *NewTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Ssdt3Code);
    119  1.1.1.2.2.2  bouyer     }
    120  1.1.1.2.2.2  bouyer }
    121  1.1.1.2.2.2  bouyer 
    122  1.1.1.2.2.2  bouyer 
    123  1.1.1.2.2.2  bouyer /******************************************************************************
    124  1.1.1.2.2.2  bouyer  *
    125  1.1.1.2.2.2  bouyer  * FUNCTION:    AeBuildLocalTables
    126  1.1.1.2.2.2  bouyer  *
    127  1.1.1.2.2.2  bouyer  * PARAMETERS:  TableCount      - Number of tables on the command line
    128  1.1.1.2.2.2  bouyer  *              TableList       - List of actual tables from files
    129  1.1.1.2.2.2  bouyer  *
    130  1.1.1.2.2.2  bouyer  * RETURN:      Status
    131  1.1.1.2.2.2  bouyer  *
    132  1.1.1.2.2.2  bouyer  * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, XSDT,
    133  1.1.1.2.2.2  bouyer  *              FADT, and several other test tables.
    134  1.1.1.2.2.2  bouyer  *
    135  1.1.1.2.2.2  bouyer  *****************************************************************************/
    136  1.1.1.2.2.2  bouyer 
    137  1.1.1.2.2.2  bouyer ACPI_STATUS
    138  1.1.1.2.2.2  bouyer AeBuildLocalTables (
    139  1.1.1.2.2.2  bouyer     UINT32                  TableCount,
    140  1.1.1.2.2.2  bouyer     AE_TABLE_DESC           *TableList)
    141  1.1.1.2.2.2  bouyer {
    142  1.1.1.2.2.2  bouyer     ACPI_PHYSICAL_ADDRESS   DsdtAddress = 0;
    143  1.1.1.2.2.2  bouyer     UINT32                  XsdtSize;
    144  1.1.1.2.2.2  bouyer     AE_TABLE_DESC           *NextTable;
    145  1.1.1.2.2.2  bouyer     UINT32                  NextIndex;
    146  1.1.1.2.2.2  bouyer     ACPI_TABLE_FADT         *ExternalFadt = NULL;
    147  1.1.1.2.2.2  bouyer 
    148  1.1.1.2.2.2  bouyer 
    149  1.1.1.2.2.2  bouyer     /*
    150  1.1.1.2.2.2  bouyer      * Update the table count. For DSDT, it is not put into the XSDT. For
    151  1.1.1.2.2.2  bouyer      * FADT, this is already accounted for since we usually install a
    152  1.1.1.2.2.2  bouyer      * local FADT.
    153  1.1.1.2.2.2  bouyer      */
    154  1.1.1.2.2.2  bouyer     NextTable = TableList;
    155  1.1.1.2.2.2  bouyer     while (NextTable)
    156  1.1.1.2.2.2  bouyer     {
    157  1.1.1.2.2.2  bouyer         if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) ||
    158  1.1.1.2.2.2  bouyer             ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
    159  1.1.1.2.2.2  bouyer         {
    160  1.1.1.2.2.2  bouyer             TableCount--;
    161  1.1.1.2.2.2  bouyer         }
    162  1.1.1.2.2.2  bouyer         NextTable = NextTable->Next;
    163  1.1.1.2.2.2  bouyer     }
    164  1.1.1.2.2.2  bouyer 
    165  1.1.1.2.2.2  bouyer     XsdtSize = BASE_XSDT_SIZE + (TableCount * sizeof (UINT64));
    166  1.1.1.2.2.2  bouyer 
    167  1.1.1.2.2.2  bouyer     /* Build an XSDT */
    168  1.1.1.2.2.2  bouyer 
    169  1.1.1.2.2.2  bouyer     LocalXSDT = AcpiOsAllocate (XsdtSize);
    170  1.1.1.2.2.2  bouyer     if (!LocalXSDT)
    171  1.1.1.2.2.2  bouyer     {
    172  1.1.1.2.2.2  bouyer         return (AE_NO_MEMORY);
    173  1.1.1.2.2.2  bouyer     }
    174  1.1.1.2.2.2  bouyer 
    175  1.1.1.2.2.2  bouyer     ACPI_MEMSET (LocalXSDT, 0, XsdtSize);
    176  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (LocalXSDT->Header.Signature, ACPI_SIG_XSDT, 4);
    177  1.1.1.2.2.2  bouyer     LocalXSDT->Header.Length = XsdtSize;
    178  1.1.1.2.2.2  bouyer     LocalXSDT->Header.Revision = 1;
    179  1.1.1.2.2.2  bouyer 
    180  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
    181  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
    182  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
    183  1.1.1.2.2.2  bouyer 
    184  1.1.1.2.2.2  bouyer     /* Install two SSDTs to test multiple table support */
    185  1.1.1.2.2.2  bouyer 
    186  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
    187  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
    188  1.1.1.2.2.2  bouyer 
    189  1.1.1.2.2.2  bouyer     /* Install the OEM1 table to test LoadTable */
    190  1.1.1.2.2.2  bouyer 
    191  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
    192  1.1.1.2.2.2  bouyer 
    193  1.1.1.2.2.2  bouyer     /* Install the OEMx table to test LoadTable */
    194  1.1.1.2.2.2  bouyer 
    195  1.1.1.2.2.2  bouyer     LocalXSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&OemxCode);
    196  1.1.1.2.2.2  bouyer 
    197  1.1.1.2.2.2  bouyer     /*
    198  1.1.1.2.2.2  bouyer      * Install the user tables. The DSDT must be installed in the FADT.
    199  1.1.1.2.2.2  bouyer      * All other tables are installed directly into the XSDT.
    200  1.1.1.2.2.2  bouyer      */
    201  1.1.1.2.2.2  bouyer     NextIndex = BASE_XSDT_TABLES;
    202  1.1.1.2.2.2  bouyer     NextTable = TableList;
    203  1.1.1.2.2.2  bouyer     while (NextTable)
    204  1.1.1.2.2.2  bouyer     {
    205  1.1.1.2.2.2  bouyer         /*
    206  1.1.1.2.2.2  bouyer          * Incoming DSDT or FADT are special cases. All other tables are
    207  1.1.1.2.2.2  bouyer          * just immediately installed into the XSDT.
    208  1.1.1.2.2.2  bouyer          */
    209  1.1.1.2.2.2  bouyer         if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT))
    210  1.1.1.2.2.2  bouyer         {
    211  1.1.1.2.2.2  bouyer             if (DsdtAddress)
    212  1.1.1.2.2.2  bouyer             {
    213  1.1.1.2.2.2  bouyer                 printf ("Already found a DSDT, only one allowed\n");
    214  1.1.1.2.2.2  bouyer                 return (AE_ALREADY_EXISTS);
    215  1.1.1.2.2.2  bouyer             }
    216  1.1.1.2.2.2  bouyer 
    217  1.1.1.2.2.2  bouyer             /* The incoming user table is a DSDT */
    218  1.1.1.2.2.2  bouyer 
    219  1.1.1.2.2.2  bouyer             DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode);
    220  1.1.1.2.2.2  bouyer             DsdtToInstallOverride = NextTable->Table;
    221  1.1.1.2.2.2  bouyer         }
    222  1.1.1.2.2.2  bouyer         else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
    223  1.1.1.2.2.2  bouyer         {
    224  1.1.1.2.2.2  bouyer             ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table);
    225  1.1.1.2.2.2  bouyer             LocalXSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
    226  1.1.1.2.2.2  bouyer         }
    227  1.1.1.2.2.2  bouyer         else
    228  1.1.1.2.2.2  bouyer         {
    229  1.1.1.2.2.2  bouyer             /* Install the table in the XSDT */
    230  1.1.1.2.2.2  bouyer 
    231  1.1.1.2.2.2  bouyer             LocalXSDT->TableOffsetEntry[NextIndex] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
    232  1.1.1.2.2.2  bouyer             NextIndex++;
    233  1.1.1.2.2.2  bouyer         }
    234  1.1.1.2.2.2  bouyer 
    235  1.1.1.2.2.2  bouyer         NextTable = NextTable->Next;
    236  1.1.1.2.2.2  bouyer     }
    237  1.1.1.2.2.2  bouyer 
    238  1.1.1.2.2.2  bouyer     /* Build an RSDP */
    239  1.1.1.2.2.2  bouyer 
    240  1.1.1.2.2.2  bouyer     ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP));
    241  1.1.1.2.2.2  bouyer     ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8);
    242  1.1.1.2.2.2  bouyer     ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6);
    243  1.1.1.2.2.2  bouyer     LocalRSDP.Revision = 2;
    244  1.1.1.2.2.2  bouyer     LocalRSDP.XsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalXSDT);
    245  1.1.1.2.2.2  bouyer     LocalRSDP.Length = sizeof (ACPI_TABLE_XSDT);
    246  1.1.1.2.2.2  bouyer 
    247  1.1.1.2.2.2  bouyer     /* Set checksums for both XSDT and RSDP */
    248  1.1.1.2.2.2  bouyer 
    249  1.1.1.2.2.2  bouyer     LocalXSDT->Header.Checksum = (UINT8) -AcpiTbChecksum (
    250  1.1.1.2.2.2  bouyer         (void *) LocalXSDT, LocalXSDT->Header.Length);
    251  1.1.1.2.2.2  bouyer     LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum (
    252  1.1.1.2.2.2  bouyer         (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH);
    253  1.1.1.2.2.2  bouyer 
    254  1.1.1.2.2.2  bouyer     if (!DsdtAddress)
    255  1.1.1.2.2.2  bouyer     {
    256  1.1.1.2.2.2  bouyer         /* Use the local DSDT because incoming table(s) are all SSDT(s) */
    257  1.1.1.2.2.2  bouyer 
    258  1.1.1.2.2.2  bouyer         DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode);
    259  1.1.1.2.2.2  bouyer         DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode);
    260  1.1.1.2.2.2  bouyer     }
    261  1.1.1.2.2.2  bouyer 
    262  1.1.1.2.2.2  bouyer     if (ExternalFadt)
    263  1.1.1.2.2.2  bouyer     {
    264  1.1.1.2.2.2  bouyer         /*
    265  1.1.1.2.2.2  bouyer          * Use the external FADT, but we must update the DSDT/FACS addresses
    266  1.1.1.2.2.2  bouyer          * as well as the checksum
    267  1.1.1.2.2.2  bouyer          */
    268  1.1.1.2.2.2  bouyer         ExternalFadt->Dsdt = DsdtAddress;
    269  1.1.1.2.2.2  bouyer         ExternalFadt->Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    270  1.1.1.2.2.2  bouyer 
    271  1.1.1.2.2.2  bouyer         if (ExternalFadt->Header.Length > ACPI_PTR_DIFF (&ExternalFadt->XDsdt, ExternalFadt))
    272  1.1.1.2.2.2  bouyer         {
    273  1.1.1.2.2.2  bouyer             ExternalFadt->XDsdt = DsdtAddress;
    274  1.1.1.2.2.2  bouyer             ExternalFadt->XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    275  1.1.1.2.2.2  bouyer         }
    276  1.1.1.2.2.2  bouyer         /* Complete the FADT with the checksum */
    277  1.1.1.2.2.2  bouyer 
    278  1.1.1.2.2.2  bouyer         ExternalFadt->Header.Checksum = 0;
    279  1.1.1.2.2.2  bouyer         ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum (
    280  1.1.1.2.2.2  bouyer             (void *) ExternalFadt, ExternalFadt->Header.Length);
    281  1.1.1.2.2.2  bouyer     }
    282  1.1.1.2.2.2  bouyer     else
    283  1.1.1.2.2.2  bouyer     {
    284  1.1.1.2.2.2  bouyer         /*
    285  1.1.1.2.2.2  bouyer          * Build a local FADT so we can test the hardware/event init
    286  1.1.1.2.2.2  bouyer          */
    287  1.1.1.2.2.2  bouyer         ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
    288  1.1.1.2.2.2  bouyer         ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4);
    289  1.1.1.2.2.2  bouyer 
    290  1.1.1.2.2.2  bouyer         /* Setup FADT header and DSDT/FACS addresses */
    291  1.1.1.2.2.2  bouyer 
    292  1.1.1.2.2.2  bouyer         LocalFADT.Dsdt = 0;
    293  1.1.1.2.2.2  bouyer         LocalFADT.Facs = 0;
    294  1.1.1.2.2.2  bouyer 
    295  1.1.1.2.2.2  bouyer         LocalFADT.XDsdt = DsdtAddress;
    296  1.1.1.2.2.2  bouyer         LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
    297  1.1.1.2.2.2  bouyer 
    298  1.1.1.2.2.2  bouyer         LocalFADT.Header.Revision = 3;
    299  1.1.1.2.2.2  bouyer         LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT);
    300  1.1.1.2.2.2  bouyer 
    301  1.1.1.2.2.2  bouyer         /* Miscellaneous FADT fields */
    302  1.1.1.2.2.2  bouyer 
    303  1.1.1.2.2.2  bouyer         LocalFADT.Gpe0BlockLength = 16;
    304  1.1.1.2.2.2  bouyer         LocalFADT.Gpe0Block = 0x00001234;
    305  1.1.1.2.2.2  bouyer 
    306  1.1.1.2.2.2  bouyer         LocalFADT.Gpe1BlockLength = 6;
    307  1.1.1.2.2.2  bouyer         LocalFADT.Gpe1Block = 0x00005678;
    308  1.1.1.2.2.2  bouyer         LocalFADT.Gpe1Base = 96;
    309  1.1.1.2.2.2  bouyer 
    310  1.1.1.2.2.2  bouyer         LocalFADT.Pm1EventLength = 4;
    311  1.1.1.2.2.2  bouyer         LocalFADT.Pm1aEventBlock = 0x00001aaa;
    312  1.1.1.2.2.2  bouyer         LocalFADT.Pm1bEventBlock = 0x00001bbb;
    313  1.1.1.2.2.2  bouyer 
    314  1.1.1.2.2.2  bouyer         LocalFADT.Pm1ControlLength = 2;
    315  1.1.1.2.2.2  bouyer         LocalFADT.Pm1aControlBlock = 0xB0;
    316  1.1.1.2.2.2  bouyer 
    317  1.1.1.2.2.2  bouyer         LocalFADT.PmTimerLength = 4;
    318  1.1.1.2.2.2  bouyer         LocalFADT.PmTimerBlock = 0xA0;
    319  1.1.1.2.2.2  bouyer 
    320  1.1.1.2.2.2  bouyer         LocalFADT.Pm2ControlBlock = 0xC0;
    321  1.1.1.2.2.2  bouyer         LocalFADT.Pm2ControlLength = 1;
    322  1.1.1.2.2.2  bouyer 
    323  1.1.1.2.2.2  bouyer         /* Setup one example X-64 field */
    324  1.1.1.2.2.2  bouyer 
    325  1.1.1.2.2.2  bouyer         LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
    326  1.1.1.2.2.2  bouyer         LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock;
    327  1.1.1.2.2.2  bouyer         LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength);
    328  1.1.1.2.2.2  bouyer 
    329  1.1.1.2.2.2  bouyer         /* Complete the FADT with the checksum */
    330  1.1.1.2.2.2  bouyer 
    331  1.1.1.2.2.2  bouyer         LocalFADT.Header.Checksum = 0;
    332  1.1.1.2.2.2  bouyer         LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum (
    333  1.1.1.2.2.2  bouyer             (void *) &LocalFADT, LocalFADT.Header.Length);
    334  1.1.1.2.2.2  bouyer     }
    335  1.1.1.2.2.2  bouyer 
    336  1.1.1.2.2.2  bouyer     /* Build a FACS */
    337  1.1.1.2.2.2  bouyer 
    338  1.1.1.2.2.2  bouyer     ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
    339  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4);
    340  1.1.1.2.2.2  bouyer 
    341  1.1.1.2.2.2  bouyer     LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
    342  1.1.1.2.2.2  bouyer     LocalFACS.GlobalLock = 0x11AA0011;
    343  1.1.1.2.2.2  bouyer 
    344  1.1.1.2.2.2  bouyer     /*
    345  1.1.1.2.2.2  bouyer      * Build a fake table [TEST] so that we make sure that the
    346  1.1.1.2.2.2  bouyer      * ACPICA core ignores it
    347  1.1.1.2.2.2  bouyer      */
    348  1.1.1.2.2.2  bouyer     ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
    349  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
    350  1.1.1.2.2.2  bouyer 
    351  1.1.1.2.2.2  bouyer     LocalTEST.Revision = 1;
    352  1.1.1.2.2.2  bouyer     LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
    353  1.1.1.2.2.2  bouyer     LocalTEST.Checksum = (UINT8) -AcpiTbChecksum (
    354  1.1.1.2.2.2  bouyer         (void *) &LocalTEST, LocalTEST.Length);
    355  1.1.1.2.2.2  bouyer 
    356  1.1.1.2.2.2  bouyer     /*
    357  1.1.1.2.2.2  bouyer      * Build a fake table with a bad signature [BAD!] so that we make
    358  1.1.1.2.2.2  bouyer      * sure that the ACPICA core ignores it
    359  1.1.1.2.2.2  bouyer      */
    360  1.1.1.2.2.2  bouyer     ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
    361  1.1.1.2.2.2  bouyer     ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
    362  1.1.1.2.2.2  bouyer 
    363  1.1.1.2.2.2  bouyer     LocalBADTABLE.Revision = 1;
    364  1.1.1.2.2.2  bouyer     LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
    365  1.1.1.2.2.2  bouyer     LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum (
    366  1.1.1.2.2.2  bouyer         (void *) &LocalBADTABLE, LocalBADTABLE.Length);
    367  1.1.1.2.2.2  bouyer 
    368  1.1.1.2.2.2  bouyer     return (AE_OK);
    369  1.1.1.2.2.2  bouyer }
    370  1.1.1.2.2.2  bouyer 
    371  1.1.1.2.2.2  bouyer 
    372  1.1.1.2.2.2  bouyer /******************************************************************************
    373  1.1.1.2.2.2  bouyer  *
    374  1.1.1.2.2.2  bouyer  * FUNCTION:    AeInstallTables
    375  1.1.1.2.2.2  bouyer  *
    376  1.1.1.2.2.2  bouyer  * PARAMETERS:  None
    377  1.1.1.2.2.2  bouyer  *
    378  1.1.1.2.2.2  bouyer  * RETURN:      Status
    379  1.1.1.2.2.2  bouyer  *
    380  1.1.1.2.2.2  bouyer  * DESCRIPTION: Install the various ACPI tables
    381  1.1.1.2.2.2  bouyer  *
    382  1.1.1.2.2.2  bouyer  *****************************************************************************/
    383  1.1.1.2.2.2  bouyer 
    384  1.1.1.2.2.2  bouyer ACPI_STATUS
    385  1.1.1.2.2.2  bouyer AeInstallTables (
    386  1.1.1.2.2.2  bouyer     void)
    387  1.1.1.2.2.2  bouyer {
    388  1.1.1.2.2.2  bouyer     ACPI_STATUS             Status;
    389  1.1.1.2.2.2  bouyer 
    390  1.1.1.2.2.2  bouyer 
    391  1.1.1.2.2.2  bouyer     Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE);
    392  1.1.1.2.2.2  bouyer     AE_CHECK_OK (AcpiInitializeTables, Status);
    393  1.1.1.2.2.2  bouyer 
    394  1.1.1.2.2.2  bouyer     Status = AcpiReallocateRootTable ();
    395  1.1.1.2.2.2  bouyer     AE_CHECK_OK (AcpiReallocateRootTable, Status);
    396  1.1.1.2.2.2  bouyer 
    397  1.1.1.2.2.2  bouyer     Status = AcpiLoadTables ();
    398  1.1.1.2.2.2  bouyer     AE_CHECK_OK (AcpiLoadTables, Status);
    399  1.1.1.2.2.2  bouyer 
    400  1.1.1.2.2.2  bouyer     /*
    401  1.1.1.2.2.2  bouyer      * Test run-time control method installation. Do it twice to test code
    402  1.1.1.2.2.2  bouyer      * for an existing name.
    403  1.1.1.2.2.2  bouyer      */
    404  1.1.1.2.2.2  bouyer     Status = AcpiInstallMethod (MethodCode);
    405  1.1.1.2.2.2  bouyer     if (ACPI_FAILURE (Status))
    406  1.1.1.2.2.2  bouyer     {
    407  1.1.1.2.2.2  bouyer         AcpiOsPrintf ("%s, Could not install method\n",
    408  1.1.1.2.2.2  bouyer             AcpiFormatException (Status));
    409  1.1.1.2.2.2  bouyer     }
    410  1.1.1.2.2.2  bouyer 
    411  1.1.1.2.2.2  bouyer     Status = AcpiInstallMethod (MethodCode);
    412  1.1.1.2.2.2  bouyer     if (ACPI_FAILURE (Status))
    413  1.1.1.2.2.2  bouyer     {
    414  1.1.1.2.2.2  bouyer         AcpiOsPrintf ("%s, Could not install method\n",
    415  1.1.1.2.2.2  bouyer             AcpiFormatException (Status));
    416  1.1.1.2.2.2  bouyer     }
    417  1.1.1.2.2.2  bouyer 
    418  1.1.1.2.2.2  bouyer     return (AE_OK);
    419  1.1.1.2.2.2  bouyer }
    420  1.1.1.2.2.2  bouyer 
    421  1.1.1.2.2.2  bouyer 
    422  1.1.1.2.2.2  bouyer /******************************************************************************
    423  1.1.1.2.2.2  bouyer  *
    424  1.1.1.2.2.2  bouyer  * FUNCTION:    AeLocalGetRootPointer
    425  1.1.1.2.2.2  bouyer  *
    426  1.1.1.2.2.2  bouyer  * PARAMETERS:  Flags       - not used
    427  1.1.1.2.2.2  bouyer  *              Address     - Where the root pointer is returned
    428  1.1.1.2.2.2  bouyer  *
    429  1.1.1.2.2.2  bouyer  * RETURN:      Status
    430  1.1.1.2.2.2  bouyer  *
    431  1.1.1.2.2.2  bouyer  * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
    432  1.1.1.2.2.2  bouyer  *              standard ACPI mechanism.
    433  1.1.1.2.2.2  bouyer  *
    434  1.1.1.2.2.2  bouyer  *****************************************************************************/
    435  1.1.1.2.2.2  bouyer 
    436  1.1.1.2.2.2  bouyer ACPI_PHYSICAL_ADDRESS
    437  1.1.1.2.2.2  bouyer AeLocalGetRootPointer (
    438  1.1.1.2.2.2  bouyer     void)
    439  1.1.1.2.2.2  bouyer {
    440  1.1.1.2.2.2  bouyer 
    441  1.1.1.2.2.2  bouyer     return ((ACPI_PHYSICAL_ADDRESS) &LocalRSDP);
    442  1.1.1.2.2.2  bouyer }
    443