Browse Source

build: now that we have glob, use it

This will simplify a lot of things ...

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
2fa59efad1

+ 0 - 610
sys/src/libacpi/acpica/common/acfileio.c

@@ -1,610 +0,0 @@
-/******************************************************************************
- *
- * Module Name: acfileio - Get ACPI tables from file
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acapps.h"
-#include "actables.h"
-#include "acutils.h"
-#include <errno.h>
-
-#define _COMPONENT          ACPI_UTILITIES
-        ACPI_MODULE_NAME    ("acfileio")
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcGetOneTableFromFile (
-    char                    *Filename,
-    FILE                    *File,
-    UINT8                   GetOnlyAmlTables,
-    ACPI_TABLE_HEADER       **Table);
-
-static ACPI_STATUS
-AcCheckTextModeCorruption (
-    ACPI_TABLE_HEADER       *Table);
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcGetAllTablesFromFile
- *
- * PARAMETERS:  Filename            - Table filename
- *              GetOnlyAmlTables    - TRUE if the tables must be AML tables
- *              ReturnListHead      - Where table list is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Get all ACPI tables from within a single file.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcGetAllTablesFromFile (
-    char                    *Filename,
-    UINT8                   GetOnlyAmlTables,
-    ACPI_NEW_TABLE_DESC     **ReturnListHead)
-{
-    ACPI_NEW_TABLE_DESC     *ListHead = NULL;
-    ACPI_NEW_TABLE_DESC     *ListTail = NULL;
-    ACPI_NEW_TABLE_DESC     *TableDesc;
-    FILE                    *File;
-    ACPI_TABLE_HEADER       *Table = NULL;
-    UINT32                  FileSize;
-    ACPI_STATUS             Status = AE_OK;
-
-
-    File = fopen (Filename, "rb");
-    if (!File)
-    {
-        perror ("Could not open input file");
-        if (errno == ENOENT)
-        {
-            return (AE_NOT_EXIST);
-        }
-
-        return (AE_ERROR);
-    }
-
-    /* Get the file size */
-
-    FileSize = CmGetFileSize (File);
-    if (FileSize == ACPI_UINT32_MAX)
-    {
-        Status = AE_ERROR;
-        goto ErrorExit;
-    }
-
-    fprintf (stderr,
-        "Input file %s, Length 0x%X (%u) bytes\n",
-        Filename, FileSize, FileSize);
-
-    /* We must have at least one ACPI table header */
-
-    if (FileSize < sizeof (ACPI_TABLE_HEADER))
-    {
-        Status = AE_BAD_HEADER;
-        goto ErrorExit;
-    }
-
-    /* Check for an non-binary file */
-
-    if (!AcIsFileBinary (File))
-    {
-        fprintf (stderr,
-            "    %s: File does not appear to contain a valid AML table\n",
-            Filename);
-        return (AE_TYPE);
-    }
-
-    /* Read all tables within the file */
-
-    while (ACPI_SUCCESS (Status))
-    {
-        /* Get one entire ACPI table */
-
-        Status = AcGetOneTableFromFile (
-            Filename, File, GetOnlyAmlTables, &Table);
-
-        if (Status == AE_CTRL_TERMINATE)
-        {
-            Status = AE_OK;
-            break;
-        }
-        else if (Status == AE_TYPE)
-        {
-            return (AE_OK);
-        }
-        else if (ACPI_FAILURE (Status))
-        {
-            goto ErrorExit;
-        }
-
-        /* Print table header for iASL/disassembler only */
-
-#ifdef ACPI_ASL_COMPILER
-
-            AcpiTbPrintTableHeader (0, Table);
-#endif
-
-        /* Allocate and link a table descriptor */
-
-        TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC));
-        TableDesc->Table = Table;
-        TableDesc->Next = NULL;
-
-        /* Link at the end of the local table list */
-
-        if (!ListHead)
-        {
-            ListHead = TableDesc;
-            ListTail = TableDesc;
-        }
-        else
-        {
-            ListTail->Next = TableDesc;
-            ListTail = TableDesc;
-        }
-    }
-
-    /* Add the local table list to the end of the global list */
-
-    if (*ReturnListHead)
-    {
-        ListTail = *ReturnListHead;
-        while (ListTail->Next)
-        {
-            ListTail = ListTail->Next;
-        }
-
-        ListTail->Next = ListHead;
-    }
-    else
-    {
-        *ReturnListHead = ListHead;
-    }
-
-ErrorExit:
-    fclose(File);
-    return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcGetOneTableFromFile
- *
- * PARAMETERS:  Filename            - File where table is located
- *              File                - Open FILE pointer to Filename
- *              GetOnlyAmlTables    - TRUE if the tables must be AML tables.
- *              ReturnTable         - Where a pointer to the table is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Read the next ACPI table from a file. Implements support
- *              for multiple tables within a single file. File must already
- *              be open.
- *
- * Note: Loading an RSDP is not supported.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcGetOneTableFromFile (
-    char                    *Filename,
-    FILE                    *File,
-    UINT8                   GetOnlyAmlTables,
-    ACPI_TABLE_HEADER       **ReturnTable)
-{
-    ACPI_STATUS             Status = AE_OK;
-    ACPI_TABLE_HEADER       TableHeader;
-    ACPI_TABLE_HEADER       *Table;
-    INT32                   Count;
-    long                    TableOffset;
-
-
-    *ReturnTable = NULL;
-
-    /* Get the table header to examine signature and length */
-
-    TableOffset = ftell (File);
-    Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
-    if (Count != sizeof (ACPI_TABLE_HEADER))
-    {
-        return (AE_CTRL_TERMINATE);
-    }
-
-    /* Validate the table signature/header (limited ASCII chars) */
-
-    Status = AcValidateTableHeader (File, TableOffset);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    if (GetOnlyAmlTables)
-    {
-        /* Table must be an AML table (DSDT/SSDT) or FADT */
-
-        if (!ACPI_COMPARE_NAME (TableHeader.Signature, ACPI_SIG_FADT) &&
-            !AcpiUtIsAmlTable (&TableHeader))
-        {
-            fprintf (stderr,
-                "    %s: Table [%4.4s] is not an AML table - ignoring\n",
-                Filename, TableHeader.Signature);
-
-            return (AE_TYPE);
-        }
-    }
-
-    /* Allocate a buffer for the entire table */
-
-    Table = AcpiOsAllocate ((size_t) TableHeader.Length);
-    if (!Table)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    /* Read the entire ACPI table, including header */
-
-    fseek (File, TableOffset, SEEK_SET);
-
-    Count = fread (Table, 1, TableHeader.Length, File);
-    if (Count != (INT32) TableHeader.Length)
-    {
-        Status = AE_ERROR;
-        goto ErrorExit;
-    }
-
-    /* Validate the checksum (just issue a warning) */
-
-    Status = AcpiTbVerifyChecksum (Table, TableHeader.Length);
-    if (ACPI_FAILURE (Status))
-    {
-        Status = AcCheckTextModeCorruption (Table);
-        if (ACPI_FAILURE (Status))
-        {
-            goto ErrorExit;
-        }
-    }
-
-    *ReturnTable = Table;
-    return (AE_OK);
-
-
-ErrorExit:
-    AcpiOsFree (Table);
-    return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcIsFileBinary
- *
- * PARAMETERS:  File                - Open input file
- *
- * RETURN:      TRUE if file appears to be binary
- *
- * DESCRIPTION: Scan a file for any non-ASCII bytes.
- *
- * Note: Maintains current file position.
- *
- ******************************************************************************/
-
-BOOLEAN
-AcIsFileBinary (
-    FILE                    *File)
-{
-    UINT8                   Byte;
-    BOOLEAN                 IsBinary = FALSE;
-    long                    FileOffset;
-
-
-    /* Scan entire file for any non-ASCII bytes */
-
-    FileOffset = ftell (File);
-    while (fread (&Byte, 1, 1, File) == 1)
-    {
-        if (!isprint (Byte) && !isspace (Byte))
-        {
-            IsBinary = TRUE;
-            goto Exit;
-        }
-    }
-
-Exit:
-    fseek (File, FileOffset, SEEK_SET);
-    return (IsBinary);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcValidateTableHeader
- *
- * PARAMETERS:  File                - Open input file
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Determine if a file seems to contain one or more binary ACPI
- *              tables, via the
- *              following checks on what would be the table header:
- *              1) File must be at least as long as an ACPI_TABLE_HEADER
- *              2) There must be enough room in the file to hold entire table
- *              3) Signature, OemId, OemTableId, AslCompilerId must be ASCII
- *
- * Note: There can be multiple definition blocks per file, so we cannot
- * expect/compare the file size to be equal to the table length. 12/2015.
- *
- * Note: Maintains current file position.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcValidateTableHeader (
-    FILE                    *File,
-    long                    TableOffset)
-{
-    ACPI_TABLE_HEADER       TableHeader;
-    size_t                  Actual;
-    long                    OriginalOffset;
-    UINT32                  FileSize;
-    UINT32                  i;
-
-
-    ACPI_FUNCTION_TRACE ("AcValidateTableHeader");
-
-
-    /* Read a potential table header */
-
-    OriginalOffset = ftell (File);
-    fseek (File, TableOffset, SEEK_SET);
-
-    Actual = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
-    fseek (File, OriginalOffset, SEEK_SET);
-
-    if (Actual < sizeof (ACPI_TABLE_HEADER))
-    {
-        return (AE_ERROR);
-    }
-
-    /* Validate the signature (limited ASCII chars) */
-
-    if (!AcpiUtValidNameseg (TableHeader.Signature))
-    {
-        fprintf (stderr, "Invalid table signature: 0x%8.8X\n",
-            *ACPI_CAST_PTR (UINT32, TableHeader.Signature));
-        return (AE_BAD_SIGNATURE);
-    }
-
-    /* Validate table length against bytes remaining in the file */
-
-    FileSize = CmGetFileSize (File);
-    if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
-    {
-        fprintf (stderr, "Table [%4.4s] is too long for file - "
-            "needs: 0x%.2X, remaining in file: 0x%.2X\n",
-            TableHeader.Signature, TableHeader.Length,
-            (UINT32) (FileSize - TableOffset));
-        return (AE_BAD_HEADER);
-    }
-
-    /*
-     * These fields must be ASCII: OemId, OemTableId, AslCompilerId.
-     * We allow a NULL terminator in OemId and OemTableId.
-     */
-    for (i = 0; i < ACPI_NAME_SIZE; i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) TableHeader.AslCompilerId[i]))
-        {
-            goto BadCharacters;
-        }
-    }
-
-    for (i = 0; (i < ACPI_OEM_ID_SIZE) && (TableHeader.OemId[i]); i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemId[i]))
-        {
-            goto BadCharacters;
-        }
-    }
-
-    for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (TableHeader.OemTableId[i]); i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemTableId[i]))
-        {
-            goto BadCharacters;
-        }
-    }
-
-    return (AE_OK);
-
-
-BadCharacters:
-
-    ACPI_WARNING ((AE_INFO,
-        "Table header for [%4.4s] has invalid ASCII character(s)",
-        TableHeader.Signature));
-    return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcCheckTextModeCorruption
- *
- * PARAMETERS:  Table           - Table buffer starting with table header
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Check table for text mode file corruption where all linefeed
- *              characters (LF) have been replaced by carriage return linefeed
- *              pairs (CR/LF).
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcCheckTextModeCorruption (
-    ACPI_TABLE_HEADER       *Table)
-{
-    UINT32                  i;
-    UINT32                  Pairs = 0;
-    UINT8                   *Buffer = ACPI_CAST_PTR (UINT8, Table);
-
-
-    /* Scan entire table to determine if each LF has been prefixed with a CR */
-
-    for (i = 1; i < Table->Length; i++)
-    {
-        if (Buffer[i] == 0x0A)
-        {
-            if (Buffer[i - 1] != 0x0D)
-            {
-                /* The LF does not have a preceding CR, table not corrupted */
-
-                return (AE_OK);
-            }
-            else
-            {
-                /* Found a CR/LF pair */
-
-                Pairs++;
-            }
-
-            i++;
-        }
-    }
-
-    if (!Pairs)
-    {
-        return (AE_OK);
-    }
-
-    /*
-     * Entire table scanned, each CR is part of a CR/LF pair --
-     * meaning that the table was treated as a text file somewhere.
-     *
-     * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
-     * original table are left untouched by the text conversion process --
-     * meaning that we cannot simply replace CR/LF pairs with LFs.
-     */
-    AcpiOsPrintf ("Table has been corrupted by text mode conversion\n");
-    AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs);
-    AcpiOsPrintf ("Table cannot be repaired!\n");
-
-    return (AE_BAD_VALUE);
-}

+ 0 - 513
sys/src/libacpi/acpica/common/acgetline.c

@@ -1,513 +0,0 @@
-/******************************************************************************
- *
- * Module Name: acgetline - local line editing
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdebug.h"
-
-#include <stdio.h>
-
-/*
- * This is an os-independent implementation of line-editing services needed
- * by the AcpiExec utility. It uses getchar() and putchar() and the existing
- * history support provided by the AML debugger. It assumes that the terminal
- * is in the correct line-editing mode such as raw and noecho. The OSL
- * interface AcpiOsInitialize should do this. AcpiOsTerminate should put the
- * terminal back into the original mode.
- */
-#define _COMPONENT          ACPI_OS_SERVICES
-        ACPI_MODULE_NAME    ("acgetline")
-
-
-/* Local prototypes */
-
-static void
-AcpiAcClearLine (
-    UINT32                  EndOfLine,
-    UINT32                  CursorPosition);
-
-/* Various ASCII constants */
-
-#define _ASCII_NUL                  0
-#define _ASCII_BACKSPACE            0x08
-#define _ASCII_TAB                  0x09
-#define _ASCII_ESCAPE               0x1B
-#define _ASCII_SPACE                0x20
-#define _ASCII_LEFT_BRACKET         0x5B
-#define _ASCII_DEL                  0x7F
-#define _ASCII_UP_ARROW             'A'
-#define _ASCII_DOWN_ARROW           'B'
-#define _ASCII_RIGHT_ARROW          'C'
-#define _ASCII_LEFT_ARROW           'D'
-#define _ASCII_NEWLINE              '\n'
-
-extern UINT32               AcpiGbl_NextCmdNum;
-
-/* Erase a single character on the input command line */
-
-#define ACPI_CLEAR_CHAR() \
-    putchar (_ASCII_BACKSPACE); \
-    putchar (_ASCII_SPACE); \
-    putchar (_ASCII_BACKSPACE);
-
-/* Backup cursor by Count positions */
-
-#define ACPI_BACKUP_CURSOR(i, Count) \
-    for (i = 0; i < (Count); i++) \
-        {putchar (_ASCII_BACKSPACE);}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiAcClearLine
- *
- * PARAMETERS:  EndOfLine           - Current end-of-line index
- *              CursorPosition      - Current cursor position within line
- *
- * RETURN:      None
- *
- * DESCRIPTION: Clear the entire command line the hard way, but probably the
- *              most portable.
- *
- *****************************************************************************/
-
-static void
-AcpiAcClearLine (
-    UINT32                  EndOfLine,
-    UINT32                  CursorPosition)
-{
-    UINT32                  i;
-
-
-    if (CursorPosition < EndOfLine)
-    {
-        /* Clear line from current position to end of line */
-
-        for (i = 0; i < (EndOfLine - CursorPosition); i++)
-        {
-            putchar (' ');
-        }
-    }
-
-    /* Clear the entire line */
-
-    for (; EndOfLine > 0; EndOfLine--)
-    {
-        ACPI_CLEAR_CHAR ();
-    }
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsGetLine
- *
- * PARAMETERS:  Buffer              - Where to return the command line
- *              BufferLength        - Maximum length of Buffer
- *              BytesRead           - Where the actual byte count is returned
- *
- * RETURN:      Status and actual bytes read
- *
- * DESCRIPTION: Get the next input line from the terminal. NOTE: terminal
- *              is expected to be in a mode that supports line-editing (raw,
- *              noecho). This function is intended to be very portable. Also,
- *              it uses the history support implemented in the AML debugger.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsGetLine (
-    char                    *Buffer,
-    UINT32                  BufferLength,
-    UINT32                  *BytesRead)
-{
-    char                    *NextCommand;
-    UINT32                  MaxCommandIndex = AcpiGbl_NextCmdNum - 1;
-    UINT32                  CurrentCommandIndex = MaxCommandIndex;
-    UINT32                  PreviousCommandIndex = MaxCommandIndex;
-    int                     InputChar;
-    UINT32                  CursorPosition = 0;
-    UINT32                  EndOfLine = 0;
-    UINT32                  i;
-
-
-    /* Always clear the line buffer before we read a new line */
-
-    memset (Buffer, 0, BufferLength);
-
-    /*
-     * This loop gets one character at a time (except for esc sequences)
-     * until a newline or error is detected.
-     *
-     * Note: Don't attempt to write terminal control ESC sequences, even
-     * though it makes certain things more difficult.
-     */
-    while (1)
-    {
-        if (EndOfLine >= (BufferLength - 1))
-        {
-            return (AE_BUFFER_OVERFLOW);
-        }
-
-        InputChar = getchar ();
-        switch (InputChar)
-        {
-        default: /* This is the normal character case */
-
-            /* Echo the character (at EOL) and copy it to the line buffer */
-
-            if (EndOfLine == CursorPosition)
-            {
-                putchar (InputChar);
-                Buffer[EndOfLine] = (char) InputChar;
-
-                EndOfLine++;
-                CursorPosition++;
-                Buffer[EndOfLine] = 0;
-                continue;
-            }
-
-            /* Insert character into the middle of the buffer */
-
-            memmove (&Buffer[CursorPosition + 1], &Buffer[CursorPosition],
-                (EndOfLine - CursorPosition + 1));
-
-            Buffer [CursorPosition] = (char) InputChar;
-            Buffer [EndOfLine + 1] = 0;
-
-            /* Display the new part of line starting at the new character */
-
-            fprintf (stdout, "%s", &Buffer[CursorPosition]);
-
-            /* Restore cursor */
-
-            ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition);
-            CursorPosition++;
-            EndOfLine++;
-            continue;
-
-        case _ASCII_DEL: /* Backspace key */
-
-            if (!EndOfLine) /* Any characters on the command line? */
-            {
-                continue;
-            }
-
-            if (EndOfLine == CursorPosition) /* Erase the final character */
-            {
-                ACPI_CLEAR_CHAR ();
-                EndOfLine--;
-                CursorPosition--;
-                continue;
-            }
-
-            if (!CursorPosition) /* Do not backup beyond start of line */
-            {
-                continue;
-            }
-
-            /* Remove the character from the line */
-
-            memmove (&Buffer[CursorPosition - 1], &Buffer[CursorPosition],
-                (EndOfLine - CursorPosition + 1));
-
-            /* Display the new part of line starting at the new character */
-
-            putchar (_ASCII_BACKSPACE);
-            fprintf (stdout, "%s ", &Buffer[CursorPosition - 1]);
-
-            /* Restore cursor */
-
-            ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition + 1);
-            EndOfLine--;
-
-            if (CursorPosition > 0)
-            {
-                CursorPosition--;
-            }
-            continue;
-
-        case _ASCII_NEWLINE: /* Normal exit case at end of command line */
-        case _ASCII_NUL:
-
-            /* Return the number of bytes in the command line string */
-
-            if (BytesRead)
-            {
-                *BytesRead = EndOfLine;
-            }
-
-            /* Echo, terminate string buffer, and exit */
-
-            putchar (InputChar);
-            Buffer[EndOfLine] = 0;
-            return (AE_OK);
-
-        case _ASCII_TAB:
-
-            /* Ignore */
-
-            continue;
-
-        case EOF:
-
-            return (AE_ERROR);
-
-        case _ASCII_ESCAPE:
-
-            /* Check for escape sequences of the form "ESC[x" */
-
-            InputChar = getchar ();
-            if (InputChar != _ASCII_LEFT_BRACKET)
-            {
-                continue; /* Ignore this ESC, does not have the '[' */
-            }
-
-            /* Get the code following the ESC [ */
-
-            InputChar = getchar (); /* Backup one character */
-            switch (InputChar)
-            {
-            case _ASCII_LEFT_ARROW:
-
-                if (CursorPosition > 0)
-                {
-                    putchar (_ASCII_BACKSPACE);
-                    CursorPosition--;
-                }
-                continue;
-
-            case _ASCII_RIGHT_ARROW:
-                /*
-                 * Move one character forward. Do this without sending
-                 * ESC sequence to the terminal for max portability.
-                 */
-                if (CursorPosition < EndOfLine)
-                {
-                    /* Backup to start of line and print the entire line */
-
-                    ACPI_BACKUP_CURSOR (i, CursorPosition);
-                    fprintf (stdout, "%s", Buffer);
-
-                    /* Backup to where the cursor should be */
-
-                    CursorPosition++;
-                    ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition);
-                }
-                continue;
-
-            case _ASCII_UP_ARROW:
-
-                /* If no commands available or at start of history list, ignore */
-
-                if (!CurrentCommandIndex)
-                {
-                    continue;
-                }
-
-                /* Manage our up/down progress */
-
-                if (CurrentCommandIndex > PreviousCommandIndex)
-                {
-                    CurrentCommandIndex = PreviousCommandIndex;
-                }
-
-                /* Get the historical command from the debugger */
-
-                NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex);
-                if (!NextCommand)
-                {
-                    return (AE_ERROR);
-                }
-
-                /* Make this the active command and echo it */
-
-                AcpiAcClearLine (EndOfLine, CursorPosition);
-                strcpy (Buffer, NextCommand);
-                fprintf (stdout, "%s", Buffer);
-                EndOfLine = CursorPosition = strlen (Buffer);
-
-                PreviousCommandIndex = CurrentCommandIndex;
-                CurrentCommandIndex--;
-                continue;
-
-            case _ASCII_DOWN_ARROW:
-
-                if (!MaxCommandIndex) /* Any commands available? */
-                {
-                    continue;
-                }
-
-                /* Manage our up/down progress */
-
-                if (CurrentCommandIndex < PreviousCommandIndex)
-                {
-                    CurrentCommandIndex = PreviousCommandIndex;
-                }
-
-                /* If we are the end of the history list, output a clear new line */
-
-                if ((CurrentCommandIndex + 1) > MaxCommandIndex)
-                {
-                    AcpiAcClearLine (EndOfLine, CursorPosition);
-                    EndOfLine = CursorPosition = 0;
-                    PreviousCommandIndex = CurrentCommandIndex;
-                    continue;
-                }
-
-                PreviousCommandIndex = CurrentCommandIndex;
-                CurrentCommandIndex++;
-
-                 /* Get the historical command from the debugger */
-
-                NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex);
-                if (!NextCommand)
-                {
-                    return (AE_ERROR);
-                }
-
-                /* Make this the active command and echo it */
-
-                AcpiAcClearLine (EndOfLine, CursorPosition);
-                strcpy (Buffer, NextCommand);
-                fprintf (stdout, "%s", Buffer);
-                EndOfLine = CursorPosition = strlen (Buffer);
-                continue;
-
-            case 0x31:
-            case 0x32:
-            case 0x33:
-            case 0x34:
-            case 0x35:
-            case 0x36:
-                /*
-                 * Ignore the various keys like insert/delete/home/end, etc.
-                 * But we must eat the final character of the ESC sequence.
-                 */
-                InputChar = getchar ();
-                continue;
-
-            default:
-
-                /* Ignore random escape sequences that we don't care about */
-
-                continue;
-            }
-            continue;
-        }
-    }
-}

+ 0 - 430
sys/src/libacpi/acpica/common/adfile.c

@@ -1,430 +0,0 @@
-/******************************************************************************
- *
- * Module Name: adfile - Application-level disassembler file support routines
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "aslcompiler.h"
-#include "acpi.h"
-#include "accommon.h"
-#include "acapps.h"
-
-#include <stdio.h>
-
-
-#define _COMPONENT          ACPI_TOOLS
-        ACPI_MODULE_NAME    ("adfile")
-
-/* Local prototypes */
-
-static INT32
-AdWriteBuffer (
-    char                    *Filename,
-    char                    *Buffer,
-    UINT32                  Length);
-
-static char                 FilenameBuf[20];
-
-
-/******************************************************************************
- *
- * FUNCTION:    AfGenerateFilename
- *
- * PARAMETERS:  Prefix              - prefix string
- *              TableId             - The table ID
- *
- * RETURN:      Pointer to the completed string
- *
- * DESCRIPTION: Build an output filename from an ACPI table ID string
- *
- ******************************************************************************/
-
-char *
-AdGenerateFilename (
-    char                    *Prefix,
-    char                    *TableId)
-{
-    UINT32                  i;
-    UINT32                  j;
-
-
-    for (i = 0; Prefix[i]; i++)
-    {
-        FilenameBuf[i] = Prefix[i];
-    }
-
-    FilenameBuf[i] = '_';
-    i++;
-
-    for (j = 0; j < 8 && (TableId[j] != ' ') && (TableId[j] != 0); i++, j++)
-    {
-        FilenameBuf[i] = TableId[j];
-    }
-
-    FilenameBuf[i] = 0;
-    strcat (FilenameBuf, FILE_SUFFIX_BINARY_TABLE);
-    return (FilenameBuf);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AfWriteBuffer
- *
- * PARAMETERS:  Filename            - name of file
- *              Buffer              - data to write
- *              Length              - length of data
- *
- * RETURN:      Actual number of bytes written
- *
- * DESCRIPTION: Open a file and write out a single buffer
- *
- ******************************************************************************/
-
-static INT32
-AdWriteBuffer (
-    char                    *Filename,
-    char                    *Buffer,
-    UINT32                  Length)
-{
-    FILE                    *File;
-    ACPI_SIZE               Actual;
-
-
-    File = fopen (Filename, "wb");
-    if (!File)
-    {
-        printf ("Could not open file %s\n", Filename);
-        return (-1);
-    }
-
-    Actual = fwrite (Buffer, 1, (size_t) Length, File);
-    if (Actual != Length)
-    {
-        printf ("Could not write to file %s\n", Filename);
-    }
-
-    fclose (File);
-    return ((INT32) Actual);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AfWriteTable
- *
- * PARAMETERS:  Table               - pointer to the ACPI table
- *              Length              - length of the table
- *              TableName           - the table signature
- *              OemTableID          - from the table header
- *
- * RETURN:      None
- *
- * DESCRIPTION: Dump the loaded tables to a file (or files)
- *
- ******************************************************************************/
-
-void
-AdWriteTable (
-    ACPI_TABLE_HEADER       *Table,
-    UINT32                  Length,
-    char                    *TableName,
-    char                    *OemTableId)
-{
-    char                    *Filename;
-
-
-    Filename = AdGenerateFilename (TableName, OemTableId);
-    AdWriteBuffer (Filename, (char *) Table, Length);
-
-    AcpiOsPrintf ("Table [%s] written to \"%s\"\n", TableName, Filename);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    FlGenerateFilename
- *
- * PARAMETERS:  InputFilename       - Original ASL source filename
- *              Suffix              - New extension.
- *
- * RETURN:      New filename containing the original base + the new suffix
- *
- * DESCRIPTION: Generate a new filename from the ASL source filename and a new
- *              extension. Used to create the *.LST, *.TXT, etc. files.
- *
- ******************************************************************************/
-
-char *
-FlGenerateFilename (
-    char                    *InputFilename,
-    char                    *Suffix)
-{
-    char                    *Position;
-    char                    *NewFilename;
-    char                    *DirectoryPosition;
-
-
-    /*
-     * Copy the original filename to a new buffer. Leave room for the worst
-     * case where we append the suffix, an added dot and the null terminator.
-     */
-    NewFilename = UtStringCacheCalloc ((ACPI_SIZE)
-        strlen (InputFilename) + strlen (Suffix) + 2);
-    if (!NewFilename)
-    {
-        return (NULL);
-    }
-
-    strcpy (NewFilename, InputFilename);
-
-    /* Try to find the last dot in the filename */
-
-    DirectoryPosition = strrchr (NewFilename, '/');
-    Position = strrchr (NewFilename, '.');
-
-    if (Position && (Position > DirectoryPosition))
-    {
-        /* Tack on the new suffix */
-
-        Position++;
-        *Position = 0;
-        strcat (Position, Suffix);
-    }
-    else
-    {
-        /* No dot, add one and then the suffix */
-
-        strcat (NewFilename, ".");
-        strcat (NewFilename, Suffix);
-    }
-
-    return (NewFilename);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    FlStrdup
- *
- * DESCRIPTION: Local strdup function
- *
- ******************************************************************************/
-
-static char *
-FlStrdup (
-    char                *String)
-{
-    char                *NewString;
-
-
-    NewString = UtStringCacheCalloc ((ACPI_SIZE) strlen (String) + 1);
-    if (!NewString)
-    {
-        return (NULL);
-    }
-
-    strcpy (NewString, String);
-    return (NewString);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    FlSplitInputPathname
- *
- * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
- *                                    compiled
- *              OutDirectoryPath    - Where the directory path prefix is
- *                                    returned
- *              OutFilename         - Where the filename part is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Split the input path into a directory and filename part
- *              1) Directory part used to open include files
- *              2) Filename part used to generate output filenames
- *
- ******************************************************************************/
-
-ACPI_STATUS
-FlSplitInputPathname (
-    char                    *InputPath,
-    char                    **OutDirectoryPath,
-    char                    **OutFilename)
-{
-    char                    *Substring;
-    char                    *DirectoryPath;
-    char                    *Filename;
-
-
-    if (OutDirectoryPath)
-    {
-        *OutDirectoryPath = NULL;
-    }
-
-    if (!InputPath)
-    {
-        return (AE_OK);
-    }
-
-    /* Get the path to the input filename's directory */
-
-    DirectoryPath = FlStrdup (InputPath);
-    if (!DirectoryPath)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    /* Convert backslashes to slashes in the entire path */
-
-    UtConvertBackslashes (DirectoryPath);
-
-    /* Backup to last slash or colon */
-
-    Substring = strrchr (DirectoryPath, '/');
-    if (!Substring)
-    {
-        Substring = strrchr (DirectoryPath, ':');
-    }
-
-    /* Extract the simple filename */
-
-    if (!Substring)
-    {
-        Filename = FlStrdup (DirectoryPath);
-        DirectoryPath[0] = 0;
-    }
-    else
-    {
-        Filename = FlStrdup (Substring + 1);
-        *(Substring+1) = 0;
-    }
-
-    if (!Filename)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    if (OutDirectoryPath)
-    {
-        *OutDirectoryPath = DirectoryPath;
-    }
-
-    if (OutFilename)
-    {
-        *OutFilename = Filename;
-        return (AE_OK);
-    }
-
-    return (AE_OK);
-}

+ 0 - 728
sys/src/libacpi/acpica/common/adisasm.c

@@ -1,728 +0,0 @@
-/******************************************************************************
- *
- * Module Name: adisasm - Application-level disassembler routines
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "aslcompiler.h"
-#include "amlcode.h"
-#include "acdisasm.h"
-#include "acdispat.h"
-#include "acnamesp.h"
-#include "acparser.h"
-#include "acapps.h"
-
-#include <stdio.h>
-
-
-#define _COMPONENT          ACPI_TOOLS
-        ACPI_MODULE_NAME    ("adisasm")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AdDoExternalFileList (
-    char                    *Filename);
-
-static ACPI_STATUS
-AdDisassembleOneTable (
-    ACPI_TABLE_HEADER       *Table,
-    FILE                    *File,
-    char                    *Filename,
-    char                    *DisasmFilename);
-
-static ACPI_STATUS
-AdReparseOneTable (
-    ACPI_TABLE_HEADER       *Table,
-    FILE                    *File,
-    ACPI_OWNER_ID           OwnerId);
-
-
-ACPI_TABLE_DESC             LocalTables[1];
-ACPI_PARSE_OBJECT           *AcpiGbl_ParseOpRoot;
-
-
-/* Stubs for everything except ASL compiler */
-
-#ifndef ACPI_ASL_COMPILER
-BOOLEAN
-AcpiDsIsResultUsed (
-    ACPI_PARSE_OBJECT       *Op,
-    ACPI_WALK_STATE         *WalkState)
-{
-    return (TRUE);
-}
-
-ACPI_STATUS
-AcpiDsMethodError (
-    ACPI_STATUS             Status,
-    ACPI_WALK_STATE         *WalkState)
-{
-    return (Status);
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AdInitialize
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: ACPICA and local initialization
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AdInitialize (
-    void)
-{
-    ACPI_STATUS             Status;
-
-
-    /* ACPICA subsystem initialization */
-
-    Status = AcpiOsInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    Status = AcpiUtInitGlobals ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    Status = AcpiUtMutexInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    Status = AcpiNsRootInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Setup the Table Manager (cheat - there is no RSDT) */
-
-    AcpiGbl_RootTableList.MaxTableCount = 1;
-    AcpiGbl_RootTableList.CurrentTableCount = 0;
-    AcpiGbl_RootTableList.Tables = LocalTables;
-
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdAmlDisassemble
- *
- * PARAMETERS:  Filename            - AML input filename
- *              OutToFile           - TRUE if output should go to a file
- *              Prefix              - Path prefix for output
- *              OutFilename         - where the filename is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AdAmlDisassemble (
-    BOOLEAN                 OutToFile,
-    char                    *Filename,
-    char                    *Prefix,
-    char                    **OutFilename)
-{
-    ACPI_STATUS             Status;
-    char                    *DisasmFilename = NULL;
-    FILE                    *File = NULL;
-    ACPI_TABLE_HEADER       *Table = NULL;
-    ACPI_NEW_TABLE_DESC     *ListHead = NULL;
-
-
-    /*
-     * Input: AML code from either a file or via GetTables (memory or
-     * registry)
-     */
-    if (Filename)
-    {
-        /* Get the list of all AML tables in the file */
-
-        Status = AcGetAllTablesFromFile (Filename,
-            ACPI_GET_ALL_TABLES, &ListHead);
-        if (ACPI_FAILURE (Status))
-        {
-            AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
-                Filename, AcpiFormatException (Status));
-            return (Status);
-        }
-
-        /* Process any user-specified files for external objects */
-
-        Status = AdDoExternalFileList (Filename);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-    }
-    else
-    {
-        Status = AdGetLocalTables ();
-        if (ACPI_FAILURE (Status))
-        {
-            AcpiOsPrintf ("Could not get ACPI tables, %s\n",
-                AcpiFormatException (Status));
-            return (Status);
-        }
-
-        if (!AcpiGbl_DmOpt_Disasm)
-        {
-            return (AE_OK);
-        }
-
-        /* Obtained the local tables, just disassemble the DSDT */
-
-        Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table);
-        if (ACPI_FAILURE (Status))
-        {
-            AcpiOsPrintf ("Could not get DSDT, %s\n",
-                AcpiFormatException (Status));
-            return (Status);
-        }
-
-        AcpiOsPrintf ("\nDisassembly of DSDT\n");
-        Prefix = AdGenerateFilename ("dsdt", Table->OemTableId);
-    }
-
-    /*
-     * Output: ASL code. Redirect to a file if requested
-     */
-    if (OutToFile)
-    {
-        /* Create/Open a disassembly output file */
-
-        DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY);
-        if (!DisasmFilename)
-        {
-            fprintf (stderr, "Could not generate output filename\n");
-            Status = AE_ERROR;
-            goto Cleanup;
-        }
-
-        File = fopen (DisasmFilename, "w+");
-        if (!File)
-        {
-            fprintf (stderr, "Could not open output file %s\n",
-                DisasmFilename);
-            Status = AE_ERROR;
-            goto Cleanup;
-        }
-
-        AcpiOsRedirectOutput (File);
-    }
-
-    *OutFilename = DisasmFilename;
-
-    /* Disassemble all AML tables within the file */
-
-    while (ListHead)
-    {
-        Status = AdDisassembleOneTable (ListHead->Table,
-            File, Filename, DisasmFilename);
-        if (ACPI_FAILURE (Status))
-        {
-            break;
-        }
-
-        ListHead = ListHead->Next;
-    }
-
-Cleanup:
-
-    if (Table &&
-        !AcpiGbl_ForceAmlDisassembly &&
-        !AcpiUtIsAmlTable (Table))
-    {
-        ACPI_FREE (Table);
-    }
-
-    if (File)
-    {
-        fclose (File);
-        AcpiOsRedirectOutput (stdout);
-    }
-
-    AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
-    AcpiGbl_ParseOpRoot = NULL;
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdDisassembleOneTable
- *
- * PARAMETERS:  Table               - Raw AML table
- *              File                - Pointer for the input file
- *              Filename            - AML input filename
- *              DisasmFilename      - Output filename
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Disassemble a single ACPI table. AML or data table.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AdDisassembleOneTable (
-    ACPI_TABLE_HEADER       *Table,
-    FILE                    *File,
-    char                    *Filename,
-    char                    *DisasmFilename)
-{
-    ACPI_STATUS             Status;
-    ACPI_OWNER_ID           OwnerId;
-
-
-    /* ForceAmlDisassembly means to assume the table contains valid AML */
-
-    if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
-    {
-        AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
-
-        /* This is a "Data Table" (non-AML table) */
-
-        AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
-            Table->Signature);
-        AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]  "
-            "FieldName : FieldValue\n */\n\n");
-
-        AcpiDmDumpDataTable (Table);
-        fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
-            Table->Signature);
-
-        if (File)
-        {
-            fprintf (stderr, "Formatted output:  %s - %u bytes\n",
-                DisasmFilename, CmGetFileSize (File));
-        }
-
-        return (AE_OK);
-    }
-
-    /*
-     * This is an AML table (DSDT or SSDT).
-     * Always parse the tables, only option is what to display
-     */
-    Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
-    if (ACPI_FAILURE (Status))
-    {
-        AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
-            AcpiFormatException (Status));
-        return (Status);
-    }
-
-    /* Debug output, namespace and parse tree */
-
-    if (AslCompilerdebug && File)
-    {
-        AcpiOsPrintf ("/**** Before second load\n");
-
-        NsSetupNamespaceListing (File);
-        NsDisplayNamespace ();
-
-        AcpiOsPrintf ("*****/\n");
-    }
-
-    /* Load namespace from names created within control methods */
-
-    AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
-        AcpiGbl_RootNode, OwnerId);
-
-    /*
-     * Cross reference the namespace here, in order to
-     * generate External() statements
-     */
-    AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
-        AcpiGbl_RootNode, OwnerId);
-
-    if (AslCompilerdebug)
-    {
-        AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
-    }
-
-    /* Find possible calls to external control methods */
-
-    AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
-
-    /*
-     * If we found any external control methods, we must reparse
-     * the entire tree with the new information (namely, the
-     * number of arguments per method)
-     */
-    if (AcpiDmGetExternalMethodCount ())
-    {
-        Status = AdReparseOneTable (Table, File, OwnerId);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-    }
-
-    /*
-     * Now that the namespace is finalized, we can perform namespace
-     * transforms.
-     *
-     * 1) Convert fixed-offset references to resource descriptors
-     *    to symbolic references (Note: modifies namespace)
-     */
-    AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
-
-    /* Optional displays */
-
-    if (AcpiGbl_DmOpt_Disasm)
-    {
-        /* This is the real disassembly */
-
-        AdDisplayTables (Filename, Table);
-
-        /* Dump hex table if requested (-vt) */
-
-        AcpiDmDumpDataTable (Table);
-
-        fprintf (stderr, "Disassembly completed\n");
-        if (File)
-        {
-            fprintf (stderr, "ASL Output:    %s - %u bytes\n",
-                DisasmFilename, CmGetFileSize (File));
-        }
-
-        if (Gbl_MapfileFlag)
-        {
-            fprintf (stderr, "%14s %s - %u bytes\n",
-                Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription,
-                Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
-                FlGetFileSize (ASL_FILE_MAP_OUTPUT));
-        }
-    }
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdReparseOneTable
- *
- * PARAMETERS:  Table               - Raw AML table
- *              File                - Pointer for the input file
- *              OwnerId             - ID for this table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Reparse a table that has already been loaded. Used to
- *              integrate information about external control methods.
- *              These methods may have been previously parsed incorrectly.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AdReparseOneTable (
-    ACPI_TABLE_HEADER       *Table,
-    FILE                    *File,
-    ACPI_OWNER_ID           OwnerId)
-{
-    ACPI_STATUS             Status;
-
-
-    fprintf (stderr,
-        "\nFound %u external control methods, "
-        "reparsing with new information\n",
-        AcpiDmGetExternalMethodCount ());
-
-    /* Reparse, rebuild namespace */
-
-    AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
-    AcpiGbl_ParseOpRoot = NULL;
-    AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
-
-    AcpiGbl_RootNode                    = NULL;
-    AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
-    AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
-    AcpiGbl_RootNodeStruct.Type         = ACPI_TYPE_DEVICE;
-    AcpiGbl_RootNodeStruct.Parent       = NULL;
-    AcpiGbl_RootNodeStruct.Child        = NULL;
-    AcpiGbl_RootNodeStruct.Peer         = NULL;
-    AcpiGbl_RootNodeStruct.Object       = NULL;
-    AcpiGbl_RootNodeStruct.Flags        = 0;
-
-    Status = AcpiNsRootInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* New namespace, add the external definitions first */
-
-    AcpiDmAddExternalsToNamespace ();
-
-    /* Parse the table again. No need to reload it, however */
-
-    Status = AdParseTable (Table, NULL, FALSE, FALSE);
-    if (ACPI_FAILURE (Status))
-    {
-        AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
-            AcpiFormatException (Status));
-        return (Status);
-    }
-
-    /* Cross reference the namespace again */
-
-    AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
-        AcpiGbl_RootNode, OwnerId);
-
-    AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
-        AcpiGbl_RootNode, OwnerId);
-
-    /* Debug output - namespace and parse tree */
-
-    if (AslCompilerdebug)
-    {
-        AcpiOsPrintf ("/**** After second load and resource conversion\n");
-        if (File)
-        {
-            NsSetupNamespaceListing (File);
-            NsDisplayNamespace ();
-        }
-
-        AcpiOsPrintf ("*****/\n");
-        AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
-    }
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdDoExternalFileList
- *
- * PARAMETERS:  Filename            - Input file for the table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Process all tables found in the -e external files list
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AdDoExternalFileList (
-    char                    *Filename)
-{
-    ACPI_EXTERNAL_FILE      *ExternalFileList;
-    char                    *ExternalFilename;
-    ACPI_NEW_TABLE_DESC     *ExternalListHead = NULL;
-    ACPI_STATUS             Status;
-    ACPI_STATUS             GlobalStatus = AE_OK;
-    ACPI_OWNER_ID           OwnerId;
-
-
-    /*
-     * External filenames are specified on the command line like this:
-     * Example: iasl -e file1,file2,file3 -d xxx.aml
-     */
-    ExternalFileList = AcpiGbl_ExternalFileList;
-
-    /* Process each external file */
-
-    while (ExternalFileList)
-    {
-        ExternalFilename = ExternalFileList->Path;
-        if (!strcmp (ExternalFilename, Filename))
-        {
-            /* Next external file */
-
-            ExternalFileList = ExternalFileList->Next;
-            continue;
-        }
-
-        AcpiOsPrintf ("External object resolution file %16s\n",
-            ExternalFilename);
-
-        Status = AcGetAllTablesFromFile (
-            ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
-        if (ACPI_FAILURE (Status))
-        {
-            if (Status == AE_TYPE)
-            {
-                ExternalFileList = ExternalFileList->Next;
-                GlobalStatus = AE_TYPE;
-                Status = AE_OK;
-                continue;
-            }
-
-            return (Status);
-        }
-
-        /* Load external tables for symbol resolution */
-
-        while (ExternalListHead)
-        {
-            Status = AdParseTable (
-                ExternalListHead->Table, &OwnerId, TRUE, TRUE);
-            if (ACPI_FAILURE (Status))
-            {
-                AcpiOsPrintf ("Could not parse external ACPI tables, %s\n",
-                    AcpiFormatException (Status));
-                return (Status);
-            }
-
-            /*
-             * Load namespace from names created within control methods
-             * Set owner id of nodes in external table
-             */
-            AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
-                AcpiGbl_RootNode, OwnerId);
-            AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
-
-            ExternalListHead = ExternalListHead->Next;
-        }
-
-        /* Next external file */
-
-        ExternalFileList = ExternalFileList->Next;
-    }
-
-    if (ACPI_FAILURE (GlobalStatus))
-    {
-        return (GlobalStatus);
-    }
-
-    /* Clear external list generated by Scope in external tables */
-
-    if (AcpiGbl_ExternalFileList)
-    {
-        AcpiDmClearExternalList ();
-    }
-
-    /* Load any externals defined in the optional external ref file */
-
-    AcpiDmGetExternalsFromFile ();
-    return (AE_OK);
-}

+ 0 - 185
sys/src/libacpi/acpica/common/cmfsize.c

@@ -1,185 +0,0 @@
-/******************************************************************************
- *
- * Module Name: cfsize - Common get file size function
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acapps.h"
-#include <stdio.h>
-
-#define _COMPONENT          ACPI_TOOLS
-        ACPI_MODULE_NAME    ("cmfsize")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    CmGetFileSize
- *
- * PARAMETERS:  File                    - Open file descriptor
- *
- * RETURN:      File Size. On error, -1 (ACPI_UINT32_MAX)
- *
- * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open.
- *              Does not disturb the current file pointer.
- *
- ******************************************************************************/
-
-UINT32
-CmGetFileSize (
-    ACPI_FILE               File)
-{
-    long                    FileSize;
-    long                    CurrentOffset;
-    ACPI_STATUS             Status;
-
-
-    /* Save the current file pointer, seek to EOF to obtain file size */
-
-    CurrentOffset = AcpiOsGetFileOffset (File);
-    if (CurrentOffset < 0)
-    {
-        goto OffsetError;
-    }
-
-    Status = AcpiOsSetFileOffset (File, 0, ACPI_FILE_END);
-    if (ACPI_FAILURE (Status))
-    {
-        goto SeekError;
-    }
-
-    FileSize = AcpiOsGetFileOffset (File);
-    if (FileSize < 0)
-    {
-        goto OffsetError;
-    }
-
-    /* Restore original file pointer */
-
-    Status = AcpiOsSetFileOffset (File, CurrentOffset, ACPI_FILE_BEGIN);
-    if (ACPI_FAILURE (Status))
-    {
-        goto SeekError;
-    }
-
-    return ((UINT32) FileSize);
-
-
-OffsetError:
-    AcpiLogError ("Could not get file offset");
-    return (ACPI_UINT32_MAX);
-
-SeekError:
-    AcpiLogError ("Could not set file offset");
-    return (ACPI_UINT32_MAX);
-}

+ 0 - 1424
sys/src/libacpi/acpica/common/dmextern.c

@@ -1,1424 +0,0 @@
-/******************************************************************************
- *
- * Module Name: dmextern - Support for External() ASL statements
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "amlcode.h"
-#include "acnamesp.h"
-#include "acdisasm.h"
-#include "aslcompiler.h"
-#include <stdio.h>
-#include <errno.h>
-
-
-/*
- * This module is used for application-level code (iASL disassembler) only.
- *
- * It contains the code to create and emit any necessary External() ASL
- * statements for the module being disassembled.
- */
-#define _COMPONENT          ACPI_CA_DISASSEMBLER
-        ACPI_MODULE_NAME    ("dmextern")
-
-
-/*
- * This table maps ACPI_OBJECT_TYPEs to the corresponding ASL
- * ObjectTypeKeyword. Used to generate typed external declarations
- */
-static const char           *AcpiGbl_DmTypeNames[] =
-{
-    /* 00 */ ", UnknownObj",        /* Type ANY */
-    /* 01 */ ", IntObj",
-    /* 02 */ ", StrObj",
-    /* 03 */ ", BuffObj",
-    /* 04 */ ", PkgObj",
-    /* 05 */ ", FieldUnitObj",
-    /* 06 */ ", DeviceObj",
-    /* 07 */ ", EventObj",
-    /* 08 */ ", MethodObj",
-    /* 09 */ ", MutexObj",
-    /* 10 */ ", OpRegionObj",
-    /* 11 */ ", PowerResObj",
-    /* 12 */ ", ProcessorObj",
-    /* 13 */ ", ThermalZoneObj",
-    /* 14 */ ", BuffFieldObj",
-    /* 15 */ ", DDBHandleObj",
-    /* 16 */ "",                    /* Debug object */
-    /* 17 */ ", FieldUnitObj",
-    /* 18 */ ", FieldUnitObj",
-    /* 19 */ ", FieldUnitObj"
-};
-
-#define METHOD_SEPARATORS           " \t,()\n"
-
-
-/* Local prototypes */
-
-static const char *
-AcpiDmGetObjectTypeName (
-    ACPI_OBJECT_TYPE        Type);
-
-static char *
-AcpiDmNormalizeParentPrefix (
-    ACPI_PARSE_OBJECT       *Op,
-    char                    *Path);
-
-static void
-AcpiDmAddPathToExternalList (
-    char                    *Path,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags);
-
-static ACPI_STATUS
-AcpiDmCreateNewExternal (
-    char                    *ExternalPath,
-    char                    *InternalPath,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags);
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetObjectTypeName
- *
- * PARAMETERS:  Type                - An ACPI_OBJECT_TYPE
- *
- * RETURN:      Pointer to a string
- *
- * DESCRIPTION: Map an object type to the ASL object type string.
- *
- ******************************************************************************/
-
-static const char *
-AcpiDmGetObjectTypeName (
-    ACPI_OBJECT_TYPE        Type)
-{
-
-    if (Type == ACPI_TYPE_LOCAL_SCOPE)
-    {
-        Type = ACPI_TYPE_DEVICE;
-    }
-    else if (Type > ACPI_TYPE_LOCAL_INDEX_FIELD)
-    {
-        return ("");
-    }
-
-    return (AcpiGbl_DmTypeNames[Type]);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmNormalizeParentPrefix
- *
- * PARAMETERS:  Op                  - Parse op
- *              Path                - Path with parent prefix
- *
- * RETURN:      The full pathname to the object (from the namespace root)
- *
- * DESCRIPTION: Returns the full pathname of a path with parent prefix
- *              The caller must free the fullpath returned.
- *
- ******************************************************************************/
-
-static char *
-AcpiDmNormalizeParentPrefix (
-    ACPI_PARSE_OBJECT       *Op,
-    char                    *Path)
-{
-    ACPI_NAMESPACE_NODE     *Node;
-    char                    *Fullpath;
-    char                    *ParentPath;
-    ACPI_SIZE               Length;
-    UINT32                  Index = 0;
-
-
-    if (!Op)
-    {
-        return (NULL);
-    }
-
-    /* Search upwards in the parse tree until we reach the next namespace node */
-
-    Op = Op->Common.Parent;
-    while (Op)
-    {
-        if (Op->Common.Node)
-        {
-            break;
-        }
-
-        Op = Op->Common.Parent;
-    }
-
-    if (!Op)
-    {
-        return (NULL);
-    }
-
-    /*
-     * Find the actual parent node for the reference:
-     * Remove all carat prefixes from the input path.
-     * There may be multiple parent prefixes (For example, ^^^M000)
-     */
-    Node = Op->Common.Node;
-    while (Node && (*Path == (UINT8) AML_PARENT_PREFIX))
-    {
-        Node = Node->Parent;
-        Path++;
-    }
-
-    if (!Node)
-    {
-        return (NULL);
-    }
-
-    /* Get the full pathname for the parent node */
-
-    ParentPath = AcpiNsGetExternalPathname (Node);
-    if (!ParentPath)
-    {
-        return (NULL);
-    }
-
-    Length = (strlen (ParentPath) + strlen (Path) + 1);
-    if (ParentPath[1])
-    {
-        /*
-         * If ParentPath is not just a simple '\', increment the length
-         * for the required dot separator (ParentPath.Path)
-         */
-        Length++;
-
-        /* For External() statements, we do not want a leading '\' */
-
-        if (*ParentPath == AML_ROOT_PREFIX)
-        {
-            Index = 1;
-        }
-    }
-
-    Fullpath = ACPI_ALLOCATE_ZEROED (Length);
-    if (!Fullpath)
-    {
-        goto Cleanup;
-    }
-
-    /*
-     * Concatenate parent fullpath and path. For example,
-     * parent fullpath "\_SB_", Path "^INIT", Fullpath "\_SB_.INIT"
-     *
-     * Copy the parent path
-     */
-    strcpy (Fullpath, &ParentPath[Index]);
-
-    /*
-     * Add dot separator
-     * (don't need dot if parent fullpath is a single backslash)
-     */
-    if (ParentPath[1])
-    {
-        strcat (Fullpath, ".");
-    }
-
-    /* Copy child path (carat parent prefix(es) were skipped above) */
-
-    strcat (Fullpath, Path);
-
-Cleanup:
-    ACPI_FREE (ParentPath);
-    return (Fullpath);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddToExternalFileList
- *
- * PARAMETERS:  PathList            - Single path or list separated by comma
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add external files to global list
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDmAddToExternalFileList (
-    char                    *Pathname)
-{
-    ACPI_EXTERNAL_FILE      *ExternalFile;
-    char                    *LocalPathname;
-
-
-    if (!Pathname)
-    {
-        return (AE_OK);
-    }
-
-    LocalPathname = ACPI_ALLOCATE (strlen (Pathname) + 1);
-    if (!LocalPathname)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE));
-    if (!ExternalFile)
-    {
-        ACPI_FREE (LocalPathname);
-        return (AE_NO_MEMORY);
-    }
-
-    /* Take a copy of the file pathname */
-
-    strcpy (LocalPathname, Pathname);
-    ExternalFile->Path = LocalPathname;
-
-    if (AcpiGbl_ExternalFileList)
-    {
-        ExternalFile->Next = AcpiGbl_ExternalFileList;
-    }
-
-    AcpiGbl_ExternalFileList = ExternalFile;
-    return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmClearExternalFileList
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Clear the external file list
- *
- ******************************************************************************/
-
-void
-AcpiDmClearExternalFileList (
-    void)
-{
-    ACPI_EXTERNAL_FILE      *NextExternal;
-
-
-    while (AcpiGbl_ExternalFileList)
-    {
-        NextExternal = AcpiGbl_ExternalFileList->Next;
-        ACPI_FREE (AcpiGbl_ExternalFileList->Path);
-        ACPI_FREE (AcpiGbl_ExternalFileList);
-        AcpiGbl_ExternalFileList = NextExternal;
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetExternalsFromFile
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Process the optional external reference file.
- *
- * Each line in the file should be of the form:
- *      External (<Method namepath>, MethodObj, <ArgCount>)
- *
- * Example:
- *      External (_SB_.PCI0.XHC_.PS0X, MethodObj, 4)
- *
- ******************************************************************************/
-
-void
-AcpiDmGetExternalsFromFile (
-    void)
-{
-    FILE                    *ExternalRefFile;
-    char                    *Token;
-    char                    *MethodName;
-    UINT32                  ArgCount;
-    UINT32                  ImportCount = 0;
-
-
-    if (!Gbl_ExternalRefFilename)
-    {
-        return;
-    }
-
-    /* Open the file */
-
-    ExternalRefFile = fopen (Gbl_ExternalRefFilename, "r");
-    if (!ExternalRefFile)
-    {
-        fprintf (stderr, "Could not open external reference file \"%s\"\n",
-            Gbl_ExternalRefFilename);
-        AslAbort ();
-        return;
-    }
-
-    /* Each line defines a method */
-
-    while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ExternalRefFile))
-    {
-        Token = strtok (StringBuffer, METHOD_SEPARATORS);   /* "External" */
-        if (!Token)
-        {
-            continue;
-        }
-
-        if (strcmp (Token, "External"))
-        {
-            continue;
-        }
-
-        MethodName = strtok (NULL, METHOD_SEPARATORS);      /* Method namepath */
-        if (!MethodName)
-        {
-            continue;
-        }
-
-        Token = strtok (NULL, METHOD_SEPARATORS);           /* "MethodObj" */
-        if (!Token)
-        {
-            continue;
-        }
-
-        if (strcmp (Token, "MethodObj"))
-        {
-            continue;
-        }
-
-        Token = strtok (NULL, METHOD_SEPARATORS);           /* Arg count */
-        if (!Token)
-        {
-            continue;
-        }
-
-        /* Convert arg count string to an integer */
-
-        errno = 0;
-        ArgCount = strtoul (Token, NULL, 0);
-        if (errno)
-        {
-            fprintf (stderr, "Invalid argument count (%s)\n", Token);
-            continue;
-        }
-
-        if (ArgCount > 7)
-        {
-            fprintf (stderr, "Invalid argument count (%u)\n", ArgCount);
-            continue;
-        }
-
-        /* Add this external to the global list */
-
-        AcpiOsPrintf ("%s: Importing method external (%u arguments) %s\n",
-            Gbl_ExternalRefFilename, ArgCount, MethodName);
-
-        AcpiDmAddPathToExternalList (MethodName, ACPI_TYPE_METHOD,
-            ArgCount, (ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_FILE));
-        ImportCount++;
-    }
-
-    if (!ImportCount)
-    {
-        fprintf (stderr,
-            "Did not find any external methods in reference file \"%s\"\n",
-            Gbl_ExternalRefFilename);
-    }
-    else
-    {
-        /* Add the external(s) to the namespace */
-
-        AcpiDmAddExternalsToNamespace ();
-
-        AcpiOsPrintf ("%s: Imported %u external method definitions\n",
-            Gbl_ExternalRefFilename, ImportCount);
-    }
-
-    fclose (ExternalRefFile);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddOpToExternalList
- *
- * PARAMETERS:  Op                  - Current parser Op
- *              Path                - Internal (AML) path to the object
- *              Type                - ACPI object type to be added
- *              Value               - Arg count if adding a Method object
- *              Flags               - To be passed to the external object
- *
- * RETURN:      None
- *
- * DESCRIPTION: Insert a new name into the global list of Externals which
- *              will in turn be later emitted as an External() declaration
- *              in the disassembled output.
- *
- *              This function handles the most common case where the referenced
- *              name is simply not found in the constructed namespace.
- *
- ******************************************************************************/
-
-void
-AcpiDmAddOpToExternalList (
-    ACPI_PARSE_OBJECT       *Op,
-    char                    *Path,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags)
-{
-    char                    *ExternalPath;
-    char                    *InternalPath = Path;
-    char                    *Temp;
-    ACPI_STATUS             Status;
-
-
-    ACPI_FUNCTION_TRACE (DmAddOpToExternalList);
-
-
-    if (!Path)
-    {
-        return_VOID;
-    }
-
-    /* Remove a root backslash if present */
-
-    if ((*Path == AML_ROOT_PREFIX) && (Path[1]))
-    {
-        Path++;
-    }
-
-    /* Externalize the pathname */
-
-    Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path,
-        NULL, &ExternalPath);
-    if (ACPI_FAILURE (Status))
-    {
-        return_VOID;
-    }
-
-    /*
-     * Get the full pathname from the root if "Path" has one or more
-     * parent prefixes (^). Note: path will not contain a leading '\'.
-     */
-    if (*Path == (UINT8) AML_PARENT_PREFIX)
-    {
-        Temp = AcpiDmNormalizeParentPrefix (Op, ExternalPath);
-
-        /* Set new external path */
-
-        ACPI_FREE (ExternalPath);
-        ExternalPath = Temp;
-        if (!Temp)
-        {
-            return_VOID;
-        }
-
-        /* Create the new internal pathname */
-
-        Flags |= ACPI_EXT_INTERNAL_PATH_ALLOCATED;
-        Status = AcpiNsInternalizeName (ExternalPath, &InternalPath);
-        if (ACPI_FAILURE (Status))
-        {
-            ACPI_FREE (ExternalPath);
-            return_VOID;
-        }
-    }
-
-    /* Create the new External() declaration node */
-
-    Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath,
-        Type, Value, Flags);
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (ExternalPath);
-        if (Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED)
-        {
-            ACPI_FREE (InternalPath);
-        }
-    }
-
-    return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddNodeToExternalList
- *
- * PARAMETERS:  Node                - Namespace node for object to be added
- *              Type                - ACPI object type to be added
- *              Value               - Arg count if adding a Method object
- *              Flags               - To be passed to the external object
- *
- * RETURN:      None
- *
- * DESCRIPTION: Insert a new name into the global list of Externals which
- *              will in turn be later emitted as an External() declaration
- *              in the disassembled output.
- *
- *              This function handles the case where the referenced name has
- *              been found in the namespace, but the name originated in a
- *              table other than the one that is being disassembled (such
- *              as a table that is added via the iASL -e option).
- *
- ******************************************************************************/
-
-void
-AcpiDmAddNodeToExternalList (
-    ACPI_NAMESPACE_NODE     *Node,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags)
-{
-    char                    *ExternalPath;
-    char                    *InternalPath;
-    char                    *Temp;
-    ACPI_STATUS             Status;
-
-
-    ACPI_FUNCTION_TRACE (DmAddNodeToExternalList);
-
-
-    if (!Node)
-    {
-        return_VOID;
-    }
-
-    /* Get the full external and internal pathnames to the node */
-
-    ExternalPath = AcpiNsGetExternalPathname (Node);
-    if (!ExternalPath)
-    {
-        return_VOID;
-    }
-
-    Status = AcpiNsInternalizeName (ExternalPath, &InternalPath);
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (ExternalPath);
-        return_VOID;
-    }
-
-    /* Remove the root backslash */
-
-    if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1]))
-    {
-        Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1);
-        if (!Temp)
-        {
-            return_VOID;
-        }
-
-        strcpy (Temp, &ExternalPath[1]);
-        ACPI_FREE (ExternalPath);
-        ExternalPath = Temp;
-    }
-
-    /* Create the new External() declaration node */
-
-    Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, Type,
-        Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED));
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (ExternalPath);
-        ACPI_FREE (InternalPath);
-    }
-
-    return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddPathToExternalList
- *
- * PARAMETERS:  Path                - External name of the object to be added
- *              Type                - ACPI object type to be added
- *              Value               - Arg count if adding a Method object
- *              Flags               - To be passed to the external object
- *
- * RETURN:      None
- *
- * DESCRIPTION: Insert a new name into the global list of Externals which
- *              will in turn be later emitted as an External() declaration
- *              in the disassembled output.
- *
- *              This function currently is used to add externals via a
- *              reference file (via the -fe iASL option).
- *
- ******************************************************************************/
-
-static void
-AcpiDmAddPathToExternalList (
-    char                    *Path,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags)
-{
-    char                    *InternalPath;
-    char                    *ExternalPath;
-    ACPI_STATUS             Status;
-
-
-    ACPI_FUNCTION_TRACE (DmAddPathToExternalList);
-
-
-    if (!Path)
-    {
-        return_VOID;
-    }
-
-    /* Remove a root backslash if present */
-
-    if ((*Path == AML_ROOT_PREFIX) && (Path[1]))
-    {
-        Path++;
-    }
-
-    /* Create the internal and external pathnames */
-
-    Status = AcpiNsInternalizeName (Path, &InternalPath);
-    if (ACPI_FAILURE (Status))
-    {
-        return_VOID;
-    }
-
-    Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath,
-        NULL, &ExternalPath);
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (InternalPath);
-        return_VOID;
-    }
-
-    /* Create the new External() declaration node */
-
-    Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath,
-        Type, Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED));
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (ExternalPath);
-        ACPI_FREE (InternalPath);
-    }
-
-    return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmCreateNewExternal
- *
- * PARAMETERS:  ExternalPath        - External path to the object
- *              InternalPath        - Internal (AML) path to the object
- *              Type                - ACPI object type to be added
- *              Value               - Arg count if adding a Method object
- *              Flags               - To be passed to the external object
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Common low-level function to insert a new name into the global
- *              list of Externals which will in turn be later emitted as
- *              External() declarations in the disassembled output.
- *
- *              Note: The external name should not include a root prefix
- *              (backslash). We do not want External() statements to contain
- *              a leading '\', as this prevents duplicate external statements
- *              of the form:
- *
- *                  External (\ABCD)
- *                  External (ABCD)
- *
- *              This would cause a compile time error when the disassembled
- *              output file is recompiled.
- *
- *              There are two cases that are handled here. For both, we emit
- *              an External() statement:
- *              1) The name was simply not found in the namespace.
- *              2) The name was found, but it originated in a table other than
- *              the table that is being disassembled.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiDmCreateNewExternal (
-    char                    *ExternalPath,
-    char                    *InternalPath,
-    UINT8                   Type,
-    UINT32                  Value,
-    UINT16                  Flags)
-{
-    ACPI_EXTERNAL_LIST      *NewExternal;
-    ACPI_EXTERNAL_LIST      *NextExternal;
-    ACPI_EXTERNAL_LIST      *PrevExternal = NULL;
-
-
-    ACPI_FUNCTION_TRACE (DmCreateNewExternal);
-
-
-    /* Check all existing externals to ensure no duplicates */
-
-    NextExternal = AcpiGbl_ExternalList;
-    while (NextExternal)
-    {
-        /* Check for duplicates */
-
-        if (!strcmp (ExternalPath, NextExternal->Path))
-        {
-            /*
-             * If this external came from an External() opcode, we are
-             * finished with this one. (No need to check any further).
-             */
-            if (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_OPCODE)
-            {
-                return_ACPI_STATUS (AE_ALREADY_EXISTS);
-            }
-
-            /* Allow upgrade of type from ANY */
-
-            else if ((NextExternal->Type == ACPI_TYPE_ANY) &&
-                (Type != ACPI_TYPE_ANY))
-            {
-                NextExternal->Type = Type;
-            }
-
-            /* Update the argument count as necessary */
-
-            if (Value < NextExternal->Value)
-            {
-                NextExternal->Value = Value;
-            }
-
-            /* Update flags. */
-
-            NextExternal->Flags |= Flags;
-            NextExternal->Flags &= ~ACPI_EXT_INTERNAL_PATH_ALLOCATED;
-
-            return_ACPI_STATUS (AE_ALREADY_EXISTS);
-        }
-
-        NextExternal = NextExternal->Next;
-    }
-
-    /* Allocate and init a new External() descriptor */
-
-    NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST));
-    if (!NewExternal)
-    {
-        return_ACPI_STATUS (AE_NO_MEMORY);
-    }
-
-    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
-        "Adding external reference node (%s) type [%s]\n",
-        ExternalPath, AcpiUtGetTypeName (Type)));
-
-    NewExternal->Flags = Flags;
-    NewExternal->Value = Value;
-    NewExternal->Path = ExternalPath;
-    NewExternal->Type = Type;
-    NewExternal->Length = (UINT16) strlen (ExternalPath);
-    NewExternal->InternalPath = InternalPath;
-
-    /* Link the new descriptor into the global list, alphabetically ordered */
-
-    NextExternal = AcpiGbl_ExternalList;
-    while (NextExternal)
-    {
-        if (AcpiUtStricmp (NewExternal->Path, NextExternal->Path) < 0)
-        {
-            if (PrevExternal)
-            {
-                PrevExternal->Next = NewExternal;
-            }
-            else
-            {
-                AcpiGbl_ExternalList = NewExternal;
-            }
-
-            NewExternal->Next = NextExternal;
-            return_ACPI_STATUS (AE_OK);
-        }
-
-        PrevExternal = NextExternal;
-        NextExternal = NextExternal->Next;
-    }
-
-    if (PrevExternal)
-    {
-        PrevExternal->Next = NewExternal;
-    }
-    else
-    {
-        AcpiGbl_ExternalList = NewExternal;
-    }
-
-    return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddExternalsToNamespace
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add all externals to the namespace. Allows externals to be
- *              "resolved".
- *
- ******************************************************************************/
-
-void
-AcpiDmAddExternalsToNamespace (
-    void)
-{
-    ACPI_STATUS             Status;
-    ACPI_NAMESPACE_NODE     *Node;
-    ACPI_OPERAND_OBJECT     *ObjDesc;
-    ACPI_EXTERNAL_LIST      *External = AcpiGbl_ExternalList;
-
-
-    while (External)
-    {
-        /* Add the external name (object) into the namespace */
-
-        Status = AcpiNsLookup (NULL, External->InternalPath, External->Type,
-            ACPI_IMODE_LOAD_PASS1,
-            ACPI_NS_ERROR_IF_FOUND | ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE,
-            NULL, &Node);
-
-        if (ACPI_FAILURE (Status))
-        {
-            ACPI_EXCEPTION ((AE_INFO, Status,
-                "while adding external to namespace [%s]",
-                External->Path));
-        }
-
-        else switch (External->Type)
-        {
-        case ACPI_TYPE_METHOD:
-
-            /* For methods, we need to save the argument count */
-
-            ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
-            ObjDesc->Method.ParamCount = (UINT8) External->Value;
-            Node->Object = ObjDesc;
-            break;
-
-        case ACPI_TYPE_REGION:
-
-            /* Regions require a region sub-object */
-
-            ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
-            ObjDesc->Region.Node = Node;
-            Node->Object = ObjDesc;
-            break;
-
-        default:
-
-            break;
-        }
-
-        External = External->Next;
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetExternalMethodCount
- *
- * PARAMETERS:  None
- *
- * RETURN:      The number of control method externals in the external list
- *
- * DESCRIPTION: Return the number of method externals that have been generated.
- *              If any control method externals have been found, we must
- *              re-parse the entire definition block with the new information
- *              (number of arguments for the methods.) This is limitation of
- *              AML, we don't know the number of arguments from the control
- *              method invocation itself.
- *
- ******************************************************************************/
-
-UINT32
-AcpiDmGetExternalMethodCount (
-    void)
-{
-    ACPI_EXTERNAL_LIST      *External = AcpiGbl_ExternalList;
-    UINT32                  Count = 0;
-
-
-    while (External)
-    {
-        if (External->Type == ACPI_TYPE_METHOD)
-        {
-            Count++;
-        }
-
-        External = External->Next;
-    }
-
-    return (Count);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmClearExternalList
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Free the entire External info list
- *
- ******************************************************************************/
-
-void
-AcpiDmClearExternalList (
-    void)
-{
-    ACPI_EXTERNAL_LIST      *NextExternal;
-
-
-    while (AcpiGbl_ExternalList)
-    {
-        NextExternal = AcpiGbl_ExternalList->Next;
-        ACPI_FREE (AcpiGbl_ExternalList->Path);
-        ACPI_FREE (AcpiGbl_ExternalList);
-        AcpiGbl_ExternalList = NextExternal;
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmEmitExternals
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Emit an External() ASL statement for each of the externals in
- *              the global external info list.
- *
- ******************************************************************************/
-
-void
-AcpiDmEmitExternals (
-    void)
-{
-    ACPI_EXTERNAL_LIST      *NextExternal;
-
-
-    if (!AcpiGbl_ExternalList)
-    {
-        return;
-    }
-
-    /*
-     * Determine the number of control methods in the external list, and
-     * also how many of those externals were resolved via the namespace.
-     */
-    NextExternal = AcpiGbl_ExternalList;
-    while (NextExternal)
-    {
-        if (NextExternal->Type == ACPI_TYPE_METHOD)
-        {
-            AcpiGbl_NumExternalMethods++;
-            if (NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE)
-            {
-                AcpiGbl_ResolvedExternalMethods++;
-            }
-        }
-
-        NextExternal = NextExternal->Next;
-    }
-
-    /* Check if any control methods were unresolved */
-
-    AcpiDmUnresolvedWarning (1);
-
-    if (Gbl_ExternalRefFilename)
-    {
-        AcpiOsPrintf (
-            "    /*\n     * External declarations were imported from\n"
-            "     * a reference file -- %s\n     */\n\n",
-            Gbl_ExternalRefFilename);
-    }
-
-    /*
-     * Walk and emit the list of externals found during the AML parsing
-     */
-    while (AcpiGbl_ExternalList)
-    {
-        if (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_EXTERNAL_EMITTED))
-        {
-            AcpiOsPrintf ("    External (%s%s)",
-                AcpiGbl_ExternalList->Path,
-                AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type));
-
-            /* Check for "unresolved" method reference */
-
-            if ((AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) &&
-                (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_RESOLVED_REFERENCE)))
-            {
-                AcpiOsPrintf ("    // Warning: Unknown method, "
-                    "guessing %u arguments",
-                    AcpiGbl_ExternalList->Value);
-            }
-
-            /* Check for external from a external references file */
-
-            else if (AcpiGbl_ExternalList->Flags & ACPI_EXT_ORIGIN_FROM_FILE)
-            {
-                if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD)
-                {
-                    AcpiOsPrintf ("    // %u Arguments",
-                        AcpiGbl_ExternalList->Value);
-                }
-
-                AcpiOsPrintf ("    // From external reference file");
-            }
-
-            /* This is the normal external case */
-
-            else
-            {
-                /* For methods, add a comment with the number of arguments */
-
-                if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD)
-                {
-                    AcpiOsPrintf ("    // %u Arguments",
-                        AcpiGbl_ExternalList->Value);
-                }
-            }
-
-            AcpiOsPrintf ("\n");
-        }
-
-        /* Free this external info block and move on to next external */
-
-        NextExternal = AcpiGbl_ExternalList->Next;
-        if (AcpiGbl_ExternalList->Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED)
-        {
-            ACPI_FREE (AcpiGbl_ExternalList->InternalPath);
-        }
-
-        ACPI_FREE (AcpiGbl_ExternalList->Path);
-        ACPI_FREE (AcpiGbl_ExternalList);
-        AcpiGbl_ExternalList = NextExternal;
-    }
-
-    AcpiOsPrintf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmUnresolvedWarning
- *
- * PARAMETERS:  Type                - Where to output the warning.
- *                                    0 means write to stderr
- *                                    1 means write to AcpiOsPrintf
- *
- * RETURN:      None
- *
- * DESCRIPTION: Issue warning message if there are unresolved external control
- *              methods within the disassembly.
- *
- ******************************************************************************/
-
-#if 0
-Summary of the external control method problem:
-
-When the -e option is used with disassembly, the various SSDTs are simply
-loaded into a global namespace for the disassembler to use in order to
-resolve control method references (invocations).
-
-The disassembler tracks any such references, and will emit an External()
-statement for these types of methods, with the proper number of arguments .
-
-Without the SSDTs, the AML does not contain enough information to properly
-disassemble the control method invocation -- because the disassembler does
-not know how many arguments to parse.
-
-An example: Assume we have two control methods. ABCD has one argument, and
-EFGH has zero arguments. Further, we have two additional control methods
-that invoke ABCD and EFGH, named T1 and T2:
-
-    Method (ABCD, 1)
-    {
-    }
-    Method (EFGH, 0)
-    {
-    }
-    Method (T1)
-    {
-        ABCD (Add (2, 7, Local0))
-    }
-    Method (T2)
-    {
-        EFGH ()
-        Add (2, 7, Local0)
-    }
-
-Here is the AML code that is generated for T1 and T2:
-
-     185:      Method (T1)
-
-0000034C:  14 10 54 31 5F 5F 00 ...    "..T1__."
-
-     186:      {
-     187:          ABCD (Add (2, 7, Local0))
-
-00000353:  41 42 43 44 ............    "ABCD"
-00000357:  72 0A 02 0A 07 60 ......    "r....`"
-
-     188:      }
-
-     190:      Method (T2)
-
-0000035D:  14 10 54 32 5F 5F 00 ...    "..T2__."
-
-     191:      {
-     192:          EFGH ()
-
-00000364:  45 46 47 48 ............    "EFGH"
-
-     193:          Add (2, 7, Local0)
-
-00000368:  72 0A 02 0A 07 60 ......    "r....`"
-     194:      }
-
-Note that the AML code for T1 and T2 is essentially identical. When
-disassembling this code, the methods ABCD and EFGH must be known to the
-disassembler, otherwise it does not know how to handle the method invocations.
-
-In other words, if ABCD and EFGH are actually external control methods
-appearing in an SSDT, the disassembler does not know what to do unless
-the owning SSDT has been loaded via the -e option.
-#endif
-
-static char             ExternalWarningPart1[600];
-static char             ExternalWarningPart2[400];
-static char             ExternalWarningPart3[400];
-static char             ExternalWarningPart4[200];
-
-void
-AcpiDmUnresolvedWarning (
-    UINT8                   Type)
-{
-    char                    *Format;
-    char                    Pad[] = "     *";
-    char                    NoPad[] = "";
-
-
-    if (!AcpiGbl_NumExternalMethods)
-    {
-        return;
-    }
-
-    if (AcpiGbl_NumExternalMethods == AcpiGbl_ResolvedExternalMethods)
-    {
-        return;
-    }
-
-    Format = Type ? Pad : NoPad;
-
-    sprintf (ExternalWarningPart1,
-        "%s iASL Warning: There %s %u external control method%s found during\n"
-        "%s disassembly, but only %u %s resolved (%u unresolved). Additional\n"
-        "%s ACPI tables may be required to properly disassemble the code. This\n"
-        "%s resulting disassembler output file may not compile because the\n"
-        "%s disassembler did not know how many arguments to assign to the\n"
-        "%s unresolved methods. Note: SSDTs can be dynamically loaded at\n"
-        "%s runtime and may or may not be available via the host OS.\n",
-        Format, (AcpiGbl_NumExternalMethods != 1 ? "were" : "was"),
-        AcpiGbl_NumExternalMethods, (AcpiGbl_NumExternalMethods != 1 ? "s" : ""),
-        Format, AcpiGbl_ResolvedExternalMethods,
-        (AcpiGbl_ResolvedExternalMethods != 1 ? "were" : "was"),
-        (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods),
-        Format, Format, Format, Format, Format);
-
-    sprintf (ExternalWarningPart2,
-        "%s To specify the tables needed to resolve external control method\n"
-        "%s references, the -e option can be used to specify the filenames.\n"
-        "%s Example iASL invocations:\n"
-        "%s     iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n"
-        "%s     iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n"
-        "%s     iasl -e ssdt*.aml -d dsdt.aml\n",
-        Format, Format, Format, Format, Format, Format);
-
-    sprintf (ExternalWarningPart3,
-        "%s In addition, the -fe option can be used to specify a file containing\n"
-        "%s control method external declarations with the associated method\n"
-        "%s argument counts. Each line of the file must be of the form:\n"
-        "%s     External (<method pathname>, MethodObj, <argument count>)\n"
-        "%s Invocation:\n"
-        "%s     iasl -fe refs.txt -d dsdt.aml\n",
-        Format, Format, Format, Format, Format, Format);
-
-    sprintf (ExternalWarningPart4,
-        "%s The following methods were unresolved and many not compile properly\n"
-        "%s because the disassembler had to guess at the number of arguments\n"
-        "%s required for each:\n",
-        Format, Format, Format);
-
-    if (Type)
-    {
-        if (!AcpiGbl_ExternalFileList)
-        {
-            /* The -e option was not specified */
-
-           AcpiOsPrintf ("    /*\n%s     *\n%s     *\n%s     *\n%s     */\n",
-               ExternalWarningPart1, ExternalWarningPart2, ExternalWarningPart3,
-               ExternalWarningPart4);
-        }
-        else
-        {
-            /* The -e option was specified, but there are still some unresolved externals */
-
-            AcpiOsPrintf ("    /*\n%s     *\n%s     *\n%s     */\n",
-               ExternalWarningPart1, ExternalWarningPart3, ExternalWarningPart4);
-        }
-    }
-    else
-    {
-        if (!AcpiGbl_ExternalFileList)
-        {
-            /* The -e option was not specified */
-
-            fprintf (stderr, "\n%s\n%s\n%s\n",
-               ExternalWarningPart1, ExternalWarningPart2, ExternalWarningPart3);
-        }
-        else
-        {
-            /* The -e option was specified, but there are still some unresolved externals */
-
-            fprintf (stderr, "\n%s\n%s\n",
-               ExternalWarningPart1, ExternalWarningPart3);
-        }
-    }
-}

+ 0 - 1124
sys/src/libacpi/acpica/common/dmrestag.c

@@ -1,1124 +0,0 @@
-/******************************************************************************
- *
- * Module Name: dmrestag - Add tags to resource descriptors (Application-level)
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acparser.h"
-#include "acdisasm.h"
-#include "acnamesp.h"
-#include "amlcode.h"
-
-/* This module used for application-level code only */
-
-#define _COMPONENT          ACPI_CA_DISASSEMBLER
-        ACPI_MODULE_NAME    ("dmrestag")
-
-/* Local prototypes */
-
-static void
-AcpiDmUpdateResourceName (
-    ACPI_NAMESPACE_NODE     *ResourceNode);
-
-static char *
-AcpiDmSearchTagList (
-    UINT32                  BitIndex,
-    const ACPI_RESOURCE_TAG *TagList);
-
-static char *
-AcpiDmGetResourceTag (
-    UINT32                  BitIndex,
-    AML_RESOURCE            *Resource,
-    UINT8                   ResourceIndex);
-
-static char *
-AcpiGetTagPathname (
-    ACPI_PARSE_OBJECT       *Op,
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    ACPI_NAMESPACE_NODE     *ResourceNode,
-    UINT32                  BitIndex);
-
-static ACPI_NAMESPACE_NODE *
-AcpiDmGetResourceNode (
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    UINT32                  BitIndex);
-
-static ACPI_STATUS
-AcpiDmAddResourceToNamespace (
-    UINT8                   *Aml,
-    UINT32                  Length,
-    UINT32                  Offset,
-    UINT8                   ResourceIndex,
-    void                    **Context);
-
-static void
-AcpiDmAddResourcesToNamespace (
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    ACPI_PARSE_OBJECT       *Op);
-
-
-/******************************************************************************
- *
- * Resource Tag tables
- *
- * These are the predefined tags that refer to elements of a resource
- * descriptor. Each name and offset is defined in the ACPI specification.
- *
- * Each table entry contains the bit offset of the field and the associated
- * name.
- *
- ******************************************************************************/
-
-static const ACPI_RESOURCE_TAG      AcpiDmIrqTags[] =
-{
-    {( 1 * 8),      ACPI_RESTAG_INTERRUPT},
-    {( 3 * 8) + 0,  ACPI_RESTAG_INTERRUPTTYPE},
-    {( 3 * 8) + 3,  ACPI_RESTAG_INTERRUPTLEVEL},
-    {( 3 * 8) + 4,  ACPI_RESTAG_INTERRUPTSHARE},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmDmaTags[] =
-{
-    {( 1 * 8),      ACPI_RESTAG_DMA},
-    {( 2 * 8) + 0,  ACPI_RESTAG_XFERTYPE},
-    {( 2 * 8) + 2,  ACPI_RESTAG_BUSMASTER},
-    {( 2 * 8) + 5,  ACPI_RESTAG_DMATYPE},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmIoTags[] =
-{
-    {( 1 * 8) + 0,  ACPI_RESTAG_DECODE},
-    {( 2 * 8),      ACPI_RESTAG_MINADDR},
-    {( 4 * 8),      ACPI_RESTAG_MAXADDR},
-    {( 6 * 8),      ACPI_RESTAG_ALIGNMENT},
-    {( 7 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmFixedIoTags[] =
-{
-    {( 1 * 8),      ACPI_RESTAG_BASEADDRESS},
-    {( 3 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmFixedDmaTags[] =
-{
-    {( 1 * 8),      ACPI_RESTAG_DMA},
-    {( 3 * 8),      ACPI_RESTAG_DMATYPE},
-    {( 5 * 8),      ACPI_RESTAG_XFERTYPE},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmMemory24Tags[] =
-{
-    {( 3 * 8) + 0,  ACPI_RESTAG_READWRITETYPE},
-    {( 4 * 8),      ACPI_RESTAG_MINADDR},
-    {( 6 * 8),      ACPI_RESTAG_MAXADDR},
-    {( 8 * 8),      ACPI_RESTAG_ALIGNMENT},
-    {(10 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmRegisterTags[] =
-{
-    {( 3 * 8),      ACPI_RESTAG_ADDRESSSPACE},
-    {( 4 * 8),      ACPI_RESTAG_REGISTERBITWIDTH},
-    {( 5 * 8),      ACPI_RESTAG_REGISTERBITOFFSET},
-    {( 6 * 8),      ACPI_RESTAG_ACCESSSIZE},
-    {( 7 * 8),      ACPI_RESTAG_ADDRESS},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmMemory32Tags[] =
-{
-    {( 3 * 8) + 0,  ACPI_RESTAG_READWRITETYPE},
-    {( 4 * 8),      ACPI_RESTAG_MINADDR},
-    {( 8 * 8),      ACPI_RESTAG_MAXADDR},
-    {(12 * 8),      ACPI_RESTAG_ALIGNMENT},
-    {(16 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmFixedMemory32Tags[] =
-{
-    {( 3 * 8) + 0,  ACPI_RESTAG_READWRITETYPE},
-    {( 4 * 8),      ACPI_RESTAG_BASEADDRESS},
-    {( 8 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmInterruptTags[] =
-{
-    {( 3 * 8) + 1,  ACPI_RESTAG_INTERRUPTTYPE},
-    {( 3 * 8) + 2,  ACPI_RESTAG_INTERRUPTLEVEL},
-    {( 3 * 8) + 3,  ACPI_RESTAG_INTERRUPTSHARE},
-    {( 5 * 8),      ACPI_RESTAG_INTERRUPT},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmAddress16Tags[] =
-{
-    {( 4 * 8) + 1,  ACPI_RESTAG_DECODE},
-    {( 4 * 8) + 2,  ACPI_RESTAG_MINTYPE},
-    {( 4 * 8) + 3,  ACPI_RESTAG_MAXTYPE},
-    {( 6 * 8),      ACPI_RESTAG_GRANULARITY},
-    {( 8 * 8),      ACPI_RESTAG_MINADDR},
-    {(10 * 8),      ACPI_RESTAG_MAXADDR},
-    {(12 * 8),      ACPI_RESTAG_TRANSLATION},
-    {(14 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmAddress32Tags[] =
-{
-    {( 4 * 8) + 1,  ACPI_RESTAG_DECODE},
-    {( 4 * 8) + 2,  ACPI_RESTAG_MINTYPE},
-    {( 4 * 8) + 3,  ACPI_RESTAG_MAXTYPE},
-    {( 6 * 8),      ACPI_RESTAG_GRANULARITY},
-    {(10 * 8),      ACPI_RESTAG_MINADDR},
-    {(14 * 8),      ACPI_RESTAG_MAXADDR},
-    {(18 * 8),      ACPI_RESTAG_TRANSLATION},
-    {(22 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmAddress64Tags[] =
-{
-    {( 4 * 8) + 1,  ACPI_RESTAG_DECODE},
-    {( 4 * 8) + 2,  ACPI_RESTAG_MINTYPE},
-    {( 4 * 8) + 3,  ACPI_RESTAG_MAXTYPE},
-    {( 6 * 8),      ACPI_RESTAG_GRANULARITY},
-    {(14 * 8),      ACPI_RESTAG_MINADDR},
-    {(22 * 8),      ACPI_RESTAG_MAXADDR},
-    {(30 * 8),      ACPI_RESTAG_TRANSLATION},
-    {(38 * 8),      ACPI_RESTAG_LENGTH},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmExtendedAddressTags[] =
-{
-    {( 4 * 8) + 1,  ACPI_RESTAG_DECODE},
-    {( 4 * 8) + 2,  ACPI_RESTAG_MINTYPE},
-    {( 4 * 8) + 3,  ACPI_RESTAG_MAXTYPE},
-    {( 8 * 8),      ACPI_RESTAG_GRANULARITY},
-    {(16 * 8),      ACPI_RESTAG_MINADDR},
-    {(24 * 8),      ACPI_RESTAG_MAXADDR},
-    {(32 * 8),      ACPI_RESTAG_TRANSLATION},
-    {(40 * 8),      ACPI_RESTAG_LENGTH},
-    {(48 * 8),      ACPI_RESTAG_TYPESPECIFICATTRIBUTES},
-    {0,             NULL}
-};
-
-/* Subtype tables for GPIO descriptors */
-
-static const ACPI_RESOURCE_TAG      AcpiDmGpioIntTags[] =
-{
-    {( 7 * 8) + 0,  ACPI_RESTAG_MODE},
-    {( 7 * 8) + 1,  ACPI_RESTAG_POLARITY},
-    {( 7 * 8) + 3,  ACPI_RESTAG_INTERRUPTSHARE},
-    {( 9 * 8),      ACPI_RESTAG_PINCONFIG},
-    {(10 * 8),      ACPI_RESTAG_DRIVESTRENGTH},
-    {(12 * 8),      ACPI_RESTAG_DEBOUNCETIME},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmGpioIoTags[] =
-{
-    {( 7 * 8) + 0,  ACPI_RESTAG_IORESTRICTION},
-    {( 7 * 8) + 3,  ACPI_RESTAG_INTERRUPTSHARE},
-    {( 9 * 8),      ACPI_RESTAG_PINCONFIG},
-    {(10 * 8),      ACPI_RESTAG_DRIVESTRENGTH},
-    {(12 * 8),      ACPI_RESTAG_DEBOUNCETIME},
-    {0,             NULL}
-};
-
-/* Subtype tables for SerialBus descriptors */
-
-static const ACPI_RESOURCE_TAG      AcpiDmI2cSerialBusTags[] =
-{
-    {( 6 * 8) + 0,  ACPI_RESTAG_SLAVEMODE},
-    {( 6 * 8) + 2,  ACPI_RESTAG_INTERRUPTSHARE},    /* V2 - ACPI 6.0 */
-    {( 7 * 8) + 0,  ACPI_RESTAG_MODE},
-    {(12 * 8),      ACPI_RESTAG_SPEED},
-    {(16 * 8),      ACPI_RESTAG_ADDRESS},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmSpiSerialBusTags[] =
-{
-    {( 6 * 8) + 0,  ACPI_RESTAG_SLAVEMODE},
-    {( 6 * 8) + 2,  ACPI_RESTAG_INTERRUPTSHARE},    /* V2 - ACPI 6.0 */
-    {( 7 * 8) + 0,  ACPI_RESTAG_MODE},
-    {( 7 * 8) + 1,  ACPI_RESTAG_DEVICEPOLARITY},
-    {(12 * 8),      ACPI_RESTAG_SPEED},
-    {(16 * 8),      ACPI_RESTAG_LENGTH},
-    {(17 * 8),      ACPI_RESTAG_PHASE},
-    {(18 * 8),      ACPI_RESTAG_POLARITY},
-    {(19 * 8),      ACPI_RESTAG_ADDRESS},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmUartSerialBusTags[] =
-{
-    {( 6 * 8) + 0,  ACPI_RESTAG_SLAVEMODE},         /* Note: not part of original macro */
-    {( 6 * 8) + 2,  ACPI_RESTAG_INTERRUPTSHARE},    /* V2 - ACPI 6.0 */
-    {( 7 * 8) + 0,  ACPI_RESTAG_FLOWCONTROL},
-    {( 7 * 8) + 2,  ACPI_RESTAG_STOPBITS},
-    {( 7 * 8) + 4,  ACPI_RESTAG_LENGTH},
-    {( 7 * 8) + 7,  ACPI_RESTAG_ENDIANNESS},
-    {(12 * 8),      ACPI_RESTAG_SPEED},
-    {(16 * 8),      ACPI_RESTAG_LENGTH_RX},
-    {(18 * 8),      ACPI_RESTAG_LENGTH_TX},
-    {(20 * 8),      ACPI_RESTAG_PARITY},
-    {(21 * 8),      ACPI_RESTAG_LINE},
-    {0,             NULL}
-};
-
-/* Subtype tables for Address descriptor type-specific flags */
-
-static const ACPI_RESOURCE_TAG      AcpiDmMemoryFlagTags[] =
-{
-    {( 5 * 8) + 0,  ACPI_RESTAG_READWRITETYPE},
-    {( 5 * 8) + 1,  ACPI_RESTAG_MEMTYPE},
-    {( 5 * 8) + 3,  ACPI_RESTAG_MEMATTRIBUTES},
-    {( 5 * 8) + 5,  ACPI_RESTAG_TYPE},
-    {0,             NULL}
-};
-
-static const ACPI_RESOURCE_TAG      AcpiDmIoFlagTags[] =
-{
-    {( 5 * 8) + 0,  ACPI_RESTAG_RANGETYPE},
-    {( 5 * 8) + 4,  ACPI_RESTAG_TYPE},
-    {( 5 * 8) + 5,  ACPI_RESTAG_TRANSTYPE},
-    {0,             NULL}
-};
-
-
-/*
- * Dispatch table used to obtain the correct tag table for a descriptor.
- *
- * A NULL in this table means one of three things:
- * 1) The descriptor ID is reserved and invalid
- * 2) The descriptor has no tags associated with it
- * 3) The descriptor has subtypes and a separate table will be used.
- */
-static const ACPI_RESOURCE_TAG      *AcpiGbl_ResourceTags[] =
-{
-    /* Small descriptors */
-
-    NULL,                           /* 0x00, Reserved */
-    NULL,                           /* 0x01, Reserved */
-    NULL,                           /* 0x02, Reserved */
-    NULL,                           /* 0x03, Reserved */
-    AcpiDmIrqTags,                  /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */
-    AcpiDmDmaTags,                  /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */
-    NULL,                           /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
-    NULL,                           /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
-    AcpiDmIoTags,                   /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */
-    AcpiDmFixedIoTags,              /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */
-    AcpiDmFixedDmaTags,             /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
-    NULL,                           /* 0x0B, Reserved */
-    NULL,                           /* 0x0C, Reserved */
-    NULL,                           /* 0x0D, Reserved */
-    NULL,                           /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */
-    NULL,                           /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */
-
-    /* Large descriptors */
-
-    NULL,                           /* 0x00, Reserved */
-    AcpiDmMemory24Tags,             /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */
-    AcpiDmRegisterTags,             /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
-    NULL,                           /* 0x03, Reserved */
-    NULL,                           /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */
-    AcpiDmMemory32Tags,             /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */
-    AcpiDmFixedMemory32Tags,        /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */
-    AcpiDmAddress32Tags,            /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */
-    AcpiDmAddress16Tags,            /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */
-    AcpiDmInterruptTags,            /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */
-    AcpiDmAddress64Tags,            /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */
-    AcpiDmExtendedAddressTags,      /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */
-    NULL,                           /* 0x0C, ACPI_RESOURCE_NAME_GPIO - Use Subtype table below */
-    NULL,                           /* 0x0D, Reserved */
-    NULL                            /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use Subtype table below */
-};
-
-/* GPIO Subtypes */
-
-static const ACPI_RESOURCE_TAG      *AcpiGbl_GpioResourceTags[] =
-{
-    AcpiDmGpioIntTags,              /* 0x00 Interrupt Connection */
-    AcpiDmGpioIoTags                /* 0x01 I/O Connection */
-};
-
-/* Serial Bus Subtypes */
-
-static const ACPI_RESOURCE_TAG      *AcpiGbl_SerialResourceTags[] =
-{
-    NULL,                           /* 0x00 Reserved */
-    AcpiDmI2cSerialBusTags,         /* 0x01 I2C SerialBus */
-    AcpiDmSpiSerialBusTags,         /* 0x02 SPI SerialBus */
-    AcpiDmUartSerialBusTags         /* 0x03 UART SerialBus */
-};
-
-/*
- * Globals used to generate unique resource descriptor names. We use names that
- * start with underscore and a prefix letter that is not used by other ACPI
- * reserved names. To this, we append hex 0x00 through 0xFF. These 5 prefixes
- * allow for 5*256 = 1280 unique names, probably sufficient for any single ASL
- * file. If this becomes too small, we can use alpha+numerals for a total
- * of 5*36*36 = 6480.
- */
-#define ACPI_NUM_RES_PREFIX     5
-
-static UINT32                   AcpiGbl_NextResourceId = 0;
-static UINT8                    AcpiGbl_NextPrefix = 0;
-static char                     AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] =
-                                    {'Y','Z','J','K','X'};
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmCheckResourceReference
- *
- * PARAMETERS:  Op                  - Parse Op for the AML opcode
- *              WalkState           - Current walk state (with valid scope)
- *
- * RETURN:      None
- *
- * DESCRIPTION: Convert a reference to a resource descriptor to a symbolic
- *              reference if possible
- *
- * NOTE:        Bit index is used to transparently handle both resource bit
- *              fields and byte fields.
- *
- ******************************************************************************/
-
-void
-AcpiDmCheckResourceReference (
-    ACPI_PARSE_OBJECT       *Op,
-    ACPI_WALK_STATE         *WalkState)
-{
-    ACPI_STATUS             Status;
-    ACPI_PARSE_OBJECT       *BufferNameOp;
-    ACPI_PARSE_OBJECT       *IndexOp;
-    ACPI_NAMESPACE_NODE     *BufferNode;
-    ACPI_NAMESPACE_NODE     *ResourceNode;
-    const ACPI_OPCODE_INFO  *OpInfo;
-    UINT32                  BitIndex;
-
-
-    /* We are only interested in the CreateXxxxField opcodes */
-
-    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
-    if (OpInfo->Type != AML_TYPE_CREATE_FIELD)
-    {
-        return;
-    }
-
-    /* Get the buffer term operand */
-
-    BufferNameOp = AcpiPsGetDepthNext (NULL, Op);
-
-    /* Must be a named buffer, not an arg or local or method call */
-
-    if (BufferNameOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
-    {
-        return;
-    }
-
-    /* Get the Index term, must be an integer constant to convert */
-
-    IndexOp = BufferNameOp->Common.Next;
-
-    /* Major cheat: The Node field is also used for the Tag ptr. Clear it now */
-
-    IndexOp->Common.Node = NULL;
-
-    OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode);
-    if (OpInfo->ObjectType != ACPI_TYPE_INTEGER)
-    {
-        return;
-    }
-
-    /* Get the bit offset of the descriptor within the buffer */
-
-    if ((Op->Common.AmlOpcode == AML_CREATE_BIT_FIELD_OP) ||
-        (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP))
-    {
-        /* Index operand is a bit offset */
-
-        BitIndex = (UINT32) IndexOp->Common.Value.Integer;
-    }
-    else
-    {
-        /* Index operand is a byte offset, convert to bits */
-
-        BitIndex = (UINT32) ACPI_MUL_8 (IndexOp->Common.Value.Integer);
-    }
-
-    /* Lookup the buffer in the namespace */
-
-    Status = AcpiNsLookup (WalkState->ScopeInfo,
-        BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER,
-        ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState,
-        &BufferNode);
-    if (ACPI_FAILURE (Status))
-    {
-        return;
-    }
-
-    /* Validate object type, we must have a buffer */
-
-    if (BufferNode->Type != ACPI_TYPE_BUFFER)
-    {
-        return;
-    }
-
-    /* Find the resource descriptor node corresponding to the index */
-
-    ResourceNode = AcpiDmGetResourceNode (BufferNode, BitIndex);
-    if (!ResourceNode)
-    {
-        return;
-    }
-
-    /* Translate the Index to a resource tag pathname */
-
-    AcpiGetTagPathname (IndexOp, BufferNode, ResourceNode, BitIndex);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetResourceNode
- *
- * PARAMETERS:  BufferNode          - Node for the parent buffer
- *              BitIndex            - Index into the resource descriptor
- *
- * RETURN:      Namespace node for the resource descriptor. NULL if not found
- *
- * DESCRIPTION: Find a resource descriptor that corresponds to the bit index
- *
- ******************************************************************************/
-
-static ACPI_NAMESPACE_NODE *
-AcpiDmGetResourceNode (
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    UINT32                  BitIndex)
-{
-    ACPI_NAMESPACE_NODE     *Node;
-    UINT32                  ByteIndex = ACPI_DIV_8 (BitIndex);
-
-
-    /*
-     * Child list contains an entry for each resource descriptor. Find
-     * the descriptor that corresponds to the Index.
-     *
-     * If there are no children, this is not a resource template
-     */
-    Node = BufferNode->Child;
-    while (Node)
-    {
-        /*
-         * Check if the Index falls within this resource.
-         *
-         * Value contains the resource offset, Object contains the resource
-         * length (both in bytes)
-         */
-        if ((ByteIndex >= Node->Value) &&
-            (ByteIndex < (Node->Value + Node->Length)))
-        {
-            return (Node);
-        }
-
-        Node = Node->Peer;
-    }
-
-    return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiGetTagPathname
- *
- * PARAMETERS:  BufferNode          - Node for the parent buffer
- *              ResourceNode        - Node for a resource descriptor
- *              BitIndex            - Index into the resource descriptor
- *
- * RETURN:      Full pathname for a resource tag. NULL if no match.
- *              Path is returned in AML (packed) format.
- *
- * DESCRIPTION: Convert a BitIndex into a symbolic resource tag (full pathname)
- *
- ******************************************************************************/
-
-static char *
-AcpiGetTagPathname (
-    ACPI_PARSE_OBJECT       *IndexOp,
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    ACPI_NAMESPACE_NODE     *ResourceNode,
-    UINT32                  BitIndex)
-{
-    ACPI_STATUS             Status;
-    UINT32                  ResourceBitIndex;
-    UINT8                   ResourceTableIndex;
-    ACPI_SIZE               RequiredSize;
-    char                    *Pathname;
-    AML_RESOURCE            *Aml;
-    ACPI_PARSE_OBJECT       *Op;
-    char                    *InternalPath;
-    char                    *Tag;
-
-
-    /* Get the Op that contains the actual buffer data */
-
-    Op = BufferNode->Op->Common.Value.Arg;
-    Op = Op->Common.Next;
-    if (!Op)
-    {
-        return (NULL);
-    }
-
-    /* Get the individual resource descriptor and validate it */
-
-    Aml = ACPI_CAST_PTR (
-        AML_RESOURCE, &Op->Named.Data[ResourceNode->Value]);
-
-    Status = AcpiUtValidateResource (NULL, Aml, &ResourceTableIndex);
-    if (ACPI_FAILURE (Status))
-    {
-        return (NULL);
-    }
-
-    /* Get offset into this descriptor (from offset into entire buffer) */
-
-    ResourceBitIndex = BitIndex - ACPI_MUL_8 (ResourceNode->Value);
-
-    /* Get the tag associated with this resource descriptor and offset */
-
-    Tag = AcpiDmGetResourceTag (ResourceBitIndex, Aml, ResourceTableIndex);
-    if (!Tag)
-    {
-        return (NULL);
-    }
-
-    /*
-     * Now that we know that we have a reference that can be converted to a
-     * symbol, change the name of the resource to a unique name.
-     */
-    AcpiDmUpdateResourceName (ResourceNode);
-
-    /* Get the full pathname to the parent buffer */
-
-    RequiredSize = AcpiNsBuildNormalizedPath (BufferNode, NULL, 0, FALSE);
-    if (!RequiredSize)
-    {
-        return (NULL);
-    }
-
-    Pathname = ACPI_ALLOCATE_ZEROED (RequiredSize + ACPI_PATH_SEGMENT_LENGTH);
-    if (!Pathname)
-    {
-        return (NULL);
-    }
-
-    (void) AcpiNsBuildNormalizedPath (BufferNode, Pathname,
-        RequiredSize, FALSE);
-
-    /*
-     * Create the full path to the resource and tag by: remove the buffer name,
-     * append the resource descriptor name, append a dot, append the tag name.
-     *
-     * TBD: Always using the full path is a bit brute force, the path can be
-     * often be optimized with carats (if the original buffer namepath is a
-     * single nameseg). This doesn't really matter, because these paths do not
-     * end up in the final compiled AML, it's just an appearance issue for the
-     * disassembled code.
-     */
-    Pathname[strlen (Pathname) - ACPI_NAME_SIZE] = 0;
-    strncat (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
-    strcat (Pathname, ".");
-    strncat (Pathname, Tag, ACPI_NAME_SIZE);
-
-    /* Internalize the namepath to AML format */
-
-    AcpiNsInternalizeName (Pathname, &InternalPath);
-    ACPI_FREE (Pathname);
-
-    /* Update the Op with the symbol */
-
-    AcpiPsInitOp (IndexOp, AML_INT_NAMEPATH_OP);
-    IndexOp->Common.Value.String = InternalPath;
-
-    /* We will need the tag later. Cheat by putting it in the Node field */
-
-    IndexOp->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Tag);
-    return (InternalPath);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmUpdateResourceName
- *
- * PARAMETERS:  ResourceNode        - Node for a resource descriptor
- *
- * RETURN:      Stores new name in the ResourceNode
- *
- * DESCRIPTION: Create a new, unique name for a resource descriptor. Used by
- *              both the disassembly of the descriptor itself and any symbolic
- *              references to the descriptor. Ignored if a unique name has
- *              already been assigned to the resource.
- *
- * NOTE: Single threaded, suitable for applications only!
- *
- ******************************************************************************/
-
-static void
-AcpiDmUpdateResourceName (
-    ACPI_NAMESPACE_NODE     *ResourceNode)
-{
-    char                    Name[ACPI_NAME_SIZE];
-
-
-    /* Ignore if a unique name has already been assigned */
-
-    if (ResourceNode->Name.Integer != ACPI_DEFAULT_RESNAME)
-    {
-        return;
-    }
-
-    /* Generate a new ACPI name for the descriptor */
-
-    Name[0] = '_';
-    Name[1] = AcpiGbl_Prefix[AcpiGbl_NextPrefix];
-    Name[2] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 4);
-    Name[3] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 0);
-
-    /* Update globals for next name */
-
-    AcpiGbl_NextResourceId++;
-    if (AcpiGbl_NextResourceId >= 256)
-    {
-        AcpiGbl_NextResourceId = 0;
-        AcpiGbl_NextPrefix++;
-
-        if (AcpiGbl_NextPrefix > ACPI_NUM_RES_PREFIX)
-        {
-            AcpiGbl_NextPrefix = 0;
-        }
-    }
-
-    /* Change the resource descriptor name */
-
-    ResourceNode->Name.Integer = *ACPI_CAST_PTR (UINT32, &Name[0]);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetResourceTag
- *
- * PARAMETERS:  BitIndex            - Index into the resource descriptor
- *              Resource            - Pointer to the raw resource data
- *              ResourceIndex       - Index correspoinding to the resource type
- *
- * RETURN:      Pointer to the resource tag (ACPI_NAME). NULL if no match.
- *
- * DESCRIPTION: Convert a BitIndex into a symbolic resource tag.
- *
- * Note: ResourceIndex should be previously validated and guaranteed to ve
- *       valid.
- *
- ******************************************************************************/
-
-static char *
-AcpiDmGetResourceTag (
-    UINT32                  BitIndex,
-    AML_RESOURCE            *Resource,
-    UINT8                   ResourceIndex)
-{
-    const ACPI_RESOURCE_TAG *TagList;
-    char                    *Tag = NULL;
-
-
-    /* Get the tag list for this resource descriptor type */
-
-    TagList = AcpiGbl_ResourceTags[ResourceIndex];
-
-    /*
-     * Handle descriptors that have multiple subtypes
-     */
-    switch (Resource->DescriptorType)
-    {
-    case ACPI_RESOURCE_NAME_ADDRESS16:
-    case ACPI_RESOURCE_NAME_ADDRESS32:
-    case ACPI_RESOURCE_NAME_ADDRESS64:
-    case ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64:
-        /*
-         * Subtype differentiation is the flags.
-         * Kindof brute force, but just blindly search for an index match
-         */
-        if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_MEMORY_RANGE)
-        {
-            Tag = AcpiDmSearchTagList (BitIndex, AcpiDmMemoryFlagTags);
-        }
-        else if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_IO_RANGE)
-        {
-            Tag = AcpiDmSearchTagList (BitIndex, AcpiDmIoFlagTags);
-        }
-
-        /* If we found a match, all done. Else, drop to normal search below */
-
-        if (Tag)
-        {
-            return (Tag);
-        }
-        break;
-
-    case ACPI_RESOURCE_NAME_GPIO:
-
-        /* GPIO connection has 2 subtypes: Interrupt and I/O */
-
-        if (Resource->Gpio.ConnectionType > AML_RESOURCE_MAX_GPIOTYPE)
-        {
-            return (NULL);
-        }
-
-        TagList = AcpiGbl_GpioResourceTags[Resource->Gpio.ConnectionType];
-        break;
-
-    case ACPI_RESOURCE_NAME_SERIAL_BUS:
-
-        /* SerialBus has 3 subtypes: I2C, SPI, and UART */
-
-        if ((Resource->CommonSerialBus.Type == 0) ||
-            (Resource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
-        {
-            return (NULL);
-        }
-
-        TagList = AcpiGbl_SerialResourceTags[Resource->CommonSerialBus.Type];
-        break;
-
-    default:
-
-        break;
-    }
-
-    /* Search for a match against the BitIndex */
-
-    if (TagList)
-    {
-        Tag = AcpiDmSearchTagList (BitIndex, TagList);
-    }
-
-    return (Tag);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmSearchTagList
- *
- * PARAMETERS:  BitIndex            - Index into the resource descriptor
- *              TagList             - List to search
- *
- * RETURN:      Pointer to a tag (ACPI_NAME). NULL if no match found.
- *
- * DESCRIPTION: Search a tag list for a match to the input BitIndex. Matches
- *              a fixed offset to a symbolic resource tag name.
- *
- ******************************************************************************/
-
-static char *
-AcpiDmSearchTagList (
-    UINT32                  BitIndex,
-    const ACPI_RESOURCE_TAG *TagList)
-{
-
-    /*
-     * Walk the null-terminated tag list to find a matching bit offset.
-     * We are looking for an exact match.
-     */
-    for ( ; TagList->Tag; TagList++)
-    {
-        if (BitIndex == TagList->BitIndex)
-        {
-            return (TagList->Tag);
-        }
-    }
-
-    /* A matching offset was not found */
-
-    return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmFindResources
- *
- * PARAMETERS:  Root                - Root of the parse tree
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add all ResourceTemplate declarations to the namespace. Each
- *              resource descriptor in each template is given a node -- used
- *              for later conversion of resource references to symbolic refs.
- *
- ******************************************************************************/
-
-void
-AcpiDmFindResources (
-    ACPI_PARSE_OBJECT       *Root)
-{
-    ACPI_PARSE_OBJECT       *Op = Root;
-    ACPI_PARSE_OBJECT       *Parent;
-
-
-    /* Walk the entire parse tree */
-
-    while (Op)
-    {
-        /* We are interested in Buffer() declarations */
-
-        if (Op->Common.AmlOpcode == AML_BUFFER_OP)
-        {
-            /* And only declarations of the form Name (XXXX, Buffer()... ) */
-
-            Parent = Op->Common.Parent;
-            if (Parent->Common.AmlOpcode == AML_NAME_OP)
-            {
-                /*
-                 * If the buffer is a resource template, add the individual
-                 * resource descriptors to the namespace, as children of the
-                 * buffer node.
-                 */
-                if (ACPI_SUCCESS (AcpiDmIsResourceTemplate (NULL, Op)))
-                {
-                    Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
-                    AcpiDmAddResourcesToNamespace (Parent->Common.Node, Op);
-                }
-            }
-        }
-
-        Op = AcpiPsGetDepthNext (Root, Op);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddResourcesToNamespace
- *
- * PARAMETERS:  BufferNode          - Node for the parent buffer
- *              Op                  - Parse op for the buffer
- *
- * RETURN:      None
- *
- * DESCRIPTION: Add an entire resource template to the namespace. Each
- *              resource descriptor is added as a namespace node.
- *
- ******************************************************************************/
-
-static void
-AcpiDmAddResourcesToNamespace (
-    ACPI_NAMESPACE_NODE     *BufferNode,
-    ACPI_PARSE_OBJECT       *Op)
-{
-    ACPI_PARSE_OBJECT       *NextOp;
-
-
-    /* Get to the ByteData list */
-
-    NextOp = Op->Common.Value.Arg;
-    NextOp = NextOp->Common.Next;
-    if (!NextOp)
-    {
-        return;
-    }
-
-    /* Set Node and Op to point to each other */
-
-    BufferNode->Op = Op;
-    Op->Common.Node = BufferNode;
-
-    /*
-     * Insert each resource into the namespace
-     * NextOp contains the Aml pointer and the Aml length
-     */
-    AcpiUtWalkAmlResources (NULL, (UINT8 *) NextOp->Named.Data,
-        (ACPI_SIZE) NextOp->Common.Value.Integer,
-        AcpiDmAddResourceToNamespace, (void **) BufferNode);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmAddResourceToNamespace
- *
- * PARAMETERS:  ACPI_WALK_AML_CALLBACK
- *              BufferNode              - Node for the parent buffer
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Add one resource descriptor to the namespace as a child of the
- *              parent buffer. The same name is used for each descriptor. This
- *              is changed later to a unique name if the resource is actually
- *              referenced by an AML operator.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiDmAddResourceToNamespace (
-    UINT8                   *Aml,
-    UINT32                  Length,
-    UINT32                  Offset,
-    UINT8                   ResourceIndex,
-    void                    **Context)
-{
-    ACPI_STATUS             Status;
-    ACPI_GENERIC_STATE      ScopeInfo;
-    ACPI_NAMESPACE_NODE     *Node;
-
-
-    /* TBD: Don't need to add descriptors that have no tags defined? */
-
-    /* Add the resource to the namespace, as child of the buffer */
-
-    ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Context);
-    Status = AcpiNsLookup (&ScopeInfo, "_TMP", ACPI_TYPE_LOCAL_RESOURCE,
-        ACPI_IMODE_LOAD_PASS2,
-        ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_PREFIX_IS_SCOPE,
-        NULL, &Node);
-    if (ACPI_FAILURE (Status))
-    {
-        return (AE_OK);
-    }
-
-    /* Set the name to the default, changed later if resource is referenced */
-
-    Node->Name.Integer = ACPI_DEFAULT_RESNAME;
-
-    /* Save the offset of the descriptor (within the original buffer) */
-
-    Node->Value = Offset;
-    Node->Length = Length;
-    return (AE_OK);
-}

+ 0 - 1563
sys/src/libacpi/acpica/common/dmtable.c

@@ -1,1563 +0,0 @@
-/******************************************************************************
- *
- * Module Name: dmtable - Support for ACPI tables that contain no AML code
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acdisasm.h"
-#include "actables.h"
-#include "aslcompiler.h"
-#include "dtcompiler.h"
-
-/* This module used for application-level code only */
-
-#define _COMPONENT          ACPI_CA_DISASSEMBLER
-        ACPI_MODULE_NAME    ("dmtable")
-
-const AH_TABLE *
-AcpiAhGetTableInfo (
-    char                    *Signature);
-
-
-/* Common format strings for commented values */
-
-#define UINT8_FORMAT        "%2.2X [%s]\n"
-#define UINT16_FORMAT       "%4.4X [%s]\n"
-#define UINT32_FORMAT       "%8.8X [%s]\n"
-#define STRING_FORMAT       "[%s]\n"
-
-/* These tables map a subtable type to a description string */
-
-static const char           *AcpiDmAsfSubnames[] =
-{
-    "ASF Information",
-    "ASF Alerts",
-    "ASF Remote Control",
-    "ASF RMCP Boot Options",
-    "ASF Address",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmDmarSubnames[] =
-{
-    "Hardware Unit Definition",
-    "Reserved Memory Region",
-    "Root Port ATS Capability",
-    "Remapping Hardware Static Affinity",
-    "ACPI Namespace Device Declaration",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmDmarScope[] =
-{
-    "Reserved value",
-    "PCI Endpoint Device",
-    "PCI Bridge Device",
-    "IOAPIC Device",
-    "Message-capable HPET Device",
-    "Namespace Device",
-    "Unknown Scope Type"            /* Reserved */
-};
-
-static const char           *AcpiDmEinjActions[] =
-{
-    "Begin Operation",
-    "Get Trigger Table",
-    "Set Error Type",
-    "Get Error Type",
-    "End Operation",
-    "Execute Operation",
-    "Check Busy Status",
-    "Get Command Status",
-    "Set Error Type With Address",
-    "Get Execute Timings",
-    "Unknown Action"
-};
-
-static const char           *AcpiDmEinjInstructions[] =
-{
-    "Read Register",
-    "Read Register Value",
-    "Write Register",
-    "Write Register Value",
-    "Noop",
-    "Flush Cacheline",
-    "Unknown Instruction"
-};
-
-static const char           *AcpiDmErstActions[] =
-{
-    "Begin Write Operation",
-    "Begin Read Operation",
-    "Begin Clear Operation",
-    "End Operation",
-    "Set Record Offset",
-    "Execute Operation",
-    "Check Busy Status",
-    "Get Command Status",
-    "Get Record Identifier",
-    "Set Record Identifier",
-    "Get Record Count",
-    "Begin Dummy Write",
-    "Unused/Unknown Action",
-    "Get Error Address Range",
-    "Get Error Address Length",
-    "Get Error Attributes",
-    "Execute Timings",
-    "Unknown Action"
-};
-
-static const char           *AcpiDmErstInstructions[] =
-{
-    "Read Register",
-    "Read Register Value",
-    "Write Register",
-    "Write Register Value",
-    "Noop",
-    "Load Var1",
-    "Load Var2",
-    "Store Var1",
-    "Add",
-    "Subtract",
-    "Add Value",
-    "Subtract Value",
-    "Stall",
-    "Stall While True",
-    "Skip Next If True",
-    "GoTo",
-    "Set Source Address",
-    "Set Destination Address",
-    "Move Data",
-    "Unknown Instruction"
-};
-
-static const char           *AcpiDmGtdtSubnames[] =
-{
-    "Generic Timer Block",
-    "Generic Watchdog Timer",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmHestSubnames[] =
-{
-    "IA-32 Machine Check Exception",
-    "IA-32 Corrected Machine Check",
-    "IA-32 Non-Maskable Interrupt",
-    "Unknown SubTable Type",        /* 3 - Reserved */
-    "Unknown SubTable Type",        /* 4 - Reserved */
-    "Unknown SubTable Type",        /* 5 - Reserved */
-    "PCI Express Root Port AER",
-    "PCI Express AER (AER Endpoint)",
-    "PCI Express/PCI-X Bridge AER",
-    "Generic Hardware Error Source",
-    "Generic Hardware Error Source V2",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmHestNotifySubnames[] =
-{
-    "Polled",
-    "External Interrupt",
-    "Local Interrupt",
-    "SCI",
-    "NMI",
-    "CMCI",                         /* ACPI 5.0 */
-    "MCE",                          /* ACPI 5.0 */
-    "GPIO",                         /* ACPI 6.0 */
-    "SEA",                          /* ACPI 6.1 */
-    "SEI",                          /* ACPI 6.1 */
-    "GSIV",                         /* ACPI 6.1 */
-    "Unknown Notify Type"           /* Reserved */
-};
-
-static const char           *AcpiDmMadtSubnames[] =
-{
-    "Processor Local APIC",             /* ACPI_MADT_TYPE_LOCAL_APIC */
-    "I/O APIC",                         /* ACPI_MADT_TYPE_IO_APIC */
-    "Interrupt Source Override",        /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */
-    "NMI Source",                       /* ACPI_MADT_TYPE_NMI_SOURCE */
-    "Local APIC NMI",                   /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */
-    "Local APIC Address Override",      /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */
-    "I/O SAPIC",                        /* ACPI_MADT_TYPE_IO_SAPIC */
-    "Local SAPIC",                      /* ACPI_MADT_TYPE_LOCAL_SAPIC */
-    "Platform Interrupt Sources",       /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */
-    "Processor Local x2APIC",           /* ACPI_MADT_TYPE_LOCAL_X2APIC */
-    "Local x2APIC NMI",                 /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */
-    "Generic Interrupt Controller",     /* ACPI_MADT_GENERIC_INTERRUPT */
-    "Generic Interrupt Distributor",    /* ACPI_MADT_GENERIC_DISTRIBUTOR */
-    "Generic MSI Frame",                /* ACPI_MADT_GENERIC_MSI_FRAME */
-    "Generic Interrupt Redistributor",  /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
-    "Generic Interrupt Translator",     /* ACPI_MADT_GENERIC_TRANSLATOR */
-    "Unknown Subtable Type"             /* Reserved */
-};
-
-static const char           *AcpiDmNfitSubnames[] =
-{
-    "System Physical Address Range",    /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
-    "Memory Range Map",                 /* ACPI_NFIT_TYPE_MEMORY_MAP */
-    "Interleave Info",                  /* ACPI_NFIT_TYPE_INTERLEAVE */
-    "SMBIOS Information",               /* ACPI_NFIT_TYPE_SMBIOS */
-    "NVDIMM Control Region",            /* ACPI_NFIT_TYPE_CONTROL_REGION */
-    "NVDIMM Block Data Window Region",  /* ACPI_NFIT_TYPE_DATA_REGION */
-    "Flush Hint Address",               /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
-    "Unknown Subtable Type"             /* Reserved */
-};
-
-static const char           *AcpiDmPcctSubnames[] =
-{
-    "Generic Communications Subspace",  /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
-    "HW-Reduced Comm Subspace",         /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
-    "HW-Reduced Comm Subspace Type2",   /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2 */
-    "Unknown Subtable Type"             /* Reserved */
-};
-
-static const char           *AcpiDmPmttSubnames[] =
-{
-    "Socket",                       /* ACPI_PMTT_TYPE_SOCKET */
-    "Memory Controller",            /* ACPI_PMTT_TYPE_CONTROLLER */
-    "Physical Component (DIMM)",    /* ACPI_PMTT_TYPE_DIMM  */
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmSratSubnames[] =
-{
-    "Processor Local APIC/SAPIC Affinity",
-    "Memory Affinity",
-    "Processor Local x2APIC Affinity",
-    "GICC Affinity",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmIvrsSubnames[] =
-{
-    "Hardware Definition Block",
-    "Memory Definition Block",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-static const char           *AcpiDmLpitSubnames[] =
-{
-    "Native C-state Idle Structure",
-    "Unknown Subtable Type"         /* Reserved */
-};
-
-#define ACPI_FADT_PM_RESERVED       9
-
-static const char           *AcpiDmFadtProfiles[] =
-{
-    "Unspecified",
-    "Desktop",
-    "Mobile",
-    "Workstation",
-    "Enterprise Server",
-    "SOHO Server",
-    "Appliance PC",
-    "Performance Server",
-    "Tablet",
-    "Unknown Profile Type"
-};
-
-#define ACPI_GAS_WIDTH_RESERVED     5
-
-static const char           *AcpiDmGasAccessWidth[] =
-{
-    "Undefined/Legacy",
-    "Byte Access:8",
-    "Word Access:16",
-    "DWord Access:32",
-    "QWord Access:64",
-    "Unknown Width Encoding"
-};
-
-
-/*******************************************************************************
- *
- * ACPI Table Data, indexed by signature.
- *
- * Each entry contains: Signature, Table Info, Handler, DtHandler,
- *  Template, Description
- *
- * Simple tables have only a TableInfo structure, complex tables have a
- * handler. This table must be NULL terminated. RSDP and FACS are
- * special-cased elsewhere.
- *
- * Note: Any tables added here should be duplicated within AcpiSupportedTables
- * in the file common/ahtable.c
- *
- ******************************************************************************/
-
-const ACPI_DMTABLE_DATA     AcpiDmTableData[] =
-{
-    {ACPI_SIG_ASF,  NULL,                   AcpiDmDumpAsf,  DtCompileAsf,   TemplateAsf},
-    {ACPI_SIG_BERT, AcpiDmTableInfoBert,    NULL,           NULL,           TemplateBert},
-    {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt,    NULL,           NULL,           TemplateBgrt},
-    {ACPI_SIG_BOOT, AcpiDmTableInfoBoot,    NULL,           NULL,           TemplateBoot},
-    {ACPI_SIG_CPEP, NULL,                   AcpiDmDumpCpep, DtCompileCpep,  TemplateCpep},
-    {ACPI_SIG_CSRT, NULL,                   AcpiDmDumpCsrt, DtCompileCsrt,  TemplateCsrt},
-    {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2,    AcpiDmDumpDbg2, DtCompileDbg2,  TemplateDbg2},
-    {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp,    NULL,           NULL,           TemplateDbgp},
-    {ACPI_SIG_DMAR, NULL,                   AcpiDmDumpDmar, DtCompileDmar,  TemplateDmar},
-    {ACPI_SIG_DRTM, NULL,                   AcpiDmDumpDrtm, DtCompileDrtm,  TemplateDrtm},
-    {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt,    NULL,           NULL,           TemplateEcdt},
-    {ACPI_SIG_EINJ, NULL,                   AcpiDmDumpEinj, DtCompileEinj,  TemplateEinj},
-    {ACPI_SIG_ERST, NULL,                   AcpiDmDumpErst, DtCompileErst,  TemplateErst},
-    {ACPI_SIG_FADT, NULL,                   AcpiDmDumpFadt, DtCompileFadt,  TemplateFadt},
-    {ACPI_SIG_FPDT, NULL,                   AcpiDmDumpFpdt, DtCompileFpdt,  TemplateFpdt},
-    {ACPI_SIG_GTDT, NULL,                   AcpiDmDumpGtdt, DtCompileGtdt,  TemplateGtdt},
-    {ACPI_SIG_HEST, NULL,                   AcpiDmDumpHest, DtCompileHest,  TemplateHest},
-    {ACPI_SIG_HPET, AcpiDmTableInfoHpet,    NULL,           NULL,           TemplateHpet},
-    {ACPI_SIG_IORT, NULL,                   AcpiDmDumpIort, DtCompileIort,  TemplateIort},
-    {ACPI_SIG_IVRS, NULL,                   AcpiDmDumpIvrs, DtCompileIvrs,  TemplateIvrs},
-    {ACPI_SIG_LPIT, NULL,                   AcpiDmDumpLpit, DtCompileLpit,  TemplateLpit},
-    {ACPI_SIG_MADT, NULL,                   AcpiDmDumpMadt, DtCompileMadt,  TemplateMadt},
-    {ACPI_SIG_MCFG, NULL,                   AcpiDmDumpMcfg, DtCompileMcfg,  TemplateMcfg},
-    {ACPI_SIG_MCHI, AcpiDmTableInfoMchi,    NULL,           NULL,           TemplateMchi},
-    {ACPI_SIG_MPST, AcpiDmTableInfoMpst,    AcpiDmDumpMpst, DtCompileMpst,  TemplateMpst},
-    {ACPI_SIG_MSCT, NULL,                   AcpiDmDumpMsct, DtCompileMsct,  TemplateMsct},
-    {ACPI_SIG_MSDM, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateMsdm},
-    {ACPI_SIG_MTMR, NULL,                   AcpiDmDumpMtmr, DtCompileMtmr,  TemplateMtmr},
-    {ACPI_SIG_NFIT, AcpiDmTableInfoNfit,    AcpiDmDumpNfit, DtCompileNfit,  TemplateNfit},
-    {ACPI_SIG_PCCT, AcpiDmTableInfoPcct,    AcpiDmDumpPcct, DtCompilePcct,  TemplatePcct},
-    {ACPI_SIG_PMTT, NULL,                   AcpiDmDumpPmtt, DtCompilePmtt,  TemplatePmtt},
-    {ACPI_SIG_RASF, AcpiDmTableInfoRasf,    NULL,           NULL,           TemplateRasf},
-    {ACPI_SIG_RSDT, NULL,                   AcpiDmDumpRsdt, DtCompileRsdt,  TemplateRsdt},
-    {ACPI_SIG_S3PT, NULL,                   NULL,           NULL,           TemplateS3pt},
-    {ACPI_SIG_SBST, AcpiDmTableInfoSbst,    NULL,           NULL,           TemplateSbst},
-    {ACPI_SIG_SLIC, NULL,                   AcpiDmDumpSlic, DtCompileSlic,  TemplateSlic},
-    {ACPI_SIG_SLIT, NULL,                   AcpiDmDumpSlit, DtCompileSlit,  TemplateSlit},
-    {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr,    NULL,           NULL,           TemplateSpcr},
-    {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi,    NULL,           NULL,           TemplateSpmi},
-    {ACPI_SIG_SRAT, NULL,                   AcpiDmDumpSrat, DtCompileSrat,  TemplateSrat},
-    {ACPI_SIG_STAO, NULL,                   AcpiDmDumpStao, DtCompileStao,  TemplateStao},
-    {ACPI_SIG_TCPA, NULL,                   AcpiDmDumpTcpa, DtCompileTcpa,  TemplateTcpa},
-    {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2,    NULL,           NULL,           TemplateTpm2},
-    {ACPI_SIG_UEFI, AcpiDmTableInfoUefi,    NULL,           DtCompileUefi,  TemplateUefi},
-    {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc,    AcpiDmDumpVrtc, DtCompileVrtc,  TemplateVrtc},
-    {ACPI_SIG_WAET, AcpiDmTableInfoWaet,    NULL,           NULL,           TemplateWaet},
-    {ACPI_SIG_WDAT, NULL,                   AcpiDmDumpWdat, DtCompileWdat,  TemplateWdat},
-    {ACPI_SIG_WDDT, AcpiDmTableInfoWddt,    NULL,           NULL,           TemplateWddt},
-    {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt,    NULL,           NULL,           TemplateWdrt},
-    {ACPI_SIG_WPBT, NULL,                   AcpiDmDumpWpbt, DtCompileWpbt,  TemplateWpbt},
-    {ACPI_SIG_XENV, AcpiDmTableInfoXenv,    NULL,           NULL,           TemplateXenv},
-    {ACPI_SIG_XSDT, NULL,                   AcpiDmDumpXsdt, DtCompileXsdt,  TemplateXsdt},
-    {NULL,          NULL,                   NULL,           NULL,           NULL}
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGenerateChecksum
- *
- * PARAMETERS:  Table               - Pointer to table to be checksummed
- *              Length              - Length of the table
- *              OriginalChecksum    - Value of the checksum field
- *
- * RETURN:      8 bit checksum of buffer
- *
- * DESCRIPTION: Computes an 8 bit checksum of the table.
- *
- ******************************************************************************/
-
-UINT8
-AcpiDmGenerateChecksum (
-    void                    *Table,
-    UINT32                  Length,
-    UINT8                   OriginalChecksum)
-{
-    UINT8                   Checksum;
-
-
-    /* Sum the entire table as-is */
-
-    Checksum = AcpiTbChecksum ((UINT8 *) Table, Length);
-
-    /* Subtract off the existing checksum value in the table */
-
-    Checksum = (UINT8) (Checksum - OriginalChecksum);
-
-    /* Compute the final checksum */
-
-    Checksum = (UINT8) (0 - Checksum);
-    return (Checksum);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmGetTableData
- *
- * PARAMETERS:  Signature           - ACPI signature (4 chars) to match
- *
- * RETURN:      Pointer to a valid ACPI_DMTABLE_DATA. Null if no match found.
- *
- * DESCRIPTION: Find a match in the global table of supported ACPI tables
- *
- ******************************************************************************/
-
-const ACPI_DMTABLE_DATA *
-AcpiDmGetTableData (
-    char                    *Signature)
-{
-    const ACPI_DMTABLE_DATA *Info;
-
-
-    for (Info = AcpiDmTableData; Info->Signature; Info++)
-    {
-        if (ACPI_COMPARE_NAME (Signature, Info->Signature))
-        {
-            return (Info);
-        }
-    }
-
-    return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmDumpDataTable
- *
- * PARAMETERS:  Table               - An ACPI table
- *
- * RETURN:      None.
- *
- * DESCRIPTION: Format the contents of an ACPI data table (any table other
- *              than an SSDT or DSDT that does not contain executable AML code)
- *
- ******************************************************************************/
-
-void
-AcpiDmDumpDataTable (
-    ACPI_TABLE_HEADER       *Table)
-{
-    ACPI_STATUS             Status;
-    const ACPI_DMTABLE_DATA *TableData;
-    UINT32                  Length;
-
-
-    /* Ignore tables that contain AML */
-
-    if (AcpiUtIsAmlTable (Table))
-    {
-        if (Gbl_VerboseTemplates)
-        {
-            /* Dump the raw table data */
-
-            Length = Table->Length;
-
-            AcpiOsPrintf ("\n/*\n%s: Length %d (0x%X)\n\n",
-                ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
-            AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
-                Length, DB_BYTE_DISPLAY, 0);
-            AcpiOsPrintf (" */\n");
-        }
-        return;
-    }
-
-    /*
-     * Handle tables that don't use the common ACPI table header structure.
-     * Currently, these are the FACS, RSDP, and S3PT.
-     */
-    if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
-    {
-        Length = Table->Length;
-        Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
-        if (ACPI_FAILURE (Status))
-        {
-            return;
-        }
-    }
-    else if (ACPI_VALIDATE_RSDP_SIG (Table->Signature))
-    {
-        Length = AcpiDmDumpRsdp (Table);
-    }
-    else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
-    {
-        Length = AcpiDmDumpS3pt (Table);
-    }
-    else
-    {
-        /*
-         * All other tables must use the common ACPI table header, dump it now
-         */
-        Length = Table->Length;
-        Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
-        if (ACPI_FAILURE (Status))
-        {
-            return;
-        }
-        AcpiOsPrintf ("\n");
-
-        /* Match signature and dispatch appropriately */
-
-        TableData = AcpiDmGetTableData (Table->Signature);
-        if (!TableData)
-        {
-            if (!strncmp (Table->Signature, "OEM", 3))
-            {
-                AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
-                    Table->Signature);
-            }
-            else
-            {
-                AcpiOsPrintf ("\n**** Unknown ACPI table signature [%4.4s]\n\n",
-                    Table->Signature);
-
-                fprintf (stderr, "Unknown ACPI table signature [%4.4s], ",
-                    Table->Signature);
-
-                if (!AcpiGbl_ForceAmlDisassembly)
-                {
-                    fprintf (stderr, "decoding ACPI table header only\n");
-                }
-                else
-                {
-                    fprintf (stderr, "assuming table contains valid AML code\n");
-                }
-            }
-        }
-        else if (TableData->TableHandler)
-        {
-            /* Complex table, has a handler */
-
-            TableData->TableHandler (Table);
-        }
-        else if (TableData->TableInfo)
-        {
-            /* Simple table, just walk the info table */
-
-            Status = AcpiDmDumpTable (Length, 0, Table, 0, TableData->TableInfo);
-            if (ACPI_FAILURE (Status))
-            {
-                return;
-            }
-        }
-    }
-
-    if (!Gbl_DoTemplates || Gbl_VerboseTemplates)
-    {
-        /* Dump the raw table data */
-
-        AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n",
-            ACPI_RAW_TABLE_DATA_HEADER, Length, Length);
-        AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, Table),
-            Length, DB_BYTE_DISPLAY, 0);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmLineHeader
- *
- * PARAMETERS:  Offset              - Current byte offset, from table start
- *              ByteLength          - Length of the field in bytes, 0 for flags
- *              Name                - Name of this field
- *
- * RETURN:      None
- *
- * DESCRIPTION: Utility routines for formatting output lines. Displays the
- *              current table offset in hex and decimal, the field length,
- *              and the field name.
- *
- ******************************************************************************/
-
-void
-AcpiDmLineHeader (
-    UINT32                  Offset,
-    UINT32                  ByteLength,
-    char                    *Name)
-{
-
-    /* Allow a null name for fields that span multiple lines (large buffers) */
-
-    if (!Name)
-    {
-        Name = "";
-    }
-
-    if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
-    {
-        if (ByteLength)
-        {
-            AcpiOsPrintf ("[%.4d] %34s : ", ByteLength, Name);
-        }
-        else
-        {
-            if (*Name)
-            {
-                AcpiOsPrintf ("%41s : ", Name);
-            }
-            else
-            {
-                AcpiOsPrintf ("%41s   ", Name);
-            }
-        }
-    }
-    else /* Normal disassembler or verbose template */
-    {
-        if (ByteLength)
-        {
-            AcpiOsPrintf ("[%3.3Xh %4.4d% 4d] %28s : ",
-                Offset, Offset, ByteLength, Name);
-        }
-        else
-        {
-            if (*Name)
-            {
-                AcpiOsPrintf ("%44s : ", Name);
-            }
-            else
-            {
-                AcpiOsPrintf ("%44s   ", Name);
-            }
-        }
-    }
-}
-
-void
-AcpiDmLineHeader2 (
-    UINT32                  Offset,
-    UINT32                  ByteLength,
-    char                    *Name,
-    UINT32                  Value)
-{
-
-    if (Gbl_DoTemplates && !Gbl_VerboseTemplates) /* Terse template */
-    {
-        if (ByteLength)
-        {
-            AcpiOsPrintf ("[%.4d] %30s %3d : ",
-                ByteLength, Name, Value);
-        }
-        else
-        {
-            AcpiOsPrintf ("%36s % 3d : ",
-                Name, Value);
-        }
-    }
-    else /* Normal disassembler or verbose template */
-    {
-        if (ByteLength)
-        {
-            AcpiOsPrintf ("[%3.3Xh %4.4d %3d] %24s %3d : ",
-                Offset, Offset, ByteLength, Name, Value);
-        }
-        else
-        {
-            AcpiOsPrintf ("[%3.3Xh %4.4d   ] %24s %3d : ",
-                Offset, Offset, Name, Value);
-        }
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmDumpTable
- *
- * PARAMETERS:  TableLength         - Length of the entire ACPI table
- *              TableOffset         - Starting offset within the table for this
- *                                    sub-descriptor (0 if main table)
- *              Table               - The ACPI table
- *              SubtableLength      - Length of this sub-descriptor
- *              Info                - Info table for this ACPI table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Display ACPI table contents by walking the Info table.
- *
- * Note: This function must remain in sync with DtGetFieldLength.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDmDumpTable (
-    UINT32                  TableLength,
-    UINT32                  TableOffset,
-    void                    *Table,
-    UINT32                  SubtableLength,
-    ACPI_DMTABLE_INFO       *Info)
-{
-    UINT8                   *Target;
-    UINT32                  CurrentOffset;
-    UINT32                  ByteLength;
-    UINT8                   Temp8;
-    UINT16                  Temp16;
-    UINT32                  Temp32;
-    UINT64                  Value;
-    const AH_TABLE          *TableData;
-    const char              *Name;
-    BOOLEAN                 LastOutputBlankLine = FALSE;
-    ACPI_STATUS             Status;
-    char                    RepairedName[8];
-
-
-    if (!Info)
-    {
-        AcpiOsPrintf ("Display not implemented\n");
-        return (AE_NOT_IMPLEMENTED);
-    }
-
-    /* Walk entire Info table; Null name terminates */
-
-    for (; Info->Name; Info++)
-    {
-        /*
-         * Target points to the field within the ACPI Table. CurrentOffset is
-         * the offset of the field from the start of the main table.
-         */
-        Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
-        CurrentOffset = TableOffset + Info->Offset;
-
-        /* Check for beyond subtable end or (worse) beyond EOT */
-
-        if (SubtableLength && (Info->Offset >= SubtableLength))
-        {
-            AcpiOsPrintf (
-                "/**** ACPI subtable terminates early - "
-                "may be older version (dump table) */\n");
-
-            /* Move on to next subtable */
-
-            return (AE_OK);
-        }
-
-        if (CurrentOffset >= TableLength)
-        {
-            AcpiOsPrintf (
-                "/**** ACPI table terminates "
-                "in the middle of a data structure! (dump table) */\n");
-            return (AE_BAD_DATA);
-        }
-
-        /* Generate the byte length for this field */
-
-        switch (Info->Opcode)
-        {
-        case ACPI_DMT_UINT8:
-        case ACPI_DMT_CHKSUM:
-        case ACPI_DMT_SPACEID:
-        case ACPI_DMT_ACCWIDTH:
-        case ACPI_DMT_IVRS:
-        case ACPI_DMT_GTDT:
-        case ACPI_DMT_MADT:
-        case ACPI_DMT_PCCT:
-        case ACPI_DMT_PMTT:
-        case ACPI_DMT_SRAT:
-        case ACPI_DMT_ASF:
-        case ACPI_DMT_HESTNTYP:
-        case ACPI_DMT_FADTPM:
-        case ACPI_DMT_EINJACT:
-        case ACPI_DMT_EINJINST:
-        case ACPI_DMT_ERSTACT:
-        case ACPI_DMT_ERSTINST:
-        case ACPI_DMT_DMAR_SCOPE:
-
-            ByteLength = 1;
-            break;
-
-        case ACPI_DMT_UINT16:
-        case ACPI_DMT_DMAR:
-        case ACPI_DMT_HEST:
-        case ACPI_DMT_NFIT:
-
-            ByteLength = 2;
-            break;
-
-        case ACPI_DMT_UINT24:
-
-            ByteLength = 3;
-            break;
-
-        case ACPI_DMT_UINT32:
-        case ACPI_DMT_NAME4:
-        case ACPI_DMT_SIG:
-        case ACPI_DMT_LPIT:
-
-            ByteLength = 4;
-            break;
-
-        case ACPI_DMT_UINT40:
-
-            ByteLength = 5;
-            break;
-
-        case ACPI_DMT_UINT48:
-        case ACPI_DMT_NAME6:
-
-            ByteLength = 6;
-            break;
-
-        case ACPI_DMT_UINT56:
-        case ACPI_DMT_BUF7:
-
-            ByteLength = 7;
-            break;
-
-        case ACPI_DMT_UINT64:
-        case ACPI_DMT_NAME8:
-
-            ByteLength = 8;
-            break;
-
-        case ACPI_DMT_BUF10:
-
-            ByteLength = 10;
-            break;
-
-        case ACPI_DMT_BUF12:
-
-            ByteLength = 12;
-            break;
-
-        case ACPI_DMT_BUF16:
-        case ACPI_DMT_UUID:
-
-            ByteLength = 16;
-            break;
-
-        case ACPI_DMT_BUF128:
-
-            ByteLength = 128;
-            break;
-
-        case ACPI_DMT_UNICODE:
-        case ACPI_DMT_BUFFER:
-        case ACPI_DMT_RAW_BUFFER:
-
-            ByteLength = SubtableLength;
-            break;
-
-        case ACPI_DMT_STRING:
-
-            ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
-            break;
-
-        case ACPI_DMT_GAS:
-
-            if (!LastOutputBlankLine)
-            {
-                AcpiOsPrintf ("\n");
-                LastOutputBlankLine = TRUE;
-            }
-
-            ByteLength = sizeof (ACPI_GENERIC_ADDRESS);
-            break;
-
-        case ACPI_DMT_HESTNTFY:
-
-            if (!LastOutputBlankLine)
-            {
-                AcpiOsPrintf ("\n");
-                LastOutputBlankLine = TRUE;
-            }
-
-            ByteLength = sizeof (ACPI_HEST_NOTIFY);
-            break;
-
-        case ACPI_DMT_IORTMEM:
-
-            if (!LastOutputBlankLine)
-            {
-                LastOutputBlankLine = FALSE;
-            }
-
-            ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
-            break;
-
-        default:
-
-            ByteLength = 0;
-            break;
-        }
-
-        /* Check if we are beyond a subtable, or (worse) beyond EOT */
-
-        if (CurrentOffset + ByteLength > TableLength)
-        {
-            if (SubtableLength)
-            {
-                AcpiOsPrintf (
-                    "/**** ACPI subtable terminates early - "
-                    "may be older version (dump table) */\n");
-
-                /* Move on to next subtable */
-
-                return (AE_OK);
-            }
-
-            AcpiOsPrintf (
-                "/**** ACPI table terminates "
-                "in the middle of a data structure! */\n");
-            return (AE_BAD_DATA);
-        }
-
-        if (Info->Opcode == ACPI_DMT_EXTRA_TEXT)
-        {
-            AcpiOsPrintf ("%s", Info->Name);
-            continue;
-        }
-
-        /* Start a new line and decode the opcode */
-
-        AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name);
-
-        switch (Info->Opcode)
-        {
-        /* Single-bit Flag fields. Note: Opcode is the bit position */
-
-        case ACPI_DMT_FLAG0:
-        case ACPI_DMT_FLAG1:
-        case ACPI_DMT_FLAG2:
-        case ACPI_DMT_FLAG3:
-        case ACPI_DMT_FLAG4:
-        case ACPI_DMT_FLAG5:
-        case ACPI_DMT_FLAG6:
-        case ACPI_DMT_FLAG7:
-
-            AcpiOsPrintf ("%1.1X\n", (*Target >> Info->Opcode) & 0x01);
-            break;
-
-        /* 2-bit Flag fields */
-
-        case ACPI_DMT_FLAGS0:
-
-            AcpiOsPrintf ("%1.1X\n", *Target & 0x03);
-            break;
-
-        case ACPI_DMT_FLAGS1:
-
-            AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03);
-            break;
-
-        case ACPI_DMT_FLAGS2:
-
-            AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03);
-            break;
-
-        case ACPI_DMT_FLAGS4:
-
-            AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03);
-            break;
-
-        /* Integer Data Types */
-
-        case ACPI_DMT_UINT8:
-        case ACPI_DMT_UINT16:
-        case ACPI_DMT_UINT24:
-        case ACPI_DMT_UINT32:
-        case ACPI_DMT_UINT40:
-        case ACPI_DMT_UINT48:
-        case ACPI_DMT_UINT56:
-        case ACPI_DMT_UINT64:
-            /*
-             * Dump bytes - high byte first, low byte last.
-             * Note: All ACPI tables are little-endian.
-             */
-            Value = 0;
-            for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--)
-            {
-                AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]);
-                Value |= Target[Temp8 - 1];
-                Value <<= 8;
-            }
-
-            if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL))
-            {
-                AcpiOsPrintf (" [Optional field not present]");
-            }
-
-            AcpiOsPrintf ("\n");
-            break;
-
-        case ACPI_DMT_BUF7:
-        case ACPI_DMT_BUF10:
-        case ACPI_DMT_BUF12:
-        case ACPI_DMT_BUF16:
-        case ACPI_DMT_BUF128:
-            /*
-             * Buffer: Size depends on the opcode and was set above.
-             * Each hex byte is separated with a space.
-             * Multiple lines are separated by line continuation char.
-             */
-            for (Temp16 = 0; Temp16 < ByteLength; Temp16++)
-            {
-                AcpiOsPrintf ("%2.2X", Target[Temp16]);
-                if ((UINT32) (Temp16 + 1) < ByteLength)
-                {
-                    if ((Temp16 > 0) && (!((Temp16+1) % 16)))
-                    {
-                        AcpiOsPrintf (" \\\n"); /* Line continuation */
-                        AcpiDmLineHeader (0, 0, NULL);
-                    }
-                    else
-                    {
-                        AcpiOsPrintf (" ");
-                    }
-                }
-            }
-
-            AcpiOsPrintf ("\n");
-            break;
-
-        case ACPI_DMT_UUID:
-
-            /* Convert 16-byte UUID buffer to 36-byte formatted UUID string */
-
-            (void) AuConvertUuidToString ((char *) Target, MsgBuffer);
-
-            AcpiOsPrintf ("%s\n", MsgBuffer);
-            break;
-
-        case ACPI_DMT_STRING:
-
-            AcpiOsPrintf ("\"%s\"\n", ACPI_CAST_PTR (char, Target));
-            break;
-
-        /* Fixed length ASCII name fields */
-
-        case ACPI_DMT_SIG:
-
-            AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
-            AcpiOsPrintf ("\"%.4s\"    ", RepairedName);
-
-            TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
-            if (TableData)
-            {
-                AcpiOsPrintf (STRING_FORMAT, TableData->Description);
-            }
-            else
-            {
-                AcpiOsPrintf ("\n");
-            }
-            break;
-
-        case ACPI_DMT_NAME4:
-
-            AcpiUtCheckAndRepairAscii (Target, RepairedName, 4);
-            AcpiOsPrintf ("\"%.4s\"\n", RepairedName);
-            break;
-
-        case ACPI_DMT_NAME6:
-
-            AcpiUtCheckAndRepairAscii (Target, RepairedName, 6);
-            AcpiOsPrintf ("\"%.6s\"\n", RepairedName);
-            break;
-
-        case ACPI_DMT_NAME8:
-
-            AcpiUtCheckAndRepairAscii (Target, RepairedName, 8);
-            AcpiOsPrintf ("\"%.8s\"\n", RepairedName);
-            break;
-
-        /* Special Data Types */
-
-        case ACPI_DMT_CHKSUM:
-
-            /* Checksum, display and validate */
-
-            AcpiOsPrintf ("%2.2X", *Target);
-            Temp8 = AcpiDmGenerateChecksum (Table,
-                ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
-                ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
-
-            if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
-            {
-                AcpiOsPrintf (
-                    "     /* Incorrect checksum, should be %2.2X */", Temp8);
-            }
-
-            AcpiOsPrintf ("\n");
-            break;
-
-        case ACPI_DMT_SPACEID:
-
-            /* Address Space ID */
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiUtGetRegionName (*Target));
-            break;
-
-        case ACPI_DMT_ACCWIDTH:
-
-            /* Encoded Access Width */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_GAS_WIDTH_RESERVED)
-            {
-                Temp8 = ACPI_GAS_WIDTH_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGasAccessWidth[Temp8]);
-            break;
-
-        case ACPI_DMT_GAS:
-
-            /* Generic Address Structure */
-
-            AcpiOsPrintf (STRING_FORMAT, "Generic Address Structure");
-            Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
-                sizeof (ACPI_GENERIC_ADDRESS), AcpiDmTableInfoGas);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-
-            AcpiOsPrintf ("\n");
-            LastOutputBlankLine = TRUE;
-            break;
-
-        case ACPI_DMT_ASF:
-
-            /* ASF subtable types */
-
-            Temp16 = (UINT16) ((*Target) & 0x7F);  /* Top bit can be zero or one */
-            if (Temp16 > ACPI_ASF_TYPE_RESERVED)
-            {
-                Temp16 = ACPI_ASF_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmAsfSubnames[Temp16]);
-            break;
-
-        case ACPI_DMT_DMAR:
-
-            /* DMAR subtable types */
-
-            Temp16 = ACPI_GET16 (Target);
-            if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
-            {
-                Temp16 = ACPI_DMAR_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
-                AcpiDmDmarSubnames[Temp16]);
-            break;
-
-        case ACPI_DMT_DMAR_SCOPE:
-
-            /* DMAR device scope types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmDmarScope[Temp8]);
-            break;
-
-        case ACPI_DMT_EINJACT:
-
-            /* EINJ Action types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_EINJ_ACTION_RESERVED)
-            {
-                Temp8 = ACPI_EINJ_ACTION_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmEinjActions[Temp8]);
-            break;
-
-        case ACPI_DMT_EINJINST:
-
-            /* EINJ Instruction types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_EINJ_INSTRUCTION_RESERVED)
-            {
-                Temp8 = ACPI_EINJ_INSTRUCTION_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmEinjInstructions[Temp8]);
-            break;
-
-        case ACPI_DMT_ERSTACT:
-
-            /* ERST Action types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_ERST_ACTION_RESERVED)
-            {
-                Temp8 = ACPI_ERST_ACTION_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmErstActions[Temp8]);
-            break;
-
-        case ACPI_DMT_ERSTINST:
-
-            /* ERST Instruction types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_ERST_INSTRUCTION_RESERVED)
-            {
-                Temp8 = ACPI_ERST_INSTRUCTION_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmErstInstructions[Temp8]);
-            break;
-
-        case ACPI_DMT_GTDT:
-
-            /* GTDT subtable types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_GTDT_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_GTDT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmGtdtSubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_HEST:
-
-            /* HEST subtable types */
-
-            Temp16 = ACPI_GET16 (Target);
-            if (Temp16 > ACPI_HEST_TYPE_RESERVED)
-            {
-                Temp16 = ACPI_HEST_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
-                AcpiDmHestSubnames[Temp16]);
-            break;
-
-        case ACPI_DMT_HESTNTFY:
-
-            AcpiOsPrintf (STRING_FORMAT,
-                "Hardware Error Notification Structure");
-
-            Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
-                sizeof (ACPI_HEST_NOTIFY), AcpiDmTableInfoHestNotify);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-
-            AcpiOsPrintf ("\n");
-            LastOutputBlankLine = TRUE;
-            break;
-
-        case ACPI_DMT_HESTNTYP:
-
-            /* HEST Notify types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_HEST_NOTIFY_RESERVED)
-            {
-                Temp8 = ACPI_HEST_NOTIFY_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmHestNotifySubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_IORTMEM:
-
-            AcpiOsPrintf (STRING_FORMAT,
-                "IORT Memory Access Properties");
-
-            Status = AcpiDmDumpTable (TableLength, CurrentOffset, Target,
-                sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-
-            LastOutputBlankLine = TRUE;
-            break;
-
-        case ACPI_DMT_MADT:
-
-            /* MADT subtable types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_MADT_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_MADT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmMadtSubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_NFIT:
-
-            /* NFIT subtable types */
-
-            Temp16 = ACPI_GET16 (Target);
-            if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
-            {
-                Temp16 = ACPI_NFIT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
-                AcpiDmNfitSubnames[Temp16]);
-            break;
-
-        case ACPI_DMT_PCCT:
-
-            /* PCCT subtable types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_PCCT_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_PCCT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmPcctSubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_PMTT:
-
-            /* PMTT subtable types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_PMTT_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_PMTT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmPmttSubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_UNICODE:
-
-            if (ByteLength == 0)
-            {
-                AcpiOsPrintf ("/* Zero-length Data */\n");
-                break;
-            }
-
-            AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
-            break;
-
-        case ACPI_DMT_RAW_BUFFER:
-
-            if (ByteLength == 0)
-            {
-                AcpiOsPrintf ("/* Zero-length Data */\n");
-                break;
-            }
-
-            AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
-                CurrentOffset, NULL);
-            break;
-
-        case ACPI_DMT_SRAT:
-
-            /* SRAT subtable types */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_SRAT_TYPE_RESERVED)
-            {
-                Temp8 = ACPI_SRAT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmSratSubnames[Temp8]);
-            break;
-
-        case ACPI_DMT_FADTPM:
-
-            /* FADT Preferred PM Profile names */
-
-            Temp8 = *Target;
-            if (Temp8 > ACPI_FADT_PM_RESERVED)
-            {
-                Temp8 = ACPI_FADT_PM_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target,
-                AcpiDmFadtProfiles[Temp8]);
-            break;
-
-        case ACPI_DMT_IVRS:
-
-            /* IVRS subtable types */
-
-            Temp8 = *Target;
-            switch (Temp8)
-            {
-            case ACPI_IVRS_TYPE_HARDWARE:
-
-                Name = AcpiDmIvrsSubnames[0];
-                break;
-
-            case ACPI_IVRS_TYPE_MEMORY1:
-            case ACPI_IVRS_TYPE_MEMORY2:
-            case ACPI_IVRS_TYPE_MEMORY3:
-
-                Name = AcpiDmIvrsSubnames[1];
-                break;
-
-            default:
-
-                Name = AcpiDmIvrsSubnames[2];
-                break;
-            }
-
-            AcpiOsPrintf (UINT8_FORMAT, *Target, Name);
-            break;
-
-        case ACPI_DMT_LPIT:
-
-            /* LPIT subtable types */
-
-            Temp32 = ACPI_GET32 (Target);
-            if (Temp32 > ACPI_LPIT_TYPE_RESERVED)
-            {
-                Temp32 = ACPI_LPIT_TYPE_RESERVED;
-            }
-
-            AcpiOsPrintf (UINT32_FORMAT, ACPI_GET32 (Target),
-                AcpiDmLpitSubnames[Temp32]);
-            break;
-
-        case ACPI_DMT_EXIT:
-
-            return (AE_OK);
-
-        default:
-
-            ACPI_ERROR ((AE_INFO,
-                "**** Invalid table opcode [0x%X] ****\n", Info->Opcode));
-            return (AE_SUPPORT);
-        }
-    }
-
-    if (TableOffset && !SubtableLength)
-    {
-        /*
-         * If this table is not the main table, the subtable must have a
-         * valid length
-         */
-        AcpiOsPrintf ("Invalid zero length subtable\n");
-        return (AE_BAD_DATA);
-    }
-
-    return (AE_OK);
-}

+ 0 - 557
sys/src/libacpi/acpica/common/dmtables.c

@@ -1,557 +0,0 @@
-/******************************************************************************
- *
- * Module Name: dmtables - disassembler ACPI table support
- *
- *****************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "aslcompiler.h"
-#include "acapps.h"
-#include "acdispat.h"
-#include "acnamesp.h"
-#include "actables.h"
-#include "acparser.h"
-
-#include <stdio.h>
-#include <time.h>
-
-#define _COMPONENT          ACPI_TOOLS
-        ACPI_MODULE_NAME    ("dmtables")
-
-
-/* Local prototypes */
-
-static void
-AdCreateTableHeader (
-    char                    *Filename,
-    ACPI_TABLE_HEADER       *Table);
-
-static ACPI_STATUS
-AdStoreTable (
-    ACPI_TABLE_HEADER       *Table,
-    UINT32                  *TableIndex);
-
-
-extern ACPI_TABLE_DESC      LocalTables[1];
-extern ACPI_PARSE_OBJECT    *AcpiGbl_ParseOpRoot;
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdDisassemblerHeader
- *
- * PARAMETERS:  Filename            - Input file for the table
- *              TableType           - Either AML or DataTable
- *
- * RETURN:      None
- *
- * DESCRIPTION: Create the disassembler header, including ACPICA signon with
- *              current time and date.
- *
- *****************************************************************************/
-
-void
-AdDisassemblerHeader (
-    char                    *Filename,
-    UINT8                   TableType)
-{
-    time_t                  Timer;
-
-
-    time (&Timer);
-
-    /* Header and input table info */
-
-    AcpiOsPrintf ("/*\n");
-    AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * "));
-
-    if (TableType == ACPI_IS_AML_TABLE)
-    {
-        if (AcpiGbl_CstyleDisassembly)
-        {
-            AcpiOsPrintf (
-                " * Disassembling to symbolic ASL+ operators\n"
-                " *\n");
-        }
-        else
-        {
-            AcpiOsPrintf (
-                " * Disassembling to non-symbolic legacy ASL operators\n"
-                " *\n");
-        }
-    }
-
-    AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer));
-    AcpiOsPrintf (" *\n");
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdCreateTableHeader
- *
- * PARAMETERS:  Filename            - Input file for the table
- *              Table               - Pointer to the raw table
- *
- * RETURN:      None
- *
- * DESCRIPTION: Create the ASL table header, including ACPICA signon with
- *              current time and date.
- *
- *****************************************************************************/
-
-static void
-AdCreateTableHeader (
-    char                    *Filename,
-    ACPI_TABLE_HEADER       *Table)
-{
-    UINT8                   Checksum;
-
-
-    /* Reset globals for External statements */
-
-    AcpiGbl_NumExternalMethods = 0;
-    AcpiGbl_ResolvedExternalMethods = 0;
-
-    /*
-     * Print file header and dump original table header
-     */
-    AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE);
-
-    AcpiOsPrintf (" * Original Table Header:\n");
-    AcpiOsPrintf (" *     Signature        \"%4.4s\"\n",    Table->Signature);
-    AcpiOsPrintf (" *     Length           0x%8.8X (%u)\n", Table->Length, Table->Length);
-
-    /* Print and validate the revision */
-
-    AcpiOsPrintf (" *     Revision         0x%2.2X",      Table->Revision);
-
-    switch (Table->Revision)
-    {
-    case 0:
-
-        AcpiOsPrintf (" **** Invalid Revision");
-        break;
-
-    case 1:
-
-        /* Revision of DSDT controls the ACPI integer width */
-
-        if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT))
-        {
-            AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support");
-        }
-        break;
-
-    default:
-
-        break;
-    }
-
-    /* Print and validate the table checksum */
-
-    AcpiOsPrintf ("\n *     Checksum         0x%2.2X",        Table->Checksum);
-
-    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
-    if (Checksum)
-    {
-        AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
-            (UINT8) (Table->Checksum - Checksum));
-    }
-
-    AcpiOsPrintf ("\n");
-    AcpiOsPrintf (" *     OEM ID           \"%.6s\"\n",     Table->OemId);
-    AcpiOsPrintf (" *     OEM Table ID     \"%.8s\"\n",     Table->OemTableId);
-    AcpiOsPrintf (" *     OEM Revision     0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
-    AcpiOsPrintf (" *     Compiler ID      \"%.4s\"\n",     Table->AslCompilerId);
-    AcpiOsPrintf (" *     Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
-    AcpiOsPrintf (" */\n");
-
-    /*
-     * Open the ASL definition block.
-     *
-     * Note: the AMLFilename string is left zero-length in order to just let
-     * the compiler create it when the disassembled file is compiled. This
-     * makes it easier to rename the disassembled ASL file if needed.
-     */
-    AcpiOsPrintf (
-        "DefinitionBlock (\"\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
-        Table->Signature, Table->Revision,
-        Table->OemId, Table->OemTableId, Table->OemRevision);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdDisplayTables
- *
- * PARAMETERS:  Filename            - Input file for the table
- *              Table               - Pointer to the raw table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AdDisplayTables (
-    char                    *Filename,
-    ACPI_TABLE_HEADER       *Table)
-{
-
-
-    if (!AcpiGbl_ParseOpRoot)
-    {
-        return (AE_NOT_EXIST);
-    }
-
-    if (!AcpiGbl_DmOpt_Listing)
-    {
-        AdCreateTableHeader (Filename, Table);
-    }
-
-    AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX);
-    MpEmitMappingInfo ();
-
-    if (AcpiGbl_DmOpt_Listing)
-    {
-        AcpiOsPrintf ("\n\nTable Header:\n");
-        AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER),
-            DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
-
-        AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length);
-        AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)),
-            Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
-    }
-
-    return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AdStoreTable
- *
- * PARAMETERS:  Table               - Table header
- *              TableIndex          - Where the table index is returned
- *
- * RETURN:      Status and table index.
- *
- * DESCRIPTION: Add an ACPI table to the global table list
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AdStoreTable (
-    ACPI_TABLE_HEADER       *Table,
-    UINT32                  *TableIndex)
-{
-    ACPI_STATUS             Status;
-    ACPI_TABLE_DESC         *TableDesc;
-
-
-    Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Initialize added table */
-
-    AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table),
-        ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table);
-    Status = AcpiTbValidateTable (TableDesc);
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdGetLocalTables
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Get the ACPI tables from either memory or a file
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AdGetLocalTables (
-    void)
-{
-    ACPI_STATUS             Status;
-    ACPI_TABLE_HEADER       TableHeader;
-    ACPI_TABLE_HEADER       *NewTable;
-    UINT32                  TableIndex;
-
-
-    /* Get the DSDT via table override */
-
-    ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT);
-    AcpiOsTableOverride (&TableHeader, &NewTable);
-    if (!NewTable)
-    {
-        fprintf (stderr, "Could not obtain DSDT\n");
-        return (AE_NO_ACPI_TABLES);
-    }
-
-    AdWriteTable (NewTable, NewTable->Length,
-        ACPI_SIG_DSDT, NewTable->OemTableId);
-
-    /* Store DSDT in the Table Manager */
-
-    Status = AdStoreTable (NewTable, &TableIndex);
-    if (ACPI_FAILURE (Status))
-    {
-        fprintf (stderr, "Could not store DSDT\n");
-        return (AE_NO_ACPI_TABLES);
-    }
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AdParseTable
- *
- * PARAMETERS:  Table               - Pointer to the raw table
- *              OwnerId             - Returned OwnerId of the table
- *              LoadTable           - If add table to the global table list
- *              External            - If this is an external table
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Parse an ACPI AML table
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AdParseTable (
-    ACPI_TABLE_HEADER       *Table,
-    ACPI_OWNER_ID           *OwnerId,
-    BOOLEAN                 LoadTable,
-    BOOLEAN                 External)
-{
-    ACPI_STATUS             Status = AE_OK;
-    ACPI_WALK_STATE         *WalkState;
-    UINT8                   *AmlStart;
-    UINT32                  AmlLength;
-    UINT32                  TableIndex;
-
-
-    if (!Table)
-    {
-        return (AE_NOT_EXIST);
-    }
-
-    /* Pass 1:  Parse everything except control method bodies */
-
-    fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
-
-    AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
-    AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
-
-    /* Create the root object */
-
-    AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart);
-    if (!AcpiGbl_ParseOpRoot)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    /* Create and initialize a new walk state */
-
-    WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL);
-    if (!WalkState)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot,
-        NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
-    WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
-
-    Status = AcpiPsParseAml (WalkState);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* If LoadTable is FALSE, we are parsing the last loaded table */
-
-    TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1;
-
-    /* Pass 2 */
-
-    if (LoadTable)
-    {
-        Status = AdStoreTable (Table, &TableIndex);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-        Status = AcpiTbAllocateOwnerId (TableIndex);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-        if (OwnerId)
-        {
-            Status = AcpiTbGetOwnerId (TableIndex, OwnerId);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-        }
-    }
-
-    fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature);
-
-    Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* No need to parse control methods of external table */
-
-    if (External)
-    {
-        return (AE_OK);
-    }
-
-    /*
-     * Pass 3: Parse control methods and link their parse trees
-     * into the main parse tree
-     */
-    fprintf (stderr,
-        "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n");
-
-    Status = AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot);
-    fprintf (stderr, "\n");
-
-    /* Process Resource Templates */
-
-    AcpiDmFindResources (AcpiGbl_ParseOpRoot);
-
-    fprintf (stderr, "Parsing completed\n");
-    return (AE_OK);
-}

+ 0 - 252
sys/src/libacpi/acpica/components/debugger/dbfileio.c

@@ -1,252 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: dbfileio - Debugger file I/O commands. These can't usually
- *              be used when running the debugger in Ring 0 (Kernel mode)
- *
- ******************************************************************************/
-
-/******************************************************************************
- *
- * 1. Copyright Notice
- *
- * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
- * All rights reserved.
- *
- * 2. License
- *
- * 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
- * you this software, covering your right to use that party's intellectual
- * property rights.
- *
- * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
- * copy of the source code appearing in this file ("Covered Code") an
- * irrevocable, perpetual, worldwide license under Intel's copyrights in the
- * base code distributed originally by Intel ("Original Intel Code") to copy,
- * make derivatives, distribute, use and display any portion of the Covered
- * Code in any form, with the right to sublicense such rights; and
- *
- * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
- * license (with the right to sublicense), under only those claims of Intel
- * patents that are infringed by the Original Intel Code, to make, use, sell,
- * offer to sell, and import the Covered Code and derivative works thereof
- * solely to the minimum extent necessary to exercise the above copyright
- * license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
- * is granted directly or by implication, estoppel or otherwise;
- *
- * The above copyright and patent license is granted only if the following
- * conditions are met:
- *
- * 3. Conditions
- *
- * 3.1. Redistribution of Source with Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification with rights to further distribute source must include
- * the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
- * Licensee must cause all Covered Code to which Licensee contributes to
- * contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
- * must include a prominent statement that the modification is derived,
- * directly or indirectly, from Original Intel Code.
- *
- * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
- * Redistribution of source code of any substantial portion of the Covered
- * Code or modification without rights to further distribute source must
- * include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
- * addition, Licensee may not authorize further sublicense of source of any
- * portion of the Covered Code, and must include terms to the effect that the
- * license from Licensee to its licensee is limited to the intellectual
- * property embodied in the software Licensee provides to its licensee, and
- * not to intellectual property embodied in modifications its licensee may
- * make.
- *
- * 3.3. Redistribution of Executable. Redistribution in executable form of any
- * substantial portion of the Covered Code or modification must reproduce the
- * above Copyright Notice, and the following Disclaimer and Export Compliance
- * provision in the documentation and/or other materials provided with the
- * distribution.
- *
- * 3.4. Intel retains all right, title, and interest in and to the Original
- * Intel Code.
- *
- * 3.5. Neither the name Intel nor any other trademark owned or controlled by
- * Intel shall be used in advertising or otherwise to promote the sale, use or
- * other dealings in products derived from or relating to the Covered Code
- * without prior written authorization from Intel.
- *
- * 4. Disclaimer and Export Compliance
- *
- * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
- * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
- * PARTICULAR PURPOSE.
- *
- * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
- * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
- * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
- * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
- * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
- * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
- * LIMITED REMEDY.
- *
- * 4.3. Licensee shall not export, either directly or indirectly, any of this
- * software or system incorporating such software without first obtaining any
- * required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
- * event Licensee exports any such software from the United States or
- * re-exports any such software from a foreign destination, Licensee shall
- * ensure that the distribution and export/re-export of the software is in
- * compliance with all laws, regulations, orders, or other restrictions of the
- * U.S. Export Administration Regulations. Licensee agrees that neither it nor
- * any of its subsidiaries will export/re-export any technical data, process,
- * software, or service, directly or indirectly, to any country for which the
- * United States government or any agency thereof requires an export license,
- * other governmental approval, or letter of assurance, without first obtaining
- * such license, approval or letter.
- *
- *****************************************************************************/
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acdebug.h"
-#include "actables.h"
-#include <stdio.h>
-#ifdef ACPI_APPLICATION
-#include "acapps.h"
-#endif
-
-#define _COMPONENT          ACPI_CA_DEBUGGER
-        ACPI_MODULE_NAME    ("dbfileio")
-
-
-#ifdef ACPI_DEBUGGER
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDbCloseDebugFile
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: If open, close the current debug output file
- *
- ******************************************************************************/
-
-void
-AcpiDbCloseDebugFile (
-    void)
-{
-
-#ifdef ACPI_APPLICATION
-
-    if (AcpiGbl_DebugFile)
-    {
-       fclose (AcpiGbl_DebugFile);
-       AcpiGbl_DebugFile = NULL;
-       AcpiGbl_DbOutputToFile = FALSE;
-       AcpiOsPrintf ("Debug output file %s closed\n",
-            AcpiGbl_DbDebugFilename);
-    }
-#endif
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDbOpenDebugFile
- *
- * PARAMETERS:  Name                - Filename to open
- *
- * RETURN:      None
- *
- * DESCRIPTION: Open a file where debug output will be directed.
- *
- ******************************************************************************/
-
-void
-AcpiDbOpenDebugFile (
-    char                    *Name)
-{
-
-#ifdef ACPI_APPLICATION
-
-    AcpiDbCloseDebugFile ();
-    AcpiGbl_DebugFile = fopen (Name, "w+");
-    if (!AcpiGbl_DebugFile)
-    {
-        AcpiOsPrintf ("Could not open debug file %s\n", Name);
-        return;
-    }
-
-    AcpiOsPrintf ("Debug output file %s opened\n", Name);
-    strncpy (AcpiGbl_DbDebugFilename, Name,
-        sizeof (AcpiGbl_DbDebugFilename));
-    AcpiGbl_DbOutputToFile = TRUE;
-
-#endif
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDbLoadTables
- *
- * PARAMETERS:  ListHead        - List of ACPI tables to load
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Load ACPI tables from a previously constructed table list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDbLoadTables (
-    ACPI_NEW_TABLE_DESC     *ListHead)
-{
-    ACPI_STATUS             Status;
-    ACPI_NEW_TABLE_DESC     *TableListHead;
-    ACPI_TABLE_HEADER       *Table;
-
-
-    /* Load all ACPI tables in the list */
-
-    TableListHead = ListHead;
-    while (TableListHead)
-    {
-        Table = TableListHead->Table;
-
-        Status = AcpiLoadTable (Table);
-        if (ACPI_FAILURE (Status))
-        {
-            if (Status == AE_ALREADY_EXISTS)
-            {
-                AcpiOsPrintf ("Table %4.4s is already installed\n",
-                    Table->Signature);
-            }
-            else
-            {
-                AcpiOsPrintf ("Could not install table, %s\n",
-                    AcpiFormatException (Status));
-            }
-
-            return (Status);
-        }
-
-        fprintf (stderr,
-            "Acpi table [%4.4s] successfully installed and loaded\n",
-            Table->Signature);
-
-        TableListHead = TableListHead->Next;
-    }
-
-    return (AE_OK);
-}

+ 15 - 7
sys/src/libacpi/build.json

@@ -1,6 +1,6 @@
 {
 	"Libacpi": {
-		"Projects": [
+		"#Projects": [
 		    "acpica/libacpi.json"
 		],
 		"Include": [
@@ -9,12 +9,20 @@
 		"Install": "/$ARCH/lib/",
 		"Library": "libacpi.a",
 		"SourceFiles": [
-			"acfileio.c",
-			"dbfileio.c",
-			"hack.c",
-			"harvey.c",
-			"olsneracpi.c"
+			"*.c",
+		"/sys/src/libacpi/acpica/components/events/*.c",
+		"/sys/src/libacpi/acpica/components/parser/*.c",
+		"/sys/src/libacpi/acpica/components/utilities/*.c",
+		"/sys/src/libacpi/acpica/components/executer/*.c",
+		"/sys/src/libacpi/acpica/components/namespace/*.c",
+		"/sys/src/libacpi/acpica/components/hardware/*.c",
+		"/sys/src/libacpi/acpica/components/tables/*.c",
+		"/sys/src/libacpi/acpica/components/disassembler/*.c",
+		"/sys/src/libacpi/acpica/components/debugger/*.c",
+		"/sys/src/libacpi/acpica/components/resources/*.c",
+		"/sys/src/libacpi/acpica/components/dispatcher/*.c",
+		"/sys/src/libacpi/acpica/common/*.c"
 		]
 	}
 }
-	
+	

+ 0 - 1175
sys/src/libacpi/old.c

@@ -1,1175 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-#include	"u.h"
-#include	"../port/lib.h"
-#include	"mem.h"
-#include	"dat.h"
-#include	"fns.h"
-#include	"io.h"
-#include	"../port/error.h"
-#include "apic.h"
-#include "mp.h"
-#include <acpi/acpica/acpi.h>
-
-enum
-{
-
-	Sdthdrsz	= 36,	/* size of SDT header */
-	Qdir = 0,
-	Qctl,
-	Qtbl,
-	Qio,
-};
-
-#if 0
-static Cmdtab ctls[] =
-{
-	{CMregion,	"region",	6},
-	{CMgpe,		"gpe",		3},
-};
-#endif
-
-
-/* 
- * This is the array of eyesores.
- * An Eyesore is an Interrupt Source Over Ride, which maps from
- * what they want to what it needs to be. You are not expected
- * to understand this.
- */
-static ACPI_MADT_INTERRUPT_OVERRIDE *eyesore;
-static int numeyesore;
-
-static Dirtab acpidir[]={
-	".",		{Qdir, 0, QTDIR},	0,	DMDIR|0555,
-	"acpictl",	{Qctl},			0,	0666,
-	"acpitbl",	{Qtbl},			0,	0444,
-	"acpiregio",	{Qio},			0,	0666,
-};
-
-#if 0
-static char* regnames[] = {
-	"mem", "io", "pcicfg", "embed",
-	"smb", "cmos", "pcibar",
-};
-#endif
-
-static void *rsd;
-/*
- * we use mp->machno (or index in Mach array) as the identifier,
- * but ACPI relies on the apic identifier.
- */
-int
-corecolor(int core)
-{
-	Mach *m;
-	static int colors[32];
-
-	if(core < 0 || core >= MACHMAX)
-		return -1;
-	m = sys->machptr[core];
-	if(m == nil)
-		return -1;
-
-	if(core >= 0 && core < nelem(colors) && colors[core] != 0)
-		return colors[core] - 1;
-
-	return -1;
-}
-
-
-int
-pickcore(int mycolor, int index)
-{
-	return 0;
-}
-static void*
-rsdscan(uint8_t* addr, int len, char* signature)
-{
-	int sl;
-	uint8_t *e, *p;
-
-	e = addr+len;
-	sl = strlen(signature);
-	for(p = addr; p+sl < e; p += 16){
-		if(memcmp(p, signature, sl))
-			continue;
-		return p;
-	}
-
-	return nil;
-}
-
-
-static void*
-rsdsearch(char* signature)
-{
-	uintptr_t p;
-	uint8_t *bda;
-	void *rsd;
-
-	/*
-	 * Search for the data structure signature:
-	 * 1) in the first KB of the EBDA;
-	 * 2) in the BIOS ROM between 0xE0000 and 0xFFFFF.
-	 */
-	if(strncmp((char*)KADDR(0xFFFD9), "EISA", 4) == 0){
-		bda = BIOSSEG(0x40);
-		if((p = (bda[0x0F]<<8)|bda[0x0E])){
-			if(rsd = rsdscan(KADDR(p), 1024, signature))
-				return rsd;
-		}
-	}
-	return rsdscan(BIOSSEG(0xE000), 0x20000, signature);
-}
-
-
-static void
-acpirsdptr(void)
-{
-	rsd = rsdsearch("RSD PTR ");
-	if (rsd == nil) {
-		print("NO RSD PTR found\n");
-		return;
-	}
-	print("Found RST PTR ta %p\n", rsd);
-
-#if 0
-	assert(sizeof(Sdthdr) == 36);
-
-	DBG("acpi: RSD PTR@ %#p, physaddr %#ux length %u %#llux rev %d\n",
-		rsd, l32get(rsd->raddr), l32get(rsd->length),
-		l64get(rsd->xaddr), rsd->revision);
-
-	if(rsd->revision >= 2){
-		if(sdtchecksum(rsd, 36) == nil){
-			DBG("acpi: RSD: bad checksum\n");
-			return;
-		}
-		sdtpa = l64get(rsd->xaddr);
-		asize = 8;
-	}
-	else{
-		if(sdtchecksum(rsd, 20) == nil){
-			DBG("acpi: RSD: bad checksum\n");
-			return;
-		}
-		sdtpa = l32get(rsd->raddr);
-		asize = 4;
-	}
-
-	/*
-	 * process the RSDT or XSDT table.
-	 */
-	xsdt = malloc(sizeof(Xsdt));
-	if(xsdt == nil){
-		DBG("acpi: malloc failed\n");
-		return;
-	}
-	if((xsdt->p = sdtmap(sdtpa, &xsdt->len, 1)) == nil){
-		DBG("acpi: sdtmap failed\n");
-		return;
-	}
-	if((xsdt->p[0] != 'R' && xsdt->p[0] != 'X') || memcmp(xsdt->p+1, "SDT", 3) != 0){
-		DBG("acpi: xsdt sig: %c%c%c%c\n",
-			xsdt->p[0], xsdt->p[1], xsdt->p[2], xsdt->p[3]);
-		free(xsdt);
-		xsdt = nil;
-		vunmap(xsdt, xsdt->len);
-		return;
-	}
-	xsdt->p += sizeof(Sdthdr);
-	xsdt->len -= sizeof(Sdthdr);
-	xsdt->asize = asize;
-	DBG("acpi: XSDT %#p\n", xsdt);
-	acpixsdtload(nil);
-	/* xsdt is kept and not unmapped */
-#endif
-}
-
-static int
-acpigen(Chan *c, char* d, Dirtab *tab, int ntab, int i, Dir *dp)
-{
-	Qid qid;
-
-	if(i == DEVDOTDOT){
-		mkqid(&qid, Qdir, 0, QTDIR);
-		devdir(c, qid, ".", 0, eve, 0555, dp);
-		return 1;
-	}
-	i++; /* skip first element for . itself */
-	if(tab==0 || i>=ntab)
-		return -1;
-	tab += i;
-	qid = tab->qid;
-	qid.path &= ~Qdir;
-	qid.vers = 0;
-	devdir(c, qid, tab->name, tab->length, eve, tab->perm, dp);
-	return 1;
-}
-
-ACPI_STATUS
-AcpiOsInitialize(void)
-{
-	print("%s\n", __func__);
-	acpirsdptr();
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsTerminate (
-	void)
-{
-	print("%s\n", __func__);
-	return AE_OK;
-}
-
-/* run AML with one integer arg. */
-static int
-run_aml_arg(char *name, int val)
-{
-    ACPI_OBJECT arg1;
-    ACPI_OBJECT_LIST args;
-    ACPI_STATUS as;
-
-    arg1.Type = ACPI_TYPE_INTEGER;
-    arg1.Integer.Value = 1;
-    args.Count = 1;
-    args.Pointer = &arg1;
-
-    /* This does not work. Just leaving it here in case someone
-     * else thinks it will.
-	ACPI_STATUS as;
-	ACPI_OBJECT arg[] = {
-		{
-			.Type = ACPI_TYPE_INTEGER,
-			.Integer.Value = val
-		}
-	};
-	ACPI_OBJECT_LIST args = {
-		.Count = 1,
-		.Pointer = arg
-	};
-    */
-	as = AcpiEvaluateObject(ACPI_ROOT_OBJECT, name, &args, NULL);
-	print("run_aml_arg(%s, %d) returns %d\n", name, val, as);
-	return ACPI_SUCCESS(as);
-}
-
-static int
-set_machine_mode(void)
-{
-	/* we always enable the APIC. */
-	return run_aml_arg("_PIC", 1);
-}
-
-void pi(int indent)
-{
-	int i;
-	for(i = 0; i < indent; i++)
-		print(" ");
-}
-
-/* walk the whatever. Limited, right now. */
-static void
-objwalk(ACPI_OBJECT *p)
-{
-	static int indent;
-	int cnt;
-	ACPI_OBJECT *e;
-	pi(indent);
-	switch(p->Type) {
-	case 4: // ACPI_DESC_TYPE_STATE_PACKAGE:
-		print("Package:\n");
-		indent += 2;
-		e = p->Package.Elements;
-		for(cnt = 0; cnt < p->Package.Count; cnt++, e++){
-			objwalk(e);
-		}
-
-		indent -= 2;
-		print("\n");
-		break;
-	case 1:
-		print("Integer:0x%llx", p->Integer.Value);
-		break;
-	default:
-		print("Can't handle type %d\n", p->Type);
-		break;
-	}
-
-}
-
-static ACPI_STATUS
-resource(ACPI_RESOURCE *r, void *Context)
-{
-	ACPI_RESOURCE_IRQ *i = &r->Data.Irq;
-	print("\tACPI_RESOURCE_TYPE_%d: Length %d\n", r->Type, r->Length);
-	if (r->Type != ACPI_RESOURCE_TYPE_IRQ)
-		return 0;
-	print("\t\tIRQ Triggering %d Polarity %d Sharable %d InterruptCount %d: ", 
-	      i->Triggering, i->Polarity, i->Sharable, i->InterruptCount);
-	for(int j = 0; j < i->InterruptCount; j++)
-		print("%d,", i->Interrupts[j]);
-	print("\n");
-	/* assumptions: we assume apic 0 for now. This will need to be fixed.
-	 * We also just take the first interrupt. 
-	 */
-	uint32_t low = Im;
-	switch (i->Polarity){
-	case ACPI_ACTIVE_HIGH:
-		low |= IPhigh;
-		break;
-	case ACPI_ACTIVE_LOW:
-		low |= IPlow;
-		break;
-	case ACPI_ACTIVE_BOTH:
-		low |= IPlow | IPhigh;
-		break;
-	default:
-		print("BOTCH! i->Polarity is 0x%x and I don't do that\n", i->Polarity);
-		break;
-	}
-
-	switch (i->Triggering) {
-	case ACPI_LEVEL_SENSITIVE:
-		low |= TMlevel;
-		break;
-	case ACPI_EDGE_SENSITIVE:
-		low |= TMedge;
-		break;
-	default:
-		print("BOTCH! i->Triggering is 0x%x and I don't do that\n", i->Triggering);
-		break;
-	}
-	print("ACPICODE: ioapicintrinit(0xff, 0x%x, 0x%x, 0x%x, 0x%x\n", 1, i->Interrupts[0], i->Interrupts[0]<<2, low);
-	return 0;
-}
-ACPI_STATUS
-device(ACPI_HANDLE                     Object,
-    UINT32                          NestingLevel,
-    void                            *Context,
-    void                            **ReturnValue)
-
-{
-	ACPI_STATUS as;
-	ACPI_DEVICE_INFO *info;
-	as = AcpiGetObjectInfo(Object, &info);
-	print("as is %d\n", as);
-	if (!ACPI_SUCCESS(as))
-		return 0;
-	ACPI_BUFFER out;
-	out.Length = ACPI_ALLOCATE_BUFFER;
-	out.Pointer = nil;
-	char n[5];
-	memmove(n, &info->Name, sizeof(info->Name));
-	n[4] = 0;
-	print("%s\n", n);
-	as = AcpiGetIrqRoutingTable(Object, &out);
-	print("get the PRT: %d\n", as);
-	print("Length is %u ptr is %p\n", out.Length, out.Pointer);
-	if (ACPI_SUCCESS(as)) {
-		void *p = (void *)out.Pointer;
-		while(((ACPI_PCI_ROUTING_TABLE*)p)->Length > 0) {
-			ACPI_PCI_ROUTING_TABLE *t = p;
-			print("%s: ", t->Source);
-			print("Pin 0x%x, Address 0x%llx, SourceIndex 0x%x\n", 
-			      t->Address, t->SourceIndex);
-			p += t->Length;
-		}
-	}
-	as = AcpiWalkResources(Object, "_CRS", resource, nil);
-	print("Walk resources: as is %d\n", as);
-#if 0
-	out.Length = ACPI_ALLOCATE_BUFFER;
-	out.Pointer = nil;
-	as = AcpiGetPossibleResources(Object, &out);
-	print("get the possible resources: %d\n", as);
-	if (ACPI_SUCCESS(as)) {
-		void *p = (void *)out.Pointer;
-		hexdump(out.Pointer, out.Length);
-		while(((ACPI_RESOURCE*)p)->Type != ACPI_RESOURCE_TYPE_END_TAG) {
-			ACPI_RESOURCE *r = p;
-			ACPI_RESOURCE_IRQ *i = p + sizeof(r->Type);
-			print("\tACPI_RESOURCE_TYPE_%d: Length %d\n", r->Type, r->Length);
-			p += r->Length;
-			if (r->Type != ACPI_RESOURCE_TYPE_IRQ)
-				continue;
-			print("\t\tIRQ Triggering %d Polarity %d Sharable %d InterruptCount %d: ", 
-			      i->Triggering, i->Polarity, i->Sharable, i->InterruptCount);
-			for(int j = 0; j < i->InterruptCount; j++)
-				print("%d,", i->Interrupts[j]);
-			print("\n");
-
-
-		}
-		print("Length is %u ptr is %p\n", out.Length, out.Pointer);
-
-	}
-#endif
-	print("hi\n");
-
-	return 0;
-}
-
-int
-acpiinit(void)
-{
-	ACPI_STATUS as;
-	ACPI_TABLE_HEADER *h;
-	ACPI_BUFFER out;
-	int status;
-	int apiccnt = 1;
-	out.Length = ACPI_ALLOCATE_BUFFER;
-	out.Pointer = nil;
-	status = AcpiInitializeSubsystem();
-        if (ACPI_FAILURE(status))
-		panic("can't start acpi");
-
-
-        status = AcpiInitializeTables(NULL, 16, FALSE);
-        if (ACPI_FAILURE(status))
-		panic("can't set up acpi tables");
-
-        status = AcpiLoadTables();
-        if (ACPI_FAILURE(status))
-		panic("Can't load ACPI tables");
-
-        status = AcpiEnableSubsystem(0);
-        if (ACPI_FAILURE(status))
-		panic("Can't enable ACPI subsystem");
-
-        status = AcpiInitializeObjects(0);
-        if (ACPI_FAILURE(status))
-		panic("Can't Initialize ACPI objects");
-
-	int sublen;
-	uint8_t *p;
-	extern uint8_t *apicbase;
-	ACPI_TABLE_MADT *m;
-	status = AcpiGetTable(ACPI_SIG_MADT, apiccnt, &h);
-	if (ACPI_FAILURE(status))
-		panic("Can't find a MADT");
-	m = (ACPI_TABLE_MADT *)h;
-	print("APIC %d: %p 0x%x\n", apiccnt, (void *)(uint64_t)m->Address, m->Flags);
-	if(apicbase == nil){
-		if((apicbase = vmap((uintptr_t)m->Address, 1024)) == nil){
-			panic("%s: can't map apicbase\n", __func__);
-		}
-		print("%s: apicbase %#p -> %#p\n", __func__, (void *)(uint64_t)m->Address, apicbase);
-	}
-	if (! set_machine_mode()){
-		print("Set machine mode failed\n");
-		return 0;
-	}
-
-	p = (void*)&m[1];
-	sublen = m->Header.Length;
-	/* we only process the ones we're certain we need to. */
-	while (sublen > 0) {
-		switch(p[0]){
-		case ACPI_MADT_TYPE_LOCAL_APIC:
-		{
-			ACPI_MADT_LOCAL_APIC *l = (void *)p;
-			if (!l->LapicFlags)
-				break;
-			apicinit(l->Id, m->Address, apiccnt == 1);
-print("ACPICODE: apicinit(%d, %p, %d\n", l->Id, m->Address, apiccnt == 1);
-			apiccnt++;
-		}
-			break;
-		case ACPI_MADT_TYPE_IO_APIC:
-		{
-			ACPI_MADT_IO_APIC *io = (void *)p;
-			print("IOapic %d @ %p\n", io->Id, io->Address);
-			ioapicinit(io->Id, io->Address);
-print("ACPICODE: ioapicinit(%d, %p);\n", io->Id, (void*)(uint64_t)io->Address);
-		}
-			break;
-		case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
-		{
-			ACPI_MADT_INTERRUPT_OVERRIDE *e = (void *)p;
-			print("What an eyesore. Bus %d, SourceIrq %d, GlobalIrq %d, InitFlags 0x%x\n",
-			      e->Bus, e->SourceIrq, e->GlobalIrq, e->IntiFlags);
-			eyesore = realloc(eyesore, numeyesore+1);
-			if (! eyesore)
-				panic("Ran out of eyesores");
-			eyesore[numeyesore] = *e;
-			numeyesore++;
-		}
-		break;
-		case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
-		{
-			ACPI_MADT_LOCAL_APIC_NMI *nmi = (void *)p;
-			apicnmi(nmi->ProcessorId, nmi->Lint, nmi->IntiFlags);
-		}
-			break;
-		default:
-			print("%s: can't handle subtable type %d\n", __func__, p[0]);
-			break;
-		}
-		sublen -= p[1];
-		p += p[1];
-	}
-
-	/* Get the _PRT */
-	int i;
-	for(i = 0; i < 255; i++) {
-		static char path[255];
-		snprint(path, sizeof(path), "\\_SB.PCI%d._PRT", i);
-		as = AcpiEvaluateObject(ACPI_ROOT_OBJECT, path, NULL, &out);
-		if (!ACPI_SUCCESS(as))
-			continue;
-		print("------>GOT the PRT: %d\n", i);
-		print("Length is %u ptr is %p\n", out.Length, out.Pointer);
-		hexdump(out.Pointer, out.Length);
-		objwalk(out.Pointer);
-
-		as = AcpiGetDevices (nil, device, nil, nil);
-		print("acpigetdevices %d\n", as);
-	}
-
-/* per device code. Not useful yet.
-
-	as = AcpiGetIrqRoutingTable(some device, &out);
-	print("get the PRT: %d\n", as);
-	print("Length is %u ptr is %p\n", out.Length, out.Pointer);
-	hexdump(out.Pointer, out.Length);
-*/
-	/* PCI devices: Walk all devices. For those with interrupts, enable them. */
-	Pcidev*pci = nil;
-	for(pci = pcimatch(pci, 0, 0); pci; pci = pcimatch(pci, 0, 0)){
-		if (!pci->intl || pci->intl == 0xff)
-			continue;
-		print("Interrupt %d: \n", pci->intl);
-		pcishowdev(pci);
-		int bus = BUSBNO(pci->tbdf);
-		int apicno = 1; /* for now */
-		int low = 0x1a000; /* is PCI always this? */
-		print("ACPICODE: ioapicintrinit(%d, %d, %d, 0x%x, 0x%x);\n", bus, apicno, pci->intl, pci->tbdf, low);
-
-	}
-	print("ACPICODE: ioapicintrinit(0xff, DONE\n");
-	return 0;
-}
-
-static Chan*
-acpiattach(char *spec)
-{
-	return nil;
-//	return devattach(L'α', spec);
-}
-
-static Walkqid*
-acpiwalk(Chan *c, Chan *nc, char **name, int nname)
-{
-	return devwalk(c, nc, name, nname, acpidir, nelem(acpidir), acpigen);
-}
-
-static int32_t
-acpistat(Chan *c, uint8_t *dp, int32_t n)
-{
-	return devstat(c, dp, n, acpidir, nelem(acpidir), acpigen);
-}
-
-static Chan*
-acpiopen(Chan *c, int omode)
-{
-	return devopen(c, omode, acpidir, nelem(acpidir), acpigen);
-}
-
-static void
-acpiclose(Chan *c)
-{
-}
-
-#if 0
-static char*ttext;
-static int tlen;
-#endif
-
-static int32_t
-acpiread(Chan *c, void *a, int32_t n, int64_t off)
-{
-	uint64_t q;
-
-	q = c->qid.path;
-	switch(q){
-	case Qdir:
-		return devdirread(c, a, n, acpidir, nelem(acpidir), acpigen);
-	case Qtbl:
-		return -1; //readstr(off, a, n, ttext);
-	case Qio:
-		return -1; //regio(reg, a, n, off, 0);
-	}
-	error(Eperm);
-	return -1;
-}
-
-static int32_t
-acpiwrite(Chan *c, void *a, int32_t n, int64_t off)
-{
-	if(c->qid.path == Qio){
-		//if(reg == nil)
-		error("region not configured");
-	}
-	if(c->qid.path != Qctl)
-		error(Eperm);
-
-	error("NP");
-#if 0
-	cb = parsecmd(a, n);
-	if(waserror()){
-		free(cb);
-		nexterror();
-	}
-	ct = lookupcmd(cb, ctls, nelem(ctls));
-	DBG("acpi ctl %s\n", cb->f[0]);
-	switch(ct->index){
-	case CMregion:
-		r = reg;
-		if(r == nil){
-			r = smalloc(sizeof(Reg));
-			r->name = nil;
-		}
-		kstrdup(&r->name, cb->f[1]);
-		r->spc = acpiregid(cb->f[2]);
-		if(r->spc < 0){
-			free(r);
-			reg = nil;
-			error("bad region type");
-		}
-		if(r->spc == Rpcicfg || r->spc == Rpcibar){
-			rno = r->base>>Rpciregshift & Rpciregmask;
-			fun = r->base>>Rpcifunshift & Rpcifunmask;
-			dev = r->base>>Rpcidevshift & Rpcidevmask;
-			bus = r->base>>Rpcibusshift & Rpcibusmask;
-			r->tbdf = MKBUS(BusPCI, bus, dev, fun);
-			r->base = rno;	/* register ~ our base addr */
-		}
-		r->base = strtoull(cb->f[3], nil, 0);
-		r->len = strtoull(cb->f[4], nil, 0);
-		r->accsz = strtoul(cb->f[5], nil, 0);
-		if(r->accsz < 1 || r->accsz > 4){
-			free(r);
-			reg = nil;
-			error("bad region access size");
-		}
-		reg = r;
-		DBG("region %s %s %llux %llux sz%d",
-			r->name, acpiregstr(r->spc), r->base, r->len, r->accsz);
-		break;
-	case CMgpe:
-		i = strtoul(cb->f[1], nil, 0);
-		if(i >= ngpes)
-			error("gpe out of range");
-		kstrdup(&gpes[i].obj, cb->f[2]);
-		DBG("gpe %d %s\n", i, gpes[i].obj);
-		setgpeen(i, 1);
-		break;
-	default:
-		panic("acpi: unknown ctl");
-	}
-	poperror();
-	free(cb);
-	return n;
-#endif
-	return -1;
-}
-
-
-Dev acpidevtab = {
-	.dc = L'α',
-	.name = "acpi",
-
-	.reset = devreset,
-	.init = devinit,
-	.shutdown = devshutdown,
-	.attach = acpiattach,
-	.walk = acpiwalk,
-	.stat = acpistat,
-	.open = acpiopen,
-	.create = devcreate,
-	.close = acpiclose,
-	.read = acpiread,
-	.bread = devbread,
-	.write = acpiwrite,
-	.bwrite = devbwrite,
-	.remove = devremove,
-	.wstat = devwstat,
-};
-
-static int tbdf(ACPI_PCI_ID *p)
-{
-	return (p->Bus << 8) | (p->Device << 3) | (p->Function);
-}
-
-ACPI_STATUS
-AcpiOsReadPciConfiguration (
-    ACPI_PCI_ID             *PciId,
-    UINT32                  Reg,
-    UINT64                  *Value,
-    UINT32                  Width)
-{
-	Pcidev p;
-	p.tbdf = tbdf(PciId);
-	print("%s\n", __func__);
-	switch(Width) {
-	case 32:
-		*Value = pcicfgr32(&p, Reg);
-		break;
-	case 16:
-		*Value = pcicfgr16(&p, Reg);
-		break;
-	case 8:
-		*Value = pcicfgr8(&p, Reg);
-		break;
-	default:
-		panic("Can't read pci: bad width %d\n", Width);
-	}
-
-	return AE_OK;
-
-}
-
-ACPI_STATUS
-AcpiOsWritePciConfiguration (
-    ACPI_PCI_ID             *PciId,
-    UINT32                  Reg,
-    UINT64                  Value,
-    UINT32                  Width)
-{
-	Pcidev p;
-	p.tbdf = tbdf(PciId);
-	print("%s\n", __func__);
-	switch(Width) {
-	case 32:
-		pcicfgw32(&p, Reg, Value);
-		break;
-	case 16:
-		pcicfgw16(&p, Reg, Value);
-		break;
-	case 8:
-		pcicfgw8(&p, Reg, Value);
-		break;
-	default:
-		panic("Can't read pci: bad width %d\n", Width);
-	}
-
-	return AE_OK;
-}
-
-/*
- * Miscellaneous
- */
-BOOLEAN
-AcpiOsReadable (
-    void                    *Pointer,
-    ACPI_SIZE               Length)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-
-BOOLEAN
-AcpiOsWritable (
-    void                    *Pointer,
-    ACPI_SIZE               Length)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-
-UINT64
-AcpiOsGetTimer (
-    void)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-
-ACPI_STATUS
-AcpiOsSignal (
-    UINT32                  Function,
-    void                    *Info)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiOsPrintf (
-    const char              *Format,
-    ...)
-{
-	va_list args;
-
-	va_start(args, Format);
-	print((char *)Format, args);
-	va_end(args);
-}
-
-void
-AcpiOsVprintf (
-    const char              *Format,
-    va_list                 Args)
-{
-	/* This is a leaf function, and this function is required to implement
-	 * the va_list argument. I couldn't find any other way to do this. */
-	static char buf[1024];
-	vseprint(buf, &buf[1023], (char *)Format, Args);
-	print(buf);
-}
-
-void
-AcpiOsFree (
-    void *                  Memory)
-{
-	//print("%s\n", __func__);
-	free(Memory);
-}
-
-void *
-AcpiOsAllocate (
-    ACPI_SIZE               Size)
-{
-	//print("%s\n", __func__);
-	return malloc(Size);
-}
-
-void *
-AcpiOsMapMemory (
-    ACPI_PHYSICAL_ADDRESS   Where,
-    ACPI_SIZE               Length)
-{
-	void *v = vmap(Where, Length);
-	print("%s %p = vmap(%p,0x%x)\n", __func__, v, (void*)Where, Length);
-	print("Val @ %p is 0x%x\n", v, *(int *)v);
-	return v;
-}
-
-void
-AcpiOsUnmapMemory (
-    void                    *LogicalAddress,
-    ACPI_SIZE               Size)
-{
-	print("%s %p %d \n", __func__, LogicalAddress, Size);
-	vunmap(LogicalAddress, Size);
-}
-
-ACPI_STATUS
-AcpiOsGetPhysicalAddress (
-    void                    *LogicalAddress,
-    ACPI_PHYSICAL_ADDRESS   *PhysicalAddress)
-{
-	ACPI_PHYSICAL_ADDRESS ret = mmuphysaddr((uintptr_t)LogicalAddress);
-	print("%s %p = mmyphysaddr(%p)", __func__, (void *)ret, LogicalAddress);
-	*PhysicalAddress = ret;
-	return AE_OK;
-}
-
-/* This is the single threaded version of
- * these functions. This is now NetBSD does it. */
-ACPI_STATUS
-AcpiOsCreateSemaphore (
-    UINT32                  MaxUnits,
-    UINT32                  InitialUnits,
-    ACPI_SEMAPHORE          *OutHandle)
-{
-	//print("%s\n", __func__);
-	*OutHandle = (ACPI_SEMAPHORE) 1;
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsDeleteSemaphore (
-    ACPI_SEMAPHORE          Handle)
-{
-	//print("%s\n", __func__);
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsWaitSemaphore (
-    ACPI_SEMAPHORE          Handle,
-    UINT32                  Units,
-    UINT16                  Timeout)
-{
-	//print("%s\n", __func__);
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsSignalSemaphore (
-    ACPI_SEMAPHORE          Handle,
-    UINT32                  Units)
-{
-	//print("%s\n", __func__);
-	return AE_OK;
-}
-
-/* this is the single threaded case and as minix shows there is nothing to do. */
-ACPI_STATUS
-AcpiOsCreateLock (
-    ACPI_SPINLOCK           *OutHandle)
-{
-	//print("%s\n", __func__);
-	*OutHandle = nil;
-	return AE_OK;
-}
-
-void
-AcpiOsDeleteLock (
-    ACPI_SPINLOCK           Handle)
-{
-	//print("%s\n", __func__);
-}
-
-ACPI_CPU_FLAGS
-AcpiOsAcquireLock (
-    ACPI_SPINLOCK           Handle)
-{
-	//print("%s\n", __func__);
-	return 0;
-}
-
-void
-AcpiOsReleaseLock (
-    ACPI_SPINLOCK           Handle,
-    ACPI_CPU_FLAGS          Flags)
-{
-	//print("%s\n", __func__);
-}
-
-struct handler {
-	ACPI_OSD_HANDLER        ServiceRoutine;
-	void                    *Context;
-};
-
-/* The ACPI interrupt signature and the Harvey one are not compatible. So, we pass an arg to
- * intrenable that can in turn be used to this function to call the ACPI handler. */
-static void acpihandler(Ureg *_, void *arg)
-{
-	struct handler *h = arg;
-	h->ServiceRoutine(h->Context);
-}
-
-ACPI_STATUS
-AcpiOsInstallInterruptHandler (
-    UINT32                  InterruptNumber,
-    ACPI_OSD_HANDLER        ServiceRoutine,
-    void                    *Context)
-{
-	/* minix says "don't do it". So we don't, yet. */
-	return AE_OK;
-	struct handler *h = malloc(sizeof(*h));
-	if (! h)
-		return AE_NO_MEMORY;
-	h->ServiceRoutine = ServiceRoutine;
-	h->Context = Context;
-	print("%s %d %p %p \n", __func__, InterruptNumber, ServiceRoutine, Context);
-	/* once enabled, can't be disabled; ignore the return value unless it's nil. */
-	intrenable(InterruptNumber, acpihandler, h, 0x5, "ACPI interrupt handler");
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsRemoveInterruptHandler (
-    UINT32                  InterruptNumber,
-    ACPI_OSD_HANDLER        ServiceRoutine)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-void
-AcpiOsWaitEventsComplete (
-	void)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-}
-
-void
-AcpiOsSleep (
-    UINT64                  Milliseconds)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-}
-
-void
-AcpiOsStall(
-    UINT32                  Microseconds)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-}
-
-ACPI_THREAD_ID
-AcpiOsGetThreadId (
-    void)
-{
-	/* What to do here? ACPI won't take 0 for an answer.
-	 * I guess tell it we're 1? What do we do? */
-	return 1;
-	//print("%s\n", __func__);
-	Proc *up = externup();
-	return up->pid;
-}
-
-ACPI_STATUS
-AcpiOsExecute (
-    ACPI_EXECUTE_TYPE       Type,
-    ACPI_OSD_EXEC_CALLBACK  Function,
-    void                    *Context)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsReadPort (
-    ACPI_IO_ADDRESS         Address,
-    UINT32                  *Value,
-    UINT32                  Width)
-{
-	/* Ooooooookay ... ACPI specifies the IO width in *bits*. */
-	switch(Width) {
-	case 4*8:
-		*Value = inl(Address);
-		break;
-	case 2*8:
-		*Value = ins(Address);
-		break;
-	case 1*8:
-		*Value = inb(Address);
-		break;
-	default:
-		panic("%s, bad width %d", __func__, Width);
-		break;
-	}
-	print("%s 0x%x 0x%x\n", __func__, Address, *Value);
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsWritePort (
-    ACPI_IO_ADDRESS         Address,
-    UINT32                  Value,
-    UINT32                  Width)
-{
-	switch(Width) {
-	case 4*8:
-		outl(Address, Value);
-		break;
-	case 2*8:
-		outs(Address, Value);
-		break;
-	case 1*8:
-		outb(Address, Value);
-		break;
-	default:
-		panic("%s, bad width %d", __func__, Width);
-		break;
-	}
-	print("%s 0x%x 0x%x\n", __func__, Address, Value);
-	return AE_OK;
-}
-
-/*
- * Platform and hardware-independent physical memory interfaces
- */
-ACPI_STATUS
-AcpiOsReadMemory (
-    ACPI_PHYSICAL_ADDRESS   Address,
-    UINT64                  *Value,
-    UINT32                  Width)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsWriteMemory (
-    ACPI_PHYSICAL_ADDRESS   Address,
-    UINT64                  Value,
-    UINT32                  Width)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-
-/*
- * ACPI Table interfaces
- */
-ACPI_PHYSICAL_ADDRESS
-AcpiOsGetRootPointer (
-    void)
-{
-	print("%s returns %p\n", __func__, rsd);
-	return (ACPI_PHYSICAL_ADDRESS) PADDR(rsd);
-}
-
-ACPI_STATUS
-AcpiOsPredefinedOverride (
-    const ACPI_PREDEFINED_NAMES *InitVal,
-    ACPI_STRING                 *NewVal)
-{
-	print("%s\n", __func__);
-	*NewVal = nil;
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsTableOverride (
-    ACPI_TABLE_HEADER       *ExistingTable,
-    ACPI_TABLE_HEADER       **NewTable)
-{
-	print("%s\n", __func__);
-	*NewTable = nil;
-	return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsPhysicalTableOverride (
-    ACPI_TABLE_HEADER       *ExistingTable,
-    ACPI_PHYSICAL_ADDRESS   *NewAddress,
-    UINT32                  *NewTableLength)
-{
-	print("%s\n", __func__);
-	*NewAddress = (ACPI_PHYSICAL_ADDRESS)nil;
-	return AE_OK;
-}
-
-/*
- * Debug input
- */
-ACPI_STATUS
-AcpiOsGetLine (
-    char                    *Buffer,
-    UINT32                  BufferLength,
-    UINT32                  *BytesRead)
-{
-	print("%s\n", __func__);
-	panic("%s", __func__);
-	return AE_OK;
-}
-

+ 5 - 2
util/src/harvey/cmd/build/build.go

@@ -80,7 +80,7 @@ func globby(s []string) []string {
 
 	for _, n := range s {
 		l, err := filepath.Glob(n)
-		if err != nil {
+		if err != nil || len(l) == 0 {
 			f[n] = true
 		} else {
 			for _, n := range l {
@@ -93,6 +93,7 @@ func globby(s []string) []string {
 	for n := range f {
 		all = append(all, n)
 	}
+	debug("Glob of '%v' is '%v'", s, all)
 	return all
 }
 
@@ -179,7 +180,9 @@ func fromRoot(p string) string {
 	return p
 }
 
-func include(f string, b *build) {
+func include(f string, targ string, b *build) {
+       debug("include(%s, %s, %v)", f, targ, b)
+
 	if b.jsons[f] {
 		return
 	}