Some small Lint changes

date	2002.05.02.22.11.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 16:03:31 +00:00
parent 4b856918ff
commit 26cc36c346
2 changed files with 197 additions and 156 deletions

View File

@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: aslmain - compiler main and utilities * Module Name: aslmain - compiler main and utilities
* $Revision: 1.50 $ * $Revision: 1.51 $
* *
*****************************************************************************/ *****************************************************************************/
@ -119,7 +119,6 @@
#define _DECLARE_GLOBALS #define _DECLARE_GLOBALS
#include "aslcompiler.h" #include "aslcompiler.h"
#include "acparser.h"
#ifdef _DEBUG #ifdef _DEBUG
#include <crtdbg.h> #include <crtdbg.h>
@ -349,7 +348,6 @@ main (
case 'd': case 'd':
printf ("AML Disassembly not yet supported\n"); printf ("AML Disassembly not yet supported\n");
return (0); return (0);
break;
case 'e': case 'e':
@ -424,6 +422,7 @@ main (
printf ("Unknown option: -q%s\n", optarg); printf ("Unknown option: -q%s\n", optarg);
BadCommandLine = TRUE; BadCommandLine = TRUE;
} }
break;
case 's': case 's':

View File

@ -2,7 +2,7 @@
/****************************************************************************** /******************************************************************************
* *
* Module Name: aslopcode - AML opcode generation * Module Name: aslopcode - AML opcode generation
* $Revision: 1.14 $ * $Revision: 1.41 $
* *
*****************************************************************************/ *****************************************************************************/
@ -10,8 +10,8 @@
* *
* 1. Copyright Notice * 1. Copyright Notice
* *
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* reserved. * All rights reserved.
* *
* 2. License * 2. License
* *
@ -116,326 +116,369 @@
*****************************************************************************/ *****************************************************************************/
#include "AslCompiler.h" #include "aslcompiler.h"
#include "AslCompiler.y.h" #include "aslcompiler.y.h"
#include "amlcode.h" #include "amlcode.h"
#include "acnamesp.h" #define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopcodes")
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: * FUNCTION: OpcAmlOpcodeWalk
* *
* PARAMETERS: * PARAMETERS: ASL_WALK_CALLBACK
* *
* RETURN: * RETURN: Status
* *
* DESCRIPTION: * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
* operands.
* *
******************************************************************************/ ******************************************************************************/
void ACPI_STATUS
CgAmlOpcodeWalk ( OpcAmlOpcodeWalk (
ASL_PARSE_NODE *Node, ACPI_PARSE_OBJECT *Op,
UINT32 Level, UINT32 Level,
void *Context) void *Context)
{ {
CgGenerateAmlOpcode (Node); TotalParseNodes++;
CgGenerateAmlOperands (Node);
OpcGenerateAmlOpcode (Op);
OpnGenerateAmlOperands (Op);
return (AE_OK);
} }
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: * FUNCTION: OpcSetOptimalIntegerSize
* *
* PARAMETERS: * PARAMETERS: Op - A parse tree node
* *
* RETURN: * RETURN: Integer width, in bytes. Also sets the node AML opcode to the
* optimal integer AML prefix opcode.
* *
* DESCRIPTION: * DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
* zeros can be truncated to squeeze the integer into the
* minimal number of AML bytes.
* *
******************************************************************************/ ******************************************************************************/
UINT32 UINT32
CgSetOptimalIntegerSize ( OpcSetOptimalIntegerSize (
ASL_PARSE_NODE *Node) ACPI_PARSE_OBJECT *Op)
{ {
/* Check for the special AML integers first */
if (Node->Value.Integer <= ACPI_UINT8_MAX) if (Op->Asl.Value.Integer == 0)
{ {
Node->AmlOpcode = AML_BYTE_OP; Op->Asl.AmlOpcode = AML_ZERO_OP;
return 1;
}
if (Op->Asl.Value.Integer == 1)
{
Op->Asl.AmlOpcode = AML_ONE_OP;
return 1; return 1;
} }
else if (Node->Value.Integer <= ACPI_UINT16_MAX) /* TBD: add check for table width (32 or 64) */
if (Op->Asl.Value.Integer == ACPI_INTEGER_MAX)
{ {
Node->AmlOpcode = AML_WORD_OP; Op->Asl.AmlOpcode = AML_ONES_OP;
return 1;
}
/* Find the best fit */
if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
{
Op->Asl.AmlOpcode = AML_BYTE_OP;
return 1;
}
if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
{
Op->Asl.AmlOpcode = AML_WORD_OP;
return 2; return 2;
} }
if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
else if (Node->Value.Integer <= ACPI_UINT32_MAX)
{ {
Node->AmlOpcode = AML_DWORD_OP; Op->Asl.AmlOpcode = AML_DWORD_OP;
return 4; return 4;
} }
else else
{ {
Node->AmlOpcode = AML_QWORD_OP; Op->Asl.AmlOpcode = AML_QWORD_OP;
return 8; return 8;
} }
} }
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: * FUNCTION: OpcDoAccessAs
* *
* PARAMETERS: * PARAMETERS: Op - Parse node
* *
* RETURN: * RETURN: None
* *
* DESCRIPTION: * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
* *
******************************************************************************/ ******************************************************************************/
void void
CgDoOffset ( OpcDoAccessAs (
ASL_PARSE_NODE *Node) ACPI_PARSE_OBJECT *Op)
{ {
ASL_PARSE_NODE *InitializerNode; ACPI_PARSE_OBJECT *Next;
/* Entire proc unnecessary? */
Node->AmlOpcodeLength = 1;
InitializerNode = Node->Child;
}
Op->Asl.AmlOpcodeLength = 1;
/******************************************************************************* Next = Op->Asl.Child;
*
* FUNCTION:
*
* PARAMETERS:
*
* RETURN:
*
* DESCRIPTION:
*
******************************************************************************/
void
CgDoAccessAs (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
Node->AmlOpcodeLength = 1;
Next = Node->Child;
/* First child is the access type */ /* First child is the access type */
Next->AmlOpcode = AML_RAW_DATA_BYTE; Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->ParseOpcode = RAW_DATA; Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
/* Second child is the optional access attribute */ /* Second child is the optional access attribute */
Next = Next->Peer; Next = Next->Asl.Next;
if (Next->ParseOpcode == DEFAULT_ARG) if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{ {
Next->Value.Integer = 0; Next->Asl.Value.Integer = 0;
} }
Next->AmlOpcode = AML_RAW_DATA_BYTE; Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
Next->ParseOpcode = RAW_DATA; Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
} }
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: * FUNCTION: OpcDoUnicode
* *
* PARAMETERS: * PARAMETERS: Op - Parse node
* *
* RETURN: * RETURN: None
* *
* DESCRIPTION: * DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
* to a unicode buffer. There is no Unicode AML opcode.
*
* Note: The Unicode string is 16 bits per character, no leading signature,
* with a 16-bit terminating NULL.
* *
******************************************************************************/ ******************************************************************************/
void void
CgDoUnicode ( OpcDoUnicode (
ASL_PARSE_NODE *Node) ACPI_PARSE_OBJECT *Op)
{ {
ASL_PARSE_NODE *InitializerNode; ACPI_PARSE_OBJECT *InitializerOp;
UINT32 Length; UINT32 Length;
UINT32 Count; UINT32 Count;
UINT32 i; UINT32 i;
UINT8 *AsciiString; UINT8 *AsciiString;
UINT16 *UnicodeString; UINT16 *UnicodeString;
ASL_PARSE_NODE *BufferLengthNode; ACPI_PARSE_OBJECT *BufferLengthOp;
/* Opcode and package length first */ /* Change op into a buffer object */
/* Buffer Length is next, followed by the initializer list */
BufferLengthNode = Node->Child; Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
InitializerNode = BufferLengthNode->Peer; 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); /* Create a new buffer for the Unicode string */
Length = (Count * 2) + sizeof (UINT16);
Count = strlen (InitializerOp->Asl.Value.String) + 1;
Length = Count * sizeof (UINT16);
UnicodeString = UtLocalCalloc (Length); UnicodeString = UtLocalCalloc (Length);
/* Convert to Unicode string (including null terminator) */
for (i = 0; i < Count; i++) 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 * Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder * 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; (void) OpcSetOptimalIntegerSize (BufferLengthOp);
BufferLengthNode->AmlOpcode = AML_DWORD_OP;
BufferLengthNode->Value.Integer = Length;
CgSetOptimalIntegerSize (BufferLengthNode); /* The Unicode string is a raw data buffer */
InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
InitializerNode->Value.Pointer = UnicodeString; InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
InitializerNode->AmlOpcode = AML_RAW_DATA_BUFFER; InitializerOp->Asl.AmlLength = Length;
InitializerNode->AmlLength = Length; InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
InitializerNode->ParseOpcode = RAW_DATA; InitializerOp->Asl.Child = NULL;
UtSetParseOpName (InitializerOp);
} }
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: CgDoEisaId * FUNCTION: OpcDoEisaId
* *
* PARAMETERS: * PARAMETERS: Op - Parse node
*
* RETURN: None
* *
* RETURN:
* *
* DESCRIPTION: Convert a string EISA ID to numeric representation * DESCRIPTION: Convert a string EISA ID to numeric representation
* *
******************************************************************************/ ******************************************************************************/
void void
CgDoEisaId ( OpcDoEisaId (
ASL_PARSE_NODE *Node) ACPI_PARSE_OBJECT *Op)
{ {
UINT32 id; UINT32 id;
UINT32 SwappedId; UINT32 SwappedId;
NATIVE_CHAR *InString; UINT8 *InString;
InString = (UINT8 *) Op->Asl.Value.String;
InString = Node->Value.String;
/* Create ID big-endian first */ /* Create ID big-endian first */
id = 0; id = 0;
id |= (InString[0] - '@') << 26; id |= (UINT32) (InString[0] - '@') << 26;
id |= (InString[1] - '@') << 21; id |= (UINT32) (InString[1] - '@') << 21;
id |= (InString[2] - '@') << 16; id |= (UINT32) (InString[2] - '@') << 16;
id |= (UtHexCharToValue (InString[3])) << 12; id |= (UtHexCharToValue (InString[3])) << 12;
id |= (UtHexCharToValue (InString[4])) << 8; id |= (UtHexCharToValue (InString[4])) << 8;
id |= (UtHexCharToValue (InString[5])) << 4; id |= (UtHexCharToValue (InString[5])) << 4;
id |= UtHexCharToValue (InString[6]); id |= UtHexCharToValue (InString[6]);
/* swap to little-endian */ /* swap to little-endian */
SwappedId = (id & 0xFF) << 24; SwappedId = (id & 0xFF) << 24;
SwappedId |= ((id >> 8) & 0xFF) << 16; SwappedId |= ((id >> 8) & 0xFF) << 16;
SwappedId |= ((id >> 16) & 0xFF) << 8; SwappedId |= ((id >> 16) & 0xFF) << 8;
SwappedId |= (id >> 24) & 0xFF; SwappedId |= (id >> 24) & 0xFF;
Node->Value.Integer32 = SwappedId; Op->Asl.Value.Integer32 = SwappedId;
/* Node is now an integer */ /* Op is now an integer */
Node->ParseOpcode = INTEGER; Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
CgSetOptimalIntegerSize (Node); Op->Asl.ParseOpcode = PARSEOP_INTEGER;
(void) OpcSetOptimalIntegerSize (Op);
UtSetParseOpName (Op);
} }
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: * FUNCTION: OpcGenerateAmlOpcode
* *
* PARAMETERS: * PARAMETERS: Op - Parse node
* *
* RETURN: * RETURN: None
* *
* DESCRIPTION: * DESCRIPTION: Generate the AML opcode associated with the node and its
* parse (lex/flex) keyword opcode. Essentially implements
* a mapping between the parse opcodes and the actual AML opcodes.
* *
******************************************************************************/ ******************************************************************************/
void void
CgGenerateAmlOpcode ( 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; if (!Op->Asl.Value.Integer)
Node->Flags |= AslKeywordMapping[Index].Flags;
if (!Node->Value.Integer)
{ {
Node->Value.Integer = AslKeywordMapping[Index].Value; Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
} }
/* Special handling for some opcodes */ /* 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 * Set the opcode based on the size of the integer
*/ */
CgSetOptimalIntegerSize (Node); (void) OpcSetOptimalIntegerSize (Op);
break; break;
case OFFSET: case PARSEOP_OFFSET:
CgDoOffset (Node);
Op->Asl.AmlOpcodeLength = 1;
break; break;
case ACCESSAS: case PARSEOP_ACCESSAS:
CgDoAccessAs (Node);
OpcDoAccessAs (Op);
break; break;
case EISAID: case PARSEOP_EISAID:
CgDoEisaId (Node);
OpcDoEisaId (Op);
break; break;
case UNICODE: case PARSEOP_UNICODE:
CgDoUnicode (Node);
OpcDoUnicode (Op);
break;
case PARSEOP_INCLUDE:
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
Gbl_HasIncludeFiles = TRUE;
break;
case PARSEOP_EXTERNAL:
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
break;
case PARSEOP_PACKAGE:
/*
* The variable-length package has a different opcode
*/
if ((Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) &&
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_BYTECONST))
{
Op->Asl.AmlOpcode = AML_VAR_PACKAGE_OP;
}
break;
default:
/* Nothing to do for other opcodes */
break; break;
} }
@ -443,4 +486,3 @@ CgGenerateAmlOpcode (
} }