Automated code cleanup

date	2002.12.06.16.31.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 16:00:45 +00:00
parent fa5bc76816
commit 761f6ce09f
5 changed files with 732 additions and 290 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: dswload - Dispatcher namespace load callbacks
* $Revision: 1.54 $
* $Revision: 1.55 $
*
*****************************************************************************/
@ -375,7 +375,7 @@ LdNamespace1Begin (
ACPI_FUNCTION_NAME ("LdNamespace1Begin");
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
Op, Op->Asl.ParseOpName));
@ -477,7 +477,7 @@ LdNamespace1Begin (
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.
@ -508,7 +508,7 @@ LdNamespace1Begin (
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:
*
@ -518,11 +518,11 @@ LdNamespace1Begin (
* 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)",
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;
@ -530,14 +530,14 @@ LdNamespace1Begin (
default:
/*
* All other types are an error
/*
* 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
/*
* However, switch the type to be an actual scope so
* that compilation can continue without generating a whole
* cascade of additional errors.
*/
@ -548,7 +548,7 @@ LdNamespace1Begin (
Status = AE_OK;
goto FinishNode;
default:
ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: asllookup- Namespace lookup
* $Revision: 1.74 $
* $Revision: 1.77 $
*
*****************************************************************************/
@ -484,7 +484,7 @@ LkNamespaceLocateBegin (
ACPI_FUNCTION_TRACE_PTR ("LkNamespaceLocateBegin", Op);
/*
* If this node is the actual declaration of a name
* 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
@ -523,14 +523,20 @@ LkNamespaceLocateBegin (
*/
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;
}
}
@ -562,7 +568,7 @@ LkNamespaceLocateBegin (
*/
Gbl_NsLookupCount++;
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
@ -616,7 +622,7 @@ LkNamespaceLocateBegin (
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
*/
@ -624,7 +630,7 @@ LkNamespaceLocateBegin (
{
/* This node points back to the original PARSEOP_ALIAS */
NextOp = (ACPI_PARSE_OBJECT *) Node->Object;
NextOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object);
/* The first child is the alias target op */

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslmain - compiler main and utilities
* $Revision: 1.56 $
* $Revision: 1.71 $
*
*****************************************************************************/
@ -120,7 +120,7 @@
#include "aslcompiler.h"
#include "acnamesp.h"
#include "adisasm.h"
#include "acapps.h"
#ifdef _DEBUG
#include <crtdbg.h>
@ -129,10 +129,10 @@
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmain")
int optind;
NATIVE_CHAR *optarg;
BOOLEAN AslToFile = TRUE;
BOOLEAN DoCompile = TRUE;
BOOLEAN DoSignon = TRUE;
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'};
@ -154,21 +154,39 @@ 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 to ASL source code file (*.dsl)\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 (" -qc Display operators allowed in constant expressions\n");
printf (" -qr 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 (" -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 ("\nACPI Tables and AML 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 (" -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");
}
@ -193,7 +211,7 @@ HelpMessage (
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 -o option specifies the prefix\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");
@ -201,12 +219,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 (" -e Ignore errors, always create 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");
}
@ -227,7 +245,7 @@ Usage (
void)
{
printf ("Usage: %s <Options> <InputFile>\n\n", CompilerName);
printf ("Usage: %s [Options] [InputFile]\n\n", CompilerName);
Options ();
}
@ -247,7 +265,7 @@ Usage (
void
AslInitialize (void)
{
UINT32 i;
UINT32 i;
#ifdef _DEBUG
@ -272,53 +290,41 @@ 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 (
int argc,
char **argv)
void
AslCommandLine (
int argc,
char **argv)
{
int j;
BOOLEAN BadCommandLine = FALSE;
int Status;
BOOLEAN AslToFile = TRUE;
BOOLEAN BadCommandLine = FALSE;
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)
{
AslCompilerSignon (ASL_FILE_STDOUT);
Usage ();
return 0;
exit (1);
}
/* Get the command line options */
while ((j = getopt (argc, argv, "ab:cdefhilno:pq:rst:v:x")) != EOF) switch (j)
while ((j = AcpiGetopt (argc, argv, "b:cd^egh^i^l^o:p:rs:t:v:x:")) != EOF) switch (j)
{
case 'a':
/* Produce assembly code output file */
Gbl_AsmOutputFlag = TRUE;
break;
case 'b':
switch (optarg[0])
switch (AcpiGbl_Optarg[0])
{
case 'b':
AslCompilerdebug = 1; /* same as yydebug */
@ -332,8 +338,9 @@ main (
break;
default:
printf ("Unknown option: -d%s\n", optarg);
printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
/* Produce debug output file */
@ -341,108 +348,228 @@ main (
Gbl_DebugFlag = TRUE;
break;
case 'c':
/* Produce C hex output file */
Gbl_C_OutputFlag = TRUE;
break;
case 'd':
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;
case 'i':
/* Ignore errors and always attempt to create aml file */
Gbl_IgnoreErrors = TRUE;
break;
case 'l':
/* Produce listing file (Mixed source/aml) */
Gbl_ListingFlag = TRUE;
break;
case 'n':
/* Produce namespace file */
Gbl_NsOutputFlag = TRUE;
break;
case 'o':
/* Override default AML output filename */
Gbl_OutputFilenamePrefix = optarg;
Gbl_UseDefaultAmlFilename = FALSE;
break;
case 'p':
/* Parse only */
Gbl_ParseOnlyFlag = TRUE;
break;
case 'q':
switch (optarg[0])
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':
/* Ignore errors and always attempt to create 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 ();
return (0);
exit (0);
case 'r':
/* reserved names */
MpDisplayReservedNames ();
return (0);
exit (0);
default:
printf ("Unknown option: -q%s\n", optarg);
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':
/* Produce combined source file */
switch (AcpiGbl_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", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 't':
/* Produce hex table output file */
switch (optarg[0])
switch (AcpiGbl_Optarg[0])
{
case 'a':
Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
@ -453,24 +580,49 @@ main (
break;
default:
printf ("Unknown option: -t%s\n", optarg);
printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'v':
AcpiDbgLevel = strtoul (optarg, NULL, 16);
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':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
break;
default:
BadCommandLine = TRUE;
@ -479,59 +631,154 @@ main (
/* Next parameter must be the input filename */
Gbl_Files[ASL_FILE_INPUT].Filename = argv[optind];
if (!Gbl_Files[ASL_FILE_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 ();
return 0;
exit (1);
}
if ((optind + 1) < argc)
if ((AcpiGbl_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 - AcpiGbl_Optind - 1);
}
}
/* ACPI CA subsystem initialization */
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
/*******************************************************************************
*
* 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)
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
Gbl_OutputFilenamePrefix = Prefix;
}
/*
* If -o not specified, we will use the input filename as the
* output filename prefix
* AML Disassembly (Optional)
*/
if (Gbl_UseDefaultAmlFilename)
if (Gbl_DisasmFlag || Gbl_GetAllTables)
{
Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
}
/* ACPI CA subsystem initialization */
AcpiUtInitGlobals ();
Status = AcpiOsInitialize ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
/* This is where the disassembly happens */
if (Gbl_DisasmFlag)
{
AcpiGbl_DbOpt_disasm = TRUE;
Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename);
return (0);
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) */
AcpiUtInitGlobals ();
Status = AcpiOsInitialize ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = CmDoCompile ();
}
Status = CmDoCompile ();
return (0);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslopcode - AML opcode generation
* $Revision: 1.19 $
* $Revision: 1.49 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -116,11 +116,12 @@
*****************************************************************************/
#include "AslCompiler.h"
#include "AslCompiler.y.h"
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopcodes")
/*******************************************************************************
@ -129,22 +130,59 @@
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: None
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
* operands.
*
******************************************************************************/
void
ACPI_STATUS
OpcAmlOpcodeWalk (
ASL_PARSE_NODE *Node,
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
OpcGenerateAmlOpcode (Node);
OpnGenerateAmlOperands (Node);
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 (Child->Asl.Value.Integer8);
}
@ -152,7 +190,7 @@ OpcAmlOpcodeWalk (
*
* FUNCTION: OpcSetOptimalIntegerSize
*
* PARAMETERS: Node - A parse tree node
* PARAMETERS: Op - A parse tree node
*
* RETURN: Integer width, in bytes. Also sets the node AML opcode to the
* optimal integer AML prefix opcode.
@ -165,31 +203,81 @@ OpcAmlOpcodeWalk (
UINT32
OpcSetOptimalIntegerSize (
ASL_PARSE_NODE *Node)
ACPI_PARSE_OBJECT *Op)
{
if (Node->Value.Integer <= ACPI_UINT8_MAX)
/*
* 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)
{
Node->AmlOpcode = AML_BYTE_OP;
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;
}
else if (Node->Value.Integer <= ACPI_UINT16_MAX)
if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
{
Node->AmlOpcode = AML_WORD_OP;
Op->Asl.AmlOpcode = AML_WORD_OP;
return 2;
}
else if (Node->Value.Integer <= ACPI_UINT32_MAX)
if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
{
Node->AmlOpcode = AML_DWORD_OP;
Op->Asl.AmlOpcode = AML_DWORD_OP;
return 4;
}
else
{
Node->AmlOpcode = AML_QWORD_OP;
Op->Asl.AmlOpcode = AML_QWORD_OP;
return 8;
}
}
@ -199,7 +287,7 @@ OpcSetOptimalIntegerSize (
*
* FUNCTION: OpcDoAccessAs
*
* PARAMETERS: Node - Parse node
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
@ -209,28 +297,28 @@ OpcSetOptimalIntegerSize (
void
OpcDoAccessAs (
ASL_PARSE_NODE *Node)
ACPI_PARSE_OBJECT *Op)
{
ASL_PARSE_NODE *Next;
ACPI_PARSE_OBJECT *Next;
Node->AmlOpcodeLength = 1;
Next = Node->Child;
Op->Asl.AmlOpcodeLength = 1;
Next = Op->Asl.Child;
/* First child is the access type */
Next->AmlOpcode = AML_RAW_DATA_BYTE;
Next->ParseOpcode = RAW_DATA;
Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
/* Second child is the optional access attribute */
Next = Next->Peer;
if (Next->ParseOpcode == DEFAULT_ARG)
Next = Next->Asl.Next;
if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
Next->Value.Integer = 0;
Next->Asl.Value.Integer = 0;
}
Next->AmlOpcode = AML_RAW_DATA_BYTE;
Next->ParseOpcode = RAW_DATA;
Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
}
@ -238,65 +326,76 @@ OpcDoAccessAs (
*
* FUNCTION: OpcDoUnicode
*
* PARAMETERS: Node - Parse node
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
* to a unicode buffer.
* 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 (
ASL_PARSE_NODE *Node)
ACPI_PARSE_OBJECT *Op)
{
ASL_PARSE_NODE *InitializerNode;
ACPI_PARSE_OBJECT *InitializerOp;
UINT32 Length;
UINT32 Count;
UINT32 i;
UINT8 *AsciiString;
UINT16 *UnicodeString;
ASL_PARSE_NODE *BufferLengthNode;
ACPI_PARSE_OBJECT *BufferLengthOp;
/* Opcode and package length first */
/* Buffer Length is next, followed by the initializer list */
/* Change op into a buffer object */
BufferLengthNode = Node->Child;
InitializerNode = BufferLengthNode->Peer;
Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
UtSetParseOpName (Op);
/* Buffer Length is first, followed by the string */
AsciiString = InitializerNode->Value.String;
BufferLengthOp = Op->Asl.Child;
InitializerOp = BufferLengthOp->Asl.Next;
AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
Count = strlen (AsciiString);
Length = (Count * 2) + sizeof (UINT16);
/* 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] = AsciiString[i];
UnicodeString[i] = (UINT16) AsciiString[i];
}
free (AsciiString);
/*
* 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);
BufferLengthNode->ParseOpcode = INTEGER;
BufferLengthNode->AmlOpcode = AML_DWORD_OP;
BufferLengthNode->Value.Integer = Length;
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
OpcSetOptimalIntegerSize (BufferLengthNode);
/* The Unicode string is a raw data buffer */
InitializerNode->Value.Pointer = UnicodeString;
InitializerNode->AmlOpcode = AML_RAW_DATA_BUFFER;
InitializerNode->AmlLength = Length;
InitializerNode->ParseOpcode = RAW_DATA;
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);
}
@ -304,51 +403,121 @@ OpcDoUnicode (
*
* FUNCTION: OpcDoEisaId
*
* PARAMETERS: Node - Parse node
* PARAMETERS: Op - Parse node
*
* 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
*
******************************************************************************/
void
OpcDoEisaId (
ASL_PARSE_NODE *Node)
ACPI_PARSE_OBJECT *Op)
{
UINT32 id;
UINT32 SwappedId;
UINT32 EisaId = 0;
UINT32 BigEndianId;
NATIVE_CHAR *InString;
ACPI_STATUS Status = AE_OK;
NATIVE_UINT i;
InString = Node->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 |= (InString[0] - '@') << 26;
id |= (InString[1] - '@') << 21;
id |= (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;
}
}
}
Node->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) */
/* Node is now an integer */
BigEndianId = (UINT32) (InString[0] - 0x40) << 26 |
(UINT32) (InString[1] - 0x40) << 21 |
(UINT32) (InString[2] - 0x40) << 16 |
Node->ParseOpcode = INTEGER;
OpcSetOptimalIntegerSize (Node);
(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);
}
@ -356,7 +525,7 @@ OpcDoEisaId (
*
* FUNCTION: OpcGenerateAmlOpcode
*
* PARAMETERS: Node - Parse node
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
@ -368,60 +537,80 @@ OpcDoEisaId (
void
OpcGenerateAmlOpcode (
ASL_PARSE_NODE *Node)
ACPI_PARSE_OBJECT *Op)
{
UINT16 Index = Node->ParseOpcode;
UINT16 Index;
Index = Node->ParseOpcode - ASL_PARSE_OPCODE_BASE;
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;
Node->AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
Node->AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
Node->Flags |= AslKeywordMapping[Index].Flags;
if (!Node->Value.Integer)
if (!Op->Asl.Value.Integer)
{
Node->Value.Integer = AslKeywordMapping[Index].Value;
Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
}
/* Special handling for some opcodes */
switch (Node->ParseOpcode)
switch (Op->Asl.ParseOpcode)
{
case INTEGER:
case PARSEOP_INTEGER:
/*
* Set the opcode based on the size of the integer
*/
OpcSetOptimalIntegerSize (Node);
(void) OpcSetOptimalIntegerSize (Op);
break;
case OFFSET:
Node->AmlOpcodeLength = 1;
case PARSEOP_OFFSET:
Op->Asl.AmlOpcodeLength = 1;
break;
case ACCESSAS:
OpcDoAccessAs (Node);
case PARSEOP_ACCESSAS:
OpcDoAccessAs (Op);
break;
case EISAID:
OpcDoEisaId (Node);
case PARSEOP_EISAID:
OpcDoEisaId (Op);
break;
case UNICODE:
OpcDoUnicode (Node);
case PARSEOP_UNICODE:
OpcDoUnicode (Op);
break;
case INCLUDE:
Node->Child->ParseOpcode = DEFAULT_ARG;
case PARSEOP_INCLUDE:
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
Gbl_HasIncludeFiles = TRUE;
break;
case EXTERNAL:
Node->Child->ParseOpcode = DEFAULT_ARG;
Node->Child->Peer->ParseOpcode = DEFAULT_ARG;
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;
}

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: aslopt- Compiler optimizations
* $Revision: 1.10 $
* $Revision: 1.9 $
*
*****************************************************************************/
@ -174,7 +174,7 @@ OptSearchToRoot (
* 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]),
Path = &(((NATIVE_CHAR *) TargetPath->Pointer)[TargetPath->Length - ACPI_NAME_SIZE]),
ScopeInfo.Scope.Node = CurrentNode;
/* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
@ -292,8 +292,8 @@ OptBuildShortestPath (
/* 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],
&((NATIVE_CHAR *) TargetPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
&((NATIVE_CHAR *) CurrentPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
ACPI_NAME_SIZE))
{
/* Mismatch */
@ -356,7 +356,7 @@ OptBuildShortestPath (
Index -= ACPI_PATH_SEGMENT_LENGTH;
}
ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
ACPI_STRCPY (&NewPathExternal[i], &((NATIVE_CHAR *) TargetPath->Pointer)[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
@ -448,7 +448,7 @@ OptOptimizeNameDeclaration (
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
char *AmlNameString,
NATIVE_CHAR *AmlNameString,
char **NewPath)
{
ACPI_STATUS Status;
@ -555,7 +555,7 @@ OptOptimizeNamePath (
ACPI_PARSE_OBJECT *Op,
UINT32 Flags,
ACPI_WALK_STATE *WalkState,
char *AmlNameString,
NATIVE_CHAR *AmlNameString,
ACPI_NAMESPACE_NODE *TargetNode)
{
ACPI_STATUS Status;