nrelease - fix/improve livecd
[dragonfly.git] / sys / contrib / dev / acpica / source / tools / acpiexec / aetables.c
1 /******************************************************************************
2  *
3  * Module Name: aetables - ACPI table setup/install for acpiexec utility
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2021, 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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151
152 #include "aecommon.h"
153 #include "aetables.h"
154
155 #define _COMPONENT          ACPI_TOOLS
156         ACPI_MODULE_NAME    ("aetables")
157
158 /* Local prototypes */
159
160 static void
161 AeInitializeTableHeader (
162     ACPI_TABLE_HEADER       *Header,
163     char                    *Signature,
164     UINT32                  Length);
165
166 void
167 AeTableOverride (
168     ACPI_TABLE_HEADER       *ExistingTable,
169     ACPI_TABLE_HEADER       **NewTable);
170
171 /* User table (DSDT) */
172
173 static ACPI_TABLE_HEADER        *DsdtToInstallOverride;
174
175 /* Non-AML tables that are constructed locally and installed */
176
177 static ACPI_TABLE_RSDP          LocalRSDP;
178 static ACPI_TABLE_FACS          LocalFACS;
179 static ACPI_TABLE_HEADER        LocalTEST;
180 static ACPI_TABLE_HEADER        LocalBADTABLE;
181
182 /*
183  * We need a local FADT so that the hardware subcomponent will function,
184  * even though the underlying OSD HW access functions don't do anything.
185  */
186 static ACPI_TABLE_FADT          LocalFADT;
187
188 /*
189  * Use XSDT so that both 32- and 64-bit versions of this utility will
190  * function automatically.
191  */
192 static ACPI_TABLE_XSDT          *LocalXSDT;
193
194 #define BASE_XSDT_TABLES        9
195 #define BASE_XSDT_SIZE          ((BASE_XSDT_TABLES) * sizeof (UINT64))
196
197 #define ACPI_MAX_INIT_TABLES    (32)
198
199
200 /******************************************************************************
201  *
202  * FUNCTION:    AeTableOverride
203  *
204  * DESCRIPTION: Local implementation of AcpiOsTableOverride.
205  *              Exercise the override mechanism
206  *
207  *****************************************************************************/
208
209 void
210 AeTableOverride (
211     ACPI_TABLE_HEADER       *ExistingTable,
212     ACPI_TABLE_HEADER       **NewTable)
213 {
214
215     if (!AcpiGbl_LoadTestTables)
216     {
217         *NewTable = NULL;
218         return;
219     }
220
221     /* This code exercises the table override mechanism in the core */
222
223     if (ACPI_COMPARE_NAMESEG (ExistingTable->Signature, ACPI_SIG_DSDT))
224     {
225         *NewTable = DsdtToInstallOverride;
226     }
227
228     /* This code tests override of dynamically loaded tables */
229
230     else if (ACPI_COMPARE_NAMESEG (ExistingTable->Signature, "OEM9"))
231     {
232         *NewTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Ssdt3Code);
233     }
234 }
235
236
237 /******************************************************************************
238  *
239  * FUNCTION:    AeInitializeTableHeader
240  *
241  * PARAMETERS:  Header          - A valid standard ACPI table header
242  *              Signature       - Signature to insert
243  *              Length          - Length of the table
244  *
245  * RETURN:      None. Header is modified.
246  *
247  * DESCRIPTION: Initialize the table header for a local ACPI table.
248  *
249  *****************************************************************************/
250
251 static void
252 AeInitializeTableHeader (
253     ACPI_TABLE_HEADER       *Header,
254     char                    *Signature,
255     UINT32                  Length)
256 {
257
258     ACPI_COPY_NAMESEG (Header->Signature, Signature);
259     Header->Length = Length;
260
261     Header->OemRevision = 0x1001;
262     memcpy (Header->OemId, "Intel ", ACPI_OEM_ID_SIZE);
263     memcpy (Header->OemTableId, "AcpiExec", ACPI_OEM_TABLE_ID_SIZE);
264     ACPI_COPY_NAMESEG (Header->AslCompilerId, "INTL");
265     Header->AslCompilerRevision = ACPI_CA_VERSION;
266
267     /* Set the checksum, must set to zero first */
268
269     Header->Checksum = 0;
270     Header->Checksum = (UINT8) -AcpiTbChecksum (
271         (void *) Header, Header->Length);
272 }
273
274
275 /******************************************************************************
276  *
277  * FUNCTION:    AeBuildLocalTables
278  *
279  * PARAMETERS:  TableCount      - Number of tables on the command line
280  *              ListHead        - List of actual tables from files
281  *
282  * RETURN:      Status
283  *
284  * DESCRIPTION: Build a complete ACPI table chain, with a local RSDP, XSDT,
285  *              FADT, and several other test tables.
286  *
287  *****************************************************************************/
288
289 ACPI_STATUS
290 AeBuildLocalTables (
291     ACPI_NEW_TABLE_DESC     *ListHead)
292 {
293     UINT32                  TableCount = 1;
294     ACPI_PHYSICAL_ADDRESS   DsdtAddress = 0;
295     UINT32                  XsdtSize;
296     ACPI_NEW_TABLE_DESC     *NextTable;
297     UINT32                  NextIndex;
298     ACPI_TABLE_FADT         *ExternalFadt = NULL;
299
300
301     /*
302      * Update the table count. For the DSDT, it is not put into the XSDT.
303      * For the FADT, this table is already accounted for since we usually
304      * install a local FADT.
305      */
306     NextTable = ListHead;
307     while (NextTable)
308     {
309         if (!ACPI_COMPARE_NAMESEG (NextTable->Table->Signature, ACPI_SIG_DSDT) &&
310             !ACPI_COMPARE_NAMESEG (NextTable->Table->Signature, ACPI_SIG_FADT))
311         {
312             TableCount++;
313         }
314
315         NextTable = NextTable->Next;
316     }
317
318     XsdtSize = (((TableCount + 1) * sizeof (UINT64)) +
319         sizeof (ACPI_TABLE_HEADER));
320     if (AcpiGbl_LoadTestTables)
321     {
322         XsdtSize += BASE_XSDT_SIZE;
323     }
324
325     /* Build an XSDT */
326
327     LocalXSDT = AcpiOsAllocate (XsdtSize);
328     if (!LocalXSDT)
329     {
330         return (AE_NO_MEMORY);
331     }
332
333     memset (LocalXSDT, 0, XsdtSize);
334     LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
335     NextIndex = 1;
336
337     /*
338      * Install the user tables. The DSDT must be installed in the FADT.
339      * All other tables are installed directly into the XSDT.
340      */
341     NextTable = ListHead;
342     while (NextTable)
343     {
344         /*
345          * Incoming DSDT or FADT are special cases. All other tables are
346          * just immediately installed into the XSDT.
347          */
348         if (ACPI_COMPARE_NAMESEG (NextTable->Table->Signature, ACPI_SIG_DSDT))
349         {
350             if (DsdtAddress)
351             {
352                 printf ("Already found a DSDT, only one allowed\n");
353                 return (AE_ALREADY_EXISTS);
354             }
355
356             /* The incoming user table is a DSDT */
357
358             DsdtAddress = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
359             DsdtToInstallOverride = NextTable->Table;
360         }
361         else if (ACPI_COMPARE_NAMESEG (NextTable->Table->Signature, ACPI_SIG_FADT))
362         {
363             ExternalFadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, NextTable->Table);
364             LocalXSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (NextTable->Table);
365         }
366         else
367         {
368             /* Install the table in the XSDT */
369
370             LocalXSDT->TableOffsetEntry[NextIndex] =
371                 ACPI_PTR_TO_PHYSADDR (NextTable->Table);
372             NextIndex++;
373         }
374
375         NextTable = NextTable->Next;
376     }
377
378     /* Install the optional extra local tables */
379
380     if (AcpiGbl_LoadTestTables)
381     {
382         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
383         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
384
385         /* Install two SSDTs to test multiple table support */
386
387         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
388         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
389
390         /* Install the OEM1 table to test LoadTable */
391
392         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
393
394         /* Install the OEMx table to test LoadTable */
395
396         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&OemxCode);
397
398          /* Install the ECDT table to test _REG */
399
400         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&EcdtCode);
401
402         /* Install two UEFIs to test multiple table support */
403
404         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Uefi1Code);
405         LocalXSDT->TableOffsetEntry[NextIndex++] = ACPI_PTR_TO_PHYSADDR (&Uefi2Code);
406     }
407
408     /* Build an RSDP. Contains a valid XSDT only, no RSDT */
409
410     memset (&LocalRSDP, 0, sizeof (ACPI_TABLE_RSDP));
411     ACPI_MAKE_RSDP_SIG (LocalRSDP.Signature);
412     memcpy (LocalRSDP.OemId, "Intel", 6);
413
414     LocalRSDP.Revision = 2;
415     LocalRSDP.XsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalXSDT);
416     LocalRSDP.Length = sizeof (ACPI_TABLE_RSDP);
417
418     /* Set checksums for both XSDT and RSDP */
419
420     AeInitializeTableHeader ((void *) LocalXSDT, ACPI_SIG_XSDT, XsdtSize);
421
422     LocalRSDP.Checksum = 0;
423     LocalRSDP.Checksum = (UINT8) -AcpiTbChecksum (
424         (void *) &LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH);
425
426     if (!DsdtAddress)
427     {
428         /* Use the local DSDT because incoming table(s) are all SSDT(s) */
429
430         DsdtAddress = ACPI_PTR_TO_PHYSADDR (LocalDsdtCode);
431         DsdtToInstallOverride = ACPI_CAST_PTR (ACPI_TABLE_HEADER, LocalDsdtCode);
432     }
433
434     /*
435      * Build an FADT. There are three options for the FADT:
436      * 1) Incoming external FADT specified on the command line
437      * 2) A "hardware reduced" local FADT
438      * 3) A fully featured local FADT
439      */
440     memset (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
441
442     if (ExternalFadt)
443     {
444         /*
445          * Use the external FADT, but we must update the DSDT/FACS
446          * addresses as well as the checksum
447          */
448         ExternalFadt->Dsdt = (UINT32) DsdtAddress;
449         if (!AcpiGbl_ReducedHardware)
450         {
451             ExternalFadt->Facs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
452         }
453
454         /*
455          * If there room in the FADT for the XDsdt and XFacs 64-bit
456          * pointers, use them.
457          */
458         if (ExternalFadt->Header.Length > ACPI_PTR_DIFF (
459             &ExternalFadt->XDsdt, ExternalFadt))
460         {
461             ExternalFadt->Dsdt = 0;
462             ExternalFadt->Facs = 0;
463
464             ExternalFadt->XDsdt = DsdtAddress;
465             if (!AcpiGbl_ReducedHardware)
466             {
467                 ExternalFadt->XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
468             }
469         }
470
471         /* Complete the external FADT with the checksum */
472
473         ExternalFadt->Header.Checksum = 0;
474         ExternalFadt->Header.Checksum = (UINT8) -AcpiTbChecksum (
475             (void *) ExternalFadt, ExternalFadt->Header.Length);
476     }
477     else if (AcpiGbl_UseHwReducedFadt)
478     {
479         memcpy (&LocalFADT, HwReducedFadtCode, ACPI_FADT_V5_SIZE);
480         LocalFADT.Dsdt = 0;
481         LocalFADT.XDsdt = DsdtAddress;
482     }
483     else
484     {
485         /*
486          * Build a local FADT so we can test the hardware/event init
487          */
488         LocalFADT.Header.Revision = 5;
489
490         /* Setup FADT header and DSDT/FACS addresses */
491
492         LocalFADT.Dsdt = 0;
493         LocalFADT.Facs = 0;
494
495         LocalFADT.XDsdt = DsdtAddress;
496         LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
497
498         /* Miscellaneous FADT fields */
499
500         LocalFADT.Gpe0BlockLength = 0x20;
501         LocalFADT.Gpe0Block = 0x00003210;
502
503         LocalFADT.Gpe1BlockLength = 0x20;
504         LocalFADT.Gpe1Block = 0x0000BA98;
505         LocalFADT.Gpe1Base = 0x80;
506
507         LocalFADT.Pm1EventLength = 4;
508         LocalFADT.Pm1aEventBlock = 0x00001aaa;
509         LocalFADT.Pm1bEventBlock = 0x00001bbb;
510
511         LocalFADT.Pm1ControlLength = 2;
512         LocalFADT.Pm1aControlBlock = 0xB0;
513
514         LocalFADT.PmTimerLength = 4;
515         LocalFADT.PmTimerBlock = 0xA0;
516
517         LocalFADT.Pm2ControlBlock = 0xC0;
518         LocalFADT.Pm2ControlLength = 1;
519
520         /* Setup one example X-64 GAS field */
521
522         LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
523         LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock;
524         LocalFADT.XPm1bEventBlock.BitWidth = (UINT8)
525             ACPI_MUL_8 (LocalFADT.Pm1EventLength);
526     }
527
528     AeInitializeTableHeader ((void *) &LocalFADT,
529         ACPI_SIG_FADT, sizeof (ACPI_TABLE_FADT));
530
531     /* Build a FACS */
532
533     memset (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
534     ACPI_COPY_NAMESEG (LocalFACS.Signature, ACPI_SIG_FACS);
535
536     LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
537     LocalFACS.GlobalLock = 0x11AA0011;
538
539     /* Build the optional local tables */
540
541     if (AcpiGbl_LoadTestTables)
542     {
543         /*
544          * Build a fake table [TEST] so that we make sure that the
545          * ACPICA core ignores it
546          */
547         memset (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
548         ACPI_COPY_NAMESEG (LocalTEST.Signature, "TEST");
549
550         LocalTEST.Revision = 1;
551         LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
552
553         LocalTEST.Checksum = 0;
554         LocalTEST.Checksum = (UINT8) -AcpiTbChecksum (
555             (void *) &LocalTEST, LocalTEST.Length);
556
557         /*
558          * Build a fake table with a bad signature [BAD!] so that we make
559          * sure that the ACPICA core ignores it
560          */
561         memset (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
562         ACPI_COPY_NAMESEG (LocalBADTABLE.Signature, "BAD!");
563
564         LocalBADTABLE.Revision = 1;
565         LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
566
567         LocalBADTABLE.Checksum = 0;
568         LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum (
569             (void *) &LocalBADTABLE, LocalBADTABLE.Length);
570     }
571
572     return (AE_OK);
573 }
574
575
576 /******************************************************************************
577  *
578  * FUNCTION:    AeInstallTables
579  *
580  * PARAMETERS:  None
581  *
582  * RETURN:      Status
583  *
584  * DESCRIPTION: Install the various ACPI tables
585  *
586  *****************************************************************************/
587
588 ACPI_STATUS
589 AeInstallTables (
590     void)
591 {
592     ACPI_STATUS             Status;
593     ACPI_TABLE_HEADER       Header;
594     ACPI_TABLE_HEADER       *Table;
595     UINT32                  i;
596
597
598     Status = AcpiInitializeTables (NULL, ACPI_MAX_INIT_TABLES, TRUE);
599     ACPI_CHECK_OK (AcpiInitializeTables, Status);
600
601     /*
602      * The following code is prepared to test the deferred table
603      * verification mechanism. When AcpiGbl_EnableTableValidation is set
604      * to FALSE by default, AcpiReallocateRootTable() sets it back to TRUE
605      * and triggers the deferred table verification mechanism accordingly.
606      */
607     (void) AcpiReallocateRootTable ();
608
609     if (AcpiGbl_LoadTestTables)
610     {
611         /* Test multiple table/UEFI support. First, get the headers */
612
613         Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 1, &Header);
614         ACPI_CHECK_OK (AcpiGetTableHeader, Status);
615
616         Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 2, &Header);
617         ACPI_CHECK_OK (AcpiGetTableHeader, Status);
618
619         Status = AcpiGetTableHeader (ACPI_SIG_UEFI, 3, &Header);
620         ACPI_CHECK_STATUS (AcpiGetTableHeader, Status, AE_NOT_FOUND);
621
622         /* Now get the actual tables */
623
624         Status = AcpiGetTable (ACPI_SIG_UEFI, 1, &Table);
625         ACPI_CHECK_OK (AcpiGetTable, Status);
626
627         Status = AcpiGetTable (ACPI_SIG_UEFI, 2, &Table);
628         ACPI_CHECK_OK (AcpiGetTable, Status);
629
630         Status = AcpiGetTable (ACPI_SIG_UEFI, 3, &Table);
631         ACPI_CHECK_STATUS (AcpiGetTable, Status, AE_NOT_FOUND);
632     }
633
634     /* Check that we can get all of the ACPI tables */
635
636     for (i = 0; ; i++)
637     {
638         Status = AcpiGetTableByIndex (i, &Table);
639         if ((Status == AE_BAD_PARAMETER) || !Table)
640         {
641             break;
642         }
643
644         ACPI_CHECK_OK (AcpiGetTableByIndex, Status);
645     }
646
647     return (AE_OK);
648 }
649
650
651 /******************************************************************************
652  *
653  * FUNCTION:    AeLoadTables
654  *
655  * PARAMETERS:  None
656  *
657  * RETURN:      Status
658  *
659  * DESCRIPTION: Load the definition block ACPI tables
660  *
661  *****************************************************************************/
662
663 ACPI_STATUS
664 AeLoadTables (
665     void)
666 {
667     ACPI_STATUS             Status;
668
669
670     Status = AcpiLoadTables ();
671     ACPI_CHECK_OK (AcpiLoadTables, Status);
672
673     /*
674      * Test run-time control method installation. Do it twice to test code
675      * for an existing name.
676      */
677     Status = AcpiInstallMethod (MethodCode);
678     ACPI_CHECK_OK (AcpiInstallMethod, Status);
679
680     Status = AcpiInstallMethod (MethodCode);
681     ACPI_CHECK_OK (AcpiInstallMethod, Status);
682
683     return (AE_OK);
684 }
685
686
687 /******************************************************************************
688  *
689  * FUNCTION:    AcpiOsGetRootPointer
690  *
691  * PARAMETERS:  Flags       - not used
692  *              Address     - Where the root pointer is returned
693  *
694  * RETURN:      Status
695  *
696  * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
697  *              standard ACPI mechanism.
698  *
699  *****************************************************************************/
700
701 ACPI_PHYSICAL_ADDRESS
702 AcpiOsGetRootPointer (
703     void)
704 {
705
706     return (ACPI_PTR_TO_PHYSADDR (&LocalRSDP));
707 }