Automated cleanup

date	2002.07.30.22.07.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 15:52:58 +00:00
parent 95aa1658b5
commit 588126a6c3
15 changed files with 1637 additions and 285 deletions

View File

@ -3,7 +3,7 @@
/******************************************************************************
*
* Module Name: aslcompiler.y - Bison input file (ASL grammar and actions)
* $Revision: 1.60 $
* $Revision: 1.61 $
*
*****************************************************************************/
@ -2849,8 +2849,8 @@ NameStringItem
%%
/*
* Local support functions
/*
* Local support functions
*/
int

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslfiles - file I/O suppoert
* $Revision: 1.34 $
* $Revision: 1.40 $
*
*****************************************************************************/
@ -116,6 +116,7 @@
*****************************************************************************/
#include "aslcompiler.h"
#include "adisasm.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfiles")
@ -146,7 +147,7 @@ AslAbort (void)
AePrintErrorLog (ASL_FILE_STDERR);
}
exit (1);
exit (0);
}
@ -374,7 +375,7 @@ FlSeekFile (
UINT32 FileId,
long Offset)
{
UINT32 Error;
int Error;
Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
@ -394,21 +395,20 @@ FlSeekFile (
*
* RETURN: Status
*
* DESCRIPTION: Close an open file. Does not abort on error, simply logs
* the problem.
* DESCRIPTION: Close an open file. Aborts compiler on error
*
******************************************************************************/
ACPI_STATUS
void
FlCloseFile (
UINT32 FileId)
{
UINT32 Error;
int Error;
if (!Gbl_Files[FileId].Handle)
{
return AE_OK;
return;
}
Error = fclose (Gbl_Files[FileId].Handle);
@ -417,10 +417,10 @@ FlCloseFile (
if (Error)
{
FlFileError (FileId, ASL_MSG_CLOSE);
return (AE_ERROR);
AslAbort ();
}
return (AE_OK);
return;
}
@ -502,56 +502,6 @@ FlOpenIncludeFile (
}
/*******************************************************************************
*
* FUNCTION: FlGenerateFilename
*
* PARAMETERS: InputFilename - Original ASL source filename
* Suffix - New extension.
*
* RETURN: New filename containing the original base + the new suffix
*
* DESCRIPTION: Generate a new filename from the ASL source filename and a new
* extension. Used to create the *.LST, *.TXT, etc. files.
*
******************************************************************************/
char *
FlGenerateFilename (
char *InputFilename,
char *Suffix)
{
char *Position;
char *NewFilename;
/* Copy the original filename to a new buffer */
NewFilename = UtLocalCalloc (strlen (InputFilename) + strlen (Suffix));
strcpy (NewFilename, InputFilename);
/* Try to find the last dot in the filename */
Position = strrchr (NewFilename, '.');
if (Position)
{
/* Tack on the new suffix */
Position++;
*Position = 0;
strcat (Position, Suffix);
}
else
{
/* No dot, add one and then the suffix */
strcat (NewFilename, ".");
strcat (NewFilename, Suffix);
}
return NewFilename;
}
/*******************************************************************************
*
* FUNCTION: FlOpenInputFile
@ -672,7 +622,7 @@ FlOpenMiscOutputFiles (
char *Filename;
/* Create/Open a combined source output file if asked */
/* Create/Open a combined source output file */
Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
if (!Filename)
@ -681,9 +631,12 @@ FlOpenMiscOutputFiles (
return (AE_ERROR);
}
/* Open the source output file, text mode */
FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+");
/*
* 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 */
@ -797,7 +750,7 @@ FlOpenMiscOutputFiles (
/* 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+", stderr);
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr);
AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);

532
source/compiler/aslfold.c Normal file
View File

@ -0,0 +1,532 @@
/******************************************************************************
*
* Module Name: aslfold - Constant folding
* $Revision: 1.4 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2002, 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 (TABLE_ID_DSDT, 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_REMARK, 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

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asllisting - Listing file generation
* $Revision: 1.41 $
* $Revision: 1.43 $
*
*****************************************************************************/
@ -614,8 +614,6 @@ LsWriteOneSourceLine (
}
FlWriteFile (FileId, &FileByte, 1);
DbgPrint (ASL_PARSE_OUTPUT, "%c", FileByte);
if (FileByte == '\n')
{
/*
@ -652,7 +650,6 @@ LsFinishSourceListing (
UINT32 FileId)
{
LsFlushListingBuffer (FileId);
Gbl_CurrentAmlOffset = 0;
@ -839,7 +836,7 @@ LsWriteNodeToListing (
if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
{
FlPrintFile (FileId, "%s_%s_Header \\\n",
FlPrintFile (FileId, "%s_%s_Header \\\n",
Gbl_TableSignature, Gbl_TableId);
}
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
@ -953,12 +950,12 @@ LsWriteNodeToListing (
if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
{
FlPrintFile (FileId, "%s_%s_%s \\\n",
FlPrintFile (FileId, "%s_%s_%s \\\n",
Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
}
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, " unsigned char %s_%s_%s [] = \n {\n",
FlPrintFile (FileId, " unsigned char %s_%s_%s [] = \n {\n",
Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
}
}

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: asllookup- Namespace lookup
* $Revision: 1.59 $
* $Revision: 1.62 $
*
*****************************************************************************/
@ -404,7 +404,7 @@ void
LkCheckFieldRange (
ACPI_PARSE_OBJECT *Op,
UINT32 RegionBitLength,
UINT32 FieldBitOffset,
UINT32 FieldBitOffset,
UINT32 FieldBitLength,
UINT32 AccessBitWidth)
{
@ -425,7 +425,7 @@ LkCheckFieldRange (
return;
}
/*
/*
* Now check that the field plus AccessWidth doesn't go beyond
* the end-of-region. Assumes AccessBitWidth is a power of 2
*/
@ -535,13 +535,13 @@ LkNamespaceLocateBegin (
{
/* There exists such a name, but we couldn't get to it from this scope */
AslError (ASL_WARNING, ASL_MSG_NOT_REACHABLE, Op, Op->Asl.ExternalName);
AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, Op->Asl.ExternalName);
}
else
{
/* The name doesn't exist, period */
AslError (ASL_WARNING, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
}
}
else
@ -552,13 +552,13 @@ LkNamespaceLocateBegin (
{
/* Gave full path, the object does not exist */
AslError (ASL_WARNING, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName);
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_WARNING, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName);
}
}
@ -665,6 +665,12 @@ LkNamespaceLocateBegin (
return (AE_OK);
}
if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
{
Op->Asl.Node = Node;
return (AE_OK);
}
/*
* This is a method invocation, with or without arguments.
* Count the number of arguments, each appears as a child

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslmain - compiler main and utilities
* $Revision: 1.48 $
* $Revision: 1.60 $
*
*****************************************************************************/
@ -119,6 +119,8 @@
#define _DECLARE_GLOBALS
#include "aslcompiler.h"
#include "acnamesp.h"
#include "adisasm.h"
#ifdef _DEBUG
#include <crtdbg.h>
@ -129,8 +131,12 @@
int optind;
NATIVE_CHAR *optarg;
BOOLEAN AslToFile = TRUE;
BOOLEAN DoCompile = TRUE;
BOOLEAN DoSignon = TRUE;
UINT32 Gbl_ExceptionCount[2] = {0,0};
UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0};
char hex[] = {'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'};
@ -152,20 +158,34 @@ Options (
void)
{
printf ("Options:\n");
printf (" -a Create AML in a assembler source code file (*.asm)\n");
printf (" -c Create AML in a C source code file (*.c)\n");
printf (" -d Disassemble AML file\n");
printf (" -e Less verbose errors and warnings for IDE\n");
printf (" -f Disable constant folding\n");
printf (" -h Additional help and compiler debug options\n");
printf (" -l Create listing file (mixed ASL source and AML) (*.lst)\n");
printf (" -n Create namespace file (*.nsp)\n");
printf (" -o <name> Specify filename prefix for all output files\n");
printf (" (including the .aml file)\n");
printf (" -r Display ACPI reserved method names\n");
printf (" -s Create combined (w/includes) ASL file (*.src)\n");
printf (" -t <a|c> Create AML hex table in assembler or C (*.hex)\n");
printf ("General Output:\n");
printf (" -o<prefix> Specify filename prefix for all output files (including .aml)\n");
printf (" -vi Less verbose errors and warnings for use with IDEs\n");
printf (" -vr Disable generation of 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 (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n");
printf ("\nAML Optimization:\n");
printf (" -cf Disable constant folding\n");
printf (" -ci Disable integer optimization to Zero/One/Ones\n");
printf ("\nListings:\n");
printf (" -lm 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 (" -da [file] Disassemble AML to ASL source code file (*.dsl)\n");
printf (" -dc [file] Disassemble AML (to *.dsl) and compile it\n");
printf (" (Obtain AML from current system if no input file)\n");
printf ("\nHelp:\n");
printf (" -h Additional help and compiler debug options\n");
printf (" -qc Display operators allowed in constant expressions\n");
printf (" -qr Display ACPI reserved method names\n");
}
@ -186,7 +206,7 @@ HelpMessage (
void)
{
printf ("Output Filename generation:\n");
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");
@ -198,12 +218,12 @@ HelpMessage (
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 (" -i Ignore errors, always create AML output file(s)\n");
printf (" -p Parse only, no output generation\n");
printf (" -x Display compile times\n");
printf (" -v <trace level> Set debug level for trace output\n");
printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n");
printf (" Types: Parse/Tree/Both\n");
printf (" -i Ignore errors, always create AML output file(s)\n");
printf (" -p Parse only, no output generation\n");
printf (" -ct Display compile times\n");
printf (" -x<level> Set debug level for trace output\n");
}
@ -224,7 +244,7 @@ Usage (
void)
{
printf ("Usage: %s <Options> <InputFile>\n\n", CompilerName);
printf ("Usage: %s [Options] [InputFile]\n\n", CompilerName);
Options ();
}
@ -269,49 +289,37 @@ AslInitialize (void)
/*******************************************************************************
*
* FUNCTION: main
* FUNCTION: AslCommandLine
*
* PARAMETERS: Standard argc/argv
* PARAMETERS: argc/argv
*
* RETURN: Program termination code
* RETURN: None
*
* DESCRIPTION: C main routine for the Asl Compiler. Handle command line
* options and begin the compile.
* DESCRIPTION: Command line processing
*
******************************************************************************/
int ACPI_SYSTEM_XFACE
main (
void
AslCommandLine (
int argc,
char **argv)
{
int j;
BOOLEAN BadCommandLine = FALSE;
int Status;
NATIVE_UINT j;
AslInitialize ();
AslCompilerSignon (ASL_FILE_STDOUT);
/* Minimum command line contains at least the input file */
/* Minimum command line contains at least one option or an input file */
if (argc < 2)
{
Usage ();
return 0;
exit (1);
}
/* Get the command line options */
while ((j = getopt (argc, argv, "ab:cdefhilno:prst:vx")) != EOF) switch (j)
while ((j = getopt (argc, argv, "b:c:d:hil:o:pq:rs:t:v:x")) != EOF) switch (j)
{
case 'a':
/* Produce assembly code output file */
Gbl_AsmOutputFlag = TRUE;
break;
case 'b':
switch (optarg[0])
@ -328,8 +336,9 @@ main (
break;
default:
printf ("Unknown option: -d%s\n", optarg);
printf ("Unknown option: -b%s\n", optarg);
BadCommandLine = TRUE;
break;
}
/* Produce debug output file */
@ -337,36 +346,68 @@ main (
Gbl_DebugFlag = TRUE;
break;
case 'c':
/* Produce C hex output file */
switch (optarg[0])
{
case 'f':
Gbl_C_OutputFlag = TRUE;
/* Disable folding on "normal" expressions */
Gbl_FoldConstants = FALSE;
break;
case 'i':
/* Disable integer optimization to constants */
Gbl_IntegerOptimizationFlag = FALSE;
break;
case 't':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
break;
default:
printf ("Unknown option: -c%s\n", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'd':
printf ("AML Disassembly not yet supported\n");
return (0);
switch (optarg[0])
{
case 'a':
AslCompilerdebug = 1; /* same as yydebug */
DoCompile = FALSE;
break;
case 'c':
AslCompilerdebug = 1; /* same as yydebug */
break;
default:
printf ("Unknown option: -d%s\n", optarg);
BadCommandLine = TRUE;
break;
}
Gbl_DisasmFlag = TRUE;
break;
case 'e':
/* Less verbose error messages */
Gbl_VerboseErrors = FALSE;
break;
case 'f':
/* Disable folding on "normal" expressions */
Gbl_FoldConstants = FALSE;
break;
case 'h':
HelpMessage ();
return 0;
exit (0);
case 'i':
@ -375,19 +416,36 @@ main (
Gbl_IgnoreErrors = TRUE;
break;
case 'l':
/* Produce listing file (Mixed source/aml) */
switch (optarg[0])
{
case 'm':
/* Produce listing file (Mixed source/aml) */
Gbl_ListingFlag = TRUE;
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", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'n':
/* Produce namespace file */
Gbl_NsOutputFlag = TRUE;
break;
case 'o':
@ -397,6 +455,7 @@ main (
Gbl_UseDefaultAmlFilename = FALSE;
break;
case 'p':
/* Parse only */
@ -404,20 +463,60 @@ main (
Gbl_ParseOnlyFlag = TRUE;
break;
case 'q':
switch (optarg[0])
{
case 'c':
UtDisplayConstantOpcodes ();
exit (0);
case 'r':
/* reserved names */
MpDisplayReservedNames ();
exit (0);
default:
printf ("Unknown option: -q%s\n", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'r':
AslToFile = FALSE;
break;
/* reserved names */
MpDisplayReservedNames ();
return (0);
case 's':
/* Produce combined source file */
switch (optarg[0])
{
case 'a':
Gbl_SourceOutputFlag = TRUE;
/* 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", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 't':
/* Produce hex table output file */
@ -435,21 +534,42 @@ main (
default:
printf ("Unknown option: -t%s\n", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'v':
switch (optarg[0])
{
case 'i':
/* Less verbose error messages */
Gbl_VerboseErrors = FALSE;
break;
case 'r':
printf ("-vr not implemented\n");
break;
case 's':
DoSignon = FALSE;
break;
default:
printf ("Unknown option: -v%s\n", optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'x':
AcpiDbgLevel = strtoul (optarg, NULL, 16);
break;
case 'x':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
break;
default:
@ -460,7 +580,7 @@ main (
/* Next parameter must be the input filename */
Gbl_Files[ASL_FILE_INPUT].Filename = argv[optind];
if (!Gbl_Files[ASL_FILE_INPUT].Filename)
if (!Gbl_Files[ASL_FILE_INPUT].Filename && !Gbl_DisasmFlag)
{
printf ("Missing input filename\n");
BadCommandLine = TRUE;
@ -472,12 +592,45 @@ main (
{
printf ("\n");
Usage ();
return -1;
exit (1);
}
if ((optind + 1) < argc)
{
printf ("Warning: extra arguments (%d) after input filename are ignored\n\n", argc - optind - 1);
printf ("Warning: extra arguments (%d) after input filename are ignored\n\n",
argc - 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;
/* Init and command line */
AslInitialize ();
AslCommandLine (argc, argv);
if (DoSignon)
{
AslCompilerSignon (ASL_FILE_STDOUT);
}
/*
@ -489,8 +642,77 @@ main (
Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
}
Status = CmDoCompile ();
return (Status);
/*
* AML Disassembly
*/
if (Gbl_DisasmFlag)
{
/* ACPI CA subsystem initialization */
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
AcpiGbl_DbOpt_disasm = TRUE;
Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename,
&Gbl_Files[ASL_FILE_INPUT].Filename);
if (ACPI_FAILURE (Status))
{
return -1;
}
Gbl_Files[ASL_FILE_INPUT].Filename =
FlGenerateFilename (Gbl_Files[ASL_FILE_INPUT].Filename,
FILE_SUFFIX_DISASSEMBLY);
if (DoCompile)
{
AcpiOsPrintf ("\nCompiling \"%s\"\n",
Gbl_Files[ASL_FILE_INPUT].Filename);
}
}
/*
* ASL Compilation
*/
if (DoCompile)
{
/*
* If -o not specified, we will use the input filename as the
* output filename prefix
*/
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
}
/* ACPI CA subsystem initialization (Must be Re-initialized) */
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = CmDoCompile ();
}
return (0);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslmap - parser to AML opcode mapping table
* $Revision: 1.58 $
* $Revision: 1.64 $
*
*****************************************************************************/
@ -197,12 +197,16 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_AL1", 0, ASL_RSVD_RETURN_VALUE},
{"_AL2", 0, ASL_RSVD_RETURN_VALUE},
{"_AL3", 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},
@ -212,7 +216,8 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_DCK", 1, ASL_RSVD_RETURN_VALUE},
{"_DCS", 0, ASL_RSVD_RETURN_VALUE},
{"_DDC", 1, ASL_RSVD_RETURN_VALUE},
{"_DDN", 1, 0}, /* Spec is ambiguous about this */
{"_DDN", 0, 0},
{"_DEC", 0, ASL_RSVD_RESOURCE_NAME},
{"_DGS", 0, ASL_RSVD_RETURN_VALUE},
{"_DIS", 0, 0},
{"_DMA", 0, ASL_RSVD_RETURN_VALUE},
@ -231,23 +236,36 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_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},
{"_PIC", 1, 0},
@ -271,9 +289,14 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_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},
@ -284,9 +307,13 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_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},
@ -297,7 +324,12 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
{"_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},
@ -307,10 +339,9 @@ const ASL_RESERVED_INFO ReservedMethods[] = {
};
/*******************************************************************************
*
* FUNCTION: MpDisplayReservedNames
* FUNCTION: MpDisplayReservedNames
*
* PARAMETERS: None
*
@ -330,15 +361,27 @@ MpDisplayReservedNames (
for (i = 0; ReservedMethods[i].Name; i++)
{
printf ("%s %d arguments, ", ReservedMethods[i].Name,
ReservedMethods[i].NumArguments);
if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE)
printf ("%s ", ReservedMethods[i].Name);
if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)
{
printf ("must return a value\n");
printf ("Reserved scope name\n");
}
else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)
{
printf ("Resource data type reserved field name\n");
}
else
{
printf ("no return value\n");
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");
}
}
}
}
@ -602,7 +645,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* 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, 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),

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslopcode - AML opcode generation
* $Revision: 1.39 $
* $Revision: 1.46 $
*
*****************************************************************************/
@ -120,9 +120,6 @@
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acparser.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopcodes")
@ -156,6 +153,39 @@ OpcAmlOpcodeWalk (
}
/*******************************************************************************
*
* 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 (Child->Asl.Value.Integer8);
}
/*******************************************************************************
*
* FUNCTION: OpcSetOptimalIntegerSize
@ -178,25 +208,36 @@ OpcSetOptimalIntegerSize (
/* Check for the special AML integers first */
if (Op->Asl.Value.Integer == 0)
if (Gbl_IntegerOptimizationFlag)
{
Op->Asl.AmlOpcode = AML_ZERO_OP;
return 1;
}
if (Op->Asl.Value.Integer == 1)
{
Op->Asl.AmlOpcode = AML_ONE_OP;
return 1;
if (Op->Asl.Value.Integer == 0)
{
Op->Asl.AmlOpcode = AML_ZERO_OP;
return 1;
}
if (Op->Asl.Value.Integer == 1)
{
Op->Asl.AmlOpcode = AML_ONE_OP;
return 1;
}
/* Check for table integer width (32 or 64) */
if (AcpiGbl_IntegerByteWidth == 4)
{
if (Op->Asl.Value.Integer == ACPI_UINT32_MAX)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
return 1;
}
}
else if (Op->Asl.Value.Integer == ACPI_INTEGER_MAX)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
return 1;
}
}
/* TBD: add check for table width (32 or 64) */
if (Op->Asl.Value.Integer == ACPI_INTEGER_MAX)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
return 1;
}
/* Find the best fit */
if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
@ -333,6 +374,7 @@ OpcDoUnicode (
InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
InitializerOp->Asl.AmlLength = Length;
InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
InitializerOp->Asl.Child = NULL;
UtSetParseOpName (InitializerOp);
}
@ -346,7 +388,32 @@ OpcDoUnicode (
* RETURN: None
*
*
* DESCRIPTION: Convert a string EISA ID to numeric representation
* 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
*
******************************************************************************/
@ -354,39 +421,82 @@ void
OpcDoEisaId (
ACPI_PARSE_OBJECT *Op)
{
UINT32 id;
UINT32 SwappedId;
UINT8 *InString;
UINT32 EisaId = 0;
UINT32 BigEndianId;
NATIVE_CHAR *InString;
ACPI_STATUS Status = AE_OK;
NATIVE_UINT i;
InString = (UINT8 *) Op->Asl.Value.String;
InString = (NATIVE_CHAR *) Op->Asl.Value.String;
/* Create ID big-endian first */
/*
* 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 */
id = 0;
id |= (UINT32) (InString[0] - '@') << 26;
id |= (UINT32) (InString[1] - '@') << 21;
id |= (UINT32) (InString[2] - '@') << 16;
for (i = 0; i < 7; i++)
{
/* First 3 characters must be letters */
id |= (UtHexCharToValue (InString[3])) << 12;
id |= (UtHexCharToValue (InString[4])) << 8;
id |= (UtHexCharToValue (InString[5])) << 4;
id |= UtHexCharToValue (InString[6]);
if (i < 3)
{
if (!isalpha (InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
/* swap to little-endian */
/* Last 4 characters must be hex digits */
SwappedId = (id & 0xFF) << 24;
SwappedId |= ((id >> 8) & 0xFF) << 16;
SwappedId |= ((id >> 16) & 0xFF) << 8;
SwappedId |= (id >> 24) & 0xFF;
else if (!isxdigit (InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
}
Op->Asl.Value.Integer32 = SwappedId;
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) */
/* Op is now an integer */
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.Integer32 = EisaId;
Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
(void) OpcSetOptimalIntegerSize (Op);
/* Op is now an integer */
UtSetParseOpName (Op);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asloperands - AML operand processing
* $Revision: 1.38 $
* $Revision: 1.41 $
*
*****************************************************************************/
@ -546,7 +546,7 @@ OpnDoBuffer (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *BufferLengthNode;
ACPI_PARSE_OBJECT *BufferLengthOp;
/* Optional arguments for this opcode with defaults */
@ -556,16 +556,16 @@ OpnDoBuffer (
/* Opcode and package length first */
/* Buffer Length is next, followed by the initializer list */
BufferLengthNode = Op->Asl.Child;
InitializerOp = BufferLengthNode->Asl.Next;
BufferLengthOp = Op->Asl.Child;
InitializerOp = BufferLengthOp->Asl.Next;
/*
* If the BufferLength is not an INTEGER or was not specified in the ASL
* (DEFAULT_ARG), it is a TermArg that is
* evaluated at run-time, and we are therefore finished.
*/
if ((BufferLengthNode->Asl.ParseOpcode != PARSEOP_INTEGER) &&
(BufferLengthNode->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
(BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
{
return;
}
@ -612,11 +612,19 @@ OpnDoBuffer (
break;
case PARSEOP_RAW_DATA:
/* Buffer nodes are already initialized (e.g. Unicode operator) */
return;
case PARSEOP_DEFAULT_ARG:
break;
default:
AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
"Unknown buffer initializer opcode");
printf ("Unknown buffer initializer opcode [%s]\n",
UtGetOpName (InitializerOp->Asl.ParseOpcode));
return;
@ -624,16 +632,16 @@ OpnDoBuffer (
/* Check if initializer list is longer than the buffer length */
if (BufferLengthNode->Asl.Value.Integer > BufferLength)
if (BufferLengthOp->Asl.Value.Integer > BufferLength)
{
BufferLength = BufferLengthNode->Asl.Value.Integer32;
BufferLength = BufferLengthOp->Asl.Value.Integer32;
}
if (!BufferLength)
{
/* No length AND no items -- issue a warning */
AslError (ASL_WARNING, ASL_MSG_BUFFER_LENGTH, BufferLengthNode, NULL);
AslError (ASL_WARNING, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
/* But go ahead and put the buffer length of zero into the AML */
}
@ -642,11 +650,11 @@ OpnDoBuffer (
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
BufferLengthNode->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthNode->Asl.AmlOpcode = AML_DWORD_OP;
BufferLengthNode->Asl.Value.Integer = BufferLength;
BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
BufferLengthOp->Asl.Value.Integer = BufferLength;
(void) OpcSetOptimalIntegerSize (BufferLengthNode);
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
/* Remaining nodes are handled via the tree walk */
}
@ -669,7 +677,7 @@ OpnDoPackage (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *PackageLengthNode;
ACPI_PARSE_OBJECT *PackageLengthOp;
/* Optional arguments for this opcode with defaults */
@ -679,8 +687,8 @@ OpnDoPackage (
/* Opcode and package length first */
/* Buffer Length is next, followed by the initializer list */
PackageLengthNode = Op->Asl.Child;
InitializerOp = PackageLengthNode->Asl.Next;
PackageLengthOp = Op->Asl.Child;
InitializerOp = PackageLengthOp->Asl.Next;
/*
* We always count the number of items in the initializer list, because if
@ -700,12 +708,12 @@ OpnDoPackage (
/* Check if initializer list is longer than the buffer length */
if ((PackageLengthNode->Asl.ParseOpcode == PARSEOP_INTEGER) ||
(PackageLengthNode->Asl.ParseOpcode == PARSEOP_BYTECONST))
if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
(PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST))
{
if (PackageLengthNode->Asl.Value.Integer > PackageLength)
if (PackageLengthOp->Asl.Value.Integer > PackageLength)
{
PackageLength = PackageLengthNode->Asl.Value.Integer32;
PackageLength = PackageLengthOp->Asl.Value.Integer32;
}
}
@ -713,15 +721,15 @@ OpnDoPackage (
* If not a variable-length package, check for a zero
* package length
*/
if ((PackageLengthNode->Asl.ParseOpcode == PARSEOP_INTEGER) ||
(PackageLengthNode->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
(PackageLengthNode->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
(PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
(PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
{
if (!PackageLength)
{
/* No length AND no items -- issue a warning */
AslError (ASL_WARNING, ASL_MSG_PACKAGE_LENGTH, PackageLengthNode, NULL);
AslError (ASL_WARNING, ASL_MSG_PACKAGE_LENGTH, PackageLengthOp, NULL);
/* But go ahead and put the buffer length of zero into the AML */
}
@ -731,10 +739,10 @@ OpnDoPackage (
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
PackageLengthNode->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
PackageLengthNode->Asl.AmlLength = 1;
PackageLengthNode->Asl.ParseOpcode = PARSEOP_RAW_DATA;
PackageLengthNode->Asl.Value.Integer = PackageLength;
PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
PackageLengthOp->Asl.AmlLength = 1;
PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
PackageLengthOp->Asl.Value.Integer = PackageLength;
/* Remaining nodes are handled via the tree walk */
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslrestype2 - Long (type2) resource templates and descriptors
* $Revision: 1.18 $
* $Revision: 1.22 $
*
*****************************************************************************/
@ -118,8 +118,6 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "aslresource.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2")
@ -160,7 +158,7 @@ RsGetStringDataLength (
*
* FUNCTION: RsDoDwordIoDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -318,6 +316,11 @@ RsDoDwordIoDescriptor (
RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -334,7 +337,7 @@ RsDoDwordIoDescriptor (
*
* FUNCTION: RsDoDwordMemoryDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -500,6 +503,11 @@ RsDoDwordMemoryDescriptor (
RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -516,7 +524,7 @@ RsDoDwordMemoryDescriptor (
*
* FUNCTION: RsDoQwordIoDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -673,6 +681,11 @@ RsDoQwordIoDescriptor (
RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -689,7 +702,7 @@ RsDoQwordIoDescriptor (
*
* FUNCTION: RsDoQwordMemoryDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -854,6 +867,11 @@ RsDoQwordMemoryDescriptor (
RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -870,7 +888,7 @@ RsDoQwordMemoryDescriptor (
*
* FUNCTION: RsDoWordIoDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -1028,6 +1046,11 @@ RsDoWordIoDescriptor (
RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -1044,7 +1067,7 @@ RsDoWordIoDescriptor (
*
* FUNCTION: RsDoWordBusNumberDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -1181,6 +1204,11 @@ RsDoWordBusNumberDescriptor (
UtAttachNamepathToOwner (Op, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
@ -1197,7 +1225,7 @@ RsDoWordBusNumberDescriptor (
*
* FUNCTION: RsDoInterruptDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -1259,7 +1287,7 @@ RsDoInterruptDescriptor (
Descriptor->Exx.Length = 2; /* Flags and table length byte */
Descriptor->Exx.TableLength = 0;
Rover = (ASL_RESOURCE_DESC *) (&(Descriptor->Exx.InterruptNumber[0]));
Rover = ACPI_CAST_PTR (ASL_RESOURCE_DESC, (&(Descriptor->Exx.InterruptNumber[0])));
/*
* Process all child initialization nodes
@ -1326,7 +1354,7 @@ RsDoInterruptDescriptor (
* Store the integer and move pointer to the next one.
*/
Rover->U32Item = InitializerOp->Asl.Value.Integer32;
Rover = (ASL_RESOURCE_DESC *) (&(Rover->U32Item) + 1);
Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U32Item), 1);
Descriptor->Exx.TableLength++;
Descriptor->Exx.Length += 4;
@ -1347,22 +1375,22 @@ RsDoInterruptDescriptor (
if (HasResSourceIndex)
{
Rover->U8Item = ResSourceIndex;
Rover = (ASL_RESOURCE_DESC *) (&(Rover->U8Item) + 1);
Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), 1);
Descriptor->Exx.Length += 1;
}
/*
* Add optional ResSource string if present
*/
if (StringLength)
if (StringLength && ResSourceString)
{
strcpy ((char *) Rover, (char *) ResSourceString);
Rover = (ASL_RESOURCE_DESC *) (&(Rover->U8Item) + StringLength);
Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), StringLength);
Descriptor->Exx.Length = (UINT16) (Descriptor->Exx.Length + StringLength);
}
Rnode->BufferLength = (ASL_RESDESC_OFFSET (Exx.InterruptNumber) -
Rnode->BufferLength = (ASL_RESDESC_OFFSET (Exx.InterruptNumber[0]) -
ASL_RESDESC_OFFSET (Exx.DescriptorType))
+ OptionIndex + StringLength;
return (Rnode);
@ -1373,7 +1401,7 @@ RsDoInterruptDescriptor (
*
* FUNCTION: RsDoVendorLargeDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -1397,6 +1425,7 @@ RsDoVendorLargeDescriptor (
/* Count the number of data bytes */
InitializerOp = Op->Asl.Child;
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
for (i = 0; InitializerOp; i++)
{
@ -1404,10 +1433,12 @@ RsDoVendorLargeDescriptor (
}
InitializerOp = Op->Asl.Child;
Rnode = RsAllocateResourceNode (sizeof (ASL_LARGE_VENDOR_DESC) + (i + 1));
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
Rnode = RsAllocateResourceNode (sizeof (ASL_LARGE_VENDOR_DESC) + (i - 1));
Descriptor = Rnode->Buffer;
Descriptor->Lgv.DescriptorType = ACPI_RDESC_TYPE_LARGE_VENDOR;
Descriptor->Lgv.Length = (UINT16) i;
/*
* Process all child initialization nodes
@ -1427,7 +1458,7 @@ RsDoVendorLargeDescriptor (
*
* FUNCTION: RsDoGeneralRegisterDescriptor
*
* PARAMETERS: Op - Parent resource descriptor parse node
* PARAMETERS: Op - Parent resource descriptor parse node
* CurrentByteOffset - Offset into the resource template AML
* buffer (to track references to the desc)
*
@ -1490,6 +1521,11 @@ RsDoGeneralRegisterDescriptor (
CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.Address));
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);

363
source/compiler/aslstubs.c Normal file
View File

@ -0,0 +1,363 @@
/******************************************************************************
*
* Module Name: aslstubs - Stubs used to link to Aml interpreter
* $Revision: 1.6 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2002, 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 "acnamesp.h"
#include "acdispat.h"
#include "actables.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslstubs")
/*
* Stubs to simplify linkage to the
* ACPI Namespace Manager (Unused functions).
* TBD: These functions should be split out so
* that these stubs are no longer needed.
*/
ACPI_STATUS
AcpiEvAcquireGlobalLock(
UINT32 Timeout)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvReleaseGlobalLock(
void)
{
return (AE_OK);
}
/************************************************
ACPI_STATUS
AcpiDsLoad2BeginOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsLoad2EndOp (
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}
ACPI_STATUS
AcpiNsLoadTable (
ACPI_TABLE_DESC *TableDesc,
ACPI_NAMESPACE_NODE *Node)
{
return (AE_OK);
}
ACPI_STATUS
AcpiNsLoadNamespace (
void)
{
return (AE_OK);
}
****************************************************/
ACPI_STATUS
AeLocalGetRootPointer (
UINT32 Flags,
ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
{
return AE_ERROR;
}
ACPI_STATUS
AcpiEvAddressSpaceDispatch (
ACPI_OPERAND_OBJECT *RegionObj,
UINT32 Function,
ACPI_PHYSICAL_ADDRESS Address,
UINT32 BitWidth,
void *Value)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvInitializeRegion (
ACPI_OPERAND_OBJECT *RegionObj,
BOOLEAN AcpiNsLocked)
{
return (AE_OK);
}
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_OBJECT_TYPE
AcpiDsMethodDataGetType (
UINT16 Opcode,
UINT32 Index,
ACPI_WALK_STATE *WalkState)
{
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
AcpiDsStoreObjectToLocal (
UINT16 Opcode,
UINT32 Index,
ACPI_OPERAND_OBJECT *SrcDesc,
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsParseMethod (
ACPI_HANDLE ObjHandle)
{
return (AE_OK);
}
ACPI_STATUS
AcpiWalkNamespace (
ACPI_OBJECT_TYPE Type,
ACPI_HANDLE StartObject,
UINT32 MaxDepth,
ACPI_WALK_CALLBACK UserFunction,
void *Context,
void * *ReturnValue)
{
return (AE_OK);
}
ACPI_STATUS
AcpiTbFindTable (
NATIVE_CHAR *Signature,
NATIVE_CHAR *OemId,
NATIVE_CHAR *OemTableId,
ACPI_TABLE_HEADER **TablePtr)
{
return (AE_SUPPORT);
}
/*
void
AcpiPsDeleteParseTree (
ACPI_PARSE_OBJECT *root)
{
return;
}
ACPI_STATUS
AcpiDsInitAmlWalk (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
ACPI_NAMESPACE_NODE *MethodNode,
UINT8 *AmlStart,
UINT32 AmlLength,
ACPI_OPERAND_OBJECT **Params,
ACPI_OPERAND_OBJECT **ReturnObjDesc,
UINT32 PassNumber)
{
return (AE_OK);
}
void
AcpiTbDeleteAcpiTables (
void)
{
return;
}
ACPI_TABLE_DESC *
AcpiTbUninstallTable (
ACPI_TABLE_DESC *TableDesc)
{
return NULL;
}
ACPI_STATUS
AcpiTbInstallTable (
ACPI_TABLE_DESC *TableInfo)
{
return (AE_OK);
}
ACPI_STATUS
AcpiTbMatchSignature (
NATIVE_CHAR *Signature,
ACPI_TABLE_DESC *TableInfo,
UINT8 SearchType)
{
return (AE_OK);
}
ACPI_STATUS
AcpiPsParseAml (
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}
ACPI_PARSE_OBJECT *
AcpiPsGetArg(
ACPI_PARSE_OBJECT *op,
UINT32 argn)
{
return NULL;
}
*/

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltransform - Parse tree transforms
* $Revision: 1.15 $
* $Revision: 1.16 $
*
*****************************************************************************/
@ -546,7 +546,7 @@ TrDoSwitch (
{
/* Unkown peer opcode */
printf ("Unknown parse opcode for switch statement: %s (%d)\n",
printf ("Unknown parse opcode for switch statement: %s (%d)\n",
Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
}
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltree - parse tree management
* $Revision: 1.45 $
* $Revision: 1.49 $
*
*****************************************************************************/
@ -226,7 +226,6 @@ TrUpdateNode (
ACPI_PARSE_OBJECT *Op)
{
if (!Op)
{
return NULL;
@ -239,6 +238,28 @@ TrUpdateNode (
/* Assign new opcode and name */
if (Op->Asl.ParseOpcode == PARSEOP_ONES)
{
switch (ParseOpcode)
{
case PARSEOP_BYTECONST:
Op->Asl.Value.Integer = 0xFF;
break;
case PARSEOP_WORDCONST:
Op->Asl.Value.Integer = 0xFFFF;
break;
case PARSEOP_DWORDCONST:
Op->Asl.Value.Integer = 0xFFFFFFFF;
break;
default:
/* Don't care about others, don't need to check QWORD */
break;
}
}
Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
UtSetParseOpName (Op);
@ -269,6 +290,18 @@ TrUpdateNode (
}
/*******************************************************************************
*
* FUNCTION: TrGetNodeFlagName
*
* PARAMETERS: Flags - Flags word to be decoded
*
* RETURN: Name string
*
* DESCRIPTION: Decode a flags word
*
******************************************************************************/
char *
TrGetNodeFlagName (
UINT32 Flags)
@ -321,6 +354,9 @@ TrGetNodeFlagName (
case NODE_IS_TERM_ARG:
return ("NODE_IS_TERM_ARG");
case NODE_WAS_ONES_OP:
return ("NODE_WAS_ONES_OP");
default:
return ("Multiple Flags (or unknown flag) set");
}
@ -445,7 +481,7 @@ TrCreateValuedLeafNode (
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateValuedLeafNode Line %d NewNode %p Op %s Value %8.8X%8.8X ",
Op->Asl.LineNumber, Op, UtGetOpName(ParseOpcode),
Op->Asl.LineNumber, Op, UtGetOpName(ParseOpcode),
ACPI_HIDWORD (Value), ACPI_LODWORD (Value));
Op->Asl.Value.Integer = Value;

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: asltypes.h - compiler data types and struct definitions
* $Revision: 1.38 $
* $Revision: 1.46 $
*
*****************************************************************************/
@ -130,8 +130,6 @@
******************************************************************************/
/* Op flags for the ACPI_PARSE_OBJECT */
#define NODE_VISITED 0x0001
@ -149,6 +147,7 @@
#define NODE_IS_BIT_OFFSET 0x1000
#define NODE_COMPILE_TIME_CONST 0x2000
#define NODE_IS_TERM_ARG 0x4000
#define NODE_WAS_ONES_OP 0x8000
/* Keeps information about individual control methods */
@ -190,6 +189,8 @@ typedef struct 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
{
@ -294,6 +295,7 @@ typedef struct
#define ASL_ERROR 0
#define ASL_WARNING 1
#define ASL_REMARK 2
#define ASL_NUM_REPORT_LEVELS 3
typedef enum
@ -362,7 +364,16 @@ typedef enum
ASL_MSG_INVALID_TARGET,
ASL_MSG_INVALID_CONSTANT_OP,
ASL_MSG_CONSTANT_EVALUATION,
ASL_MSG_CONSTANT_FOLDED
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_MESSAGE_IDS;

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslutils -- compiler utilities
* $Revision: 1.45 $
* $Revision: 1.49 $
*
*****************************************************************************/
@ -117,7 +117,9 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acnamesp.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslutils")
@ -130,6 +132,36 @@ extern const char * const yytname[];
#endif
/*******************************************************************************
*
* FUNCTION: AcpiPsDisplayConstantOpcodes
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Print AML opcodes that can be used in constant expressions.
*
******************************************************************************/
void
UtDisplayConstantOpcodes (
void)
{
UINT32 i;
printf ("Constant expression opcode information\n\n");
for (i = 0; i < sizeof (AcpiGbl_AmlOpInfo) / sizeof (ACPI_OPCODE_INFO); i++)
{
if (AcpiGbl_AmlOpInfo[i].Flags & AML_CONSTANT)
{
printf ("%s\n", AcpiGbl_AmlOpInfo[i].Name);
}
}
}
/*******************************************************************************
*
* FUNCTION: UtLocalCalloc
@ -412,7 +444,11 @@ UtGetOpName (
UINT32 ParseOpcode)
{
return ((char *) yytname [ParseOpcode - 255] + 8);
/*
* First entries (ASL_YYTNAME_START) in yytname are special reserved names.
* Ignore first 8 characters of the name
*/
return ((char *) yytname [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
}
@ -437,8 +473,8 @@ UtDisplaySummary (
{
/* Compiler name and version number */
FlPrintFile (FileId, "%s %s [%s]\n",
CompilerId, CompilerVersion, __DATE__);
FlPrintFile (FileId, "%s version %X [%s]\n",
CompilerId, (UINT32) ACPI_CA_VERSION, __DATE__);
}
/* Input/Output summary */
@ -659,7 +695,6 @@ UtDoConstant (
char ErrBuf[64];
Status = UtStrtoul64 (String, 0, &Converted);
if (ACPI_FAILURE (Status))
{