mirror of
https://github.com/acpica/acpica/
synced 2025-01-15 22:09:17 +03:00
Some small Lint changes
date 2002.05.02.22.11.00; author rmoore1; state Exp;
This commit is contained in:
parent
4b856918ff
commit
26cc36c346
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: aslmain - compiler main and utilities
|
||||
* $Revision: 1.50 $
|
||||
* $Revision: 1.51 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -119,7 +119,6 @@
|
||||
#define _DECLARE_GLOBALS
|
||||
|
||||
#include "aslcompiler.h"
|
||||
#include "acparser.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <crtdbg.h>
|
||||
@ -349,7 +348,6 @@ main (
|
||||
case 'd':
|
||||
printf ("AML Disassembly not yet supported\n");
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
|
||||
@ -424,6 +422,7 @@ main (
|
||||
printf ("Unknown option: -q%s\n", optarg);
|
||||
BadCommandLine = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: aslopcode - AML opcode generation
|
||||
* $Revision: 1.14 $
|
||||
* $Revision: 1.41 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
|
||||
* reserved.
|
||||
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
*
|
||||
@ -116,326 +116,369 @@
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#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")
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* 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
|
||||
CgAmlOpcodeWalk (
|
||||
ASL_PARSE_NODE *Node,
|
||||
UINT32 Level,
|
||||
void *Context)
|
||||
ACPI_STATUS
|
||||
OpcAmlOpcodeWalk (
|
||||
ACPI_PARSE_OBJECT *Op,
|
||||
UINT32 Level,
|
||||
void *Context)
|
||||
{
|
||||
|
||||
CgGenerateAmlOpcode (Node);
|
||||
CgGenerateAmlOperands (Node);
|
||||
TotalParseNodes++;
|
||||
|
||||
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
|
||||
CgSetOptimalIntegerSize (
|
||||
ASL_PARSE_NODE *Node)
|
||||
OpcSetOptimalIntegerSize (
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION:
|
||||
* FUNCTION: OpcDoAccessAs
|
||||
*
|
||||
* PARAMETERS:
|
||||
* PARAMETERS: Op - Parse node
|
||||
*
|
||||
* RETURN:
|
||||
* RETURN: None
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION: Implement the ACCESS_AS ASL keyword.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
CgDoOffset (
|
||||
ASL_PARSE_NODE *Node)
|
||||
OpcDoAccessAs (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
ASL_PARSE_NODE *InitializerNode;
|
||||
|
||||
/* Entire proc unnecessary? */
|
||||
|
||||
Node->AmlOpcodeLength = 1;
|
||||
InitializerNode = Node->Child;
|
||||
}
|
||||
ACPI_PARSE_OBJECT *Next;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION:
|
||||
*
|
||||
* PARAMETERS:
|
||||
*
|
||||
* RETURN:
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
CgDoAccessAs (
|
||||
ASL_PARSE_NODE *Node)
|
||||
{
|
||||
ASL_PARSE_NODE *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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* 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
|
||||
CgDoUnicode (
|
||||
ASL_PARSE_NODE *Node)
|
||||
OpcDoUnicode (
|
||||
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);
|
||||
|
||||
CgSetOptimalIntegerSize (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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: CgDoEisaId
|
||||
* FUNCTION: OpcDoEisaId
|
||||
*
|
||||
* PARAMETERS:
|
||||
* PARAMETERS: Op - Parse node
|
||||
*
|
||||
* RETURN: None
|
||||
*
|
||||
* RETURN:
|
||||
*
|
||||
* DESCRIPTION: Convert a string EISA ID to numeric representation
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
CgDoEisaId (
|
||||
ASL_PARSE_NODE *Node)
|
||||
OpcDoEisaId (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
UINT32 id;
|
||||
UINT32 SwappedId;
|
||||
NATIVE_CHAR *InString;
|
||||
UINT8 *InString;
|
||||
|
||||
|
||||
|
||||
InString = Node->Value.String;
|
||||
InString = (UINT8 *) Op->Asl.Value.String;
|
||||
|
||||
/* Create ID big-endian first */
|
||||
|
||||
id = 0;
|
||||
id |= (InString[0] - '@') << 26;
|
||||
id |= (InString[1] - '@') << 21;
|
||||
id |= (InString[2] - '@') << 16;
|
||||
id |= (UINT32) (InString[0] - '@') << 26;
|
||||
id |= (UINT32) (InString[1] - '@') << 21;
|
||||
id |= (UINT32) (InString[2] - '@') << 16;
|
||||
|
||||
id |= (UtHexCharToValue (InString[3])) << 12;
|
||||
id |= (UtHexCharToValue (InString[4])) << 8;
|
||||
id |= (UtHexCharToValue (InString[5])) << 4;
|
||||
id |= UtHexCharToValue (InString[6]);
|
||||
id |= UtHexCharToValue (InString[6]);
|
||||
|
||||
/* swap to little-endian */
|
||||
|
||||
SwappedId = (id & 0xFF) << 24;
|
||||
SwappedId = (id & 0xFF) << 24;
|
||||
SwappedId |= ((id >> 8) & 0xFF) << 16;
|
||||
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;
|
||||
CgSetOptimalIntegerSize (Node);
|
||||
Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST;
|
||||
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
|
||||
CgGenerateAmlOpcode (
|
||||
ASL_PARSE_NODE *Node)
|
||||
OpcGenerateAmlOpcode (
|
||||
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->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
|
||||
*/
|
||||
CgSetOptimalIntegerSize (Node);
|
||||
(void) OpcSetOptimalIntegerSize (Op);
|
||||
break;
|
||||
|
||||
case OFFSET:
|
||||
CgDoOffset (Node);
|
||||
case PARSEOP_OFFSET:
|
||||
|
||||
Op->Asl.AmlOpcodeLength = 1;
|
||||
break;
|
||||
|
||||
case ACCESSAS:
|
||||
CgDoAccessAs (Node);
|
||||
case PARSEOP_ACCESSAS:
|
||||
|
||||
OpcDoAccessAs (Op);
|
||||
break;
|
||||
|
||||
case EISAID:
|
||||
CgDoEisaId (Node);
|
||||
case PARSEOP_EISAID:
|
||||
|
||||
OpcDoEisaId (Op);
|
||||
break;
|
||||
|
||||
case UNICODE:
|
||||
CgDoUnicode (Node);
|
||||
case PARSEOP_UNICODE:
|
||||
|
||||
OpcDoUnicode (Op);
|
||||
break;
|
||||
|
||||
case PARSEOP_INCLUDE:
|
||||
|
||||
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
|
||||
Gbl_HasIncludeFiles = TRUE;
|
||||
break;
|
||||
|
||||
case PARSEOP_EXTERNAL:
|
||||
|
||||
Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
|
||||
Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
|
||||
break;
|
||||
|
||||
case PARSEOP_PACKAGE:
|
||||
/*
|
||||
* The variable-length package has a different opcode
|
||||
*/
|
||||
if ((Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
|
||||
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) &&
|
||||
(Op->Asl.Child->Asl.ParseOpcode != PARSEOP_BYTECONST))
|
||||
{
|
||||
Op->Asl.AmlOpcode = AML_VAR_PACKAGE_OP;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Nothing to do for other opcodes */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -443,4 +486,3 @@ CgGenerateAmlOpcode (
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user