This commit was generated by cvs2svn to compensate for changes in r118611,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Nate Lawson 2003-08-07 16:38:31 +00:00
commit b9361fabdb
27 changed files with 24646 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,608 @@
/******************************************************************************
*
* Module Name: aslcodegen - AML code generation
* $Revision: 49 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslcodegen")
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlOutput
*
* PARAMETERS: None.
*
* RETURN: None
*
* DESCRIPTION: Generate AML code. Currently generates the listing file
* simultaneously.
*
******************************************************************************/
void
CgGenerateAmlOutput (void)
{
DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n");
/* Generate the AML output file */
FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
Gbl_SourceLine = 0;
Gbl_NextError = Gbl_ErrorLog;
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL);
CgCloseTable ();
}
/*******************************************************************************
*
* FUNCTION: CgAmlWriteWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate the AML code.
*
******************************************************************************/
ACPI_STATUS
CgAmlWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/*
* Debug output
*/
DbgPrint (ASL_TREE_OUTPUT,
"%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG ||
Op->Asl.ParseOpcode == PARSEOP_NAMESTRING ||
Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
{
DbgPrint (ASL_TREE_OUTPUT,
"%10.32s ", Op->Asl.ExternalName);
}
else
{
DbgPrint (ASL_TREE_OUTPUT, " ");
}
DbgPrint (ASL_TREE_OUTPUT,
"Val-%08X POp-%04X AOp-%04X OpLen-%01X PByts-%01X Len-%04X SubLen-%04X PSubLen-%04X Op-%08X Chld-%08X Paren-%08X Flags-%04X AcTyp-%08X C-%2d L-%d\n",
(UINT32) Op->Asl.Value.Integer,
Op->Asl.ParseOpcode,
Op->Asl.AmlOpcode,
Op->Asl.AmlOpcodeLength,
Op->Asl.AmlPkgLenBytes,
Op->Asl.AmlLength,
Op->Asl.AmlSubtreeLength,
Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
Op,
Op->Asl.Child,
Op->Asl.Parent,
Op->Asl.CompileFlags,
Op->Asl.AcpiBtype,
Op->Asl.Column,
Op->Asl.LineNumber);
/*
* Generate the AML for this node
*/
CgWriteNode (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: CgLocalWriteAmlData
*
* PARAMETERS: Buffer - Buffer to write
* Length - Size of data in buffer
*
* RETURN: None
*
* DESCRIPTION: Write a buffer of AML data to the AML output file.
*
******************************************************************************/
void
CgLocalWriteAmlData (
ACPI_PARSE_OBJECT *Op,
void *Buffer,
UINT32 Length)
{
/* Write the raw data to the AML file */
FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
/* Update the final AML length for this node (used for listings) */
if (Op)
{
Op->Asl.FinalAmlLength += Length;
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteAmlOpcode
*
* PARAMETERS: Op - Parse node with an AML opcode
*
* RETURN: None.
*
* DESCRIPTION: Write the AML opcode corresponding to a parse node.
*
******************************************************************************/
void
CgWriteAmlOpcode (
ACPI_PARSE_OBJECT *Op)
{
union {
UINT16 Opcode;
UINT8 OpcodeBytes[2];
} Aml;
union {
UINT32 Len;
UINT8 LenBytes[4];
} PkgLen;
UINT8 PkgLenFirstByte;
UINT32 i;
/* We expect some DEFAULT_ARGs, just ignore them */
if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
return;
}
switch (Op->Asl.AmlOpcode)
{
case AML_UNASSIGNED_OPCODE:
/* These opcodes should not get here */
printf ("Found a node with an unassigned AML opcode\n");
fprintf (stderr, "Found a node with an unassigned AML opcode\n");
return;
case AML_INT_RESERVEDFIELD_OP:
/* Special opcodes for within a field definition */
Aml.Opcode = 0x00;
break;
case AML_INT_ACCESSFIELD_OP:
Aml.Opcode = 0x01;
break;
default:
Aml.Opcode = Op->Asl.AmlOpcode;
break;
}
switch (Aml.Opcode)
{
case AML_PACKAGE_LENGTH:
/* Value is the length to be encoded (Used in field definitions) */
PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
break;
default:
/* Check for two-byte opcode */
if (Aml.Opcode > 0x00FF)
{
/* Write the high byte first */
CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
}
CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
/* Subtreelength doesn't include length of package length bytes */
PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
break;
}
/* Does this opcode have an associated "PackageLength" field? */
if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
{
if (Op->Asl.AmlPkgLenBytes == 1)
{
/* Simplest case -- no bytes to follow, just write the count */
CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
}
else
{
/*
* Encode the "bytes to follow" in the first byte, top two bits.
* The low-order nybble of the length is in the bottom 4 bits
*/
PkgLenFirstByte = (UINT8) (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
(PkgLen.LenBytes[0] & 0x0F));
CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
/* Shift the length over by the 4 bits we just stuffed in the first byte */
PkgLen.Len >>= 4;
/* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
{
CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
}
}
}
switch (Aml.Opcode)
{
case AML_BYTE_OP:
CgLocalWriteAmlData (Op, (UINT8 *) &Op->Asl.Value.Integer, 1);
break;
case AML_WORD_OP:
CgLocalWriteAmlData (Op, (UINT16 *) &Op->Asl.Value.Integer, 2);
break;
case AML_DWORD_OP:
CgLocalWriteAmlData (Op, (UINT32 *) &Op->Asl.Value.Integer, 4);
break;
case AML_QWORD_OP:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
break;
case AML_STRING_OP:
CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
break;
default:
/* All data opcodes must appear above */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteTableHeader
*
* PARAMETERS: Op - The DEFINITIONBLOCK node
*
* RETURN: None.
*
* DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
*
******************************************************************************/
void
CgWriteTableHeader (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child;
/* AML filename */
Child = Op->Asl.Child;
/* Signature */
Child = Child->Asl.Next;
strncpy (TableHeader.Signature, Child->Asl.Value.String, 4);
/* Revision */
Child = Child->Asl.Next;
TableHeader.Revision = (UINT8) Child->Asl.Value.Integer;
/* OEMID */
Child = Child->Asl.Next;
strncpy (TableHeader.OemId, Child->Asl.Value.String, 6);
/* OEM TableID */
Child = Child->Asl.Next;
strncpy (TableHeader.OemTableId, Child->Asl.Value.String, 8);
/* OEM Revision */
Child = Child->Asl.Next;
TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
/* Compiler ID */
strncpy (TableHeader.AslCompilerId, CompilerCreatorId, 4);
/* Compiler version */
TableHeader.AslCompilerRevision = CompilerCreatorRevision;
/* Table length. Checksum zero for now, will rewrite later */
TableHeader.Length = Gbl_TableLength;
TableHeader.Checksum = 0;
CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER));
}
/*******************************************************************************
*
* FUNCTION: CgCloseTable
*
* PARAMETERS: None.
*
* RETURN: None.
*
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
* re-writing the header.
*
******************************************************************************/
void
CgCloseTable (void)
{
signed char Sum;
UINT8 FileByte;
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
Sum = 0;
/* Calculate the checksum over the entire file */
while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
{
Sum = (signed char) (Sum + FileByte);
}
/* Re-write the table header with the checksum */
TableHeader.Checksum = (UINT8) (0 - Sum);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
}
/*******************************************************************************
*
* FUNCTION: CgWriteNode
*
* PARAMETERS: Op - Parse node to write.
*
* RETURN: None.
*
* DESCRIPTION: Write the AML that corresponds to a parse node.
*
******************************************************************************/
void
CgWriteNode (
ACPI_PARSE_OBJECT *Op)
{
ASL_RESOURCE_NODE *Rnode;
Op->Asl.FinalAmlLength = 0;
/* Always check for DEFAULT_ARG and other "Noop" nodes */
/* TBD: this may not be the best place for this check */
if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) ||
(Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) ||
(Op->Asl.ParseOpcode == PARSEOP_INCLUDE) ||
(Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END))
{
return;
}
switch (Op->Asl.AmlOpcode)
{
case AML_RAW_DATA_BYTE:
case AML_RAW_DATA_WORD:
case AML_RAW_DATA_DWORD:
case AML_RAW_DATA_QWORD:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
return;
case AML_RAW_DATA_BUFFER:
CgLocalWriteAmlData (Op, Op->Asl.Value.Buffer, Op->Asl.AmlLength);
return;
case AML_RAW_DATA_CHAIN:
Rnode = ACPI_CAST_PTR (ASL_RESOURCE_NODE, Op->Asl.Value.Buffer);
while (Rnode)
{
CgLocalWriteAmlData (Op, Rnode->Buffer, Rnode->BufferLength);
Rnode = Rnode->Next;
}
return;
default:
/* Internal data opcodes must all appear above */
break;
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFAULT_ARG:
break;
case PARSEOP_DEFINITIONBLOCK:
CgWriteTableHeader (Op);
break;
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
break;
default:
CgWriteAmlOpcode (Op);
break;
}
}

View File

@ -0,0 +1,615 @@
/******************************************************************************
*
* Module Name: aslcompile - top level compile module
* $Revision: 69 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdio.h>
#include "aslcompiler.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslcompile")
/*******************************************************************************
*
* FUNCTION: AslCompilerSignon
*
* PARAMETERS: FileId - ID of the output file
*
* RETURN: None
*
* DESCRIPTION: Display compiler signon
*
******************************************************************************/
void
AslCompilerSignon (
UINT32 FileId)
{
char *Prefix = "";
/*
* Set line prefix depending on the destination file type
*/
switch (FileId)
{
case ASL_FILE_ASM_SOURCE_OUTPUT:
case ASL_FILE_ASM_INCLUDE_OUTPUT:
Prefix = "; ";
break;
case ASL_FILE_HEX_OUTPUT:
if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
{
Prefix = "; ";
}
else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
Prefix = " * ";
}
break;
case ASL_FILE_C_SOURCE_OUTPUT:
case ASL_FILE_C_INCLUDE_OUTPUT:
Prefix = " * ";
break;
default:
/* No other output types supported */
break;
}
/* Compiler signon with copyright */
FlPrintFile (FileId,
"%s\n%s%s\n%s%s version %X [%s]\n%s%s\n%sSupports ACPI Specification Revision 2.0b\n%s\n",
Prefix,
Prefix, IntelAcpiCA,
Prefix, CompilerId, ACPI_CA_VERSION, __DATE__,
Prefix, CompilerCopyright,
Prefix,
Prefix);
}
/*******************************************************************************
*
* FUNCTION: AslCompilerFileHeader
*
* PARAMETERS: FileId - ID of the output file
*
* RETURN: None
*
* DESCRIPTION: Header used at the beginning of output files
*
******************************************************************************/
void
AslCompilerFileHeader (
UINT32 FileId)
{
struct tm *NewTime;
time_t Aclock;
char *Prefix = "";
/*
* Set line prefix depending on the destination file type
*/
switch (FileId)
{
case ASL_FILE_ASM_SOURCE_OUTPUT:
case ASL_FILE_ASM_INCLUDE_OUTPUT:
Prefix = "; ";
break;
case ASL_FILE_HEX_OUTPUT:
if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
{
Prefix = "; ";
}
else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
{
Prefix = " * ";
}
break;
case ASL_FILE_C_SOURCE_OUTPUT:
case ASL_FILE_C_INCLUDE_OUTPUT:
Prefix = " * ";
break;
default:
/* No other output types supported */
break;
}
/* Compilation header with timestamp */
(void) time (&Aclock);
NewTime = localtime (&Aclock);
FlPrintFile (FileId,
"%sCompilation of \"%s\" - %s%s\n",
Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
Prefix);
switch (FileId)
{
case ASL_FILE_C_SOURCE_OUTPUT:
case ASL_FILE_C_INCLUDE_OUTPUT:
FlPrintFile (FileId, " */\n");
break;
default:
/* Nothing to do for other output types */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CmFlushSourceCode
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Read in any remaining source code after the parse tree
* has been constructed.
*
******************************************************************************/
void
CmFlushSourceCode (void)
{
char Buffer;
while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
{
InsertLineBuffer ((int) Buffer);
}
ResetCurrentLineBuffer ();
}
/*******************************************************************************
*
* FUNCTION: CmDoCompile
*
* PARAMETERS: None
*
* RETURN: Status (0 = OK)
*
* DESCRIPTION: This procedure performs the entire compile
*
******************************************************************************/
int
CmDoCompile (void)
{
ACPI_STATUS Status;
UINT32 i = 0;
UtBeginEvent (12, "Total Compile time");
UtBeginEvent (i, "Initialize");
/* Open the required input and output files */
Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
UtEndEvent (i++);
/* Build the parse tree */
UtBeginEvent (i, "Parse source code and build parse tree");
AslCompilerparse();
UtEndEvent (i++);
/* Flush out any remaining source after parse tree is complete */
CmFlushSourceCode ();
/* Did the parse tree get successfully constructed? */
if (!RootNode)
{
CmCleanupAndExit ();
return -1;
}
OpcGetIntegerWidth (RootNode);
/* Pre-process parse tree for any operator transforms */
UtBeginEvent (i, "Generate AML opcodes");
DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, TrAmlTransformWalk, NULL, NULL);
/* Generate AML opcodes corresponding to the parse tokens */
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL);
UtEndEvent (i++);
/*
* Now that the input is parsed, we can open the AML output file.
* Note: by default, the name of this file comes from the table descriptor
* within the input file.
*/
Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
/* Interpret and generate all compile-time constants */
UtBeginEvent (i, "Constant folding via AML interpreter");
DbgPrint (ASL_DEBUG_OUTPUT, "\nInterpreting compile-time constant expressions\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, OpcAmlConstantWalk, NULL, NULL);
UtEndEvent (i++);
/* Calculate all AML package lengths */
UtBeginEvent (i, "Generate AML package lengths");
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
UtEndEvent (i++);
if (Gbl_ParseOnlyFlag)
{
AePrintErrorLog (ASL_FILE_STDOUT);
UtDisplaySummary (ASL_FILE_STDOUT);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
AePrintErrorLog (ASL_FILE_STDERR);
UtDisplaySummary (ASL_FILE_STDERR);
}
return 0;
}
/*
* Create an internal namespace and use it as a symbol table
*/
/* Namespace loading */
UtBeginEvent (i, "Create ACPI Namespace");
Status = LdLoadNamespace (RootNode);
UtEndEvent (i++);
if (ACPI_FAILURE (Status))
{
return -1;
}
/* Namespace lookup */
UtBeginEvent (i, "Cross reference parse tree and Namespace");
Status = LkCrossReferenceNamespace ();
UtEndEvent (i++);
UtEndEvent (i++);
if (ACPI_FAILURE (Status))
{
return -1;
}
/*
* Semantic analysis. This can happen only after the
* namespace has been loaded and cross-referenced.
*
* part one - check control methods
*/
UtBeginEvent (i, "Analyze control method return types");
AnalysisWalkInfo.MethodStack = NULL;
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodAnalysisWalkBegin,
AnMethodAnalysisWalkEnd, &AnalysisWalkInfo);
UtEndEvent (i++);
/* Semantic error checking part two - typing of method returns */
UtBeginEvent (i, "Determine object types returned by methods");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing \n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
AnMethodTypingWalkEnd, NULL);
UtEndEvent (i++);
/* Semantic error checking part three - operand type checking */
UtBeginEvent (i, "Analyze AML operand types");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking \n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOperandTypecheckWalkBegin,
AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
UtEndEvent (i++);
/* Semantic error checking part four - other miscellaneous checks */
UtBeginEvent (i, "Miscellaneous analysis");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous \n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOtherSemanticAnalysisWalkBegin,
AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
UtEndEvent (i++);
/* Calculate all AML package lengths */
UtBeginEvent (i, "Finish AML package length generation");
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL);
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
UtEndEvent (i++);
/* Code generation - emit the AML */
UtBeginEvent (i, "Generate AML code and write output files");
CgGenerateAmlOutput ();
UtEndEvent (i++);
UtBeginEvent (i, "Write optional output files");
CmDoOutputFiles ();
UtEndEvent (i++);
UtEndEvent (13);
CmCleanupAndExit ();
return 0;
}
void
CmDoOutputFiles (void)
{
/* Create listings and hex files */
LsDoListings ();
LsDoHexOutput ();
/* Dump the namespace to the .nsp file if requested */
LsDisplayNamespace ();
}
/*******************************************************************************
*
* FUNCTION: CmCleanupAndExit
*
* PARAMETERS: None
*
* RETURN: None.
*
* DESCRIPTION: Close all open files and exit the compiler
*
******************************************************************************/
void
CmCleanupAndExit (void)
{
UINT32 i;
AePrintErrorLog (ASL_FILE_STDOUT);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
AePrintErrorLog (ASL_FILE_STDERR);
}
DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
for (i = 0; i < 13; i++)
{
if (AslGbl_Events[i].Valid)
{
DbgPrint (ASL_DEBUG_OUTPUT, "%8lu ms - %s\n",
AslGbl_Events[i].EndTime -
AslGbl_Events[i].StartTime,
AslGbl_Events[i].EventName);
}
}
if (Gbl_CompileTimesFlag)
{
printf ("\nElapsed time for major events\n\n");
for (i = 0; i < 13; i++)
{
if (AslGbl_Events[i].Valid)
{
printf ("%8lu ms : %s\n",
AslGbl_Events[i].EndTime -
AslGbl_Events[i].StartTime,
AslGbl_Events[i].EventName);
}
}
printf ("\nMiscellaneous compile statistics\n\n");
printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
printf ("%11u : %s\n", TotalMethods, "Control methods");
printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
printf ("\n");
}
if (Gbl_NsLookupCount)
{
DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n");
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", Gbl_NsLookupCount);
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Time per search",
((UINT32) (AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) /
Gbl_NsLookupCount);
}
/* Close all open files */
for (i = 2; i < ASL_MAX_FILE_TYPE; i++)
{
FlCloseFile (i);
}
/*
* TBD: SourceOutput should be .TMP, then rename if we want to keep it?
*/
if (!Gbl_SourceOutputFlag)
{
unlink (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
}
/* Delete AML file if there are errors */
if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
{
unlink (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename);
}
if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
{
printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT);
}
UtDisplaySummary (ASL_FILE_STDOUT);
exit (0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,621 @@
/******************************************************************************
*
* Module Name: aslerror - Error handling and statistics
* $Revision: 82 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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.
*
*****************************************************************************/
#define ASL_EXCEPTIONS
#include "aslcompiler.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslerror")
/*******************************************************************************
*
* FUNCTION: AeAddToErrorLog
*
* PARAMETERS: Enode - An error node to add to the log
*
* RETURN: None
*
* DESCRIPTION: Add a new error node to the error log. The error log is
* ordered by the "logical" line number (cumulative line number
* including all include files.)
*
******************************************************************************/
void
AeAddToErrorLog (
ASL_ERROR_MSG *Enode)
{
ASL_ERROR_MSG *Next;
ASL_ERROR_MSG *Prev;
if (!Gbl_ErrorLog)
{
Gbl_ErrorLog = Enode;
return;
}
/* List is sorted according to line number */
if (!Gbl_ErrorLog)
{
Gbl_ErrorLog = Enode;
return;
}
/* Walk error list until we find a line number greater than ours */
Prev = NULL;
Next = Gbl_ErrorLog;
while ((Next) &&
(Next->LogicalLineNumber <= Enode->LogicalLineNumber))
{
Prev = Next;
Next = Next->Next;
}
/* Found our place in the list */
Enode->Next = Next;
if (Prev)
{
Prev->Next = Enode;
}
else
{
Gbl_ErrorLog = Enode;
}
}
/*******************************************************************************
*
* FUNCTION: AePrintException
*
* PARAMETERS: Where - Where to send the message
* Enode - Error node to print
* Header - Additional text before each message
*
* RETURN: None
*
* DESCRIPTION: Print the contents of an error node.
*
* NOTE: We don't use the FlxxxFile I/O functions here because on error
* they abort the compiler and call this function! Since we
* are reporting errors here, we ignore most output errors and
* just try to get out as much as we can.
*
******************************************************************************/
void
AePrintException (
UINT32 FileId,
ASL_ERROR_MSG *Enode,
char *Header)
{
UINT8 SourceByte;
UINT32 Actual;
UINT32 MsgLength;
char *MainMessage;
char *ExtraMessage;
UINT32 SourceColumn;
UINT32 ErrorColumn;
FILE *OutputFile;
FILE *SourceFile;
/* Only listing files have a header, and remarks/optimizations are always output */
if (!Header)
{
/* Ignore remarks if requested */
switch (Enode->Level)
{
case ASL_REMARK:
if (!Gbl_DisplayRemarks)
{
return;
}
break;
case ASL_OPTIMIZATION:
if (!Gbl_DisplayOptimizations)
{
return;
}
break;
default:
break;
}
}
/* Get the file handles */
OutputFile = Gbl_Files[FileId].Handle;
SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
if (Header)
{
fprintf (OutputFile, "%s", Header);
}
/* Print filename and line number if present and valid */
if (Enode->Filename)
{
if (Gbl_VerboseErrors)
{
fprintf (OutputFile, "%6s", Enode->Filename);
if (Enode->LineNumber)
{
fprintf (OutputFile, "%6u: ", Enode->LineNumber);
/*
* Seek to the offset in the combined source file, read the source
* line, and write it to the output.
*/
Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, SEEK_SET);
if (Actual)
{
fprintf (OutputFile, "[*** iASL: Seek error on source code temp file ***]");
}
else
{
Actual = fread (&SourceByte, 1, 1, SourceFile);
if (!Actual)
{
fprintf (OutputFile, "[*** iASL: Read error on source code temp file ***]");
}
else while (Actual && SourceByte && (SourceByte != '\n'))
{
fwrite (&SourceByte, 1, 1, OutputFile);
Actual = fread (&SourceByte, 1, 1, SourceFile);
}
}
fprintf (OutputFile, "\n");
}
}
else
{
fprintf (OutputFile, "%s", Enode->Filename);
if (Enode->LineNumber)
{
fprintf (OutputFile, "(%u) : ", Enode->LineNumber);
}
}
}
/* NULL message ID, just print the raw message */
if (Enode->MessageId == 0)
{
fprintf (OutputFile, "%s\n", Enode->Message);
}
else
{
/* Decode the message ID */
fprintf (OutputFile, "%s %4.4d -",
AslErrorLevel[Enode->Level],
Enode->MessageId + ((Enode->Level+1) * 1000));
MainMessage = AslMessages[Enode->MessageId];
ExtraMessage = Enode->Message;
if (Enode->LineNumber)
{
MsgLength = strlen (MainMessage);
if (MsgLength == 0)
{
MainMessage = Enode->Message;
MsgLength = strlen (MainMessage);
ExtraMessage = NULL;
}
if (Gbl_VerboseErrors)
{
SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
{
fprintf (OutputFile, "%*s%s",
(int) ((SourceColumn - 1) - ErrorColumn),
MainMessage, " ^ ");
}
else
{
fprintf (OutputFile, "%*s %s",
(int) ((SourceColumn - ErrorColumn) + 1), "^",
MainMessage);
}
}
else
{
fprintf (OutputFile, " %s", MainMessage);
}
/* Print the extra info message if present */
if (ExtraMessage)
{
fprintf (OutputFile, " (%s)", ExtraMessage);
}
fprintf (OutputFile, "\n");
if (Gbl_VerboseErrors)
{
fprintf (OutputFile, "\n");
}
}
else
{
fprintf (OutputFile, " %s %s\n\n",
MainMessage,
ExtraMessage);
}
}
}
/*******************************************************************************
*
* FUNCTION: AePrintErrorLog
*
* PARAMETERS: FileId - Where to output the error log
*
* RETURN: None
*
* DESCRIPTION: Print the entire contents of the error log
*
******************************************************************************/
void
AePrintErrorLog (
UINT32 FileId)
{
ASL_ERROR_MSG *Enode = Gbl_ErrorLog;
/* Walk the error node list */
while (Enode)
{
AePrintException (FileId, Enode, NULL);
Enode = Enode->Next;
}
}
/*******************************************************************************
*
* FUNCTION: AslCommonError
*
* PARAMETERS: Level - Seriousness (Warning/error, etc.)
* MessageId - Index into global message buffer
* CurrentLineNumber - Actual file line number
* LogicalLineNumber - Cumulative line number
* LogicalByteOffset - Byte offset in source file
* Column - Column in current line
* Filename - source filename
* ExtraMessage - additional error message
*
* RETURN: New error node for this error
*
* DESCRIPTION: Create a new error node and add it to the error log
*
******************************************************************************/
void
AslCommonError (
UINT8 Level,
UINT8 MessageId,
UINT32 CurrentLineNumber,
UINT32 LogicalLineNumber,
UINT32 LogicalByteOffset,
UINT32 Column,
char *Filename,
char *ExtraMessage)
{
UINT32 MessageSize;
char *MessageBuffer = NULL;
ASL_ERROR_MSG *Enode;
Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
if (ExtraMessage)
{
/* Allocate a buffer for the message and a new error node */
MessageSize = strlen (ExtraMessage) + 1;
MessageBuffer = UtLocalCalloc (MessageSize);
/* Keep a copy of the extra message */
ACPI_STRCPY (MessageBuffer, ExtraMessage);
}
/* Initialize the error node */
if (Filename)
{
Enode->Filename = Filename;
Enode->FilenameLength = strlen (Filename);
if (Enode->FilenameLength < 6)
{
Enode->FilenameLength = 6;
}
}
Enode->MessageId = MessageId;
Enode->Level = Level;
Enode->LineNumber = CurrentLineNumber;
Enode->LogicalLineNumber = LogicalLineNumber;
Enode->LogicalByteOffset = LogicalByteOffset;
Enode->Column = Column;
Enode->Message = MessageBuffer;
/* Add the new node to the error node list */
AeAddToErrorLog (Enode);
if (Gbl_DebugFlag)
{
/* stderr is a file, send error to it immediately */
AePrintException (ASL_FILE_STDERR, Enode, NULL);
}
Gbl_ExceptionCount[Level]++;
if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
{
printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT);
Gbl_SourceLine = 0;
Gbl_NextError = Gbl_ErrorLog;
CmDoOutputFiles ();
CmCleanupAndExit ();
}
return;
}
/*******************************************************************************
*
* FUNCTION: AslError
*
* PARAMETERS: Level - Seriousness (Warning/error, etc.)
* MessageId - Index into global message buffer
* Op - Parse node where error happened
* ExtraMessage - additional error message
*
* RETURN: None
*
* DESCRIPTION: Main error reporting routine for the ASL compiler (all code
* except the parser.)
*
******************************************************************************/
void
AslError (
UINT8 Level,
UINT8 MessageId,
ACPI_PARSE_OBJECT *Op,
char *ExtraMessage)
{
if (Op)
{
AslCommonError (Level, MessageId, Op->Asl.LineNumber,
Op->Asl.LogicalLineNumber,
Op->Asl.LogicalByteOffset,
Op->Asl.Column,
Op->Asl.Filename, ExtraMessage);
}
else
{
AslCommonError (Level, MessageId, 0,
0, 0, 0, NULL, ExtraMessage);
}
}
/*******************************************************************************
*
* FUNCTION: AslCoreSubsystemError
*
* PARAMETERS: Op - Parse node where error happened
* Status - The ACPI CA Exception
* ExtraMessage - additional error message
* Abort - TRUE -> Abort compilation
*
* RETURN: None
*
* DESCRIPTION: Error reporting routine for exceptions returned by the ACPI
* CA core subsystem.
*
******************************************************************************/
void
AslCoreSubsystemError (
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS Status,
char *ExtraMessage,
BOOLEAN Abort)
{
sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
if (Op)
{
AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
Op->Asl.LogicalLineNumber,
Op->Asl.LogicalByteOffset,
Op->Asl.Column,
Op->Asl.Filename, MsgBuffer);
}
else
{
AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
0, 0, 0, NULL, MsgBuffer);
}
if (Abort)
{
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: AslCompilererror
*
* PARAMETERS: CompilerMessage - Error message from the parser
*
* RETURN: Status?
*
* DESCRIPTION: Report an error situation discovered in a production
* NOTE: don't change the name of this function.
*
******************************************************************************/
int
AslCompilererror (
char *CompilerMessage)
{
AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
CompilerMessage);
return 0;
}

View File

@ -0,0 +1,839 @@
/******************************************************************************
*
* Module Name: aslfiles - file I/O suppoert
* $Revision: 46 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfiles")
/*******************************************************************************
*
* FUNCTION: AslAbort
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Dump the error log and abort the compiler. Used for serious
* I/O errors
*
******************************************************************************/
void
AslAbort (void)
{
AePrintErrorLog (ASL_FILE_STDOUT);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
AePrintErrorLog (ASL_FILE_STDERR);
}
exit (0);
}
/*******************************************************************************
*
* FUNCTION: FlOpenLocalFile
*
* PARAMETERS: LocalName - Single filename (not a pathname)
* Mode - Open mode for fopen
*
* RETURN: File descriptor
*
* DESCRIPTION: Build a complete pathname for the input filename and open
* the file.
*
******************************************************************************/
FILE *
FlOpenLocalFile (
char *LocalName,
char *Mode)
{
strcpy (StringBuffer, Gbl_DirectoryPath);
strcat (StringBuffer, LocalName);
DbgPrint (ASL_PARSE_OUTPUT, "FlOpenLocalFile: %s\n", StringBuffer);
return (fopen (StringBuffer, (const char *) Mode));
}
/*******************************************************************************
*
* FUNCTION: FlFileError
*
* PARAMETERS: FileId - Index into file info array
* ErrorId - Index into error message array
*
* RETURN: None
*
* DESCRIPTION: Decode errno to an error message and add the entire error
* to the error log.
*
******************************************************************************/
void
FlFileError (
UINT32 FileId,
UINT8 ErrorId)
{
sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, strerror (errno));
AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
}
/*******************************************************************************
*
* FUNCTION: FlOpenFile
*
* PARAMETERS: FileId - Index into file info array
* Filename - file pathname to open
* Mode - Open mode for fopen
*
* RETURN: File descriptor
*
* DESCRIPTION: Open a file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlOpenFile (
UINT32 FileId,
char *Filename,
char *Mode)
{
FILE *File;
File = fopen (Filename, Mode);
Gbl_Files[FileId].Filename = Filename;
Gbl_Files[FileId].Handle = File;
if (!File)
{
FlFileError (FileId, ASL_MSG_OPEN);
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: FlReadFile
*
* PARAMETERS: FileId - Index into file info array
* Buffer - Where to place the data
* Length - Amount to read
*
* RETURN: Status. AE_ERROR indicates EOF.
*
* DESCRIPTION: Read data from an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
ACPI_STATUS
FlReadFile (
UINT32 FileId,
void *Buffer,
UINT32 Length)
{
UINT32 Actual;
/* Read and check for error */
Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
if (Actual != Length)
{
if (feof (Gbl_Files[FileId].Handle))
{
/* End-of-file, just return error */
return (AE_ERROR);
}
FlFileError (FileId, ASL_MSG_READ);
AslAbort ();
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlWriteFile
*
* PARAMETERS: FileId - Index into file info array
* Buffer - Data to write
* Length - Amount of data to write
*
* RETURN: Status
*
* DESCRIPTION: Write data to an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlWriteFile (
UINT32 FileId,
void *Buffer,
UINT32 Length)
{
UINT32 Actual;
/* Write and check for error */
Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
if (Actual != Length)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: FlPrintFile
*
* PARAMETERS: FileId - Index into file info array
* Format - Printf format string
* ... - Printf arguments
*
* RETURN: None
*
* DESCRIPTION: Formatted write to an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlPrintFile (
UINT32 FileId,
char *Format,
...)
{
INT32 Actual;
va_list Args;
va_start (Args, Format);
Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
if (Actual == -1)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: FlSeekFile
*
* PARAMETERS: FileId - Index into file info array
* Offset - Absolute byte offset in file
*
* RETURN: Status
*
* DESCRIPTION: Seek to absolute offset
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlSeekFile (
UINT32 FileId,
long Offset)
{
int Error;
Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
if (Error)
{
FlFileError (FileId, ASL_MSG_SEEK);
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: FlCloseFile
*
* PARAMETERS: FileId - Index into file info array
*
* RETURN: Status
*
* DESCRIPTION: Close an open file. Aborts compiler on error
*
******************************************************************************/
void
FlCloseFile (
UINT32 FileId)
{
int Error;
if (!Gbl_Files[FileId].Handle)
{
return;
}
Error = fclose (Gbl_Files[FileId].Handle);
Gbl_Files[FileId].Handle = NULL;
if (Error)
{
FlFileError (FileId, ASL_MSG_CLOSE);
AslAbort ();
}
return;
}
/*******************************************************************************
*
* FUNCTION: FlSetLineNumber
*
* PARAMETERS: Op - Parse node for the LINE asl statement
*
* RETURN: None.
*
* DESCRIPTION: Set the current line number
*
******************************************************************************/
void
FlSetLineNumber (
ACPI_PARSE_OBJECT *Op)
{
Gbl_CurrentLineNumber = (UINT32) Op->Asl.Value.Integer;
Gbl_LogicalLineNumber = (UINT32) Op->Asl.Value.Integer;
}
/*******************************************************************************
*
* FUNCTION: FlOpenIncludeFile
*
* PARAMETERS: Op - Parse node for the INCLUDE ASL statement
*
* RETURN: None.
*
* DESCRIPTION: Open an include file and push it on the input file stack.
*
******************************************************************************/
void
FlOpenIncludeFile (
ACPI_PARSE_OBJECT *Op)
{
FILE *IncFile;
/* Op must be valid */
if (!Op)
{
AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
Gbl_InputByteCount, Gbl_CurrentColumn,
Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
return;
}
/*
* Flush out the "include ()" statement on this line, start
* the actual include file on the next line
*/
ResetCurrentLineBuffer ();
FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
Gbl_CurrentLineOffset++;
/* Prepend the directory pathname and open the include file */
DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", Op->Asl.Value.String);
IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r");
if (!IncFile)
{
sprintf (MsgBuffer, "%s (%s)", Op->Asl.Value.String, strerror (errno));
AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
return;
}
/* Push the include file on the open input file stack */
AslPushInputFileStack (IncFile, Op->Asl.Value.String);
}
/*******************************************************************************
*
* FUNCTION: FlParseInputPathname
*
* PARAMETERS: InputFilename - The user-specified ASL source file to be
* compiled
*
* 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
FlParseInputPathname (
char *InputFilename)
{
char *Substring;
if (!InputFilename)
{
return (AE_OK);
}
/* Get the path to the input filename's directory */
Gbl_DirectoryPath = strdup (InputFilename);
if (!Gbl_DirectoryPath)
{
return (AE_NO_MEMORY);
}
Substring = strrchr (Gbl_DirectoryPath, '\\');
if (!Substring)
{
Substring = strrchr (Gbl_DirectoryPath, '/');
if (!Substring)
{
Substring = strrchr (Gbl_DirectoryPath, ':');
}
}
if (!Substring)
{
Gbl_DirectoryPath[0] = 0;
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = strdup (InputFilename);
}
}
else
{
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = strdup (Substring + 1);
}
*(Substring+1) = 0;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlOpenInputFile
*
* PARAMETERS: InputFilename - The user-specified ASL source file to be
* compiled
*
* RETURN: Status
*
* DESCRIPTION: Open the specified input file, and save the directory path to
* the file so that include files can be opened in
* the same directory.
*
******************************************************************************/
ACPI_STATUS
FlOpenInputFile (
char *InputFilename)
{
/* Open the input ASL file, text mode */
FlOpenFile (ASL_FILE_INPUT, InputFilename, "r");
AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlOpenAmlOutputFile
*
* PARAMETERS: FilenamePrefix - The user-specified ASL source file
*
* RETURN: Status
*
* DESCRIPTION: Create the output filename (*.AML) and open the file. The file
* is created in the same directory as the parent input file.
*
******************************************************************************/
ACPI_STATUS
FlOpenAmlOutputFile (
char *FilenamePrefix)
{
char *Filename;
/* Output filename usually comes from the ASL itself */
Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
if (!Filename)
{
/* Create the output AML filename */
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
}
/* Open the output AML file in binary mode */
FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlOpenMiscOutputFiles
*
* PARAMETERS: FilenamePrefix - The user-specified ASL source file
*
* RETURN: Status
*
* DESCRIPTION: Create and open the various output files needed, depending on
* the command line options
*
******************************************************************************/
ACPI_STATUS
FlOpenMiscOutputFiles (
char *FilenamePrefix)
{
char *Filename;
/* Create/Open a combined source output file */
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/*
* Open the source output file, binary mode (so that LF does not get
* expanded to CR/LF on some systems, messing up our seek
* calculations.)
*/
FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
/* Create/Open a listing output file if asked */
if (Gbl_ListingFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the listing file, text mode */
FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+");
AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
}
/* Create/Open a assembly code source output file if asked */
if (Gbl_AsmOutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the assembly code source file, text mode */
FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+");
AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
}
/* Create/Open a C code source output file if asked */
if (Gbl_C_OutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the C code source file, text mode */
FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+");
FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
}
/* Create/Open a assembly include output file if asked */
if (Gbl_AsmIncludeOutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the assembly include file, text mode */
FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+");
AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
}
/* Create/Open a C include output file if asked */
if (Gbl_C_IncludeOutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the C include file, text mode */
FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+");
FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
}
/* Create/Open a hex output file if asked */
if (Gbl_HexOutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the hex file, text mode */
FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+");
AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
}
/* Create a namespace output file if asked */
if (Gbl_NsOutputFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the namespace file, text mode */
FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+");
AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
}
/* Create/Open a debug output file if asked */
if (Gbl_DebugFlag)
{
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, 0, 0, 0, 0, NULL, NULL);
return (AE_ERROR);
}
/* Open the debug file as STDERR, text mode */
/* TBD: hide this behind a FlReopenFile function */
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr);
AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
}
return (AE_OK);
}

View File

@ -0,0 +1,532 @@
/******************************************************************************
*
* Module Name: aslfold - Constant folding
* $Revision: 7 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acparser.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfold")
/*******************************************************************************
*
* FUNCTION: OpcAmlEvaluationWalk1
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Descending callback for AML execution of constant subtrees
*
******************************************************************************/
ACPI_STATUS
OpcAmlEvaluationWalk1 (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = Context;
ACPI_STATUS Status;
ACPI_PARSE_OBJECT *OutOp;
WalkState->Op = Op;
WalkState->Opcode = Op->Common.AmlOpcode;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
/* Copy child pointer to Arg for compatibility with Interpreter */
if (Op->Asl.Child)
{
Op->Common.Value.Arg = Op->Asl.Child;
}
/* Call AML dispatcher */
Status = AcpiDsExecBeginOp (WalkState, &OutOp);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Constant interpretation failed - %s\n",
AcpiFormatException (Status));
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: OpcAmlEvaluationWalk2
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback for AML execution of constant subtrees
*
******************************************************************************/
ACPI_STATUS
OpcAmlEvaluationWalk2 (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = Context;
ACPI_STATUS Status;
WalkState->Op = Op;
WalkState->Opcode = Op->Common.AmlOpcode;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
/* Copy child pointer to Arg for compatibility with Interpreter */
if (Op->Asl.Child)
{
Op->Common.Value.Arg = Op->Asl.Child;
}
/* Call AML dispatcher */
Status = AcpiDsExecEndOp (WalkState);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Constant interpretation failed - %s\n",
AcpiFormatException (Status));
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: OpcAmlCheckForConstant
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Check one Op for a type 3/4/5 AML opcode
*
******************************************************************************/
ACPI_STATUS
OpcAmlCheckForConstant (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = Context;
WalkState->Op = Op;
WalkState->Opcode = Op->Common.AmlOpcode;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
{
/* The opcode is not a Type 3/4/5 opcode */
if (Op->Asl.CompileFlags & NODE_IS_TARGET)
{
DbgPrint (ASL_PARSE_OUTPUT, "**** Valid Target, cannot reduce ****\n");
}
else
{
DbgPrint (ASL_PARSE_OUTPUT, "**** Not a Type 3/4/5 opcode ****\n");
}
if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
{
/*
* We are looking at at normal expression to see if it can be
* reduced. It can't. No error
*/
return (AE_TYPE);
}
/*
* This is an expression that MUST reduce to a constant, and it
* can't be reduced. This is an error
*/
if (Op->Asl.CompileFlags & NODE_IS_TARGET)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, Op->Asl.ParseOpName);
}
else
{
AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op, Op->Asl.ParseOpName);
}
return (AE_TYPE);
}
/* Debug output */
DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");
if (Op->Asl.CompileFlags & NODE_IS_TARGET)
{
DbgPrint (ASL_PARSE_OUTPUT, " TARGET");
}
if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
{
DbgPrint (ASL_PARSE_OUTPUT, " TERMARG");
}
DbgPrint (ASL_PARSE_OUTPUT, "\n");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OpcAmlConstantWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Reduce an Op and its subtree to a constant if possible
*
******************************************************************************/
ACPI_STATUS
OpcAmlConstantWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState;
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_PARSE_OBJECT *RootOp;
ACPI_PARSE_OBJECT *OriginalParentOp;
UINT8 WalkType;
/*
* Only interested in subtrees that could possibly contain
* expressions that can be evaluated at this time
*/
if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||
(Op->Asl.CompileFlags & NODE_IS_TARGET))
{
return (AE_OK);
}
/*
* Set the walk type based on the reduction used for this op
*/
if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
{
/* Op is a TermArg, constant folding is merely optional */
if (!Gbl_FoldConstants)
{
return (AE_CTRL_DEPTH);
}
WalkType = ACPI_WALK_CONST_OPTIONAL;
}
else
{
/* Op is a DataObject, the expression MUST reduced to a constant */
WalkType = ACPI_WALK_CONST_REQUIRED;
}
/* Create a new walk state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
return AE_NO_MEMORY;
}
WalkState->NextOp = NULL;
WalkState->Params = NULL;
WalkState->CallerReturnDesc = &ObjDesc;
WalkState->WalkType = WalkType;
/* Examine the entire subtree -- all nodes must be constants or type 3/4/5 opcodes */
Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
OpcAmlCheckForConstant, NULL, WalkState);
/*
* Did we find an entire subtree that contains all constants and type 3/4/5
* opcodes? (Only AE_OK or AE_TYPE returned from above)
*/
if (Status == AE_TYPE)
{
/* Subtree cannot be reduced to a constant */
if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)
{
AcpiDsDeleteWalkState (WalkState);
return (AE_OK);
}
/* Don't descend any further, and use a default "constant" value */
Status = AE_CTRL_DEPTH;
}
else
{
/* Subtree can be reduced */
/* Allocate a new temporary root for this subtree */
RootOp = TrAllocateNode (PARSEOP_INTEGER);
if (!RootOp)
{
return (AE_NO_MEMORY);
}
RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;
OriginalParentOp = Op->Common.Parent;
Op->Common.Parent = RootOp;
/*
* Hand off the subtree to the AML interpreter
*/
Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);
Op->Common.Parent = OriginalParentOp;
/* TBD: we really *should* release the RootOp node */
if (ACPI_SUCCESS (Status))
{
TotalFolds++;
/* Get the final result */
Status = AcpiDsResultPop (&ObjDesc, WalkState);
}
}
if (ACPI_FAILURE (Status))
{
/* We could not resolve the subtree for some reason */
AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, Op->Asl.ParseOpName);
/* Set the subtree value to ZERO anyway. Eliminates further errors */
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
Op->Common.Value.Integer = 0;
OpcSetOptimalIntegerSize (Op);
}
else
{
AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, Op->Asl.ParseOpName);
/*
* Because we know we executed type 3/4/5 opcodes above, we know that
* the result must be either an Integer, String, or Buffer.
*/
switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
case ACPI_TYPE_INTEGER:
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
Op->Common.Value.Integer = ObjDesc->Integer.Value;
OpcSetOptimalIntegerSize (Op);
DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (INTEGER) %8.8X%8.8X\n",
ACPI_HIDWORD (ObjDesc->Integer.Value),
ACPI_LODWORD (ObjDesc->Integer.Value));
break;
case ACPI_TYPE_STRING:
Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
Op->Common.AmlOpcode = AML_STRING_OP;
Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
Op->Common.Value.String = ObjDesc->String.Pointer;
DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (STRING) %s\n",
Op->Common.Value.String);
break;
case ACPI_TYPE_BUFFER:
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Common.AmlOpcode = AML_BUFFER_OP;
UtSetParseOpName (Op);
/* Child node is the buffer length */
RootOp = TrAllocateNode (PARSEOP_INTEGER);
RootOp->Asl.AmlOpcode = AML_DWORD_OP;
RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
RootOp->Asl.Parent = Op;
(void) OpcSetOptimalIntegerSize (RootOp);
Op->Asl.Child = RootOp;
Op = RootOp;
UtSetParseOpName (Op);
/* Peer to the child is the raw buffer data */
RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
RootOp->Asl.Parent = Op->Asl.Parent;
Op->Asl.Next = RootOp;
Op = RootOp;
DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (BUFFER) length %X\n",
ObjDesc->Buffer.Length);
break;
default:
printf ("Unsupported return type: %s\n",
AcpiUtGetObjectTypeName (ObjDesc));
break;
}
}
UtSetParseOpName (Op);
Op->Asl.Child = NULL;
AcpiDsDeleteWalkState (WalkState);
return (AE_CTRL_DEPTH);
}

View File

@ -0,0 +1,267 @@
/******************************************************************************
*
* Module Name: aslglobal.h - Global variable definitions
* $Revision: 42 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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.
*
*****************************************************************************/
#ifndef __ASLGLOBAL_H
#define __ASLGLOBAL_H
/*
* Global variables. Defined in aslmain.c only, externed in all other files
*/
#ifdef _DECLARE_GLOBALS
#define ASL_EXTERN
#define ASL_INIT_GLOBAL(a,b) (a)=(b)
#else
#define ASL_EXTERN extern
#define ASL_INIT_GLOBAL(a,b) (a)
#endif
/*
* Parser and other externals
*/
extern int yydebug;
extern FILE *AslCompilerin;
extern int AslCompilerdebug;
extern const ASL_MAPPING_ENTRY AslKeywordMapping[];
extern char *AslCompilertext;
extern char hex[];
#define ASL_LINE_BUFFER_SIZE 512
#define ASL_MSG_BUFFER_SIZE (ASL_LINE_BUFFER_SIZE * 2)
#define HEX_TABLE_LINE_SIZE 8
#define HEX_LISTING_LINE_SIZE 16
/* Source code buffers and pointers for error reporting */
ASL_EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE];
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer);
/* Exception reporting */
ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_ErrorLog,NULL);
ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*Gbl_NextError,NULL);
extern UINT32 Gbl_ExceptionCount[];
/* Option flags */
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GenerateExternals, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE);
#define HEX_OUTPUT_NONE 0
#define HEX_OUTPUT_C 1
#define HEX_OUTPUT_ASM 2
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE);
/* Files */
ASL_EXTERN ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES];
ASL_EXTERN char *Gbl_DirectoryPath;
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
ASL_EXTERN char *Gbl_CurrentInputFilename;
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
/* Statistics */
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_InputByteCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NsLookupCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalKeywords, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalNamedObjects, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalExecutableOpcodes, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalParseNodes, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalMethods, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocations, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocated, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0);
/* Misc */
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0);
ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TempCount, 0);
ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode;
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLine, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0);
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG");
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID");
ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswinxf only */
/* Static structures */
ASL_EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo;
ASL_EXTERN ACPI_TABLE_HEADER TableHeader;
extern const ASL_RESERVED_INFO ReservedMethods[];
ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[21];
/* Scratch buffers */
ASL_EXTERN UINT8 Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
ASL_EXTERN char MsgBuffer[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE];
#endif /* __ASLGLOBAL_H */

View File

@ -0,0 +1,504 @@
/******************************************************************************
*
* Module Name: asllength - Tree walk to determine package and opcode lengths
* $Revision: 30 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asllength")
/*******************************************************************************
*
* FUNCTION: LnInitLengthsWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Walk callback to initialize (and re-initialize) the node
* subtree length(s) to zero. The Subtree lengths are bubbled
* up to the root node in order to get a total AML length.
*
******************************************************************************/
ACPI_STATUS
LnInitLengthsWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
Op->Asl.AmlSubtreeLength = 0;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LnPackageLengthWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Walk callback to calculate the total AML length.
* 1) Calculate the AML lengths (opcode, package length, etc.) for
* THIS node.
* 2) Bubbble up all of these lengths to the parent node by summing
* them all into the parent subtree length.
*
* Note: The SubtreeLength represents the total AML length of all child nodes
* in all subtrees under a given node. Therefore, once this walk is
* complete, the Root Node subtree length is the AML length of the entire
* tree (and thus, the entire ACPI table)
*
******************************************************************************/
ACPI_STATUS
LnPackageLengthWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/* Generate the AML lengths for this node */
CgGenerateAmlLengths (Op);
/* Bubble up all lengths (this node and all below it) to the parent */
if ((Op->Asl.Parent) &&
(Op->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
{
Op->Asl.Parent->Asl.AmlSubtreeLength += (Op->Asl.AmlLength +
Op->Asl.AmlOpcodeLength +
Op->Asl.AmlPkgLenBytes +
Op->Asl.AmlSubtreeLength);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LnAdjustLengthToRoot
*
* PARAMETERS: Op - Node whose Length was changed
*
* RETURN: None.
*
* DESCRIPTION: Change the Subtree length of the given node, and bubble the
* change all the way up to the root node. This allows for
* last second changes to a package length (for example, if the
* package length encoding gets shorter or longer.)
*
******************************************************************************/
void
LnAdjustLengthToRoot (
ACPI_PARSE_OBJECT *SubtreeOp,
UINT32 LengthDelta)
{
ACPI_PARSE_OBJECT *Op;
/* Adjust all subtree lengths up to the root */
Op = SubtreeOp->Asl.Parent;
while (Op)
{
Op->Asl.AmlSubtreeLength -= LengthDelta;
Op = Op->Asl.Parent;
}
/* Adjust the global table length */
Gbl_TableLength -= LengthDelta;
}
/*******************************************************************************
*
* FUNCTION: CgGetPackageLenByteCount
*
* PARAMETERS: Op - Parse node
* PackageLength - Length to be encoded
*
* RETURN: Required length of the package length encoding
*
* DESCRIPTION: Calculate the number of bytes required to encode the given
* package length.
*
******************************************************************************/
UINT8
CgGetPackageLenByteCount (
ACPI_PARSE_OBJECT *Op,
UINT32 PackageLength)
{
/*
* Determine the number of bytes required to encode the package length
* Note: the package length includes the number of bytes used to encode
* the package length, so we must account for this also.
*/
if (PackageLength <= (0x0000003F - 1))
{
return (1);
}
else if (PackageLength <= (0x00000FFF - 2))
{
return (2);
}
else if (PackageLength <= (0x000FFFFF - 3))
{
return (3);
}
else if (PackageLength <= (0x0FFFFFFF - 4))
{
return (4);
}
else
{
/* Fatal error - the package length is too large to encode */
AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, Op, NULL);
}
return (0);
}
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlOpcodeLength
*
* PARAMETERS: Op - Parse node whose AML opcode lengths will be
* calculated
*
* RETURN: None.
*
* DESCRIPTION: Calculate the AmlOpcodeLength, AmlPkgLenBytes, and AmlLength
* fields for this node.
*
******************************************************************************/
void
CgGenerateAmlOpcodeLength (
ACPI_PARSE_OBJECT *Op)
{
/* Check for two-byte opcode */
if (Op->Asl.AmlOpcode > 0x00FF)
{
Op->Asl.AmlOpcodeLength = 2;
}
else
{
Op->Asl.AmlOpcodeLength = 1;
}
/* Does this opcode have an associated "PackageLength" field? */
Op->Asl.AmlPkgLenBytes = 0;
if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
{
Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, Op->Asl.AmlSubtreeLength);
}
/* Data opcode lengths are easy */
switch (Op->Asl.AmlOpcode)
{
case AML_BYTE_OP:
Op->Asl.AmlLength = 1;
break;
case AML_WORD_OP:
Op->Asl.AmlLength = 2;
break;
case AML_DWORD_OP:
Op->Asl.AmlLength = 4;
break;
case AML_QWORD_OP:
Op->Asl.AmlLength = 8;
break;
default:
/* All data opcodes must be above */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlLengths
*
* PARAMETERS: Op - Parse node
*
* RETURN: None.
*
* DESCRIPTION: Generate internal length fields based on the AML opcode or
* parse opcode.
*
******************************************************************************/
void
CgGenerateAmlLengths (
ACPI_PARSE_OBJECT *Op)
{
char *Buffer;
ACPI_STATUS Status;
switch (Op->Asl.AmlOpcode)
{
case AML_RAW_DATA_BYTE:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 1;
return;
case AML_RAW_DATA_WORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 2;
return;
case AML_RAW_DATA_DWORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 4;
return;
case AML_RAW_DATA_QWORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 8;
return;
case AML_RAW_DATA_BUFFER:
/* Aml length is/was set by creator */
Op->Asl.AmlOpcodeLength = 0;
return;
case AML_RAW_DATA_CHAIN:
/* Aml length is/was set by creator */
Op->Asl.AmlOpcodeLength = 0;
return;
default:
break;
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFINITIONBLOCK:
Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
break;
case PARSEOP_NAMESEG:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 4;
Op->Asl.ExternalName = Op->Asl.Value.String;
break;
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
if (Op->Asl.CompileFlags & NODE_NAME_INTERNALIZED)
{
break;
}
Op->Asl.AmlOpcodeLength = 0;
Status = UtInternalizeName (Op->Asl.Value.String, &Buffer);
if (ACPI_FAILURE (Status))
{
DbgPrint (ASL_DEBUG_OUTPUT,
"Failure from internalize name %X\n", Status);
break;
}
Op->Asl.ExternalName = Op->Asl.Value.String;
Op->Asl.Value.String = Buffer;
Op->Asl.CompileFlags |= NODE_NAME_INTERNALIZED;
Op->Asl.AmlLength = strlen (Buffer);
/*
* Check for single backslash reference to root,
* make it a null terminated string in the AML
*/
if (Op->Asl.AmlLength == 1)
{
Op->Asl.AmlLength = 2;
}
break;
case PARSEOP_STRING_LITERAL:
Op->Asl.AmlOpcodeLength = 1;
Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1; /* Get null terminator */
break;
case PARSEOP_PACKAGE_LENGTH:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, (UINT32) Op->Asl.Value.Integer);
break;
case PARSEOP_RAW_DATA:
Op->Asl.AmlOpcodeLength = 0;
break;
case PARSEOP_DEFAULT_ARG:
case PARSEOP_EXTERNAL:
case PARSEOP_INCLUDE:
case PARSEOP_INCLUDE_END:
/* Ignore the "default arg" nodes, they are extraneous at this point */
break;
default:
CgGenerateAmlOpcodeLength (Op);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,691 @@
/******************************************************************************
*
* Module Name: dswload - Dispatcher namespace load callbacks
* $Revision: 59 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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.
*
*****************************************************************************/
#define __ASLLOAD_C__
#include "aslcompiler.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslload")
/*******************************************************************************
*
* FUNCTION: LdLoadNamespace
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the
* named ASL/AML objects into the namespace. The namespace is
* constructed in order to resolve named references and references
* to named fields within resource templates/descriptors.
*
******************************************************************************/
ACPI_STATUS
LdLoadNamespace (
ACPI_PARSE_OBJECT *RootOp)
{
ACPI_WALK_STATE *WalkState;
DbgPrint (ASL_DEBUG_OUTPUT, "\nCreating namespace\n\n");
/* Create a new walk state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
return AE_NO_MEMORY;
}
/* Perform the walk of the parse tree */
TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin,
LdNamespace1End, WalkState);
/* Dump the namespace if debug is enabled */
AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX);
return AE_OK;
}
/*******************************************************************************
*
* FUNCTION: LdLoadFieldElements
*
* PARAMETERS: Op - Parent node (Field)
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Enter the named elements of the field (children of the parent)
* into the namespace.
*
******************************************************************************/
ACPI_STATUS
LdLoadFieldElements (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Child = NULL;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
/* Get the first named field element */
switch (Op->Asl.AmlOpcode)
{
case AML_BANK_FIELD_OP:
Child = UtGetArg (Op, 6);
break;
case AML_INDEX_FIELD_OP:
Child = UtGetArg (Op, 5);
break;
case AML_FIELD_OP:
Child = UtGetArg (Op, 4);
break;
default:
/* No other opcodes should arrive here */
return (AE_BAD_PARAMETER);
}
/* Enter all elements into the namespace */
while (Child)
{
switch (Child->Asl.AmlOpcode)
{
case AML_INT_RESERVEDFIELD_OP:
case AML_INT_ACCESSFIELD_OP:
break;
default:
Status = AcpiNsLookup (WalkState->ScopeInfo, Child->Asl.Value.String,
ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_IMODE_LOAD_PASS1,
ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
NULL, &Node);
if (ACPI_FAILURE (Status))
{
if (Status != AE_ALREADY_EXISTS)
{
return (Status);
}
/*
* The name already exists in this scope
* But continue processing the elements
*/
AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, Child->Asl.Value.String);
}
else
{
Child->Asl.Node = Node;
Node->Object = (ACPI_OPERAND_OBJECT *) Child;
}
break;
}
Child = Child->Asl.Next;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LdLoadResourceElements
*
* PARAMETERS: Op - Parent node (Resource Descriptor)
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Enter the named elements of the resource descriptor (children
* of the parent) into the namespace.
*
* NOTE: In the real AML namespace, these named elements never exist. But
* we simply use the namespace here as a symbol table so we can look
* them up as they are referenced.
*
******************************************************************************/
ACPI_STATUS
LdLoadResourceElements (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *InitializerOp = NULL;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
/*
* Enter the resouce name into the namespace
* This opens a scope
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath,
ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH,
WalkState, &Node);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Now enter the predefined fields, for easy lookup when referenced
* by the source ASL
*/
InitializerOp = ASL_GET_CHILD_NODE (Op);
while (InitializerOp)
{
if (InitializerOp->Asl.ExternalName)
{
Status = AcpiNsLookup (WalkState->ScopeInfo,
InitializerOp->Asl.ExternalName,
ACPI_TYPE_LOCAL_RESOURCE_FIELD,
ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE,
NULL, &Node);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Store the field offset in the namespace node so it
* can be used when the field is referenced
*/
Node->OwnerId = (UINT16) InitializerOp->Asl.Value.Integer;
InitializerOp->Asl.Node = Node;
Node->Object = (ACPI_OPERAND_OBJECT *) InitializerOp;
/* Pass thru the field type (Bitfield or Bytefield) */
if (InitializerOp->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
{
Node->Flags |= ANOBJ_IS_BIT_OFFSET;
}
}
InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LdNamespace1Begin
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Descending callback used during the parse tree walk. If this
* is a named AML opcode, enter into the namespace
*
******************************************************************************/
ACPI_STATUS
LdNamespace1Begin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE ObjectType;
ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY;
char *Path;
UINT32 Flags = ACPI_NS_NO_UPSEARCH;
ACPI_PARSE_OBJECT *Arg;
UINT32 i;
ACPI_FUNCTION_NAME ("LdNamespace1Begin");
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
Op, Op->Asl.ParseOpName));
/*
* We are only interested in opcodes that have an associated name
* (or multiple names)
*/
switch (Op->Asl.AmlOpcode)
{
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_FIELD_OP:
Status = LdLoadFieldElements (Op, WalkState);
return (Status);
default:
/* All other opcodes go below */
break;
}
/* Check if this object has already been installed in the namespace */
if (Op->Asl.Node)
{
return (AE_OK);
}
Path = Op->Asl.Namepath;
if (!Path)
{
return (AE_OK);
}
/* Map the raw opcode into an internal object type */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_NAME:
Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */
Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */
/* Get the data type associated with the named object, not the name itself */
/* Log2 loop to convert from Btype (binary) to Etype (encoded) */
ObjectType = 1;
for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2)
{
ObjectType++;
}
break;
case PARSEOP_EXTERNAL:
/*
* "External" simply enters a name and type into the namespace.
* We must be careful to not open a new scope, however, no matter
* what type the external name refers to (e.g., a method)
*
* first child is name, next child is ObjectType
*/
ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer;
ObjectType = ACPI_TYPE_ANY;
break;
case PARSEOP_DEFAULT_ARG:
if(Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC)
{
Status = LdLoadResourceElements (Op, WalkState);
goto Exit;
}
ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
break;
case PARSEOP_SCOPE:
/*
* The name referenced by Scope(Name) must already exist at this point.
* In other words, forward references for Scope() are not supported.
* The only real reason for this is that the MS interpreter cannot
* handle this case. Perhaps someday this case can go away.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
if (Status == AE_NOT_FOUND)
{
/* The name was not found, go ahead and create it */
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_LOCAL_SCOPE,
ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
/*
* However, this is an error -- primarily because the MS
* interpreter can't handle a forward reference from the
* Scope() operator.
*/
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, Op->Asl.ExternalName);
goto FinishNode;
}
AslCoreSubsystemError (Op, Status, "Failure from lookup\n", FALSE);
goto Exit;
}
/* We found a node with this name, now check the type */
switch (Node->Type)
{
case ACPI_TYPE_LOCAL_SCOPE:
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
/* These are acceptable types - they all open a new scope */
break;
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* These types we will allow, but we will change the type. This
* enables some existing code of the form:
*
* Name (DEB, 0)
* Scope (DEB) { ... }
*
* Which is used to workaround the fact that the MS interpreter
* does not allow Scope() forward references.
*/
sprintf (MsgBuffer, "%s, %s, Changing type to (Scope)",
Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
/*
* Switch the type
*/
Node->Type = ACPI_TYPE_ANY;
break;
default:
/*
* All other types are an error
*/
sprintf (MsgBuffer, "%s, %s", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer);
/*
* However, switch the type to be an actual scope so
* that compilation can continue without generating a whole
* cascade of additional errors.
*/
Node->Type = ACPI_TYPE_ANY;
break;
}
Status = AE_OK;
goto FinishNode;
default:
ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
break;
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n",
Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType)));
/* The name must not already exist */
Flags |= ACPI_NS_ERROR_IF_FOUND;
/*
* Enter the named type into the internal namespace. We enter the name
* as we go downward in the parse tree. Any necessary subobjects that involve
* arguments to the opcode must be created as we go back up the parse tree later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
if (Status == AE_ALREADY_EXISTS)
{
/* The name already exists in this scope */
if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
{
Node->Type = (UINT8) ObjectType;
Status = AE_OK;
}
else
{
AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, Op->Asl.ExternalName);
Status = AE_OK;
goto Exit;
}
}
else
{
AslCoreSubsystemError (Op, Status, "Failure from lookup %s\n", FALSE);
goto Exit;
}
}
FinishNode:
/*
* Point the parse node to the new namespace node, and point
* the Node back to the original Parse node
*/
Op->Asl.Node = Node;
Node->Object = (ACPI_OPERAND_OBJECT *) Op;
/* Set the actual data type if appropriate (EXTERNAL term only) */
if (ActualObjectType != ACPI_TYPE_ANY)
{
Node->Type = (UINT8) ActualObjectType;
Node->OwnerId = ASL_EXTERNAL_METHOD;
}
if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
{
/*
* Get the method argument count from "Extra" and store
* it in the OwnerId field of the namespace node
*/
Node->OwnerId = (UINT16) Op->Asl.Extra;
}
Exit:
return (Status);
}
/*******************************************************************************
*
* FUNCTION: LdNamespace1End
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback used during the loading of the namespace,
* We only need to worry about managing the scope stack here.
*
******************************************************************************/
ACPI_STATUS
LdNamespace1End (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
ACPI_OBJECT_TYPE ObjectType;
ACPI_FUNCTION_NAME ("LdNamespace1End");
/* We are only interested in opcodes that have an associated name */
if (!Op->Asl.Namepath)
{
return (AE_OK);
}
/* Get the type to determine if we should pop the scope */
if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) &&
(Op->Asl.CompileFlags == NODE_IS_RESOURCE_DESC))
{
/* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */
ObjectType = ACPI_TYPE_LOCAL_RESOURCE;
}
else
{
ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
}
/* Pop the scope stack */
if (AcpiNsOpensScope (ObjectType))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"(%s): Popping scope for Op [%s] %p\n",
AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op));
AcpiDsScopeStackPop (WalkState);
}
return (AE_OK);
}

View File

@ -0,0 +1,974 @@
/******************************************************************************
*
* Module Name: asllookup- Namespace lookup
* $Revision: 82 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "acdispat.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asllookup")
/*******************************************************************************
*
* FUNCTION: LsDoOneNamespaceObject
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Dump a namespace object to the namespace output file.
* Called during the walk of the namespace to dump all objects.
*
******************************************************************************/
ACPI_STATUS
LsDoOneNamespaceObject (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_PARSE_OBJECT *Op;
Gbl_NumNamespaceObjects++;
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5d [%d] %*s %4.4s - %s",
Gbl_NumNamespaceObjects, Level, (Level * 3), " ",
&Node->Name,
AcpiUtGetTypeName (Node->Type));
Op = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
if (Op)
{
if (Op->Asl.ParseOpcode == PARSEOP_NAME)
{
Op = Op->Asl.Child;
}
switch (Node->Type)
{
case ACPI_TYPE_INTEGER:
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
if (Op->Asl.Value.Integer > ACPI_UINT32_MAX)
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X%X]",
ACPI_HIDWORD (Op->Asl.Value.Integer64), (UINT32) Op->Asl.Value.Integer);
}
else
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X]",
(UINT32) Op->Asl.Value.Integer);
}
break;
case ACPI_TYPE_STRING:
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = \"%s\"]",
Op->Asl.Value.String);
break;
case ACPI_TYPE_LOCAL_REGION_FIELD:
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Child;
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Offset 0x%02X, Length 0x%02X]",
Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer);
break;
default:
/* Nothing to do for other types */
break;
}
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LsDisplayNamespace
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Walk the namespace an display information about each node
* in the tree. Information is written to the optional
* namespace output file.
*
******************************************************************************/
ACPI_STATUS
LsDisplayNamespace (
void)
{
ACPI_STATUS Status;
if (!Gbl_NsOutputFlag)
{
return (AE_OK);
}
/* File header */
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n");
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n");
/* Walk entire namespace from the root */
Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject,
NULL, NULL);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: LsCompareOneNamespaceObject
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Compare name of one object.
*
******************************************************************************/
ACPI_STATUS
LsCompareOneNamespaceObject (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
/* Simply check the name */
if (*((UINT32 *) (Context)) == Node->Name.Integer)
{
/* Abort walk if we found one instance */
return (AE_CTRL_TRUE);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LkObjectExists
*
* PARAMETERS: Name - 4 char ACPI name
*
* RETURN: TRUE if name exists in namespace
*
* DESCRIPTION: Walk the namespace to find an object
*
******************************************************************************/
BOOLEAN
LkObjectExists (
char *Name)
{
ACPI_STATUS Status;
/* Walk entire namespace from the supplied root */
Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject,
Name, NULL);
if (Status == AE_CTRL_TRUE)
{
/* At least one instance of the name was found */
return (TRUE);
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: LkCrossReferenceNamespace
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Perform a cross reference check of the parse tree against the
* namespace. Every named referenced within the parse tree
* should be get resolved with a namespace lookup. If not, the
* original reference in the ASL code is invalid -- i.e., refers
* to a non-existent object.
*
* NOTE: The ASL "External" operator causes the name to be inserted into the
* namespace so that references to the external name will be resolved
* correctly here.
*
******************************************************************************/
ACPI_STATUS
LkCrossReferenceNamespace (
void)
{
ACPI_WALK_STATE *WalkState;
DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n");
/*
* Create a new walk state for use when looking up names
* within the namespace (Passed as context to the callbacks)
*/
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
return AE_NO_MEMORY;
}
/* Walk the entire parse tree */
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin,
LkNamespaceLocateEnd, WalkState);
return AE_OK;
}
/*******************************************************************************
*
* FUNCTION: LkCheckFieldRange
*
* PARAMETERS: RegionBitLength - Length of entire parent region
* FieldBitOffset - Start of the field unit (within region)
* FieldBitLength - Entire length of field unit
* AccessBitWidth - Access width of the field unit
*
* RETURN: None
*
* DESCRIPTION: Check one field unit to make sure it fits in the parent
* op region.
*
* Note: AccessBitWidth must be either 8,16,32, or 64
*
******************************************************************************/
void
LkCheckFieldRange (
ACPI_PARSE_OBJECT *Op,
UINT32 RegionBitLength,
UINT32 FieldBitOffset,
UINT32 FieldBitLength,
UINT32 AccessBitWidth)
{
UINT32 FieldEndBitOffset;
/*
* Check each field unit against the region size. The entire
* field unit (start offset plus length) must fit within the
* region.
*/
FieldEndBitOffset = FieldBitOffset + FieldBitLength;
if (FieldEndBitOffset > RegionBitLength)
{
/* Field definition itself is beyond the end-of-region */
AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
return;
}
/*
* Now check that the field plus AccessWidth doesn't go beyond
* the end-of-region. Assumes AccessBitWidth is a power of 2
*/
FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
if (FieldEndBitOffset > RegionBitLength)
{
/* Field definition combined with the access is beyond EOR */
AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
}
}
/*******************************************************************************
*
* FUNCTION: LkNamespaceLocateBegin
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Descending callback used during cross-reference. For named
* object references, attempt to locate the name in the
* namespace.
*
* NOTE: ASL references to named fields within resource descriptors are
* resolved to integer values here. Therefore, this step is an
* important part of the code generation. We don't know that the
* name refers to a resource descriptor until now.
*
******************************************************************************/
ACPI_STATUS
LkNamespaceLocateBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE ObjectType;
char *Path;
UINT8 PassedArgs;
ACPI_PARSE_OBJECT *NextOp;
ACPI_PARSE_OBJECT *OwningOp;
ACPI_PARSE_OBJECT *SpaceIdOp;
UINT32 MinimumLength;
UINT32 Temp;
const ACPI_OPCODE_INFO *OpInfo;
UINT32 Flags;
ACPI_FUNCTION_TRACE_PTR ("LkNamespaceLocateBegin", Op);
/*
* If this node is the actual declaration of a name
* [such as the XXXX name in "Method (XXXX)"],
* we are not interested in it here. We only care about names that are
* references to other objects within the namespace and the parent objects
* of name declarations
*/
if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
{
return (AE_OK);
}
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
if ((!(OpInfo->Flags & AML_NAMED)) &&
(!(OpInfo->Flags & AML_CREATE)) &&
(Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
(Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
(Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
{
return (AE_OK);
}
/*
* We must enable the "search-to-root" for single NameSegs, but
* we have to be very careful about opening up scopes
*/
Flags = ACPI_NS_SEARCH_PARENT;
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
/*
* These are name references, do not push the scope stack
* for them.
*/
Flags |= ACPI_NS_DONT_OPEN_SCOPE;
}
/* Get the NamePath from the appropriate place */
if (OpInfo->Flags & AML_NAMED)
{
/* For all NAMED operators, the name reference is the first child */
Path = Op->Asl.Child->Asl.Value.String;
if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
{
/*
* ALIAS is the only oddball opcode, the name declaration
* (alias name) is the second operand
*/
Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
}
}
else if (OpInfo->Flags & AML_CREATE)
{
/* Name must appear as the last parameter */
NextOp = Op->Asl.Child;
while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
{
NextOp = NextOp->Asl.Next;
}
Path = NextOp->Asl.Value.String;
}
else
{
Path = Op->Asl.Value.String;
}
ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
/*
* Lookup the name in the namespace. Name must exist at this point, or it
* is an invalid reference.
*
* The namespace is also used as a lookup table for references to resource
* descriptors and the fields within them.
*/
Gbl_NsLookupCount++;
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
if (Status == AE_NOT_FOUND)
{
/*
* We didn't find the name reference by path -- we can qualify this
* a little better before we print an error message
*/
if (strlen (Path) == ACPI_NAME_SIZE)
{
/* A simple, one-segment ACPI name */
if (LkObjectExists (Path))
{
/* There exists such a name, but we couldn't get to it from this scope */
AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, Op->Asl.ExternalName);
}
else
{
/* The name doesn't exist, period */
AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
}
}
else
{
/* Check for a fully qualified path */
if (Path[0] == AML_ROOT_PREFIX)
{
/* Gave full path, the object does not exist */
AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
}
else
{
/* We can't tell whether it doesn't exist or just can't be reached. */
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
}
}
Status = AE_OK;
}
return (Status);
}
/* Attempt to optimize the NamePath */
OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
/*
* Dereference an alias. (A name reference that is an alias.)
* Aliases are not nested; The alias always points to the final object
*/
if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
{
/* This node points back to the original PARSEOP_ALIAS */
NextOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
/* The first child is the alias target op */
NextOp = NextOp->Asl.Child;
/* Who in turn points back to original target alias node */
if (NextOp->Asl.Node)
{
Node = NextOp->Asl.Node;
}
else
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "Missing alias link");
}
}
/* 1) Check for a reference to a resource descriptor */
else if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
(Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
{
/*
* This was a reference to a field within a resource descriptor. Extract
* the associated field offset (either a bit or byte offset depending on
* the field type) and change the named reference into an integer for
* AML code generation
*/
Temp = (UINT32) Node->OwnerId;
if (Node->Flags & ANOBJ_IS_BIT_OFFSET)
{
Op->Asl.CompileFlags |= NODE_IS_BIT_OFFSET;
}
/* Perform BitOffset <--> ByteOffset conversion if necessary */
switch (Op->Asl.Parent->Asl.AmlOpcode)
{
case AML_CREATE_FIELD_OP:
/* We allow a Byte offset to Bit Offset conversion for this op */
if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
{
/* Simply multiply byte offset times 8 to get bit offset */
Temp = ACPI_MUL_8 (Temp);
}
break;
case AML_CREATE_BIT_FIELD_OP:
/* This op requires a Bit Offset */
if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
{
AslError (ASL_ERROR, ASL_MSG_BYTES_TO_BITS, Op, NULL);
}
break;
case AML_CREATE_BYTE_FIELD_OP:
case AML_CREATE_WORD_FIELD_OP:
case AML_CREATE_DWORD_FIELD_OP:
case AML_CREATE_QWORD_FIELD_OP:
case AML_INDEX_OP:
/* These Ops require Byte offsets */
if (Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
{
AslError (ASL_ERROR, ASL_MSG_BITS_TO_BYTES, Op, NULL);
}
break;
default:
/* Nothing to do for other opcodes */
break;
}
/* Now convert this node to an integer whose value is the field offset */
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
Op->Asl.Value.Integer = (UINT64) Temp;
Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
OpcGenerateAmlOpcode (Op);
Op->Asl.AmlLength = OpcSetOptimalIntegerSize (Op);
}
/* 2) Check for a method invocation */
else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
(Node->Type == ACPI_TYPE_METHOD) &&
(Op->Asl.Parent) &&
(Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
/*
* There are two types of method invocation:
* 1) Invocation with arguments -- the parser recognizes this as a METHODCALL
* 2) Invocation with no arguments --the parser cannot determine that this is a method
* invocation, therefore we have to figure it out here.
*/
if (Node->Type != ACPI_TYPE_METHOD)
{
sprintf (MsgBuffer, "%s is a %s", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
return (AE_OK);
}
/* Save the method node in the caller's op */
Op->Asl.Node = Node;
if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
{
return (AE_OK);
}
/*
* This is a method invocation, with or without arguments.
* Count the number of arguments, each appears as a child
* under the parent node
*/
Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
UtSetParseOpName (Op);
PassedArgs = 0;
NextOp = Op->Asl.Child;
while (NextOp)
{
PassedArgs++;
NextOp = NextOp->Asl.Next;
}
if (Node->OwnerId != ASL_EXTERNAL_METHOD)
{
/*
* Check the parsed arguments with the number expected by the
* method declaration itself
*/
if (PassedArgs != Node->OwnerId)
{
sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName,
Node->OwnerId);
if (PassedArgs < Node->OwnerId)
{
AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
}
else
{
AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
}
}
}
}
/*
* 3) Check for an ASL Field definition
*/
else if ((Op->Asl.Parent) &&
((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
{
/*
* Offset checking for fields. If the parent operation region has a
* constant length (known at compile time), we can check fields
* defined in that region against the region length. This will catch
* fields and field units that cannot possibly fit within the region.
*
* Note: Index fields do not directly reference an operation region,
* thus they are not included in this check.
*/
if (Op == Op->Asl.Parent->Asl.Child)
{
/*
* This is the first child of the field node, which is
* the name of the region. Get the parse node for the
* region -- which contains the length of the region.
*/
OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
Op->Asl.Parent->Asl.ExtraValue = ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
/* Examine the field access width */
switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
{
case AML_FIELD_ACCESS_ANY:
case AML_FIELD_ACCESS_BYTE:
case AML_FIELD_ACCESS_BUFFER:
default:
MinimumLength = 1;
break;
case AML_FIELD_ACCESS_WORD:
MinimumLength = 2;
break;
case AML_FIELD_ACCESS_DWORD:
MinimumLength = 4;
break;
case AML_FIELD_ACCESS_QWORD:
MinimumLength = 8;
break;
}
/*
* Is the region at least as big as the access width?
* Note: DataTableRegions have 0 length
*/
if (((UINT32) OwningOp->Asl.Value.Integer) &&
((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
{
AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
}
/*
* Check EC/CMOS/SMBUS fields to make sure that the correct
* access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
*/
SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
{
case REGION_EC:
case REGION_CMOS:
if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
{
AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
}
break;
case REGION_SMBUS:
if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
{
AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
}
break;
default:
/* Nothing to do for other address spaces */
break;
}
}
else
{
/*
* This is one element of the field list. Check to make sure
* that it does not go beyond the end of the parent operation region.
*
* In the code below:
* Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
* Op->Asl.ExtraValue - Field start offset (bits)
* Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
* Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
*/
if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
{
LkCheckFieldRange (Op,
Op->Asl.Parent->Asl.ExtraValue,
Op->Asl.ExtraValue,
(UINT32) Op->Asl.Child->Asl.Value.Integer,
Op->Asl.Child->Asl.ExtraValue);
}
}
}
Op->Asl.Node = Node;
return (Status);
}
/*******************************************************************************
*
* FUNCTION: LkNamespaceLocateEnd
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback used during cross reference. We only
* need to worry about scope management here.
*
******************************************************************************/
ACPI_STATUS
LkNamespaceLocateEnd (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
const ACPI_OPCODE_INFO *OpInfo;
ACPI_FUNCTION_TRACE ("LkNamespaceLocateEnd");
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
if (!(OpInfo->Flags & AML_NAMED))
{
return (AE_OK);
}
/* Not interested in name references, we did not open a scope for them */
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
return (AE_OK);
}
/* Pop the scope stack if necessary */
if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"%s: Popping scope for Op %p\n",
AcpiUtGetTypeName (OpInfo->ObjectType), Op));
AcpiDsScopeStackPop (WalkState);
}
return (AE_OK);
}

View File

@ -0,0 +1,794 @@
/******************************************************************************
*
* Module Name: aslmain - compiler main and utilities
* $Revision: 75 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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.
*
*****************************************************************************/
#define _DECLARE_GLOBALS
#include "aslcompiler.h"
#include "acnamesp.h"
#include "acapps.h"
#ifdef _DEBUG
#include <crtdbg.h>
#endif
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmain")
BOOLEAN AslToFile = TRUE;
BOOLEAN DoCompile = TRUE;
BOOLEAN DoSignon = TRUE;
char hex[] = {'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'};
/*******************************************************************************
*
* FUNCTION: Options
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display option help message
*
******************************************************************************/
void
Options (
void)
{
printf ("General Output:\n");
printf (" -p <prefix> Specify filename prefix for all output files (including .aml)\n");
printf (" -vi Less verbose errors and warnings for use with IDEs\n");
printf (" -vo Enable optimization comments\n");
printf (" -vr Disable remarks\n");
printf (" -vs Disable signon\n");
printf ("\nAML Output:\n");
printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n");
printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n");
printf (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n");
printf ("\nAML Optimization:\n");
printf (" -oa Disable all optimizations (compatibility mode)\n");
printf (" -of Disable constant folding\n");
printf (" -oi Disable integer optimization to Zero/One/Ones\n");
printf (" -on Disable named reference string optimization\n");
printf ("\nListings:\n");
printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n");
printf (" -ln Create namespace file (*.nsp)\n");
printf (" -ls Create combined source file (expanded includes) (*.src)\n");
printf ("\nAML Disassembler:\n");
printf (" -d [file] Disassemble AML to ASL source code file (*.dsl)\n");
printf (" -dc [file] Disassemble AML and immediately compile it\n");
printf (" (Obtain DSDT from current system if no input file)\n");
printf (" -e Generate External() statements for unresolved symbols\n");
printf (" -g Get ACPI tables and write to files (*.dat)\n");
printf ("\nHelp:\n");
printf (" -h Additional help and compiler debug options\n");
printf (" -hc Display operators allowed in constant expressions\n");
printf (" -hr Display ACPI reserved method names\n");
}
/*******************************************************************************
*
* FUNCTION: Usage
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display help message
*
******************************************************************************/
void
HelpMessage (
void)
{
printf ("AML output filename generation:\n");
printf (" Output filenames are generated by appending an extension to a common\n");
printf (" filename prefix. The filename prefix is obtained via one of the\n");
printf (" following methods (in priority order):\n");
printf (" 1) The -p option specifies the prefix\n");
printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n");
printf (" 3) The prefix of the input filename\n");
printf ("\n");
Options ();
printf ("\nCompiler Debug Options:\n");
printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n");
printf (" Types: Parse/Tree/Both\n");
printf (" -f Ignore errors, force creation of AML output file(s)\n");
printf (" -c Parse only, no output generation\n");
printf (" -ot Display compile times\n");
printf (" -x<level> Set debug level for trace output\n");
}
/*******************************************************************************
*
* FUNCTION: Usage
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display usage and option message
*
******************************************************************************/
void
Usage (
void)
{
printf ("Usage: %s [Options] [InputFile]\n\n", CompilerName);
Options ();
}
/*******************************************************************************
*
* FUNCTION: AslInitialize
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Initialize compiler globals
*
******************************************************************************/
void
AslInitialize (void)
{
UINT32 i;
#ifdef _DEBUG
_CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
#endif
AcpiDbgLevel = 0;
for (i = 0; i < ASL_NUM_FILES; i++)
{
Gbl_Files[i].Handle = NULL;
Gbl_Files[i].Filename = NULL;
}
Gbl_Files[ASL_FILE_STDOUT].Handle = stdout;
Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
Gbl_Files[ASL_FILE_STDERR].Handle = stderr;
Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
}
/*******************************************************************************
*
* FUNCTION: AslCommandLine
*
* PARAMETERS: argc/argv
*
* RETURN: None
*
* DESCRIPTION: Command line processing
*
******************************************************************************/
void
AslCommandLine (
int argc,
char **argv)
{
BOOLEAN BadCommandLine = FALSE;
ACPI_NATIVE_UINT j;
/* Minimum command line contains at least one option or an input file */
if (argc < 2)
{
AslCompilerSignon (ASL_FILE_STDOUT);
Usage ();
exit (1);
}
/* Get the command line options */
while ((j = AcpiGetopt (argc, argv, "b:cd^efgh^i^l^o:p:rs:t:v:x:")) != EOF) switch (j)
{
case 'b':
switch (AcpiGbl_Optarg[0])
{
case 'b':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 'p':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 't':
break;
default:
printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
/* Produce debug output file */
Gbl_DebugFlag = TRUE;
break;
case 'c':
/* Parse only */
Gbl_ParseOnlyFlag = TRUE;
break;
case 'd':
switch (AcpiGbl_Optarg[0])
{
case '^':
DoCompile = FALSE;
break;
case 'c':
break;
default:
printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
Gbl_DisasmFlag = TRUE;
break;
case 'e':
/* Generate external statements for unresolved symbols */
Gbl_GenerateExternals = TRUE;
break;
case 'f':
/* Ignore errors and force creation of aml file */
Gbl_IgnoreErrors = TRUE;
break;
case 'g':
/* Get all ACPI tables */
Gbl_GetAllTables = TRUE;
DoCompile = FALSE;
break;
case 'h':
switch (AcpiGbl_Optarg[0])
{
case '^':
HelpMessage ();
exit (0);
case 'c':
UtDisplayConstantOpcodes ();
exit (0);
case 'r':
/* reserved names */
MpDisplayReservedNames ();
exit (0);
default:
printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'i':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code include file */
Gbl_AsmIncludeOutputFlag = TRUE;
break;
case 'c':
/* Produce C include file */
Gbl_C_IncludeOutputFlag = TRUE;
break;
default:
printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'l':
switch (AcpiGbl_Optarg[0])
{
case '^':
/* Produce listing file (Mixed source/aml) */
Gbl_ListingFlag = TRUE;
break;
case 'n':
/* Produce namespace file */
Gbl_NsOutputFlag = TRUE;
break;
case 's':
/* Produce combined source file */
Gbl_SourceOutputFlag = TRUE;
break;
default:
printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'o':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Disable all optimizations */
Gbl_FoldConstants = FALSE;
Gbl_IntegerOptimizationFlag = FALSE;
Gbl_ReferenceOptimizationFlag = FALSE;
break;
case 'f':
/* Disable folding on "normal" expressions */
Gbl_FoldConstants = FALSE;
break;
case 'i':
/* Disable integer optimization to constants */
Gbl_IntegerOptimizationFlag = FALSE;
break;
case 'n':
/* Disable named reference optimization */
Gbl_ReferenceOptimizationFlag = FALSE;
break;
case 't':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
break;
default:
printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'p':
/* Override default AML output filename */
Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
Gbl_UseDefaultAmlFilename = FALSE;
break;
case 'r':
AslToFile = FALSE;
break;
case 's':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code output file */
Gbl_AsmOutputFlag = TRUE;
break;
case 'c':
/* Produce C hex output file */
Gbl_C_OutputFlag = TRUE;
break;
default:
printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 't':
/* Produce hex table output file */
switch (AcpiGbl_Optarg[0])
{
case 'a':
Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
break;
case 'c':
Gbl_HexOutputFlag = HEX_OUTPUT_C;
break;
default:
printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'v':
switch (AcpiGbl_Optarg[0])
{
case 'i':
/* Less verbose error messages */
Gbl_VerboseErrors = FALSE;
break;
case 'o':
Gbl_DisplayOptimizations = TRUE;
break;
case 'r':
Gbl_DisplayRemarks = FALSE;
break;
case 's':
DoSignon = FALSE;
break;
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'x':
AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
break;
default:
BadCommandLine = TRUE;
break;
}
/* Next parameter must be the input filename */
Gbl_Files[ASL_FILE_INPUT].Filename = argv[AcpiGbl_Optind];
if (!Gbl_Files[ASL_FILE_INPUT].Filename && !Gbl_DisasmFlag && !Gbl_GetAllTables)
{
printf ("Missing input filename\n");
BadCommandLine = TRUE;
}
if (DoSignon)
{
AslCompilerSignon (ASL_FILE_STDOUT);
}
/* Abort if anything went wrong on the command line */
if (BadCommandLine)
{
printf ("\n");
Usage ();
exit (1);
}
if ((AcpiGbl_Optind + 1) < argc)
{
printf ("Warning: extra arguments (%d) after input filename are ignored\n\n",
argc - AcpiGbl_Optind - 1);
}
}
/*******************************************************************************
*
* FUNCTION: main
*
* PARAMETERS: Standard argc/argv
*
* RETURN: Program termination code
*
* DESCRIPTION: C main routine for the Asl Compiler. Handle command line
* options and begin the compile.
*
******************************************************************************/
int ACPI_SYSTEM_XFACE
main (
int argc,
char **argv)
{
ACPI_STATUS Status;
char *Prefix;
/* Init and command line */
AslInitialize ();
AslCommandLine (argc, argv);
/*
* If -p not specified, we will use the input filename as the
* output filename prefix
*/
FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
&Gbl_DirectoryPath, &Prefix);
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = Prefix;
}
/*
* AML Disassembly (Optional)
*/
if (Gbl_DisasmFlag || Gbl_GetAllTables)
{
/* ACPI CA subsystem initialization */
Status = AcpiOsInitialize ();
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
/* This is where the disassembly happens */
AcpiGbl_DbOpt_disasm = TRUE;
Status = AdAmlDisassemble (AslToFile,
Gbl_Files[ASL_FILE_INPUT].Filename,
Gbl_OutputFilenamePrefix,
&Gbl_Files[ASL_FILE_INPUT].Filename,
Gbl_GetAllTables);
if (ACPI_FAILURE (Status))
{
return -1;
}
/*
* Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
* .DSL disassembly file, which can now be compiled if requested
*/
if (DoCompile)
{
AcpiOsPrintf ("\nCompiling \"%s\"\n",
Gbl_Files[ASL_FILE_INPUT].Filename);
}
}
/*
* ASL Compilation (Optional)
*/
if (DoCompile)
{
/*
* If -p not specified, we will use the input filename as the
* output filename prefix
*/
FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
&Gbl_DirectoryPath, &Prefix);
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = Prefix;
}
/* ACPI CA subsystem initialization (Must be re-initialized) */
Status = AcpiOsInitialize ();
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = CmDoCompile ();
}
return (0);
}

View File

@ -0,0 +1,687 @@
/******************************************************************************
*
* Module Name: aslmap - parser to AML opcode mapping table
* $Revision: 70 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "acparser.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmap")
/*******************************************************************************
*
* FUNCTION: AslMapNamedOpcodeToDataType
*
* PARAMETERS: Opcode - The Named AML opcode to map
*
* RETURN: The ACPI type associated with the named opcode
*
* DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
* Named opcodes are a subset of the AML opcodes.
*
******************************************************************************/
ACPI_OBJECT_TYPE
AslMapNamedOpcodeToDataType (
UINT16 Opcode)
{
const ACPI_OPCODE_INFO *OpInfo;
/*
* There are some differences from the opcode table types, we
* catch them here.
*/
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (Opcode == AML_INT_NAMEPATH_OP)
{
return (ACPI_TYPE_ANY);
}
if (Opcode == AML_INT_METHODCALL_OP)
{
return (ACPI_TYPE_ANY);
}
if (OpInfo->Flags & AML_NSOBJECT)
{
return (OpInfo->ObjectType);
}
return (ACPI_TYPE_ANY);
}
/*******************************************************************************
*
* DATA STRUCTURE: ReservedMethods
*
* DESCRIPTION: Contains all reserved methods and names as defined in the
* ACPI specification. Used during the analysis phase to
* ensure that reserved methods have the required number of
* arguments and the proper return type.
*
* Each entry in the table contains the following items:
*
* Name - The ACPI reserved name
* Args - Number of arguments to the method
* Flags - Whether this method must return a value or not
*
******************************************************************************/
const ASL_RESERVED_INFO ReservedMethods[] = {
{"_AC0", 0, ASL_RSVD_RETURN_VALUE},
{"_AC1", 0, ASL_RSVD_RETURN_VALUE},
{"_AC2", 0, ASL_RSVD_RETURN_VALUE},
{"_AC3", 0, ASL_RSVD_RETURN_VALUE},
{"_AC4", 0, ASL_RSVD_RETURN_VALUE},
{"_AC5", 0, ASL_RSVD_RETURN_VALUE},
{"_AC6", 0, ASL_RSVD_RETURN_VALUE},
{"_AC7", 0, ASL_RSVD_RETURN_VALUE},
{"_AC8", 0, ASL_RSVD_RETURN_VALUE},
{"_AC9", 0, ASL_RSVD_RETURN_VALUE},
{"_ADR", 0, ASL_RSVD_RETURN_VALUE},
{"_AL0", 0, ASL_RSVD_RETURN_VALUE},
{"_AL1", 0, ASL_RSVD_RETURN_VALUE},
{"_AL2", 0, ASL_RSVD_RETURN_VALUE},
{"_AL3", 0, ASL_RSVD_RETURN_VALUE},
{"_AL4", 0, ASL_RSVD_RETURN_VALUE},
{"_AL5", 0, ASL_RSVD_RETURN_VALUE},
{"_AL6", 0, ASL_RSVD_RETURN_VALUE},
{"_AL7", 0, ASL_RSVD_RETURN_VALUE},
{"_AL8", 0, ASL_RSVD_RETURN_VALUE},
{"_AL9", 0, ASL_RSVD_RETURN_VALUE},
{"_ALN", 0, ASL_RSVD_RESOURCE_NAME},
{"_ASI", 0, ASL_RSVD_RESOURCE_NAME},
{"_BAS", 0, ASL_RSVD_RESOURCE_NAME},
{"_BBN", 0, ASL_RSVD_RETURN_VALUE},
{"_BCL", 0, ASL_RSVD_RETURN_VALUE},
{"_BCM", 1, 0},
{"_BDN", 0, ASL_RSVD_RETURN_VALUE},
{"_BFS", 1, 0},
{"_BIF", 0, ASL_RSVD_RETURN_VALUE},
{"_BM_", 0, ASL_RSVD_RESOURCE_NAME},
{"_BST", 0, ASL_RSVD_RETURN_VALUE},
{"_BTP", 1, 0},
{"_CID", 0, ASL_RSVD_RETURN_VALUE},
{"_CRS", 0, ASL_RSVD_RETURN_VALUE},
{"_CRT", 0, ASL_RSVD_RETURN_VALUE},
{"_CST", 0, ASL_RSVD_RETURN_VALUE},
{"_DCK", 1, ASL_RSVD_RETURN_VALUE},
{"_DCS", 0, ASL_RSVD_RETURN_VALUE},
{"_DDC", 1, ASL_RSVD_RETURN_VALUE},
{"_DDN", 0, 0},
{"_DEC", 0, ASL_RSVD_RESOURCE_NAME},
{"_DGS", 0, ASL_RSVD_RETURN_VALUE},
{"_DIS", 0, 0},
{"_DMA", 0, ASL_RSVD_RETURN_VALUE},
{"_DOD", 0, ASL_RSVD_RETURN_VALUE},
{"_DOS", 1, 0},
{"_DSS", 1, 0},
{"_EC_", 0, ASL_RSVD_RETURN_VALUE},
{"_EDL", 0, ASL_RSVD_RETURN_VALUE},
{"_EJ0", 1, 0},
{"_EJ1", 1, 0},
{"_EJ2", 1, 0},
{"_EJ3", 1, 0},
{"_EJ4", 1, 0},
{"_EJD", 0, ASL_RSVD_RETURN_VALUE},
{"_FDE", 0, ASL_RSVD_RETURN_VALUE},
{"_FDI", 0, ASL_RSVD_RETURN_VALUE},
{"_FDM", 1, 0},
{"_FIX", 0, ASL_RSVD_RETURN_VALUE},
{"_GL_", 0, ASL_RSVD_RETURN_VALUE},
{"_GLK", 0, ASL_RSVD_RETURN_VALUE},
{"_GPD", 0, ASL_RSVD_RETURN_VALUE},
{"_GPE", 0, ASL_RSVD_RETURN_VALUE},
{"_GRA", 0, ASL_RSVD_RESOURCE_NAME},
{"_GTF", 0, ASL_RSVD_RETURN_VALUE},
{"_GTM", 0, ASL_RSVD_RETURN_VALUE},
{"_GTS", 1, 0},
{"_HE_", 0, ASL_RSVD_RESOURCE_NAME},
{"_HID", 0, ASL_RSVD_RETURN_VALUE},
{"_HOT", 0, ASL_RSVD_RETURN_VALUE},
{"_HPP", 0, ASL_RSVD_RETURN_VALUE},
{"_INI", 0, 0},
{"_INT", 0, ASL_RSVD_RESOURCE_NAME},
{"_IRC", 0, 0},
{"_LCK", 1, 0},
{"_LEN", 0, ASL_RSVD_RESOURCE_NAME},
{"_LID", 0, ASL_RSVD_RETURN_VALUE},
{"_LL_", 0, ASL_RSVD_RESOURCE_NAME},
{"_MAF", 0, ASL_RSVD_RESOURCE_NAME},
{"_MAT", 0, ASL_RSVD_RETURN_VALUE},
{"_MAX", 0, ASL_RSVD_RESOURCE_NAME},
{"_MEM", 0, ASL_RSVD_RESOURCE_NAME},
{"_MIF", 0, ASL_RSVD_RESOURCE_NAME},
{"_MIN", 0, ASL_RSVD_RESOURCE_NAME},
{"_MSG", 1, 0},
{"_OFF", 0, 0},
{"_ON_", 0, 0},
{"_OS_", 0, ASL_RSVD_RETURN_VALUE},
{"_OSI", 1, ASL_RSVD_RETURN_VALUE},
{"_PCL", 0, ASL_RSVD_RETURN_VALUE},
{"_PCT", 0, ASL_RSVD_RETURN_VALUE},
{"_PDC", 1, 0},
{"_PIC", 1, 0},
{"_PPC", 0, ASL_RSVD_RETURN_VALUE},
{"_PR0", 0, ASL_RSVD_RETURN_VALUE},
{"_PR1", 0, ASL_RSVD_RETURN_VALUE},
{"_PR2", 0, ASL_RSVD_RETURN_VALUE},
{"_PRS", 0, ASL_RSVD_RETURN_VALUE},
{"_PRT", 0, ASL_RSVD_RETURN_VALUE},
{"_PRW", 0, ASL_RSVD_RETURN_VALUE},
{"_PS0", 0, 0},
{"_PS1", 0, 0},
{"_PS2", 0, 0},
{"_PS3", 0, 0},
{"_PSC", 0, ASL_RSVD_RETURN_VALUE},
{"_PSL", 0, ASL_RSVD_RETURN_VALUE},
{"_PSR", 0, ASL_RSVD_RETURN_VALUE},
{"_PSS", 0, ASL_RSVD_RETURN_VALUE},
{"_PSV", 0, ASL_RSVD_RETURN_VALUE},
{"_PSW", 1, 0},
{"_PTC", 0, ASL_RSVD_RETURN_VALUE},
{"_PTS", 1, 0},
{"_PXM", 0, ASL_RSVD_RETURN_VALUE},
{"_RBO", 0, ASL_RSVD_RESOURCE_NAME},
{"_RBW", 0, ASL_RSVD_RESOURCE_NAME},
{"_REG", 2, 0},
{"_REV", 0, ASL_RSVD_RETURN_VALUE},
{"_RMV", 0, ASL_RSVD_RETURN_VALUE},
{"_RNG", 0, ASL_RSVD_RESOURCE_NAME},
{"_ROM", 2, ASL_RSVD_RETURN_VALUE},
{"_RW_", 0, ASL_RSVD_RESOURCE_NAME},
{"_S0_", 0, ASL_RSVD_RETURN_VALUE},
{"_S1_", 0, ASL_RSVD_RETURN_VALUE},
{"_S2_", 0, ASL_RSVD_RETURN_VALUE},
{"_S3_", 0, ASL_RSVD_RETURN_VALUE},
{"_S4_", 0, ASL_RSVD_RETURN_VALUE},
{"_S5_", 0, ASL_RSVD_RETURN_VALUE},
{"_S1D", 0, ASL_RSVD_RETURN_VALUE},
{"_S2D", 0, ASL_RSVD_RETURN_VALUE},
{"_S3D", 0, ASL_RSVD_RETURN_VALUE},
{"_S4D", 0, ASL_RSVD_RETURN_VALUE},
{"_SB_", 0, ASL_RSVD_SCOPE},
{"_SBS", 0, ASL_RSVD_RETURN_VALUE},
{"_SCP", 1, 0},
{"_SEG", 0, ASL_RSVD_RETURN_VALUE},
{"_SHR", 0, ASL_RSVD_RESOURCE_NAME},
{"_SI_", 0, ASL_RSVD_SCOPE},
{"_SIZ", 0, ASL_RSVD_RESOURCE_NAME},
{"_SPD", 1, ASL_RSVD_RETURN_VALUE},
{"_SRS", 1, 0},
{"_SST", 1, 0},
{"_STA", 0, ASL_RSVD_RETURN_VALUE},
{"_STM", 3, 0},
{"_STR", 0, ASL_RSVD_RETURN_VALUE},
{"_SUN", 0, ASL_RSVD_RETURN_VALUE},
{"_TC1", 0, ASL_RSVD_RETURN_VALUE},
{"_TC2", 0, ASL_RSVD_RETURN_VALUE},
{"_TMP", 0, ASL_RSVD_RETURN_VALUE},
{"_TRA", 0, ASL_RSVD_RESOURCE_NAME},
{"_TRS", 0, ASL_RSVD_RESOURCE_NAME},
{"_TSP", 0, ASL_RSVD_RETURN_VALUE},
{"_TTP", 0, ASL_RSVD_RESOURCE_NAME},
{"_TYP", 0, ASL_RSVD_RESOURCE_NAME},
{"_TZ_", 0, ASL_RSVD_SCOPE},
{"_TZD", 0, ASL_RSVD_RETURN_VALUE},
{"_TZP", 0, ASL_RSVD_RETURN_VALUE},
{"_UID", 0, ASL_RSVD_RETURN_VALUE},
{"_VPO", 0, ASL_RSVD_RETURN_VALUE},
{"_WAK", 1, ASL_RSVD_RETURN_VALUE},
{NULL, 0, 0},
};
/*******************************************************************************
*
* FUNCTION: MpDisplayReservedNames
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Print the table above
*
******************************************************************************/
void
MpDisplayReservedNames (
void)
{
UINT32 i;
printf ("Reserved name information\n\n");
for (i = 0; ReservedMethods[i].Name; i++)
{
printf ("%s ", ReservedMethods[i].Name);
if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)
{
printf ("Reserved scope name\n");
}
else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)
{
printf ("Resource data type reserved field name\n");
}
else
{
printf ("Method with %d arguments, ", ReservedMethods[i].NumArguments);
if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE)
{
printf ("must return a value\n");
}
else
{
printf ("no return value\n");
}
}
}
}
/*******************************************************************************
*
* DATA STRUCTURE: AslKeywordMapping
*
* DESCRIPTION: Maps the ParseOpcode to the actual AML opcode. The parse
* opcodes are generated from Bison, and this table must
* track any additions to them.
*
* Each entry in the table contains the following items:
*
* AML opcode - Opcode that is written to the AML file
* Value - Value of the object to be written (if applicable)
* Flags - 1) Whether this opcode opens an AML "package".
*
******************************************************************************/
/*
* TBD:
* AccessAttrib
* AccessType
* AMlop for DMA?
* ObjectType keywords
* Register
*/
const ASL_MAPPING_ENTRY AslKeywordMapping [] =
{
/*! [Begin] no source code translation (keep the table structure) */
/* ACCESSAS */ OP_TABLE_ENTRY (AML_INT_ACCESSFIELD_OP, 0, 0, 0),
/* ACCESSATTRIB_BLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BLOCK, 0, 0),
/* ACCESSATTRIB_BLOCK_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BLOCK_CALL,0, 0),
/* ACCESSATTRIB_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_BYTE, 0, 0),
/* ACCESSATTRIB_WORD_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_WORD_CALL, 0, 0),
/* ACCESSATTRIB_QUICK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_QUICK, 0, 0),
/* ACCESSATTRIB_SND_RCV */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_SEND_RCV, 0, 0),
/* ACCESSATTRIB_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SMB_WORD, 0, 0),
/* ACCESSTYPE_ANY */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_ANY, 0, 0),
/* ACCESSTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BUFFER, 0, 0),
/* ACCESSTYPE_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BYTE, 0, 0),
/* ACCESSTYPE_DWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_DWORD, 0, 0),
/* ACCESSTYPE_QWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_QWORD, 0, 0),
/* ACCESSTYPE_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_WORD, 0, 0),
/* ACQUIRE */ OP_TABLE_ENTRY (AML_ACQUIRE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ADD */ OP_TABLE_ENTRY (AML_ADD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ADDRESSSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_BYTE_OP, REGION_FIXED_HW, 0, 0),
/* ADDRESSTYPE_ACPI */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* ADDRESSTYPE_MEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ADDRESSTYPE_NVS */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* ADDRESSTYPE_RESERVED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* ALIAS */ OP_TABLE_ENTRY (AML_ALIAS_OP, 0, 0, 0),
/* AND */ OP_TABLE_ENTRY (AML_BIT_AND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ARG0 */ OP_TABLE_ENTRY (AML_ARG0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG1 */ OP_TABLE_ENTRY (AML_ARG1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG2 */ OP_TABLE_ENTRY (AML_ARG2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG3 */ OP_TABLE_ENTRY (AML_ARG3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG4 */ OP_TABLE_ENTRY (AML_ARG4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG5 */ OP_TABLE_ENTRY (AML_ARG5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG6 */ OP_TABLE_ENTRY (AML_ARG6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* BANKFIELD */ OP_TABLE_ENTRY (AML_BANK_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
/* BREAK */ OP_TABLE_ENTRY (AML_BREAK_OP, 0, 0, 0),
/* BREAKPOINT */ OP_TABLE_ENTRY (AML_BREAK_POINT_OP, 0, 0, 0),
/* BUFFER */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_BUFFER),
/* BUSMASTERTYPE_MASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* BUSMASTERTYPE_NOTMASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* BYTECONST */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, 0, 0, ACPI_BTYPE_INTEGER),
/* CASE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* CONCATENATE */ OP_TABLE_ENTRY (AML_CONCAT_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
/* CONCATENATERESTEMPLATE */ OP_TABLE_ENTRY (AML_CONCAT_RES_OP, 0, 0, ACPI_BTYPE_BUFFER),
/* CONDREFOF */ OP_TABLE_ENTRY (AML_COND_REF_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* CONTINUE */ OP_TABLE_ENTRY (AML_CONTINUE_OP, 0, 0, 0),
/* COPY */ OP_TABLE_ENTRY (AML_COPY_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* CREATEBITFIELD */ OP_TABLE_ENTRY (AML_CREATE_BIT_FIELD_OP, 0, 0, 0),
/* CREATEBYTEFIELD */ OP_TABLE_ENTRY (AML_CREATE_BYTE_FIELD_OP, 0, 0, 0),
/* CREATEDWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_DWORD_FIELD_OP, 0, 0, 0),
/* CREATEFIELD */ OP_TABLE_ENTRY (AML_CREATE_FIELD_OP, 0, 0, 0),
/* CREATEQWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_QWORD_FIELD_OP, 0, 0, 0),
/* CREATEWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_WORD_FIELD_OP, 0, 0, 0),
/* DATATABLEREGION */ OP_TABLE_ENTRY (AML_DATA_REGION_OP, 0, 0, 0),
/* DEBUG */ OP_TABLE_ENTRY (AML_DEBUG_OP, 0, 0, ACPI_BTYPE_DEBUG_OBJECT),
/* DECODETYPE_POS */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DECODETYPE_SUB */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* DECREMENT */ OP_TABLE_ENTRY (AML_DECREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* DEFAULT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEFAULT_ARG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEFINITIONBLOCK */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEREFOF */ OP_TABLE_ENTRY (AML_DEREF_OF_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_STRING),
/* DEVICE */ OP_TABLE_ENTRY (AML_DEVICE_OP, 0, NODE_AML_PACKAGE, 0),
/* DIVIDE */ OP_TABLE_ENTRY (AML_DIVIDE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* DMA */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DMATYPE_A */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* DMATYPE_COMPATIBILITY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DMATYPE_B */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* DMATYPE_F */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* DWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_DWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* DWORDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DWORDMEMORY */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* EISAID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ELSE */ OP_TABLE_ENTRY (AML_ELSE_OP, 0, NODE_AML_PACKAGE, 0),
/* ELSEIF */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, NODE_AML_PACKAGE, 0),
/* ENDDEPENDENTFN */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* ERRORNODE */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
/* EVENT */ OP_TABLE_ENTRY (AML_EVENT_OP, 0, 0, 0),
/* EXTERNAL */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* FATAL */ OP_TABLE_ENTRY (AML_FATAL_OP, 0, 0, 0),
/* FIELD */ OP_TABLE_ENTRY (AML_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
/* FINDSETLEFTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_LEFT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* FINDSETRIGHTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_RIGHT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* FIXEDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* FROMBCD */ OP_TABLE_ENTRY (AML_FROM_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, NODE_AML_PACKAGE, 0),
/* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INCLUDE_CSTYLE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INCLUDE_END */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INCREMENT */ OP_TABLE_ENTRY (AML_INCREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE),
/* INDEXFIELD */ OP_TABLE_ENTRY (AML_INDEX_FIELD_OP, 0, NODE_AML_PACKAGE, 0),
/* INTEGER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* INTERRUPT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INTLEVEL_ACTIVEHIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* INTLEVEL_ACTIVELOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* INTTYPE_EDGE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* INTTYPE_LEVEL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IODECODETYPE_10 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IODECODETYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* IRQ */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IRQNOFLAGS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* LAND */ OP_TABLE_ENTRY (AML_LAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LEQUAL */ OP_TABLE_ENTRY (AML_LEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LGREATER */ OP_TABLE_ENTRY (AML_LGREATER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LGREATEREQUAL */ OP_TABLE_ENTRY (AML_LGREATEREQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LINE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* LLESS */ OP_TABLE_ENTRY (AML_LLESS_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LLESSEQUAL */ OP_TABLE_ENTRY (AML_LLESSEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LNOT */ OP_TABLE_ENTRY (AML_LNOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LNOTEQUAL */ OP_TABLE_ENTRY (AML_LNOTEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LOAD */ OP_TABLE_ENTRY (AML_LOAD_OP, 0, 0, 0),
/* LOADTABLE */ OP_TABLE_ENTRY (AML_LOAD_TABLE_OP, 0, 0, ACPI_BTYPE_DDB_HANDLE),
/* LOCAL0 */ OP_TABLE_ENTRY (AML_LOCAL0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL1 */ OP_TABLE_ENTRY (AML_LOCAL1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL2 */ OP_TABLE_ENTRY (AML_LOCAL2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL3 */ OP_TABLE_ENTRY (AML_LOCAL3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL4 */ OP_TABLE_ENTRY (AML_LOCAL4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL5 */ OP_TABLE_ENTRY (AML_LOCAL5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL6 */ OP_TABLE_ENTRY (AML_LOCAL6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL7 */ OP_TABLE_ENTRY (AML_LOCAL7, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCKRULE_LOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_ALWAYS, 0, 0),
/* LOCKRULE_NOLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_NEVER, 0, 0),
/* LOR */ OP_TABLE_ENTRY (AML_LOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCH */ OP_TABLE_ENTRY (AML_MATCH_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MEQ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MEQ, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MGE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGE, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MGT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGT, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MLE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLE, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MLT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLT, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MTR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MTR, 0, ACPI_BTYPE_INTEGER),
/* MAXTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MAXTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MEMORY24 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMORY32 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMORY32FIXED */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMTYPE_CACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MEMTYPE_NONCACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MEMTYPE_PREFETCHABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* MEMTYPE_WRITECOMBINING */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* METHOD */ OP_TABLE_ENTRY (AML_METHOD_OP, 0, NODE_AML_PACKAGE, 0),
/* METHODCALL */ OP_TABLE_ENTRY (AML_INT_METHODCALL_OP, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* MID */ OP_TABLE_ENTRY (AML_MID_OP, 0, 0, ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER),
/* MINTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MINTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MOD */ OP_TABLE_ENTRY (AML_MOD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MULTIPLY */ OP_TABLE_ENTRY (AML_MULTIPLY_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MUTEX */ OP_TABLE_ENTRY (AML_MUTEX_OP, 0, 0, 0),
/* NAME */ OP_TABLE_ENTRY (AML_NAME_OP, 0, 0, 0),
/* NAMESEG */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
/* NAMESTRING */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
/* NAND */ OP_TABLE_ENTRY (AML_BIT_NAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOOP */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
/* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0),
/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER_FIELD, 0, 0),
/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER, 0, 0),
/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DDB_HANDLE, 0, 0),
/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DEVICE, 0, 0),
/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_EVENT, 0, 0),
/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_FIELD_UNIT, 0, 0),
/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_INTEGER, 0, 0),
/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_METHOD, 0, 0),
/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_MUTEX, 0, 0),
/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_REGION, 0, 0),
/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PACKAGE, 0, 0),
/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_POWER, 0, 0),
/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_STRING, 0, 0),
/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_THERMAL, 0, 0),
/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_ANY, 0, 0),
/* OFFSET */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
/* ONE */ OP_TABLE_ENTRY (AML_ONE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ONES */ OP_TABLE_ENTRY (AML_ONES_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* OPERATIONREGION */ OP_TABLE_ENTRY (AML_REGION_OP, 0, 0, 0),
/* OR */ OP_TABLE_ENTRY (AML_BIT_OR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* PACKAGE */ OP_TABLE_ENTRY (AML_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
/* PACKAGEP_LENGTH */ OP_TABLE_ENTRY (AML_PACKAGE_LENGTH, 0, NODE_AML_PACKAGE, 0),
/* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RES_OP, 0, NODE_AML_PACKAGE, 0),
/* PROCESSOR */ OP_TABLE_ENTRY (AML_PROCESSOR_OP, 0, NODE_AML_PACKAGE, 0),
/* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* QWORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* QWORDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RANGE_TYPE_ENTIRE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* RANGE_TYPE_ISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* RANGE_TYPE_NONISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* RAW_DATA */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE),
/* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_CMOS, 0, 0),
/* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_EC, 0, 0),
/* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IO, 0, 0),
/* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_MEMORY, 0, 0),
/* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_CONFIG, 0, 0),
/* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_BAR, 0, 0),
/* REGIONSPACE_SMBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_SMBUS, 0, 0),
/* REGISTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RELEASE */ OP_TABLE_ENTRY (AML_RELEASE_OP, 0, 0, 0),
/* RESERVED_BYTES */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
/* RESET */ OP_TABLE_ENTRY (AML_RESET_OP, 0, 0, 0),
/* RESOURCETEMPLATE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER),
/* RESOURCETYPE_CONSUMER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* RESOURCETYPE_PRODUCER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RETURN */ OP_TABLE_ENTRY (AML_RETURN_OP, 0, 0, 0),
/* REVISION */ OP_TABLE_ENTRY (AML_REVISION_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SCOPE */ OP_TABLE_ENTRY (AML_SCOPE_OP, 0, NODE_AML_PACKAGE, 0),
/* SERIALIZERULE_NOTSERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SERIALIZERULE_SERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* SHARETYPE_EXCLUSIVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SHARETYPE_SHARED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* SHIFTLEFT */ OP_TABLE_ENTRY (AML_SHIFT_LEFT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SHIFTRIGHT */ OP_TABLE_ENTRY (AML_SHIFT_RIGHT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SIGNAL */ OP_TABLE_ENTRY (AML_SIGNAL_OP, 0, 0, 0),
/* SIZEOF */ OP_TABLE_ENTRY (AML_SIZE_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SLEEP */ OP_TABLE_ENTRY (AML_SLEEP_OP, 0, 0, 0),
/* STALL */ OP_TABLE_ENTRY (AML_STALL_OP, 0, 0, 0),
/* STARTDEPENDENTFN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* STARTDEPENDENTFN_NOPRI */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* STORE */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* STRING_LITERAL */ OP_TABLE_ENTRY (AML_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* SUBTRACT */ OP_TABLE_ENTRY (AML_SUBTRACT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SWITCH */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* THERMALZONE */ OP_TABLE_ENTRY (AML_THERMAL_ZONE_OP, 0, NODE_AML_PACKAGE, 0),
/* TOBCD */ OP_TABLE_ENTRY (AML_TO_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
/* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEXSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOINTEGER */ OP_TABLE_ENTRY (AML_TO_INTEGER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOSTRING */ OP_TABLE_ENTRY (AML_TO_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TRANSLATIONTYPE_DENSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* TRANSLATIONTYPE_SPARSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* TYPE_TRANSLATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* UNICODE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, 0),
/* UNLOAD */ OP_TABLE_ENTRY (AML_UNLOAD_OP, 0, 0, 0),
/* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0),
/* UPDATERULE_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_PRESERVE, 0, 0),
/* UPDATERULE_ZEROS */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ZEROS,0, 0),
/* VAR_PACKAGE */ OP_TABLE_ENTRY (AML_VAR_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
/* VENDORLONG */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* VENDORSHORT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WAIT */ OP_TABLE_ENTRY (AML_WAIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* WHILE */ OP_TABLE_ENTRY (AML_WHILE_OP, 0, NODE_AML_PACKAGE, 0),
/* WORDBUSNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_WORD, 0, 0, ACPI_BTYPE_INTEGER),
/* WORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERTYPE_8 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERTYPE_8_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* XFERTYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* XOR */ OP_TABLE_ENTRY (AML_BIT_XOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ZERO */ OP_TABLE_ENTRY (AML_ZERO_OP, 0, 0, ACPI_BTYPE_INTEGER),
/*! [End] no source code translation !*/
};

View File

@ -0,0 +1,620 @@
/******************************************************************************
*
* Module Name: aslopcode - AML opcode generation
* $Revision: 54 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopcodes")
/*******************************************************************************
*
* FUNCTION: OpcAmlOpcodeWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
* operands.
*
******************************************************************************/
ACPI_STATUS
OpcAmlOpcodeWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
TotalParseNodes++;
OpcGenerateAmlOpcode (Op);
OpnGenerateAmlOperands (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OpcGetIntegerWidth
*
* PARAMETERS: Op - DEFINITION BLOCK op
*
* RETURN: none
*
* DESCRIPTION: Extract integer width from the table revision
*
******************************************************************************/
void
OpcGetIntegerWidth (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child;
if (!Op)
{
return;
}
Child = Op->Asl.Child;
Child = Child->Asl.Next;
Child = Child->Asl.Next;
/* Use the revision to set the integer width */
AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
}
/*******************************************************************************
*
* FUNCTION: OpcSetOptimalIntegerSize
*
* PARAMETERS: Op - A parse tree node
*
* RETURN: Integer width, in bytes. Also sets the node AML opcode to the
* optimal integer AML prefix opcode.
*
* DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
* zeros can be truncated to squeeze the integer into the
* minimal number of AML bytes.
*
******************************************************************************/
UINT32
OpcSetOptimalIntegerSize (
ACPI_PARSE_OBJECT *Op)
{
/*
* Check for the special AML integers first - Zero, One, Ones.
* These are single-byte opcodes that are the smallest possible
* representation of an integer.
*
* This optimization is optional.
*/
if (Gbl_IntegerOptimizationFlag)
{
switch (Op->Asl.Value.Integer)
{
case 0:
Op->Asl.AmlOpcode = AML_ZERO_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Zero");
return 1;
case 1:
Op->Asl.AmlOpcode = AML_ONE_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "One");
return 1;
case ACPI_UINT32_MAX:
/* Check for table integer width (32 or 64) */
if (AcpiGbl_IntegerByteWidth == 4)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones");
return 1;
}
break;
case ACPI_INTEGER_MAX:
/* Check for table integer width (32 or 64) */
if (AcpiGbl_IntegerByteWidth == 8)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones");
return 1;
}
break;
default:
break;
}
}
/* Find the best fit using the various AML integer prefixes */
if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
{
Op->Asl.AmlOpcode = AML_BYTE_OP;
return 1;
}
if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
{
Op->Asl.AmlOpcode = AML_WORD_OP;
return 2;
}
if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
{
Op->Asl.AmlOpcode = AML_DWORD_OP;
return 4;
}
else
{
Op->Asl.AmlOpcode = AML_QWORD_OP;
return 8;
}
}
/*******************************************************************************
*
* FUNCTION: OpcDoAccessAs
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the ACCESS_AS ASL keyword.
*
******************************************************************************/
void
OpcDoAccessAs (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
Op->Asl.AmlOpcodeLength = 1;
Next = Op->Asl.Child;
/* First child is the access type */
Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
/* Second child is the optional access attribute */
Next = Next->Asl.Next;
if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
Next->Asl.Value.Integer = 0;
}
Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
}
/*******************************************************************************
*
* FUNCTION: OpcDoUnicode
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
* to a unicode buffer. There is no Unicode AML opcode.
*
* Note: The Unicode string is 16 bits per character, no leading signature,
* with a 16-bit terminating NULL.
*
******************************************************************************/
void
OpcDoUnicode (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *InitializerOp;
UINT32 Length;
UINT32 Count;
UINT32 i;
UINT8 *AsciiString;
UINT16 *UnicodeString;
ACPI_PARSE_OBJECT *BufferLengthOp;
/* Change op into a buffer object */
Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
UtSetParseOpName (Op);
/* Buffer Length is first, followed by the string */
BufferLengthOp = Op->Asl.Child;
InitializerOp = BufferLengthOp->Asl.Next;
AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
/* Create a new buffer for the Unicode string */
Count = strlen (InitializerOp->Asl.Value.String) + 1;
Length = Count * sizeof (UINT16);
UnicodeString = UtLocalCalloc (Length);
/* Convert to Unicode string (including null terminator) */
for (i = 0; i < Count; i++)
{
UnicodeString[i] = (UINT16) AsciiString[i];
}
/*
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
BufferLengthOp->Asl.Value.Integer = Length;
UtSetParseOpName (BufferLengthOp);
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
/* The Unicode string is a raw data buffer */
InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
InitializerOp->Asl.AmlLength = Length;
InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
InitializerOp->Asl.Child = NULL;
UtSetParseOpName (InitializerOp);
}
/*******************************************************************************
*
* FUNCTION: OpcDoEisaId
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
*
* DESCRIPTION: Convert a string EISA ID to numeric representation. See the
* Pnp BIOS Specification for details. Here is an excerpt:
*
* A seven character ASCII representation of the product
* identifier compressed into a 32-bit identifier. The seven
* character ID consists of a three character manufacturer code,
* a three character hexadecimal product identifier, and a one
* character hexadecimal revision number. The manufacturer code
* is a 3 uppercase character code that is compressed into 3 5-bit
* values as follows:
* 1) Find hex ASCII value for each letter
* 2) Subtract 40h from each ASCII value
* 3) Retain 5 least signficant bits for each letter by
* discarding upper 3 bits because they are always 0.
* 4) Compressed code = concatenate 0 and the 3 5-bit values
*
* The format of the compressed product identifier is as follows:
* Byte 0: Bit 7 - Reserved (0)
* Bits 6-2: - 1st character of compressed mfg code
* Bits 1-0 - Upper 2 bits of 2nd character of mfg code
* Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code
* Bits 4-0 - 3rd character of mfg code
* Byte 2: Bits 7-4 - 1st hex digit of product number
* Bits 3-0 - 2nd hex digit of product number
* Byte 3: Bits 7-4 - 3st hex digit of product number
* Bits 3-0 - Hex digit of the revision number
*
******************************************************************************/
void
OpcDoEisaId (
ACPI_PARSE_OBJECT *Op)
{
UINT32 EisaId = 0;
UINT32 BigEndianId;
char *InString;
ACPI_STATUS Status = AE_OK;
ACPI_NATIVE_UINT i;
InString = (char *) Op->Asl.Value.String;
/*
* The EISAID string must be exactly 7 characters and of the form
* "LLLXXXX" -- 3 letters and 4 hex digits (e.g., "PNP0001")
*/
if (ACPI_STRLEN (InString) != 7)
{
Status = AE_BAD_PARAMETER;
}
else
{
/* Check all 7 characters for correct format */
for (i = 0; i < 7; i++)
{
/* First 3 characters must be letters */
if (i < 3)
{
if (!isalpha (InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
/* Last 4 characters must be hex digits */
else if (!isxdigit (InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
}
if (ACPI_FAILURE (Status))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
}
else
{
/* Create ID big-endian first (bits are contiguous) */
BigEndianId = (UINT32) (InString[0] - 0x40) << 26 |
(UINT32) (InString[1] - 0x40) << 21 |
(UINT32) (InString[2] - 0x40) << 16 |
(UtHexCharToValue (InString[3])) << 12 |
(UtHexCharToValue (InString[4])) << 8 |
(UtHexCharToValue (InString[5])) << 4 |
UtHexCharToValue (InString[6]);
/* Swap to little-endian to get final ID (see function header) */
EisaId = AcpiUtDwordByteSwap (BigEndianId);
}
/*
* Morph the Op into an integer, regardless of whether there
* was an error in the EISAID string
*/
Op->Asl.Value.Integer = EisaId;
Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
(void) OpcSetOptimalIntegerSize (Op);
/* Op is now an integer */
UtSetParseOpName (Op);
}
/*******************************************************************************
*
* FUNCTION: OpcGenerateAmlOpcode
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Generate the AML opcode associated with the node and its
* parse (lex/flex) keyword opcode. Essentially implements
* a mapping between the parse opcodes and the actual AML opcodes.
*
******************************************************************************/
void
OpcGenerateAmlOpcode (
ACPI_PARSE_OBJECT *Op)
{
UINT16 Index;
Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
if (!Op->Asl.Value.Integer)
{
Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
}
/* Special handling for some opcodes */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_INTEGER:
/*
* Set the opcode based on the size of the integer
*/
(void) OpcSetOptimalIntegerSize (Op);
break;
case PARSEOP_OFFSET:
Op->Asl.AmlOpcodeLength = 1;
break;
case PARSEOP_ACCESSAS:
OpcDoAccessAs (Op);
break;
case PARSEOP_EISAID:
OpcDoEisaId (Op);
break;
case PARSEOP_UNICODE:
OpcDoUnicode (Op);
break;
case PARSEOP_INCLUDE:
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
Gbl_HasIncludeFiles = TRUE;
break;
case PARSEOP_EXTERNAL:
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
break;
case PARSEOP_PACKAGE:
/*
* The variable-length package has a different opcode
*/
if ((Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) &&
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_BYTECONST))
{
Op->Asl.AmlOpcode = AML_VAR_PACKAGE_OP;
}
break;
default:
/* Nothing to do for other opcodes */
break;
}
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,800 @@
/******************************************************************************
*
* Module Name: aslopt- Compiler optimizations
* $Revision: 12 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopt")
UINT32 OptTotal = 0;
/*******************************************************************************
*
* FUNCTION: OptSearchToRoot
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* TargetNode - Node to which we are referring
* TargetPath - External full path to the target node
* NewPath - Where the optimized path is returned
*
* RETURN: Status
*
* DESCRIPTION: Attempt to optimize a reference to a single 4-character ACPI
* name utilizing the search-to-root name resolution algorithm
* that is used by AML interpreters.
*
******************************************************************************/
ACPI_STATUS
OptSearchToRoot (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *TargetPath,
char **NewPath)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
ACPI_STATUS Status;
char *Path;
ACPI_FUNCTION_NAME ("OptSearchToRoot");
/*
* Check if search-to-root can be utilized. Use the last NameSeg of
* the NamePath and 1) See if can be found and 2) If found, make
* sure that it is the same node that we want. If there is another
* name in the search path before the one we want, the nodes will
* not match, and we cannot use this optimization.
*/
Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - ACPI_NAME_SIZE]),
ScopeInfo.Scope.Node = CurrentNode;
/* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* We found the name, but we must check to make sure that the node
* matches. Otherwise, there is another identical name in the search
* path that precludes the use of this optimization.
*/
if (Node != TargetNode)
{
/*
* This means that another object with the same name was found first,
* and we cannot use this optimization.
*/
return (AE_NOT_FOUND);
}
/* Found the node, we can use this optimization */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"NAMESEG: %-24s", Path));
/* We must allocate a new string for the name (TargetPath gets deleted) */
*NewPath = ACPI_MEM_CALLOCATE (ACPI_NAME_SIZE + 1);
ACPI_STRCPY (*NewPath, Path);
AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
*NewPath);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OptBuildShortestPath
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* TargetNode - Node to which we are referring
* CurrentPath - External full path to the current node
* TargetPath - External full path to the target node
* AmlNameStringLength - Length of the original namepath
* IsDeclaration - TRUE for declaration, FALSE for reference
* ReturnNewPath - Where the optimized path is returned
*
* RETURN: Status
*
* DESCRIPTION: Build an optimal NamePath using carats
*
******************************************************************************/
ACPI_STATUS
OptBuildShortestPath (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *CurrentPath,
ACPI_BUFFER *TargetPath,
ACPI_SIZE AmlNameStringLength,
UINT8 IsDeclaration,
char **ReturnNewPath)
{
UINT32 NumCommonSegments;
UINT32 MaxCommonSegments;
ACPI_NATIVE_UINT Index;
UINT32 NumCarats;
ACPI_NATIVE_UINT i;
char *NewPath;
char *NewPathExternal;
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
ACPI_STATUS Status;
BOOLEAN SubPath = FALSE;
ACPI_FUNCTION_NAME ("OptBuildShortestPath");
ScopeInfo.Scope.Node = CurrentNode;
/*
* Determine the maximum number of NameSegs that the Target and Current paths
* can possibly have in common. (To optimize, we have to have at least 1)
*
* Note: The external NamePath string lengths are always a multiple of 5
* (ACPI_NAME_SIZE + separator)
*/
MaxCommonSegments = TargetPath->Length / ACPI_PATH_SEGMENT_LENGTH;
if (CurrentPath->Length < TargetPath->Length)
{
MaxCommonSegments = CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH;
}
/*
* Determine how many NameSegs the two paths have in common.
* (Starting from the root)
*/
for (NumCommonSegments = 0;
NumCommonSegments < MaxCommonSegments;
NumCommonSegments++)
{
/* Compare two single NameSegs */
if (ACPI_STRNCMP (
&((char *) TargetPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
&((char *) CurrentPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
ACPI_NAME_SIZE))
{
/* Mismatch */
break;
}
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", NumCommonSegments));
/* There must be at least 1 common NameSeg in order to optimize */
if (NumCommonSegments == 0)
{
return (AE_NOT_FOUND);
}
if (NumCommonSegments == MaxCommonSegments)
{
if (CurrentPath->Length == TargetPath->Length)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SAME PATH"));
return (AE_NOT_FOUND);
}
else
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SUBPATH"));
SubPath = TRUE;
}
}
/* Determine how many prefix Carats are required */
NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - NumCommonSegments;
/*
* Construct a new target string
*/
NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats);
/* Insert the Carats into the Target string */
for (i = 0; i < NumCarats; i++)
{
NewPathExternal[i] = '^';
}
/* Copy only the necessary (optimal) segments from the original target string */
Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
/* Special handling for exact subpath in a name declaration */
if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length))
{
/*
* The current path is longer than the target, and the target is a subpath
* of the current path. We must include one more NameSeg of the target path
*/
Index -= ACPI_PATH_SEGMENT_LENGTH;
}
ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
* Internalize the new target string and check it against the original string
* to make sure that this is in fact an optimization. If the original string
* is already optimal, there is no point in continuing.
*/
Status = AcpiNsInternalizeName (NewPathExternal, &NewPath);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT);
ACPI_MEM_FREE (NewPathExternal);
return (Status);
}
if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %d old %d)",
ACPI_STRLEN (NewPath), AmlNameStringLength));
ACPI_MEM_FREE (NewPathExternal);
return (AE_NOT_FOUND);
}
/*
* Check to make sure that the optimization finds the node we are
* looking for. This is simply a sanity check on the new
* path that has been created.
*/
Status = AcpiNsLookup (&ScopeInfo, NewPath,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
if (Node == TargetNode)
{
/* The lookup matched the node, accept this optimization */
AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
Op, NewPathExternal);
*ReturnNewPath = NewPath;
}
else
{
/* Node is not correct, do not use this optimization */
Status = AE_NOT_FOUND;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - found wrong node");
}
}
else
{
/* The lookup failed, we obviously cannot use this optimization */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - did not find node");
}
ACPI_MEM_FREE (NewPathExternal);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: OptOptimizeNameDeclaration
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* AmlNameString - Unoptimized namepath
* NewPath - Where the optimized path is returned
*
* RETURN: Status. AE_OK If path is optimized
*
* DESCRIPTION: Perform a simple optimization of removing an extraneous
* backslash prefix if we are already at the root scope.
*
******************************************************************************/
ACPI_STATUS
OptOptimizeNameDeclaration (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
char *AmlNameString,
char **NewPath)
{
ACPI_STATUS Status;
char *NewPathExternal;
ACPI_GENERIC_STATE ScopeInfo;
ACPI_NAMESPACE_NODE *Node;
ACPI_FUNCTION_TRACE ("OptOptimizeNameDeclaration");
if (((CurrentNode == AcpiGbl_RootNode) ||
(Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) &&
(AmlNameString[0] == '\\'))
{
/*
* The current scope is the root, and the namepath has a root prefix
* that is therefore extraneous. Remove it.
*/
*NewPath = &AmlNameString[1];
/* Debug output */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
NULL, &NewPathExternal);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
return (Status);
}
/*
* Check to make sure that the optimization finds the node we are
* looking for. This is simply a sanity check on the new
* path that has been created.
*/
ScopeInfo.Scope.Node = CurrentNode;
Status = AcpiNsLookup (&ScopeInfo, *NewPath,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
if (Node == TargetNode)
{
/* The lookup matched the node, accept this optimization */
AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
Op, NewPathExternal);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"AT ROOT: %-24s", NewPathExternal));
}
else
{
/* Node is not correct, do not use this optimization */
Status = AE_NOT_FOUND;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - found wrong node");
}
}
else
{
/* The lookup failed, we obviously cannot use this optimization */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - did not find node");
}
ACPI_MEM_FREE (NewPathExternal);
return (Status);
}
/* Could not optimize */
return (AE_NOT_FOUND);
}
/*******************************************************************************
*
* FUNCTION: OptOptimizeNamePath
*
* PARAMETERS: Op - Current parser op
* Flags - Opcode info flags
* WalkState - Current state
* AmlNameString - Unoptimized namepath
* TargetNode - Node to which AmlNameString refers
*
* RETURN: None. If path is optimized, the Op is updated with new path
*
* DESCRIPTION: Optimize a Named Declaration or Reference to the minimal length.
* Must take into account both the current location in the
* namespace and the actual reference path.
*
******************************************************************************/
void
OptOptimizeNamePath (
ACPI_PARSE_OBJECT *Op,
UINT32 Flags,
ACPI_WALK_STATE *WalkState,
char *AmlNameString,
ACPI_NAMESPACE_NODE *TargetNode)
{
ACPI_STATUS Status;
ACPI_BUFFER TargetPath;
ACPI_BUFFER CurrentPath;
ACPI_SIZE AmlNameStringLength;
ACPI_NAMESPACE_NODE *CurrentNode;
char *ExternalNameString;
char *NewPath = NULL;
ACPI_SIZE HowMuchShorter;
ACPI_PARSE_OBJECT *NextOp;
ACPI_FUNCTION_TRACE ("OptOptimizeNamePath");
/* This is an optional optimization */
if (!Gbl_ReferenceOptimizationFlag)
{
return_VOID;
}
/* Various required items */
if (!TargetNode || !WalkState || !Op->Common.Parent)
{
return_VOID;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%5d [%12.12s] [%12.12s] ",
Op->Asl.LogicalLineNumber,
AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode),
AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
if (!(Flags & (AML_NAMED | AML_CREATE)))
{
if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
{
/* We don't want to fuss with actual name declaration nodes here */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"******* NAME DECLARATION\n"));
return_VOID;
}
}
/*
* The original path must be longer than one NameSeg (4 chars) for there
* to be any possibility that it can be optimized to a shorter string
*/
AmlNameStringLength = ACPI_STRLEN (AmlNameString);
if (AmlNameStringLength <= ACPI_NAME_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"NAMESEG %4.4s\n", AmlNameString));
return_VOID;
}
/*
* We need to obtain the node that represents the current scope -- where
* we are right now in the namespace. We will compare this path
* against the Namepath, looking for commonality.
*/
CurrentNode = AcpiGbl_RootNode;
if (WalkState->ScopeInfo)
{
CurrentNode = WalkState->ScopeInfo->Scope.Node;
}
if (Flags & (AML_NAMED | AML_CREATE))
{
/* This is the declaration of a new name */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME"));
/* The node of interest is the parent of this node (the containing scope) */
CurrentNode = Op->Asl.Parent->Asl.Node;
if (!CurrentNode)
{
CurrentNode = AcpiGbl_RootNode;
}
}
else
{
/* This is a reference to an existing named object */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REF "));
}
/*
* Obtain the full paths to the two nodes that we are interested in
* (Target and current namespace location) in external
* format -- something we can easily manipulate
*/
TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (TargetNode, &TargetPath);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT);
return_VOID;
}
TargetPath.Length--; /* Subtract one for null terminator */
/* CurrentPath is the path to this scope (where we are in the namespace) */
CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT);
return_VOID;
}
CurrentPath.Length--; /* Subtract one for null terminator */
/* Debug output only */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
NULL, &ExternalNameString);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT);
return_VOID;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"%37s (%2d) ==> %-32s(%2d) %-32s",
(char *) CurrentPath.Pointer, CurrentPath.Length,
(char *) TargetPath.Pointer, TargetPath.Length, ExternalNameString));
ACPI_MEM_FREE (ExternalNameString);
/*
* Attempt an optmization depending on the type of namepath
*/
if (Flags & (AML_NAMED | AML_CREATE))
{
/*
* This is a named opcode and the namepath is a name declaration, not
* a reference.
*/
Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
TargetNode, AmlNameString, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
* 2) now attempt to
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
TargetNode, &CurrentPath, &TargetPath,
AmlNameStringLength, 1, &NewPath);
}
}
else
{
/*
* This is a reference to an existing named object
*
* 1) Check if search-to-root can be utilized using the last
* NameSeg of the NamePath
*/
Status = OptSearchToRoot (Op, WalkState, CurrentNode,
TargetNode, &TargetPath, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
* 2) Search-to-root could not be used, now attempt to
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
TargetNode, &CurrentPath, &TargetPath,
AmlNameStringLength, 0, &NewPath);
}
}
/*
* Success from above indicates that the NamePath was successfully
* optimized. We need to update the parse op with the new name
*/
if (ACPI_SUCCESS (Status))
{
HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath));
OptTotal += HowMuchShorter;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2d (%d)",
HowMuchShorter, OptTotal));
if (Flags & AML_NAMED)
{
if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
{
/*
* ALIAS is the only oddball opcode, the name declaration
* (alias name) is the second operand
*/
Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath);
}
else
{
Op->Asl.Child->Asl.Value.String = NewPath;
Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath);
}
}
else if (Flags & AML_CREATE)
{
/* Name must appear as the last parameter */
NextOp = Op->Asl.Child;
while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
{
NextOp = NextOp->Asl.Next;
}
/* Update the parse node with the new NamePath */
NextOp->Asl.Value.String = NewPath;
NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath);
}
else
{
/* Update the parse node with the new NamePath */
Op->Asl.Value.String = NewPath;
Op->Asl.AmlLength = ACPI_STRLEN (NewPath);
}
}
else
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL"));
}
/* Cleanup path buffers */
ACPI_MEM_FREE (TargetPath.Pointer);
ACPI_MEM_FREE (CurrentPath.Pointer);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n"));
return_VOID;
}

View File

@ -0,0 +1,632 @@
/******************************************************************************
*
* Module Name: aslresource - Resource templates and descriptors
* $Revision: 31 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslresource")
/*******************************************************************************
*
* FUNCTION: RsAllocateResourceNode
*
* PARAMETERS: Size - Size of node in bytes
*
* RETURN: The allocated node - aborts on allocation failure
*
* DESCRIPTION: Allocate a resource description node and the resource
* descriptor itself (the nodes are used to link descriptors).
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsAllocateResourceNode (
UINT32 Size)
{
ASL_RESOURCE_NODE *Rnode;
/* Allocate the node */
Rnode = UtLocalCalloc (sizeof (ASL_RESOURCE_NODE));
/* Allocate the resource descriptor itself */
Rnode->Buffer = UtLocalCalloc (Size);
Rnode->BufferLength = Size;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsCreateBitField
*
* PARAMETERS: Op - Resource field node
* Name - Name of the field (Used only to reference
* the field in the ASL, not in the AML)
* ByteOffset - Offset from the field start
* BitOffset - Additional bit offset
*
* RETURN: None, sets fields within the input node
*
* DESCRIPTION: Utility function to generate a named bit field within a
* resource descriptor. Mark a node as 1) a field in a resource
* descriptor, and 2) set the value to be a BIT offset
*
******************************************************************************/
void
RsCreateBitField (
ACPI_PARSE_OBJECT *Op,
char *Name,
UINT32 ByteOffset,
UINT32 BitOffset)
{
Op->Asl.ExternalName = Name;
Op->Asl.Value.Integer = (ByteOffset * 8) + BitOffset;
Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET);
}
/*******************************************************************************
*
* FUNCTION: RsCreateByteField
*
* PARAMETERS: Op - Resource field node
* Name - Name of the field (Used only to reference
* the field in the ASL, not in the AML)
* ByteOffset - Offset from the field start
*
* RETURN: None, sets fields within the input node
*
* DESCRIPTION: Utility function to generate a named byte field within a
* resource descriptor. Mark a node as 1) a field in a resource
* descriptor, and 2) set the value to be a BYTE offset
*
******************************************************************************/
void
RsCreateByteField (
ACPI_PARSE_OBJECT *Op,
char *Name,
UINT32 ByteOffset)
{
Op->Asl.ExternalName = Name;
Op->Asl.Value.Integer = ByteOffset;
Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
}
/*******************************************************************************
*
* FUNCTION: RsSetFlagBits
*
* PARAMETERS: *Flags - Pointer to the flag byte
* Op - Flag initialization node
* Position - Bit position within the flag byte
* Default - Used if the node is DEFAULT.
*
* RETURN: Sets bits within the *Flags output byte.
*
* DESCRIPTION: Set a bit in a cumulative flags word from an initialization
* node. Will use a default value if the node is DEFAULT, meaning
* that no value was specified in the ASL. Used to merge multiple
* keywords into a single flags byte.
*
******************************************************************************/
void
RsSetFlagBits (
UINT8 *Flags,
ACPI_PARSE_OBJECT *Op,
UINT8 Position,
UINT8 DefaultBit)
{
if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
/* Use the default bit */
*Flags |= (DefaultBit << Position);
}
else
{
/* Use the bit specified in the initialization node */
*Flags |= (((UINT8) Op->Asl.Value.Integer) << Position);
}
}
/*******************************************************************************
*
* FUNCTION: RsCompleteNodeAndGetNext
*
* PARAMETERS: Op - Resource node to be completed
*
* RETURN: The next peer to the input node.
*
* DESCRIPTION: Mark the current node completed and return the next peer.
* The node ParseOpcode is set to DEFAULT_ARG, meaning that
* this node is to be ignored from now on.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
RsCompleteNodeAndGetNext (
ACPI_PARSE_OBJECT *Op)
{
/* Mark this node unused */
Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
/* Move on to the next peer node in the initializer list */
return (ASL_GET_PEER_NODE (Op));
}
/*******************************************************************************
*
* FUNCTION: RsDoOneResourceDescriptor
*
* PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor
* CurrentByteOffset - Offset in the resource descriptor
* buffer.
*
* RETURN: A valid resource node for the descriptor
*
* DESCRIPTION: Dispatches the processing of one resource descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoOneResourceDescriptor (
ACPI_PARSE_OBJECT *DescriptorTypeOp,
UINT32 CurrentByteOffset,
UINT8 *State)
{
ASL_RESOURCE_NODE *Rnode = NULL;
/* Determine type of resource */
switch (DescriptorTypeOp->Asl.ParseOpcode)
{
case PARSEOP_DMA:
Rnode = RsDoDmaDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_DWORDIO:
Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_DWORDMEMORY:
Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_ENDDEPENDENTFN:
switch (*State)
{
case ACPI_RSTATE_NORMAL:
AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, DescriptorTypeOp, NULL);
break;
case ACPI_RSTATE_START_DEPENDENT:
AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
break;
case ACPI_RSTATE_DEPENDENT_LIST:
default:
break;
}
*State = ACPI_RSTATE_NORMAL;
Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_FIXEDIO:
Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_INTERRUPT:
Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_IO:
Rnode = RsDoIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_IRQ:
Rnode = RsDoIrqDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_IRQNOFLAGS:
Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_MEMORY24:
Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_MEMORY32:
Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_MEMORY32FIXED:
Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_QWORDIO:
Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_QWORDMEMORY:
Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_REGISTER:
Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_STARTDEPENDENTFN:
switch (*State)
{
case ACPI_RSTATE_START_DEPENDENT:
AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
break;
case ACPI_RSTATE_NORMAL:
case ACPI_RSTATE_DEPENDENT_LIST:
default:
break;
}
*State = ACPI_RSTATE_START_DEPENDENT;
Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, CurrentByteOffset);
*State = ACPI_RSTATE_DEPENDENT_LIST;
break;
case PARSEOP_STARTDEPENDENTFN_NOPRI:
switch (*State)
{
case ACPI_RSTATE_START_DEPENDENT:
AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL);
break;
case ACPI_RSTATE_NORMAL:
case ACPI_RSTATE_DEPENDENT_LIST:
default:
break;
}
*State = ACPI_RSTATE_START_DEPENDENT;
Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, CurrentByteOffset);
*State = ACPI_RSTATE_DEPENDENT_LIST;
break;
case PARSEOP_VENDORLONG:
Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_VENDORSHORT:
Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_WORDBUSNUMBER:
Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_WORDIO:
Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, CurrentByteOffset);
break;
case PARSEOP_DEFAULT_ARG:
/* Just ignore any of these, they are used as fillers/placeholders */
break;
default:
printf ("Unknown resource descriptor type [%s]\n",
DescriptorTypeOp->Asl.ParseOpName);
break;
}
/*
* Mark original node as unused, but head of a resource descriptor.
* This allows the resource to be installed in the namespace so that
* references to the descriptor can be resolved.
*/
DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsLinkDescriptorChain
*
* PARAMETERS: PreviousRnode - Pointer to the node that will be previous
* to the linked node, At exit, set to the
* last node in the new chain.
* Rnode - Resource node to link into the list
*
* RETURN: Cumulative buffer byte offset of the new segment of chain
*
* DESCRIPTION: Link a descriptor chain at the end of an existing chain.
*
******************************************************************************/
UINT32
RsLinkDescriptorChain (
ASL_RESOURCE_NODE **PreviousRnode,
ASL_RESOURCE_NODE *Rnode)
{
ASL_RESOURCE_NODE *LastRnode;
UINT32 CurrentByteOffset;
/* Anything to do? */
if (!Rnode)
{
return 0;
}
/* Point the previous node to the new node */
(*PreviousRnode)->Next = Rnode;
CurrentByteOffset = Rnode->BufferLength;
/* Walk to the end of the chain headed by Rnode */
LastRnode = Rnode;
while (LastRnode->Next)
{
LastRnode = LastRnode->Next;
CurrentByteOffset += LastRnode->BufferLength;
}
/* Previous node becomes the last node in the chain */
*PreviousRnode = LastRnode;
return CurrentByteOffset;
}
/*******************************************************************************
*
* FUNCTION: RsDoResourceTemplate
*
* PARAMETERS: Op - Parent of a resource template list
*
* RETURN: None. Sets input node to point to a list of AML code
*
* DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
* in preparation for output to the AML output file.
*
******************************************************************************/
void
RsDoResourceTemplate (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *BufferLengthOp;
ACPI_PARSE_OBJECT *BufferOp;
ACPI_PARSE_OBJECT *DescriptorTypeOp;
ACPI_PARSE_OBJECT *LastOp = NULL;
ASL_RESOURCE_DESC *Descriptor;
UINT32 CurrentByteOffset = 0;
ASL_RESOURCE_NODE HeadRnode;
ASL_RESOURCE_NODE *PreviousRnode;
ASL_RESOURCE_NODE *Rnode;
UINT8 State;
/* ResourceTemplate Opcode is first (Op) */
/* Buffer Length node is first child */
BufferLengthOp = ASL_GET_CHILD_NODE (Op);
/* Buffer Op is first peer */
BufferOp = ASL_GET_PEER_NODE (BufferLengthOp);
/* First Descriptor type is next */
DescriptorTypeOp = ASL_GET_PEER_NODE (BufferOp);
/* Process all resource descriptors in the list */
State = ACPI_RSTATE_NORMAL;
PreviousRnode = &HeadRnode;
while (DescriptorTypeOp)
{
Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, &State);
/*
* Update current byte offset to indicate the number of bytes from the
* start of the buffer. Buffer can include multiple descriptors, we
* must keep track of the offset of not only each descriptor, but each
* element (field) within each descriptor as well.
*/
CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
/* Get the next descriptor in the list */
LastOp = DescriptorTypeOp;
DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp);
}
if (State == ACPI_RSTATE_DEPENDENT_LIST)
{
if (LastOp)
{
LastOp = LastOp->Asl.Parent;
}
AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL);
}
/*
* Insert the EndTag descriptor after all other descriptors have been processed
*/
Rnode = RsAllocateResourceNode (sizeof (ASL_END_TAG_DESC));
Descriptor = Rnode->Buffer;
Descriptor->Et.DescriptorType = ACPI_RDESC_TYPE_END_TAG |
ASL_RDESC_END_TAG_SIZE;
Descriptor->Et.Checksum = 0;
CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
/*
* Transform the nodes into the following
*
* Op -> AML_BUFFER_OP
* First Child -> BufferLength
* Second Child -> Descriptor Buffer (raw byte data)
*/
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Asl.AmlOpcode = AML_BUFFER_OP;
Op->Asl.CompileFlags = NODE_AML_PACKAGE;
BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthOp->Asl.Value.Integer = CurrentByteOffset;
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
BufferOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
BufferOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
BufferOp->Asl.AmlOpcodeLength = 0;
BufferOp->Asl.AmlLength = CurrentByteOffset;
BufferOp->Asl.Value.Buffer = (UINT8 *) HeadRnode.Next;
return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,266 @@
/******************************************************************************
*
* Module Name: aslstubs - Stubs used to link to Aml interpreter
* $Revision: 11 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdio.h>
#include "aslcompiler.h"
#include "acdispat.h"
#include "actables.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslstubs")
/*
* Stubs to simplify linkage to the ACPI CA core subsystem.
* Things like Events, Global Lock, etc. are not used
* by the compiler, so they are stubbed out here.
*/
ACPI_STATUS
AeLocalGetRootPointer (
UINT32 Flags,
ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
{
return AE_ERROR;
}
ACPI_STATUS
AcpiDsMethodDataGetValue (
UINT16 Opcode,
UINT32 Index,
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT **DestDesc)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsMethodDataGetNode (
UINT16 Opcode,
UINT32 Index,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE **Node)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsStoreObjectToLocal (
UINT16 Opcode,
UINT32 Index,
ACPI_OPERAND_OBJECT *SrcDesc,
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvDeleteGpeBlock (
ACPI_GPE_BLOCK_INFO *GpeBlock)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvQueueNotifyRequest (
ACPI_NAMESPACE_NODE *Node,
UINT32 NotifyValue)
{
return (AE_OK);
}
BOOLEAN
AcpiEvIsNotifyObject (
ACPI_NAMESPACE_NODE *Node)
{
return (FALSE);
}
ACPI_STATUS
AcpiEvAcquireGlobalLock(
UINT32 Timeout)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvReleaseGlobalLock(
void)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvInitializeRegion (
ACPI_OPERAND_OBJECT *RegionObj,
BOOLEAN AcpiNsLocked)
{
return (AE_OK);
}
ACPI_STATUS
AcpiExReadDataFromField (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT **RetBufferDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExWriteDataToField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT **ResultDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExLoadTableOp (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT **ReturnDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExUnloadTable (
ACPI_OPERAND_OBJECT *DdbHandle)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExLoadOp (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT *Target,
ACPI_WALK_STATE *WalkState)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiTbFindTable (
char *Signature,
char *OemId,
char *OemTableId,
ACPI_TABLE_HEADER **TablePtr)
{
return (AE_SUPPORT);
}

View File

@ -0,0 +1,623 @@
/******************************************************************************
*
* Module Name: asltransform - Parse tree transforms
* $Revision: 19 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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 "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asltransform")
/*******************************************************************************
*
* FUNCTION: TrAmlGetNextTempName
*
* PARAMETERS: NamePath - Where a pointer to the temp name is returned
*
* RETURN: A pointer to the second character of the name
*
* DESCRIPTION: Generate an ACPI name of the form _Txx. These names are
* reserved for use by the ASL compiler.
*
******************************************************************************/
char *
TrAmlGetNextTempName (
char **NamePath)
{
char *TempName;
if (Gbl_TempCount > 255)
{
/* Too many temps */
/* TBD: issue eror message */
*NamePath = "ERROR";
return ("Error");
}
TempName = UtLocalCalloc (6);
UtConvertByteToHex ((UINT8) Gbl_TempCount, (UINT8 *) &TempName [1]);
Gbl_TempCount++;
/* First three characters are always "\_T" */
TempName[0] = '\\';
TempName[1] = '_';
TempName[2] = 'T';
*NamePath = TempName;
return (&TempName[1]);
}
/*******************************************************************************
*
* FUNCTION: TrAmlInitLineNumbers
*
* PARAMETERS: Op - Op to be initialized
* Neighbor - Op used for initialization values
*
* RETURN: None
*
* DESCRIPTION: Initialized the various line numbers for a parse node.
*
******************************************************************************/
void
TrAmlInitLineNumbers (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *Neighbor)
{
Op->Asl.EndLine = Neighbor->Asl.EndLine;
Op->Asl.EndLogicalLine = Neighbor->Asl.EndLogicalLine;
Op->Asl.LineNumber = Neighbor->Asl.LineNumber;
Op->Asl.LogicalByteOffset = Neighbor->Asl.LogicalByteOffset;
Op->Asl.LogicalLineNumber = Neighbor->Asl.LogicalLineNumber;
}
/*******************************************************************************
*
* FUNCTION: TrAmlInitNode
*
* PARAMETERS: Op - Op to be initialized
* ParseOpcode - Opcode for this node
*
* RETURN: None
*
* DESCRIPTION: Initialize a node with the parse opcode and opcode name.
*
******************************************************************************/
void
TrAmlInitNode (
ACPI_PARSE_OBJECT *Op,
UINT16 ParseOpcode)
{
Op->Asl.ParseOpcode = ParseOpcode;
UtSetParseOpName (Op);
}
/*******************************************************************************
*
* FUNCTION: TrAmlSetSubtreeParent
*
* PARAMETERS: Op - First node in a list of peer nodes
* Parent - Parent of the subtree
*
* RETURN: None
*
* DESCRIPTION: Set the parent for all peer nodes in a subtree
*
******************************************************************************/
void
TrAmlSetSubtreeParent (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *Parent)
{
ACPI_PARSE_OBJECT *Next;
Next = Op;
while (Next)
{
Next->Asl.Parent = Parent;
Next = Next->Asl.Next;
}
}
/*******************************************************************************
*
* FUNCTION: TrAmlInsertPeer
*
* PARAMETERS: Op - First node in a list of peer nodes
* NewPeer - Peer node to insert
*
* RETURN: None
*
* DESCRIPTION: Insert a new peer node into a list of peers.
*
******************************************************************************/
void
TrAmlInsertPeer (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *NewPeer)
{
NewPeer->Asl.Next = Op->Asl.Next;
Op->Asl.Next = NewPeer;
}
/*******************************************************************************
*
* FUNCTION: TrAmlTransformWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: None
*
* DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
* operands.
*
******************************************************************************/
ACPI_STATUS
TrAmlTransformWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
TrTransformSubtree (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: TrTransformSubtree
*
* PARAMETERS: Op - The parent parse node
*
* RETURN: None
*
* DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
* complex AML opcodes require processing of the child nodes
* (arguments/operands).
*
******************************************************************************/
void
TrTransformSubtree (
ACPI_PARSE_OBJECT *Op)
{
if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
{
return;
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFINITIONBLOCK:
TrDoDefinitionBlock (Op);
break;
case PARSEOP_ELSEIF:
TrDoElseif (Op);
break;
case PARSEOP_SWITCH:
TrDoSwitch (Op);
break;
default:
/* Nothing to do here for other opcodes */
break;
}
}
/*******************************************************************************
*
* FUNCTION: TrDoDefinitionBlock
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Find the end of the definition block and set a global to this
* node. It is used by the compiler to insert compiler-generated
* names at the root level of the namespace.
*
******************************************************************************/
void
TrDoDefinitionBlock (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
UINT32 i;
Next = Op->Asl.Child;
for (i = 0; i < 5; i++)
{
Next = Next->Asl.Next;
}
Gbl_FirstLevelInsertionNode = Next;
}
/*******************************************************************************
*
* FUNCTION: TrDoElseif
*
* PARAMETERS: Op - Parse node for ELSEIF
*
* RETURN: None
*
* DESCRIPTION: Transform an Elseif into an Else and If AML opcode pair.
* There is no AML opcode for ELSEIF -- it must be simulated
* with an if/else pair.
*
******************************************************************************/
void
TrDoElseif (
ACPI_PARSE_OBJECT *ElseNode)
{
ACPI_PARSE_OBJECT *IfNode = NULL;
ACPI_PARSE_OBJECT *NextNode;
/* Change the ELSEIF into an ELSE */
TrAmlInitNode (ElseNode, PARSEOP_ELSE);
/* Create a new IF node */
IfNode = TrCreateLeafNode (PARSEOP_IF);
IfNode->Asl.Parent = ElseNode;
TrAmlInitLineNumbers (IfNode, ElseNode);
/* Insert the the IF node first in the ELSE child list */
IfNode->Asl.Child = ElseNode->Asl.Child;
ElseNode->Asl.Child = IfNode;
/* Go to the end of the IF <Predicate><TermList> block */
NextNode = IfNode->Asl.Child; /* Next = Predicate */
NextNode = NextNode->Asl.Next; /* Nest = TermList */
/* Make the next node after the IF the rest of the original tree */
IfNode->Asl.Next = NextNode->Asl.Next;
/* Terminate the IF subtree and set IF node as the parent for all nodes */
NextNode->Asl.Next = NULL;
TrAmlSetSubtreeParent (IfNode->Asl.Child, IfNode);
}
/*******************************************************************************
*
* FUNCTION: TrDoSwitch
*
* PARAMETERS: StartNode - Parse node for SWITCH
*
* RETURN: None
*
*
* DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is
* no actual AML opcode for SWITCH -- it must be simulated.
*
******************************************************************************/
void
TrDoSwitch (
ACPI_PARSE_OBJECT *StartNode)
{
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *CaseOp = NULL;
ACPI_PARSE_OBJECT *CaseBlock = NULL;
ACPI_PARSE_OBJECT *DefaultOp = NULL;
ACPI_PARSE_OBJECT *CurrentParentNode;
ACPI_PARSE_OBJECT *Conditional = NULL;
ACPI_PARSE_OBJECT *Predicate;
ACPI_PARSE_OBJECT *Peer;
ACPI_PARSE_OBJECT *NewOp;
ACPI_PARSE_OBJECT *NewOp2;
char *PredicateValueName;
char *PredicateValuePath;
CurrentParentNode = StartNode;
PredicateValueName = TrAmlGetNextTempName (&PredicateValuePath);
/* First child is the predicate */
Next = StartNode->Asl.Child;
Peer = Next->Asl.Next;
/* CASE statements start at next child */
while (Peer)
{
Next = Peer;
Peer = Next->Asl.Next;
if (Next->Asl.ParseOpcode == PARSEOP_CASE)
{
if (CaseOp)
{
/* Add an ELSE to complete the previous CASE */
NewOp = TrCreateLeafNode (PARSEOP_ELSE);
NewOp->Asl.Parent = Conditional->Asl.Parent;
TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent);
/* Link ELSE node as a peer to the previous IF */
TrAmlInsertPeer (Conditional, NewOp);
CurrentParentNode = NewOp;
}
CaseOp = Next;
Conditional = CaseOp;
CaseBlock = CaseOp->Asl.Child->Asl.Next;
Conditional->Asl.Child->Asl.Next = NULL;
/*
* change CaseOp() to: If (PredicateValue == CaseValue) {...}
* CaseOp->Child is the case value
* CaseOp->Child->Peer is the beginning of the case block
*/
NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
(ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath));
Predicate = CaseOp->Asl.Child;
Predicate->Asl.Next = NewOp;
TrAmlInitLineNumbers (NewOp, Predicate);
NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
NewOp2->Asl.Parent = Conditional;
NewOp2->Asl.Child = Predicate;
TrAmlInitLineNumbers (NewOp2, Conditional);
TrAmlSetSubtreeParent (Predicate, NewOp2);
Predicate = NewOp2;
Predicate->Asl.Next = CaseBlock;
TrAmlSetSubtreeParent (Predicate, Conditional);
/* Reinitialize the CASE node to an IF node */
Conditional->Asl.Child = Predicate;
TrAmlInitNode (Conditional, PARSEOP_IF);
/*
* The first CASE(IF) is not nested under an ELSE.
* All other CASEs are children of a parent ELSE.
*/
if (CurrentParentNode == StartNode)
{
Conditional->Asl.Parent = CurrentParentNode->Asl.Parent;
/* Link IF into the peer list */
TrAmlInsertPeer (CurrentParentNode, Conditional);
}
else
{
/*
* The IF is a child of previous IF/ELSE. It
* is therefore without peer.
*/
CurrentParentNode->Asl.Child = Conditional;
Conditional->Asl.Parent = CurrentParentNode;
Conditional->Asl.Next = NULL;
}
}
else if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT)
{
if (DefaultOp)
{
/* More than one Default */
}
/* Save the DEFAULT node for later, after CASEs */
DefaultOp = Next;
}
else
{
/* Unkown peer opcode */
printf ("Unknown parse opcode for switch statement: %s (%d)\n",
Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
}
}
/*
* Add the default at the end of the if/else construct
*/
if (DefaultOp)
{
if (CaseOp)
{
/* Add an ELSE first */
TrAmlInitNode (DefaultOp, PARSEOP_ELSE);
DefaultOp->Asl.Parent = Conditional->Asl.Parent;
}
else
{
/* There were no CASE statements, no ELSE needed */
TrAmlInsertPeer (CurrentParentNode, DefaultOp->Asl.Child);
}
}
/*
* Add a NAME node for the temp integer
*/
NewOp = TrCreateLeafNode (PARSEOP_NAME);
NewOp->Asl.Parent = Gbl_FirstLevelInsertionNode->Asl.Parent;
NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
(ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
NewOp->Asl.Child = NewOp2;
NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_INTEGER, (ACPI_INTEGER) 0);
TrAmlSetSubtreeParent (NewOp2, NewOp);
/* Insert this node at the global level of the ASL */
TrAmlInsertPeer (Gbl_FirstLevelInsertionNode, NewOp);
TrAmlInitLineNumbers (NewOp, Gbl_FirstLevelInsertionNode);
TrAmlInitLineNumbers (NewOp2, Gbl_FirstLevelInsertionNode);
TrAmlInitLineNumbers (NewOp2->Asl.Next, Gbl_FirstLevelInsertionNode);
/*
* Change the SWITCH node to a STORE (predicate value, _Txx)
*/
TrAmlInitNode (StartNode, PARSEOP_STORE);
Predicate = StartNode->Asl.Child;
Predicate->Asl.Child = NULL;
NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
(ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath));
NewOp->Asl.Parent = StartNode;
Predicate->Asl.Next = NewOp;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,496 @@
/******************************************************************************
*
* Module Name: asltypes.h - compiler data types and struct definitions
* $Revision: 59 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, 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.
*
*****************************************************************************/
#ifndef __ASLTYPES_H
#define __ASLTYPES_H
#include <time.h>
/*******************************************************************************
*
* Structure definitions
*
******************************************************************************/
/* Op flags for the ACPI_PARSE_OBJECT */
#define NODE_VISITED 0x00000001
#define NODE_AML_PACKAGE 0x00000002
#define NODE_IS_TARGET 0x00000004
#define NODE_IS_RESOURCE_DESC 0x00000008
#define NODE_IS_RESOURCE_FIELD 0x00000010
#define NODE_HAS_NO_EXIT 0x00000020
#define NODE_IF_HAS_NO_EXIT 0x00000040
#define NODE_NAME_INTERNALIZED 0x00000080
#define NODE_METHOD_NO_RETVAL 0x00000100
#define NODE_METHOD_SOME_NO_RETVAL 0x00000200
#define NODE_RESULT_NOT_USED 0x00000400
#define NODE_METHOD_TYPED 0x00000800
#define NODE_IS_BIT_OFFSET 0x00001000
#define NODE_COMPILE_TIME_CONST 0x00002000
#define NODE_IS_TERM_ARG 0x00004000
#define NODE_WAS_ONES_OP 0x00008000
#define NODE_IS_NAME_DECLARATION 0x00010000
/* Keeps information about individual control methods */
typedef struct asl_method_info
{
UINT8 NumArguments;
UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS];
UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS];
UINT32 NumReturnNoValue;
UINT32 NumReturnWithValue;
ACPI_PARSE_OBJECT *Op;
struct asl_method_info *Next;
UINT8 HasBeenTyped;
} ASL_METHOD_INFO;
/* Parse tree walk info for control method analysis */
typedef struct asl_analysis_walk_info
{
ASL_METHOD_INFO *MethodStack;
} ASL_ANALYSIS_WALK_INFO;
/* An entry in the ParseOpcode to AmlOpcode mapping table */
typedef struct asl_mapping_entry
{
UINT32 Value;
UINT32 AcpiBtype; /* Object type or return type */
UINT16 AmlOpcode;
UINT8 Flags;
} ASL_MAPPING_ENTRY;
/* An entry in the Reserved Name information table */
#define ASL_RSVD_RETURN_VALUE 0x01
#define ASL_RSVD_RESOURCE_NAME 0x02
#define ASL_RSVD_SCOPE 0x04
typedef struct asl_reserved_info
{
char *Name;
UINT8 NumArguments;
UINT8 Flags;
} ASL_RESERVED_INFO;
/* Parse tree walk info structure */
typedef struct asl_walk_info
{
ACPI_PARSE_OBJECT **NodePtr;
UINT32 *LevelPtr;
} ASL_WALK_INFO;
/* File info */
typedef struct asl_file_info
{
FILE *Handle;
char *Filename;
} ASL_FILE_INFO;
/* File types */
typedef enum
{
ASL_FILE_STDOUT = 0,
ASL_FILE_STDERR,
ASL_FILE_INPUT,
ASL_FILE_AML_OUTPUT,
ASL_FILE_SOURCE_OUTPUT,
ASL_FILE_LISTING_OUTPUT,
ASL_FILE_HEX_OUTPUT,
ASL_FILE_NAMESPACE_OUTPUT,
ASL_FILE_DEBUG_OUTPUT,
ASL_FILE_ASM_SOURCE_OUTPUT,
ASL_FILE_C_SOURCE_OUTPUT,
ASL_FILE_ASM_INCLUDE_OUTPUT,
ASL_FILE_C_INCLUDE_OUTPUT
} ASL_FILE_TYPES;
#define ASL_MAX_FILE_TYPE 12
#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1)
/* An entry in the exception list, one for each error/warning */
typedef struct asl_error_msg
{
UINT32 LineNumber;
UINT32 LogicalLineNumber;
UINT32 LogicalByteOffset;
UINT32 Column;
char *Message;
struct asl_error_msg *Next;
char *Filename;
UINT32 FilenameLength;
UINT8 MessageId;
UINT8 Level;
} ASL_ERROR_MSG;
/* An entry in the listing file stack (for include files) */
typedef struct asl_listing_node
{
char *Filename;
UINT32 LineNumber;
struct asl_listing_node *Next;
} ASL_LISTING_NODE;
/* Callback interface for a parse tree walk */
typedef
ACPI_STATUS (*ASL_WALK_CALLBACK) (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
typedef struct asl_event_info
{
time_t StartTime;
time_t EndTime;
char *EventName;
BOOLEAN Valid;
} ASL_EVENT_INFO;
#define ASL_ERROR 0
#define ASL_WARNING 1
#define ASL_REMARK 2
#define ASL_OPTIMIZATION 3
#define ASL_NUM_REPORT_LEVELS 4
typedef enum
{
ASL_MSG_NULL = 0,
ASL_MSG_MEMORY_ALLOCATION,
ASL_MSG_INPUT_FILE_OPEN,
ASL_MSG_OUTPUT_FILENAME,
ASL_MSG_OUTPUT_FILE_OPEN,
ASL_MSG_LISTING_FILENAME,
ASL_MSG_LISTING_FILE_OPEN,
ASL_MSG_DEBUG_FILENAME,
ASL_MSG_DEBUG_FILE_OPEN,
ASL_MSG_INCLUDE_FILE_OPEN,
ASL_MSG_ENCODING_LENGTH,
ASL_MSG_INVALID_PRIORITY,
ASL_MSG_INVALID_PERFORMANCE,
ASL_MSG_LOCAL_INIT,
ASL_MSG_ARG_INIT,
ASL_MSG_UNSUPPORTED,
ASL_MSG_RESERVED_WORD,
ASL_MSG_BUFFER_LENGTH,
ASL_MSG_PACKAGE_LENGTH,
ASL_MSG_RETURN_TYPES,
ASL_MSG_NOT_FOUND,
ASL_MSG_NOT_REACHABLE,
ASL_MSG_NOT_EXIST,
ASL_MSG_NESTED_COMMENT,
ASL_MSG_RESERVED_ARG_COUNT_HI,
ASL_MSG_RESERVED_ARG_COUNT_LO,
ASL_MSG_RESERVED_RETURN_VALUE,
ASL_MSG_ARG_COUNT_HI,
ASL_MSG_ARG_COUNT_LO,
ASL_MSG_NO_RETVAL,
ASL_MSG_SOME_NO_RETVAL,
ASL_MSG_COMPILER_INTERNAL,
ASL_MSG_BACKWARDS_OFFSET,
ASL_MSG_UNKNOWN_RESERVED_NAME,
ASL_MSG_NAME_EXISTS,
ASL_MSG_INVALID_TYPE,
ASL_MSG_MULTIPLE_TYPES,
ASL_MSG_SYNTAX,
ASL_MSG_NOT_METHOD,
ASL_MSG_LONG_LINE,
ASL_MSG_RECURSION,
ASL_MSG_NOT_PARAMETER,
ASL_MSG_OPEN,
ASL_MSG_READ,
ASL_MSG_WRITE,
ASL_MSG_SEEK,
ASL_MSG_CLOSE,
ASL_MSG_FIELD_ACCESS_WIDTH,
ASL_MSG_REGION_BYTE_ACCESS,
ASL_MSG_REGION_BUFFER_ACCESS,
ASL_MSG_FIELD_UNIT_OFFSET,
ASL_MSG_FIELD_UNIT_ACCESS_WIDTH,
ASL_MSG_RESOURCE_FIELD,
ASL_MSG_BYTES_TO_BITS,
ASL_MSG_BITS_TO_BYTES,
ASL_MSG_AML_NOT_IMPLEMENTED,
ASL_MSG_NO_WHILE,
ASL_MSG_INVALID_ESCAPE,
ASL_MSG_INVALID_STRING,
ASL_MSG_TABLE_SIGNATURE,
ASL_MSG_RESOURCE_LIST,
ASL_MSG_INVALID_TARGET,
ASL_MSG_INVALID_CONSTANT_OP,
ASL_MSG_CONSTANT_EVALUATION,
ASL_MSG_CONSTANT_FOLDED,
ASL_MSG_INVALID_EISAID,
ASL_MSG_RESERVED_OPERAND_TYPE,
ASL_MSG_RESERVED_METHOD,
ASL_MSG_ALPHANUMERIC_STRING,
ASL_MSG_RESERVED_USE,
ASL_MSG_INVALID_OPERAND,
ASL_MSG_MISSING_ENDDEPENDENT,
ASL_MSG_MISSING_STARTDEPENDENT,
ASL_MSG_DEPENDENT_NESTING,
ASL_MSG_NAME_OPTIMIZATION,
ASL_MSG_SINGLE_NAME_OPTIMIZATION,
ASL_MSG_INTEGER_OPTIMIZATION,
ASL_MSG_SCOPE_TYPE,
ASL_MSG_CORE_EXCEPTION,
ASL_MSG_UNREACHABLE_CODE,
ASL_MSG_EARLY_EOF,
ASL_MSG_SCOPE_FWD_REF
} ASL_MESSAGE_IDS;
#ifdef ASL_EXCEPTIONS
char *AslMessages [] = {
/* ASL_MSG_NULL */ NULL,
/* ASL_MSG_MEMORY_ALLOCATION, */ "Memory allocation failure",
/* ASL_MSG_INPUT_FILE_OPEN, */ "Could not open input file",
/* ASL_MSG_OUTPUT_FILENAME, */ "Could not create output filename",
/* ASL_MSG_OUTPUT_FILE_OPEN, */ "Could not open output AML file",
/* ASL_MSG_LISTING_FILENAME, */ "Could not create listing filename",
/* ASL_MSG_LISTING_FILE_OPEN, */ "Could not open listing file",
/* ASL_MSG_DEBUG_FILENAME, */ "Could not create debug filename",
/* ASL_MSG_DEBUG_FILE_OPEN, */ "Could not open debug file",
/* ASL_MSG_INCLUDE_FILE_OPEN, */ "Could not open include file",
/* ASL_MSG_ENCODING_LENGTH, */ "Package length too long to encode",
/* ASL_MSG_INVALID_PRIORITY, */ "Invalid priority value",
/* ASL_MSG_INVALID_PERFORMANCE, */ "Invalid performance/robustness value",
/* ASL_MSG_LOCAL_INIT, */ "Method local variable is not initialized",
/* ASL_MSG_ARG_INIT, */ "Method argument is not initialized",
/* ASL_MSG_UNSUPPORTED, */ "Unsupported feature",
/* ASL_MSG_RESERVED_WORD, */ "Use of reserved word",
/* ASL_MSG_BUFFER_LENGTH, */ "Effective AML buffer length is zero",
/* ASL_MSG_PACKAGE_LENGTH, */ "Effective AML package length is zero",
/* ASL_MSG_RETURN_TYPES, */ "Not all control paths return a value",
/* ASL_MSG_NOT_FOUND, */ "Object not found or not accessible from scope",
/* ASL_MSG_NOT_REACHABLE, */ "Object not accessible from this scope",
/* ASL_MSG_NOT_EXIST, */ "Object does not exist",
/* ASL_MSG_NESTED_COMMENT, */ "Nested comment found",
/* ASL_MSG_RESERVED_ARG_COUNT_HI, */ "Reserved method has too many arguments",
/* ASL_MSG_RESERVED_ARG_COUNT_LO, */ "Reserved method has too few arguments",
/* ASL_MSG_RESERVED_RETURN_VALUE, */ "Reserved method must return a value",
/* ASL_MSG_ARG_COUNT_HI, */ "Too many arguments",
/* ASL_MSG_ARG_COUNT_LO, */ "Too few arguments",
/* ASL_MSG_NO_RETVAL, */ "Called method returns no value",
/* ASL_MSG_SOME_NO_RETVAL, */ "Called method may not always return a value",
/* ASL_MSG_COMPILER_INTERNAL, */ "Internal compiler error",
/* ASL_MSG_BACKWARDS_OFFSET, */ "Invalid backwards offset",
/* ASL_MSG_UNKNOWN_RESERVED_NAME, */ "Unknown reserved name",
/* ASL_MSG_NAME_EXISTS, */ "Name already exists in scope",
/* ASL_MSG_INVALID_TYPE, */ "Invalid type",
/* ASL_MSG_MULTIPLE_TYPES, */ "Multiple types",
/* ASL_MSG_SYNTAX, */ "",
/* ASL_MSG_NOT_METHOD, */ "Not a control method, cannot invoke",
/* ASL_MSG_LONG_LINE, */ "Splitting long input line",
/* ASL_MSG_RECURSION, */ "Recursive method call",
/* ASL_MSG_NOT_PARAMETER, */ "Not a parameter, used as local only",
/* ASL_MSG_OPEN, */ "Could not open file",
/* ASL_MSG_READ, */ "Could not read file",
/* ASL_MSG_WRITE, */ "Could not write file",
/* ASL_MSG_SEEK, */ "Could not seek file",
/* ASL_MSG_CLOSE, */ "Could not close file",
/* ASL_MSG_FIELD_ACCESS_WIDTH, */ "Access width is greater than region size",
/* ASL_MSG_REGION_BYTE_ACCESS, */ "Host Operation Region requires ByteAcc access",
/* ASL_MSG_REGION_BUFFER_ACCESS, */ "Host Operation Region requires BufferAcc access",
/* ASL_MSG_FIELD_UNIT_OFFSET, */ "Field Unit extends beyond region limit",
/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, */ "Access width of Field Unit extends beyond region limit",
/* ASL_MSG_RESOURCE_FIELD, */ "Resource field name cannot be used as a target",
/* ASL_MSG_BYTES_TO_BITS, */ "Field offset is in bytes, but a bit offset is required",
/* ASL_MSG_BITS_TO_BYTES, */ "Field offset is in bits, but a byte offset is required",
/* ASL_MSG_AML_NOT_IMPLEMENTED, */ "Opcode is not implemented in compiler AML code generator",
/* ASL_MSG_NO_WHILE, */ "No enclosing While statement",
/* ASL_MSG_INVALID_ESCAPE, */ "Invalid or unknown escape sequence",
/* ASL_MSG_INVALID_STRING, */ "Invalid Hex/Octal Escape - Non-ASCII or NULL",
/* ASL_MSG_TABLE_SIGNATURE, */ "Invalid Table Signature",
/* ASL_MSG_RESOURCE_LIST, */ "Too many resource items (internal error)",
/* ASL_MSG_INVALID_TARGET, */ "Target operand not allowed in constant expression",
/* ASL_MSG_INVALID_CONSTANT_OP, */ "Invalid operator in constant expression (not type 3/4/5)",
/* ASL_MSG_CONSTANT_EVALUATION, */ "Could not evaluate constant expression",
/* ASL_MSG_CONSTANT_FOLDED, */ "Constant expression evaluated and reduced",
/* ASL_MSG_INVALID_EISAID, */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)",
/* ASL_MSG_RESERVED_OPERAND_TYPE, */ "Invalid operand type for reserved name, must be",
/* ASL_MSG_RESERVED_METHOD, */ "Reserved name must be a control method",
/* ASL_MSG_ALPHANUMERIC_STRING, */ "String must be entirely alphanumeric",
/* ASL_MSG_RESERVED_USE, */ "Invalid use of reserved name",
/* ASL_MSG_INVALID_OPERAND, */ "Invalid operand",
/* ASL_MSG_MISSING_ENDDEPENDENT, */ "Missing EndDependentFn() macro in dependent resource list",
/* ASL_MSG_MISSING_STARTDEPENDENT, */ "Missing StartDependentFn() macro in dependent resource list",
/* ASL_MSG_DEPENDENT_NESTING, */ "Dependent function macros cannot be nested",\
/* ASL_MSG_NAME_OPTIMIZATION, */ "NamePath optimized",
/* ASL_MSG_SINGLE_NAME_OPTIMIZATION, */ "NamePath optimized to NameSeg (uses run-time search path)",
/* ASL_MSG_INTEGER_OPTIMIZATION, */ "Integer optimized to single-byte AML opcode",
/* ASL_MSG_SCOPE_TYPE, */ "Existing object has invalid type for Scope operator",
/* ASL_MSG_CORE_EXCEPTION, */ "From ACPI CA Subsystem",
/* ASL_MSG_UNREACHABLE_CODE, */ "Statement is unreachable",
/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached",
/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope() not allowed"
};
char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = {
"Error ",
"Warning ",
"Remark ",
"Optimize"
};
#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */
/* Exception counters */
UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0};
#endif
#endif /* __ASLTYPES_H */

File diff suppressed because it is too large Load Diff