1 /******************************************************************************
3 * Module Name: aetables - Miscellaneous ACPI tables for acpiexec utility
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
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
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
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;
37 * The above copyright and patent license is granted only if the following
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.
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
80 * 4. Disclaimer and Export Compliance
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
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
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.
114 *****************************************************************************/
116 #include "aecommon.h"
118 #define _COMPONENT ACPI_TOOLS
119 ACPI_MODULE_NAME ("aetables")
121 /* Local prototypes */
125 ACPI_TABLE_HEADER *ExistingTable,
126 ACPI_TABLE_HEADER **NewTable);
128 ACPI_PHYSICAL_ADDRESS
129 AeLocalGetRootPointer (
133 * Misc ACPI tables to be installed
136 /* Default DSDT. This will be replaced with the input DSDT */
138 unsigned char DsdtCode[] =
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" */
147 unsigned char LocalDsdtCode[] =
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" */
156 /* Several example SSDTs */
158 unsigned char Ssdt1Code[] = /* Has method _T98 */
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..`." */
168 unsigned char Ssdt2Code[] = /* Has method _T99 */
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..`." */
178 unsigned char Ssdt3Code[] = /* Has method _T97 */
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..`." */
188 /* Example OEM table */
190 unsigned char Oem1Code[] =
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" */
202 * Example installable control method
204 * DefinitionBlock ("", "DSDT", 2, "Intel", "MTHDTEST", 0x20090512)
206 * Method (\_SI_._T97, 1, Serialized)
208 * Store ("Example installed method", Debug)
209 * Store (Arg0, Debug)
214 * Compiled byte code below.
216 unsigned char MethodCode[] =
218 0x44,0x53,0x44,0x54,0x53,0x00,0x00,0x00, /* 00000000 "DSDTS..." */
219 0x02,0xF9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
220 0x4D,0x54,0x48,0x44,0x54,0x45,0x53,0x54, /* 00000010 "MTHDTEST" */
221 0x12,0x05,0x09,0x20,0x49,0x4E,0x54,0x4C, /* 00000018 "... INTL" */
222 0x22,0x04,0x09,0x20,0x14,0x2E,0x2E,0x5F, /* 00000020 "".. ..._" */
223 0x54,0x49,0x5F,0x5F,0x54,0x39,0x37,0x09, /* 00000028 "SI__T97." */
224 0x70,0x0D,0x45,0x78,0x61,0x6D,0x70,0x6C, /* 00000030 "p.Exampl" */
225 0x65,0x20,0x69,0x6E,0x73,0x74,0x61,0x6C, /* 00000038 "e instal" */
226 0x6C,0x65,0x64,0x20,0x6D,0x65,0x74,0x68, /* 00000040 "led meth" */
227 0x6F,0x64,0x00,0x5B,0x31,0x70,0x68,0x5B, /* 00000048 "od.[1ph[" */
233 * We need a local FADT so that the hardware subcomponent will function,
234 * even though the underlying OSD HW access functions don't do
237 ACPI_TABLE_HEADER *DsdtToInstallOverride;
238 ACPI_TABLE_RSDP LocalRSDP;
239 ACPI_TABLE_FADT LocalFADT;
240 ACPI_TABLE_FACS LocalFACS;
241 ACPI_TABLE_HEADER LocalTEST;
242 ACPI_TABLE_HEADER LocalBADTABLE;
243 ACPI_TABLE_RSDT *LocalRSDT;
245 #define BASE_RSDT_TABLES 6
246 #define BASE_RSDT_SIZE (sizeof (ACPI_TABLE_RSDT) + ((BASE_RSDT_TABLES -1) * sizeof (UINT32)))
248 #define ACPI_MAX_INIT_TABLES (32)
249 static ACPI_TABLE_DESC Tables[ACPI_MAX_INIT_TABLES];
252 /******************************************************************************
254 * FUNCTION: AeTableOverride
256 * DESCRIPTION: Local implementation of AcpiOsTableOverride.
257 * Exercise the override mechanism
259 *****************************************************************************/
263 ACPI_TABLE_HEADER *ExistingTable,
264 ACPI_TABLE_HEADER **NewTable)
267 /* This code exercises the table override mechanism in the core */
269 if (ACPI_COMPARE_NAME (ExistingTable->Signature, ACPI_SIG_DSDT))
271 *NewTable = DsdtToInstallOverride;
274 /* This code tests override of dynamically loaded tables */
276 else if (ACPI_COMPARE_NAME (ExistingTable->Signature, "TSDT"))
278 *NewTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Ssdt3Code);
283 /******************************************************************************
285 * FUNCTION: AeBuildLocalTables
287 * PARAMETERS: TableCount - Number of tables on the command line
288 * TableList - List of actual tables from files
292 * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, RSDT,
293 * FADT, and several other test tables.
295 *****************************************************************************/
300 AE_TABLE_DESC *TableList)
302 ACPI_PHYSICAL_ADDRESS DsdtAddress = 0;
304 AE_TABLE_DESC *NextTable;
306 ACPI_TABLE_FADT *ExternalFadt = NULL;
310 * Update the table count. For DSDT, it is not put into the RSDT. For
311 * FADT, this is already accounted for since we usually install a
314 NextTable = TableList;
317 if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT) ||
318 ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
322 NextTable = NextTable->Next;
325 RsdtSize = BASE_RSDT_SIZE + (TableCount * sizeof (UINT32));
329 LocalRSDT = AcpiOsAllocate (RsdtSize);
335 ACPI_MEMSET (LocalRSDT, 0, RsdtSize);
336 ACPI_STRNCPY (LocalRSDT->Header.Signature, ACPI_SIG_RSDT, 4);
337 LocalRSDT->Header.Length = RsdtSize;
339 LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
340 LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
341 LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
343 /* Install two SSDTs to test multiple table support */
345 LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
346 LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
348 /* Install the OEM1 table to test LoadTable */
350 LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
353 * Install the user tables. The DSDT must be installed in the FADT.
354 * All other tables are installed directly into the RSDT.
356 NextIndex = BASE_RSDT_TABLES;
357 NextTable = TableList;
361 * Incoming DSDT or FADT are special cases. All other tables are
362 * just immediately installed into the RSDT.
364 if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_DSDT))
368 printf ("Already found a DSDT, only one allowed\n");
369 return AE_ALREADY_EXISTS;
372 /* The incoming user table is a DSDT */
374 DsdtAddress = ACPI_PTR_TO_PHYSADDR (&DsdtCode);
375 DsdtToInstallOverride = NextTable->Table;
377 else if (ACPI_COMPARE_NAME (NextTable->Table->Signature, ACPI_SIG_FADT))
379 ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table);
380 LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
384 /* Install the table in the RSDT */
386 LocalRSDT->TableOffsetEntry[NextIndex] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
390 NextTable = NextTable->Next;
395 ACPI_MEMSET (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP));
396 ACPI_MEMCPY (LocalRSDP.Signature, ACPI_SIG_RSDP, 8);
397 ACPI_MEMCPY (LocalRSDP.OemId, "I_TEST", 6);
398 LocalRSDP.Revision = 1;
399 LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT);
400 LocalRSDP.Length = sizeof (ACPI_TABLE_RSDT);
402 /* Set checksums for both RSDT and RSDP */
404 LocalRSDT->Header.Checksum = (UINT8) -AcpiTbChecksum (
405 (void *) LocalRSDT, LocalRSDT->Header.Length);
406 LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum (
407 (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH);
411 /* Use the local DSDT because incoming table(s) are all SSDT(s) */
413 DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode);
414 DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode);
420 * Use the external FADT, but we must update the DSDT/FACS addresses
421 * as well as the checksum
423 ExternalFadt->Dsdt = DsdtAddress;
424 ExternalFadt->Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
426 if (ExternalFadt->Header.Length > ACPI_PTR_DIFF (&ExternalFadt->XDsdt, ExternalFadt))
428 ExternalFadt->XDsdt = DsdtAddress;
429 ExternalFadt->XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
431 /* Complete the FADT with the checksum */
433 ExternalFadt->Header.Checksum = 0;
434 ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum (
435 (void *) ExternalFadt, ExternalFadt->Header.Length);
440 * Build a local FADT so we can test the hardware/event init
442 ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
443 ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4);
445 /* Setup FADT header and DSDT/FACS addresses */
447 LocalFADT.Dsdt = DsdtAddress;
448 LocalFADT.Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
450 LocalFADT.XDsdt = DsdtAddress;
451 LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
453 LocalFADT.Header.Revision = 3;
454 LocalFADT.Header.Length = sizeof (ACPI_TABLE_FADT);
456 /* Miscellaneous FADT fields */
458 LocalFADT.Gpe0BlockLength = 16;
459 LocalFADT.Gpe1BlockLength = 6;
460 LocalFADT.Gpe1Base = 96;
462 LocalFADT.Pm1EventLength = 4;
463 LocalFADT.Pm1ControlLength = 2;
464 LocalFADT.PmTimerLength = 4;
466 LocalFADT.Gpe0Block = 0x00001234;
467 LocalFADT.Gpe1Block = 0x00005678;
469 LocalFADT.Pm1aEventBlock = 0x00001aaa;
470 LocalFADT.Pm1bEventBlock = 0x00001bbb;
471 LocalFADT.PmTimerBlock = 0xA0;
472 LocalFADT.Pm1aControlBlock = 0xB0;
474 /* Setup one example X-64 field */
476 LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
477 LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock;
478 LocalFADT.XPm1bEventBlock.BitWidth = (UINT8) ACPI_MUL_8 (LocalFADT.Pm1EventLength);
480 /* Complete the FADT with the checksum */
482 LocalFADT.Header.Checksum = 0;
483 LocalFADT.Header.Checksum = (UINT8) -AcpiTbChecksum (
484 (void *) &LocalFADT, LocalFADT.Header.Length);
489 ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
490 ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4);
492 LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
493 LocalFACS.GlobalLock = 0x11AA0011;
495 /* Build a fake table [TEST] so that we make sure that the CA core ignores it */
497 ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
498 ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
500 LocalTEST.Revision = 1;
501 LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
502 LocalTEST.Checksum = (UINT8) -AcpiTbChecksum (
503 (void *) &LocalTEST, LocalTEST.Length);
505 /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */
507 ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
508 ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
510 LocalBADTABLE.Revision = 1;
511 LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
512 LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum (
513 (void *) &LocalBADTABLE, LocalBADTABLE.Length);
519 /******************************************************************************
521 * FUNCTION: AeInstallTables
527 * DESCRIPTION: Install the various ACPI tables
529 *****************************************************************************/
537 Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE);
538 Status = AcpiReallocateRootTable ();
539 Status = AcpiLoadTables ();
542 * Test run-time control method installation. Do it twice to test code
543 * for an existing name.
545 Status = AcpiInstallMethod (MethodCode);
546 if (ACPI_FAILURE (Status))
548 AcpiOsPrintf ("%s, Could not install method\n",
549 AcpiFormatException (Status));
552 Status = AcpiInstallMethod (MethodCode);
553 if (ACPI_FAILURE (Status))
555 AcpiOsPrintf ("%s, Could not install method\n",
556 AcpiFormatException (Status));
563 /******************************************************************************
565 * FUNCTION: AeLocalGetRootPointer
567 * PARAMETERS: Flags - not used
568 * Address - Where the root pointer is returned
572 * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
573 * standard ACPI mechanism.
575 *****************************************************************************/
577 ACPI_PHYSICAL_ADDRESS
578 AeLocalGetRootPointer (
582 return ((ACPI_PHYSICAL_ADDRESS) &LocalRSDP);