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 /* Several example SSDTs */
149 unsigned char Ssdt1Code
[] = /* Has method _T98 */
151 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
152 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
153 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
154 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
155 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
156 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */
159 unsigned char Ssdt2Code
[] = /* Has method _T99 */
161 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
162 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
163 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
164 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
165 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
166 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */
169 unsigned char Ssdt3Code
[] = /* Has method _T97 */
171 0x54,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "TSDT0..." */
172 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
173 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
174 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
175 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
176 0x39,0x37,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "97.p..`." */
179 /* Example OEM table */
181 unsigned char Oem1Code
[] =
183 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */
184 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */
185 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
186 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
187 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */
188 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */
189 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */
193 * Example installable control method
195 * DefinitionBlock ("", "DSDT", 2, "Intel", "MTHDTEST", 0x20090512)
197 * Method (\_SI_._T97, 1, Serialized)
199 * Store ("Example installed method", Debug)
200 * Store (Arg0, Debug)
205 * Compiled byte code below.
207 unsigned char MethodCode
[] =
209 0x44,0x53,0x44,0x54,0x53,0x00,0x00,0x00, /* 00000000 "DSDTS..." */
210 0x02,0xF9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
211 0x4D,0x54,0x48,0x44,0x54,0x45,0x53,0x54, /* 00000010 "MTHDTEST" */
212 0x12,0x05,0x09,0x20,0x49,0x4E,0x54,0x4C, /* 00000018 "... INTL" */
213 0x22,0x04,0x09,0x20,0x14,0x2E,0x2E,0x5F, /* 00000020 "".. ..._" */
214 0x54,0x49,0x5F,0x5F,0x54,0x39,0x37,0x09, /* 00000028 "SI__T97." */
215 0x70,0x0D,0x45,0x78,0x61,0x6D,0x70,0x6C, /* 00000030 "p.Exampl" */
216 0x65,0x20,0x69,0x6E,0x73,0x74,0x61,0x6C, /* 00000038 "e instal" */
217 0x6C,0x65,0x64,0x20,0x6D,0x65,0x74,0x68, /* 00000040 "led meth" */
218 0x6F,0x64,0x00,0x5B,0x31,0x70,0x68,0x5B, /* 00000048 "od.[1ph[" */
224 * We need a local FADT so that the hardware subcomponent will function,
225 * even though the underlying OSD HW access functions don't do
228 ACPI_TABLE_HEADER
*DsdtToInstallOverride
;
229 ACPI_TABLE_RSDP LocalRSDP
;
230 ACPI_TABLE_FADT LocalFADT
;
231 ACPI_TABLE_FACS LocalFACS
;
232 ACPI_TABLE_HEADER LocalDSDT
;
233 ACPI_TABLE_HEADER LocalTEST
;
234 ACPI_TABLE_HEADER LocalBADTABLE
;
235 ACPI_TABLE_RSDT
*LocalRSDT
;
237 #define RSDT_TABLES 7
238 #define RSDT_SIZE (sizeof (ACPI_TABLE_RSDT) + ((RSDT_TABLES -1) * sizeof (UINT32)))
240 #define ACPI_MAX_INIT_TABLES (16)
241 static ACPI_TABLE_DESC Tables
[ACPI_MAX_INIT_TABLES
];
244 /******************************************************************************
246 * FUNCTION: AeTableOverride
248 * DESCRIPTION: Local implementation of AcpiOsTableOverride.
249 * Exercise the override mechanism
251 *****************************************************************************/
255 ACPI_TABLE_HEADER
*ExistingTable
,
256 ACPI_TABLE_HEADER
**NewTable
)
259 /* This code exercises the table override mechanism in the core */
261 if (ACPI_COMPARE_NAME (ExistingTable
->Signature
, ACPI_SIG_DSDT
))
263 *NewTable
= DsdtToInstallOverride
;
266 /* This code tests override of dynamically loaded tables */
268 else if (ACPI_COMPARE_NAME (ExistingTable
->Signature
, "TSDT"))
270 *NewTable
= ACPI_CAST_PTR (ACPI_TABLE_HEADER
, Ssdt3Code
);
275 /******************************************************************************
277 * FUNCTION: AeBuildLocalTables
279 * PARAMETERS: UserTable - pointer to an input table to be loaded.
284 * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, RSDT,
285 * FADT, and several other test tables.
287 *****************************************************************************/
291 ACPI_TABLE_HEADER
*UserTable
)
293 ACPI_PHYSICAL_ADDRESS DsdtAddress
;
298 LocalRSDT
= AcpiOsAllocate (RSDT_SIZE
);
304 ACPI_MEMSET (LocalRSDT
, 0, RSDT_SIZE
);
305 ACPI_STRNCPY (LocalRSDT
->Header
.Signature
, ACPI_SIG_RSDT
, 4);
306 LocalRSDT
->Header
.Length
= RSDT_SIZE
;
308 LocalRSDT
->TableOffsetEntry
[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST
);
309 LocalRSDT
->TableOffsetEntry
[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE
);
310 LocalRSDT
->TableOffsetEntry
[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT
);
311 LocalRSDT
->TableOffsetEntry
[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST
); /* Just a placeholder for a user SSDT */
313 /* Install two SSDTs to test multiple table support */
315 LocalRSDT
->TableOffsetEntry
[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code
);
316 LocalRSDT
->TableOffsetEntry
[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code
);
318 /* Install the OEM1 table to test LoadTable */
320 LocalRSDT
->TableOffsetEntry
[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code
);
324 ACPI_MEMSET (&LocalRSDP
, 0, sizeof (ACPI_TABLE_RSDP
));
325 ACPI_MEMCPY (LocalRSDP
.Signature
, ACPI_SIG_RSDP
, 8);
326 LocalRSDP
.Revision
= 1;
327 LocalRSDP
.RsdtPhysicalAddress
= ACPI_PTR_TO_PHYSADDR (LocalRSDT
);
328 LocalRSDP
.Length
= sizeof (ACPI_TABLE_RSDT
);
329 ACPI_MEMCPY (LocalRSDP
.OemId
, "I_TEST", 6);
332 * Examine the incoming user table. At this point, it has been verified
333 * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently
335 if (ACPI_COMPARE_NAME (UserTable
->Signature
, ACPI_SIG_DSDT
))
337 /* The incoming user table is a DSDT */
339 DsdtAddress
= ACPI_PTR_TO_PHYSADDR (&DsdtCode
);
340 DsdtToInstallOverride
= UserTable
;
344 /* Build a local DSDT because incoming table is an SSDT or PSDT */
346 ACPI_MEMSET (&LocalDSDT
, 0, sizeof (ACPI_TABLE_HEADER
));
347 ACPI_STRNCPY (LocalDSDT
.Signature
, ACPI_SIG_DSDT
, 4);
348 LocalDSDT
.Revision
= 1;
349 LocalDSDT
.Length
= sizeof (ACPI_TABLE_HEADER
);
350 LocalDSDT
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalDSDT
, LocalDSDT
.Length
);
352 /* Install incoming table (SSDT or PSDT) directly into the RSDT */
354 LocalRSDT
->TableOffsetEntry
[3] = ACPI_PTR_TO_PHYSADDR (UserTable
);
355 DsdtAddress
= ACPI_PTR_TO_PHYSADDR (&LocalDSDT
);
356 DsdtToInstallOverride
= &LocalDSDT
;
359 /* Set checksums for both RSDT and RSDP */
361 LocalRSDT
->Header
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) LocalRSDT
, LocalRSDT
->Header
.Length
);
362 LocalRSDP
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalRSDP
, ACPI_RSDP_CHECKSUM_LENGTH
);
365 * Build a FADT so we can test the hardware/event init
367 ACPI_MEMSET (&LocalFADT
, 0, sizeof (ACPI_TABLE_FADT
));
368 ACPI_STRNCPY (LocalFADT
.Header
.Signature
, ACPI_SIG_FADT
, 4);
370 /* Setup FADT header and DSDT/FACS addresses */
372 LocalFADT
.Dsdt
= DsdtAddress
;
373 LocalFADT
.Facs
= ACPI_PTR_TO_PHYSADDR (&LocalFACS
);
375 LocalFADT
.XDsdt
= DsdtAddress
;
376 LocalFADT
.XFacs
= ACPI_PTR_TO_PHYSADDR (&LocalFACS
);
378 LocalFADT
.Header
.Revision
= 3;
379 LocalFADT
.Header
.Length
= sizeof (ACPI_TABLE_FADT
);
381 /* Miscellaneous FADT fields */
383 LocalFADT
.Gpe0BlockLength
= 16;
384 LocalFADT
.Gpe1BlockLength
= 6;
385 LocalFADT
.Gpe1Base
= 96;
387 LocalFADT
.Pm1EventLength
= 4;
388 LocalFADT
.Pm1ControlLength
= 2;
389 LocalFADT
.PmTimerLength
= 4;
391 LocalFADT
.Gpe0Block
= 0x00001234;
392 LocalFADT
.Gpe1Block
= 0x00005678;
394 LocalFADT
.Pm1aEventBlock
= 0x00001aaa;
395 LocalFADT
.Pm1bEventBlock
= 0x00001bbb;
396 LocalFADT
.PmTimerBlock
= 0xA0;
397 LocalFADT
.Pm1aControlBlock
= 0xB0;
399 /* Setup one example X-64 field */
401 LocalFADT
.XPm1bEventBlock
.SpaceId
= ACPI_ADR_SPACE_SYSTEM_IO
;
402 LocalFADT
.XPm1bEventBlock
.Address
= LocalFADT
.Pm1bEventBlock
;
403 LocalFADT
.XPm1bEventBlock
.BitWidth
= (UINT8
) ACPI_MUL_8 (LocalFADT
.Pm1EventLength
);
405 /* Complete the FADT with the checksum */
407 LocalFADT
.Header
.Checksum
= 0;
408 LocalFADT
.Header
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalFADT
, LocalFADT
.Header
.Length
);
412 ACPI_MEMSET (&LocalFACS
, 0, sizeof (ACPI_TABLE_FACS
));
413 ACPI_STRNCPY (LocalFACS
.Signature
, ACPI_SIG_FACS
, 4);
414 LocalFACS
.Length
= sizeof (ACPI_TABLE_FACS
);
415 LocalFACS
.GlobalLock
= 0x11AA0011;
417 /* Build a fake table [TEST] so that we make sure that the CA core ignores it */
419 ACPI_MEMSET (&LocalTEST
, 0, sizeof (ACPI_TABLE_HEADER
));
420 ACPI_STRNCPY (LocalTEST
.Signature
, "TEST", 4);
422 LocalTEST
.Revision
= 1;
423 LocalTEST
.Length
= sizeof (ACPI_TABLE_HEADER
);
424 LocalTEST
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalTEST
, LocalTEST
.Length
);
426 /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */
428 ACPI_MEMSET (&LocalBADTABLE
, 0, sizeof (ACPI_TABLE_HEADER
));
429 ACPI_STRNCPY (LocalBADTABLE
.Signature
, "BAD!", 4);
431 LocalBADTABLE
.Revision
= 1;
432 LocalBADTABLE
.Length
= sizeof (ACPI_TABLE_HEADER
);
433 LocalBADTABLE
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalBADTABLE
, LocalBADTABLE
.Length
);
439 /******************************************************************************
441 * FUNCTION: AeInstallTables
447 * DESCRIPTION: Install the various ACPI tables
449 *****************************************************************************/
457 Status
= AcpiInitializeTables (Tables
, ACPI_MAX_INIT_TABLES
, TRUE
);
458 Status
= AcpiReallocateRootTable ();
459 Status
= AcpiLoadTables ();
462 * Test run-time control method installation. Do it twice to test code
463 * for an existing name.
465 Status
= AcpiInstallMethod (MethodCode
);
466 if (ACPI_FAILURE (Status
))
468 AcpiOsPrintf ("%s, Could not install method\n",
469 AcpiFormatException (Status
));
472 Status
= AcpiInstallMethod (MethodCode
);
473 if (ACPI_FAILURE (Status
))
475 AcpiOsPrintf ("%s, Could not install method\n",
476 AcpiFormatException (Status
));
483 /******************************************************************************
485 * FUNCTION: AeLocalGetRootPointer
487 * PARAMETERS: Flags - not used
488 * Address - Where the root pointer is returned
492 * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
493 * standard ACPI mechanism.
495 *****************************************************************************/
497 ACPI_PHYSICAL_ADDRESS
498 AeLocalGetRootPointer (
502 return ((ACPI_PHYSICAL_ADDRESS
) &LocalRSDP
);