1 /******************************************************************************
3 * Module Name: a16find - 16-bit (real mode) routines to find ACPI
7 *****************************************************************************/
9 /******************************************************************************
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
123 #include "acparser.h"
124 #include "actables.h"
129 #define _COMPONENT ACPI_TABLES
130 ACPI_MODULE_NAME ("a16find")
133 * This module finds ACPI tables located in memory.
134 * It is only generated for the 16-bit (real-mode) version of the utility.
137 #define ACPI_TABLE_FILE_SUFFIX ".dat"
140 #if ACPI_MACHINE_WIDTH == 16
142 UINT32 ACPI_INTERNAL_VAR_XFACE dIn32 (UINT16 port);
143 void ACPI_INTERNAL_VAR_XFACE vOut32 (UINT16 port, UINT32 Val);
144 #define ACPI_ENABLE_HPET 0x00020000
146 char FilenameBuf[20];
147 ACPI_TABLE_HEADER AcpiTblHeader;
150 UINT32 AcpiGbl_SystemFlags;
151 UINT32 AcpiGbl_RsdpOriginalLocation;
154 /******************************************************************************
156 * FUNCTION: AfWriteBuffer
162 * DESCRIPTION: Open a file and write out a single buffer
164 ******************************************************************************/
173 ACPI_NATIVE_INT Actual;
176 fp = fopen (Filename, "wb");
179 printf ("Couldn't open %s\n", Filename);
183 Actual = fwrite (Buffer, (size_t) Length, 1, fp);
189 /******************************************************************************
191 * FUNCTION: AfGenerateFilename
197 * DESCRIPTION: Build an output filename from an ACPI table ID string
199 ******************************************************************************/
202 AfGenerateFilename (char *TableId)
207 for (i = 0; i < 8 && TableId[i] != ' ' && TableId[i] != 0; i++)
209 FilenameBuf [i] = TableId[i];
213 strcat (FilenameBuf, ACPI_TABLE_FILE_SUFFIX);
218 /******************************************************************************
220 * FUNCTION: AfDumpTables
226 * DESCRIPTION: Dump the loaded tables to a file (or files)
228 ******************************************************************************/
238 AcpiOsPrintf ("No DSDT!\n");
243 Filename = AfGenerateFilename (AcpiGbl_DSDT->OemTableId);
244 AfWriteBuffer (Filename,
245 (char *) AcpiGbl_DSDT, AcpiGbl_DSDT->Length);
247 AcpiOsPrintf ("DSDT AML written to \"%s\"\n", Filename);
257 AcpiOsPrintf ("Seq: 0x%8.8X\n", value);
261 /******************************************************************************
263 * FUNCTION: CopyExtendedToReal
269 * DESCRIPTION: Copy memory above 1meg
271 ******************************************************************************/
276 UINT32 PhysicalSource,
282 RetVal = FlatMove32 (GET_PHYSICAL_ADDRESS (Destination),
283 PhysicalSource, (UINT16) Size);
285 AcpiOsPrintf ("FlatMove return: 0x%hX From %X To %X Len %X\n",
286 (int) RetVal, PhysicalSource, GET_PHYSICAL_ADDRESS (Destination), Size);
291 /******************************************************************************
293 * FUNCTION: AfFindRsdp
299 * DESCRIPTION: Scan memory to find the RSDP
301 ******************************************************************************/
304 AfFindRsdp (RSDP_DESCRIPTOR **RSDP)
309 PTR_OVL_BUILD_PTR (Rove, 0, 0);
312 /* Scan low memory */
316 if (strncmp (Rove.ptr, RSDP_SIG, (size_t) 8) == 0)
319 /* TBD: Checksum check is invalid for X descriptor */
321 /* if (AcpiTbChecksum (Rove.ptr, sizeof(RSDP_DESCRIPTOR)) != 0)
324 AcpiOsPrintf ("RSDP found at %p (Lo block)\n", Rove.ptr);
331 while (Rove.ovl.base < 0x3F);
333 /* Scan high memory */
335 PTR_OVL_BUILD_PTR (Rove, 0xE000, 0);
338 if (strncmp (Rove.ptr, RSDP_SIG, (size_t) 8) == 0)
340 AcpiOsPrintf ("RSDP found at %p (Hi block)\n", Rove.ptr);
347 while (Rove.ovl.base < 0xFFFF);
353 /******************************************************************************
355 * FUNCTION: AfRecognizeTable
357 * PARAMETERS: TablePtr - Input buffer pointer, optional
358 * TableInfo - Return value from AcpiTbGetTable
362 * DESCRIPTION: Check a table signature for a match against known table types
364 ******************************************************************************/
370 ACPI_TABLE_DESC *TableInfo)
372 ACPI_TABLE_HEADER *TableHeader;
374 ACPI_TABLE_TYPE TableType = 0;
375 void **TableGlobalPtr;
379 ACPI_FUNCTION_TRACE ("AfRecognizeTable");
382 /* Ensure that we have a valid table pointer */
384 TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer;
387 return_ACPI_STATUS (AE_BAD_PARAMETER);
390 /* Search for a signature match among the known table types */
393 for (i = 1; i < NUM_ACPI_TABLE_TYPES; i++) /* Start at one -> Skip RSDP */
395 if (!ACPI_STRNCMP (TableHeader->Signature,
396 AcpiGbl_TableData[i].Signature,
397 AcpiGbl_TableData[i].SigLength))
399 AcpiOsPrintf ("Found table [%s] Length 0x%X\n",
400 AcpiGbl_TableData[i].Signature, (UINT32) TableHeader->Length);
403 TableGlobalPtr = AcpiGbl_TableData[i].GlobalPtr;
409 /* Return the table type via the info struct */
411 TableInfo->Type = (UINT8) TableType;
412 TableInfo->Length = (ACPI_SIZE) TableHeader->Length;
415 * An AE_SUPPORT means that the table was not recognized.
416 * We ignore this table; just print a debug message
418 if (Status == AE_SUPPORT)
420 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
421 "Unsupported table %s (Type %d) was found and discarded\n",
422 AcpiGbl_TableData[TableType].Name, (UINT32) TableType));
424 return_ACPI_STATUS (Status);
427 Status = AcpiTbValidateTableHeader (TableHeader);
428 if (ACPI_FAILURE (Status))
430 /* Table failed verification, map all errors to BAD_DATA */
432 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid table header found in table named %s (Type %d)\n",
433 AcpiGbl_TableData[TableType].Name, (UINT32) TableType));
435 return_ACPI_STATUS (AE_BAD_DATA);
438 /* Now get the rest of the table */
440 *TableGlobalPtr = ACPI_MEM_ALLOCATE (AcpiTblHeader.Length);
441 if (!*TableGlobalPtr)
443 AcpiOsPrintf ("Could not allocate buffer for Acpi table of length 0x%X\n",
444 (UINT32) ((FACS_DESCRIPTOR *) &AcpiTblHeader)->Length);
445 return_ACPI_STATUS (AE_NO_MEMORY);
448 TableInfo->Pointer = *TableGlobalPtr;
450 CopyExtendedToReal (*TableGlobalPtr, PhysAddr, AcpiTblHeader.Length);
452 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s=%p, (TableGlobalPtr=%p)\n", AcpiGbl_TableData[TableType].Signature,
453 *TableGlobalPtr, TableGlobalPtr));
455 if (AcpiGbl_DbOpt_verbose)
457 AcpiUtDumpBuffer (*TableGlobalPtr, 48, 0, 0);
461 * Validate checksum for _most_ tables,
462 * even the ones whose signature we don't recognize
464 if (TableType != ACPI_TABLE_FACS)
466 /* But don't abort if the checksum is wrong */
467 /* TBD: make this a configuration option? */
469 AcpiTbVerifyTableChecksum (*TableGlobalPtr);
472 return_ACPI_STATUS (Status);
476 /******************************************************************************
478 * FUNCTION: AfGetAllTables
480 * PARAMETERS: Root - Root of the parse tree
486 *****************************************************************************/
490 UINT32 NumberOfTables,
493 ACPI_STATUS Status = AE_OK;
495 ACPI_TABLE_DESC TableInfo;
498 ACPI_FUNCTION_TRACE ("AfGetAllTables");
501 if (AcpiGbl_DbOpt_verbose)
503 AcpiOsPrintf ("Number of tables: %d\n", (UINT32) NumberOfTables);
507 * Loop through all table pointers found in RSDT.
508 * This will NOT include the FACS and DSDT - we must get
509 * them after the loop
511 for (Index = 0; Index < NumberOfTables; Index++)
513 /* Get the table via the RSDT */
515 CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]),
516 sizeof (ACPI_TABLE_HEADER));
518 TableInfo.Pointer = &AcpiTblHeader;
519 TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
520 TableInfo.Allocation = ACPI_MEM_ALLOCATED;
522 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Table pointer: %X\n",
523 (UINT32) ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index])));
525 Status = AfRecognizeTable (NULL, ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[Index]), &TableInfo);
526 if (ACPI_SUCCESS (Status))
528 AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo);
531 /* Ignore errors, just move on to next table */
536 AcpiOsPrintf ("FADT was not found, cannot obtain FACS and DSDT!\n");
537 return (AE_NO_ACPI_TABLES);
540 Status = AcpiTbConvertTableFadt ();
541 if (ACPI_FAILURE (Status))
543 return_ACPI_STATUS (Status);
549 CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl),
550 sizeof (ACPI_TABLE_HEADER));
551 AcpiGbl_FACS = ACPI_MEM_ALLOCATE (AcpiTblHeader.Length);
554 AcpiOsPrintf ("Could not allocate buffer for FADT length 0x%X\n",
555 (UINT32) AcpiTblHeader.Length);
556 return_ACPI_STATUS (AE_NO_MEMORY);
559 CopyExtendedToReal (AcpiGbl_FACS, ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl), AcpiTblHeader.Length);
561 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FACS at %p (Phys %8.8X) length %X FADT at%p\n",
562 AcpiGbl_FACS, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl),
563 (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT));
564 if (AcpiGbl_DbOpt_verbose)
566 AcpiUtDumpBuffer ((char *) AcpiGbl_FADT, sizeof (ACPI_TABLE_HEADER), 0, 0);
569 TableInfo.Type = ACPI_TABLE_FADT;
570 TableInfo.Pointer = (void *) AcpiGbl_FADT;
571 TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
572 TableInfo.Allocation = ACPI_MEM_ALLOCATED;
574 /* There is no checksum for the FACS, nothing to verify */
576 AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo);
578 AcpiTbBuildCommonFacs (&TableInfo);
583 CopyExtendedToReal (&AcpiTblHeader, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), sizeof (ACPI_TABLE_HEADER));
584 AcpiGbl_DSDT = ACPI_MEM_ALLOCATE (AcpiTblHeader.Length);
587 AcpiOsPrintf ("Could not allocate buffer for DSDT length 0x%X\n", (UINT32) AcpiTblHeader.Length);
588 return_ACPI_STATUS (AE_NO_MEMORY);
591 CopyExtendedToReal (AcpiGbl_DSDT, ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt), AcpiTblHeader.Length);
593 AcpiOsPrintf ("DSDT at %p (Phys %8.8X) length %X FADT at %p\n",
594 AcpiGbl_DSDT, (UINT32) ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt),
595 (UINT32) AcpiTblHeader.Length, AcpiGbl_FADT);
596 if (AcpiGbl_DbOpt_verbose)
598 AcpiUtDumpBuffer ((char *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER), 0, 0);
601 TableInfo.Type = ACPI_TABLE_DSDT;
602 TableInfo.Pointer = (void *) AcpiGbl_DSDT;
603 TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
604 TableInfo.Allocation = ACPI_MEM_ALLOCATED;
606 AcpiTbInitTableDescriptor (TableInfo.Type, &TableInfo);
607 AcpiTbVerifyTableChecksum ((ACPI_TABLE_HEADER *) AcpiGbl_DSDT);
609 return_ACPI_STATUS (AE_OK);
617 UINT32 PhysicalAddress;
618 UINT32 SignatureLength;
619 char *TableSignature;
621 ACPI_TABLE_DESC TableInfo;
624 ACPI_FUNCTION_TRACE ("AfGetRsdt");
631 Found = AfFindRsdp (&AcpiGbl_RSDP);
634 AcpiOsPrintf ("Could not find RSDP in the low megabyte\n");
635 return (AE_NO_ACPI_TABLES);
639 * For RSDP revision 0 or 1, we use the RSDT.
640 * For RSDP revision 2 (and above), we use the XSDT
642 if (AcpiGbl_RSDP->Revision < 2)
644 PhysicalAddress = AcpiGbl_RSDP->RsdtPhysicalAddress;
645 TableSignature = RSDT_SIG;
646 SignatureLength = sizeof (RSDT_SIG) -1;
648 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 1.0 RSDP\n"));
652 PhysicalAddress = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress);
653 TableSignature = XSDT_SIG;
654 SignatureLength = sizeof (XSDT_SIG) -1;
656 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 2.0 RSDP\n"));
659 if (AcpiGbl_DbOpt_verbose)
661 AcpiUtDumpBuffer ((char *) AcpiGbl_RSDP, sizeof (RSDP_DESCRIPTOR), 0, ACPI_UINT32_MAX);
664 /* Get the RSDT/XSDT header to determine the table length */
666 CopyExtendedToReal (&AcpiTblHeader, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
668 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDT/XSDT at %8.8X\n", (UINT32) PhysicalAddress));
669 if (AcpiGbl_DbOpt_verbose)
671 AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, ACPI_UINT32_MAX);
674 /* Validate the table header */
676 Status = AcpiTbValidateTableHeader (&AcpiTblHeader);
677 if (ACPI_FAILURE (Status))
679 /* Table failed verification, map all errors to BAD_DATA */
681 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid RSDT table header\n"));
682 return (AE_BAD_DATA);
685 /* Allocate a buffer for the entire table */
687 AcpiGbl_XSDT = (void *) malloc ((size_t) AcpiTblHeader.Length);
690 AcpiOsPrintf ("Could not allocate buffer for RSDT length 0x%X\n",
691 (UINT32) AcpiTblHeader.Length);
695 /* Get the entire RSDT/XSDT */
697 CopyExtendedToReal (AcpiGbl_XSDT, PhysicalAddress, AcpiTblHeader.Length);
698 AcpiOsPrintf ("%s at %p (Phys %8.8X)\n",
699 TableSignature, AcpiGbl_XSDT, (UINT32) PhysicalAddress);
701 if (AcpiGbl_DbOpt_verbose)
703 AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, 0);
706 /* Convert to common format XSDT */
708 TableInfo.Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_XSDT;
709 TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
710 TableInfo.Allocation = ACPI_MEM_ALLOCATED;
712 AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer);
714 Status = AcpiTbConvertToXsdt (&TableInfo);
715 if (ACPI_FAILURE (Status))
720 AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer;
732 UINT32 PhysicalAddress;
733 ACPI_TABLE_HEADER **Table;
734 ACPI_TABLE_HEADER ThisTable;
737 NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8;
739 AcpiOsPrintf ("%d Tables defined in RSDT/XSDT:\n", NumTables);
741 for (i = 0; i < NumTables; i++)
743 PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo;
744 CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
745 AcpiOsPrintf ("[%4.4s] ", ThisTable.Signature);
746 ((char *) Table) += 8;
754 ACPI_TABLE_HEADER *TableHeader,
755 UINT32 PhysicalAddress,
759 /* Allocate a buffer for the entire table */
761 *TablePtr = (void *) malloc ((size_t) TableHeader->Length);
764 AcpiOsPrintf ("Could not allocate buffer for table length 0x%X\n",
765 (UINT32) TableHeader->Length);
769 /* Get the entire table */
771 CopyExtendedToReal (*TablePtr, PhysicalAddress, TableHeader->Length);
772 AcpiOsPrintf ("%4.4s at %p (Phys %8.8X)\n",
773 TableHeader->Signature, *TablePtr, (UINT32) PhysicalAddress);
775 if (AcpiGbl_DbOpt_verbose)
777 AcpiUtDumpBuffer ((char *) TableHeader, sizeof (ACPI_TABLE_HEADER), 0, 0);
791 UINT32 PhysicalAddress;
792 ACPI_TABLE_HEADER ThisTable;
795 NumTables = (AcpiGbl_XSDT->Length - sizeof (ACPI_TABLE_HEADER)) / 8;
797 for (i = 0; i < NumTables; i++)
799 PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo;
800 CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
802 if (!ACPI_STRNCMP (TableName, ThisTable.Signature, ACPI_NAME_SIZE))
804 AfGetTable (&ThisTable, PhysicalAddress, TablePtr);
809 return (AE_NOT_FOUND);
813 /******************************************************************************
815 * FUNCTION: AfFindTable
821 * DESCRIPTION: Load the DSDT from the file pointer
823 *****************************************************************************/
834 ACPI_FUNCTION_TRACE ("AfFindTable");
839 Status = AfGetRsdt ();
840 if (ACPI_FAILURE (Status))
847 /* Get the rest of the required tables (DSDT, FADT) */
849 Status = AfGetAllTables (AcpiGbl_RsdtTableCount, NULL);
850 if (ACPI_FAILURE (Status))
855 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
859 if (!ACPI_STRNCMP (TableName, DSDT_SIG, ACPI_NAME_SIZE))
861 *TablePtr = (UINT8 *) AcpiGbl_DSDT;
862 *TableLength = AcpiGbl_DSDT->Length;
864 else if (!ACPI_STRNCMP (TableName, FADT_SIG, ACPI_NAME_SIZE))
866 *TablePtr = (UINT8 *) AcpiGbl_FADT;
867 *TableLength = AcpiGbl_FADT->Length;
869 else if (!ACPI_STRNCMP (TableName, FACS_SIG, ACPI_NAME_SIZE))
871 *TablePtr = (UINT8 *) AcpiGbl_FACS;
872 *TableLength = AcpiGbl_FACS->Length;
874 else if (!ACPI_STRNCMP (TableName, RSDT_SIG, ACPI_NAME_SIZE))
876 *TablePtr = (UINT8 *) AcpiGbl_XSDT;
877 *TableLength = AcpiGbl_XSDT->Length;
879 else if (!ACPI_STRNCMP (TableName, SSDT_SIG, ACPI_NAME_SIZE))
881 AcpiOsPrintf ("Unsupported table signature: [%4.4s]\n", TableName);
887 Status = AfGetTableFromXsdt (TableName, TablePtr);
888 if (ACPI_FAILURE (Status))
893 *TableLength = (*((ACPI_TABLE_HEADER **)TablePtr))->Length;
900 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Failure during ACPI Table initialization: %s\n",
901 AcpiFormatException (Status)));
911 HPET_DESCRIPTION_TABLE *NewTable;
912 ACPI_TABLE_HEADER TableHeader;
921 ACPI_STRNCPY (TableHeader.Signature, "HPET", 4);
922 Status = AcpiOsTableOverride (&TableHeader, (ACPI_TABLE_HEADER **) &NewTable);
923 if (ACPI_FAILURE (Status))
928 AcpiDbgLevel |= ACPI_LV_TABLES;
929 AcpiOsPrintf ("HPET table :\n");
930 AcpiUtDumpBuffer ((char *) NewTable, NewTable->Header.Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
932 for (i = 0; i < 1024; i++)
939 CopyExtendedToReal (&Value, 0xD0, 4);
940 AcpiOsPrintf ("Reg 0xD0: %8.8X\n", Value);
942 Value = dIn32 (0xD0);
943 AcpiOsPrintf ("Port 0xD0: %8.8X\n", Value);
944 Value |= ACPI_ENABLE_HPET;
946 vOut32 (0xD0, Value);
947 Value2 = dIn32 (0xD0);
948 AcpiOsPrintf ("Port 0xD0: Wrote: %8.8X got %8.8X\n", Value, Value2);
950 AcpiOsPrintf ("HPET block(at %8.8X):\n", NewTable->BaseAddress[2]);
951 CopyExtendedToReal (Hbuf, NewTable->BaseAddress[2], 1024);
952 AcpiUtDumpBuffer ((char *) Hbuf, 1024, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);