1
0
mirror of https://github.com/acpica/acpica/ synced 2025-02-15 13:04:16 +03:00

Fix for OFFSET and a new error message

date	2000.12.12.16.56.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 16:07:13 +00:00
parent 1552616d04
commit fbdbdaf7e7

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslopcode - AML opcode generation
* $Revision: 1.3 $
* $Revision: 1.8 $
*
*****************************************************************************/
@ -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, 2000, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -122,34 +122,32 @@
#include "acnamesp.h"
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoMethod
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the operands for the METHOD ASL keyword.
*
******************************************************************************/
void
CgDoMethod (
OpnDoMethod (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
/* Optional arguments for this opcode with defaults */
UINT8 NumArgs = 0;
UINT8 Serialized = 0;
UINT8 Concurrency = 0;
UINT8 MethodFlags;
/* Opcode and package length first */
/* Method name */
@ -183,7 +181,7 @@ CgDoMethod (
/* Put the bits in their proper places */
MethodFlags = (NumArgs & 0x7) | ((Serialized & 0x1) << 3) | ((Concurrency & 0xF) << 4);
MethodFlags = (NumArgs & 0x7) | ((Serialized & 0x1) << 3) | ((Concurrency & 0xF) << 4);
/* Use the last node for the combined flags byte */
@ -191,23 +189,28 @@ CgDoMethod (
Next->AmlOpcode = AML_RAW_DATA_BYTE;
Next->AmlLength = 1;
Next->ParseOpcode = RAW_DATA;
/* Save the arg count in the first node */
Node->Extra = NumArgs;
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoFieldCommon
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the various field keywords,
* FIELD, BANKFIELD, INDEXFIELD
*
******************************************************************************/
void
CgDoFieldCommon (
OpnDoFieldCommon (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
@ -249,7 +252,7 @@ CgDoFieldCommon (
Next->AmlLength = 1;
Next->ParseOpcode = RAW_DATA;
/* Process the FieldUnitList */
/* Process the FieldUnitList */
Next = Next->Peer;
CurrentBitOffset = 0;
@ -259,28 +262,70 @@ CgDoFieldCommon (
switch (Next->ParseOpcode)
{
case ACCESSAS:
/* Nothing additional to do */
break;
case OFFSET:
/* New offset into the field */
PkgLengthNode = Next->Child;
NewBitOffset = PkgLengthNode->Value.Integer32 * 8;
/*
* Examine the specified offset in relation to the
* current offset counter.
*/
if (NewBitOffset < CurrentBitOffset)
{
DbgPrint ("Offset less than current offset\n");
/*
* Not allowed to specify a backwards offset!
* Issue error and ignore this node.
*/
AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, NULL);
Next->ParseOpcode = DEFAULT_ARG;
PkgLengthNode->ParseOpcode = DEFAULT_ARG;
}
else if (NewBitOffset == CurrentBitOffset)
{
/*
* Offset is redundant; we don't need to output an
* offset opcode. Just set these nodes to default
*/
Next->ParseOpcode = DEFAULT_ARG;
PkgLengthNode->ParseOpcode = DEFAULT_ARG;
}
else
{
/*
* Valid new offset - set the value to be inserted into the AML
* and update the offset counter.
*/
PkgLengthNode->Value.Integer = NewBitOffset - CurrentBitOffset;
CurrentBitOffset = NewBitOffset;
}
PkgLengthNode->Value.Integer = NewBitOffset - CurrentBitOffset;
CurrentBitOffset = NewBitOffset;
break;
case NAMESEG:
case RESERVED_BYTES:
PkgLengthNode = Next->Child;
NewBitOffset = PkgLengthNode->Value.Integer32;
/* Named or reserved field entry */
PkgLengthNode = Next->Child;
NewBitOffset = PkgLengthNode->Value.Integer32;
CurrentBitOffset += NewBitOffset;
break;
}
/* Move on to next entry in the field list */
Next = Next->Peer;
}
}
@ -288,18 +333,18 @@ CgDoFieldCommon (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoField
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
*
******************************************************************************/
void
CgDoField (
OpnDoField (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
@ -312,31 +357,29 @@ CgDoField (
/* Second child is the AccessType */
CgDoFieldCommon (Next->Peer);
OpnDoFieldCommon (Next->Peer);
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoIndexField
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
*
******************************************************************************/
void
CgDoIndexField (
OpnDoIndexField (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
/* Opcode is parent node */
/* First child is the index name */
@ -348,31 +391,30 @@ CgDoIndexField (
/* Third child is the AccessType */
CgDoFieldCommon (Next->Peer);
OpnDoFieldCommon (Next->Peer);
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoBankField
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
*
******************************************************************************/
void
CgDoBankField (
OpnDoBankField (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Next;
/* Opcode is parent node */
/* First child is the region name */
@ -388,33 +430,34 @@ CgDoBankField (
/* Fourth child is the AccessType */
CgDoFieldCommon (Next->Peer);
OpnDoFieldCommon (Next->Peer);
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoBuffer
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
* build a single raw byte buffer from the initialization nodes,
* each parse node contains a buffer byte.
*
******************************************************************************/
void
CgDoBuffer (
OpnDoBuffer (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *InitializerNode;
ASL_PARSE_NODE *BufferLengthNode;
/* Optional arguments for this opcode with defaults */
UINT32 BufferLength = 0;
@ -424,7 +467,7 @@ CgDoBuffer (
BufferLengthNode = Node->Child;
InitializerNode = BufferLengthNode->Peer;
/*
/*
* 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.
@ -466,7 +509,7 @@ CgDoBuffer (
case STRING_LITERAL:
/*
/*
* Only one initializer, the string. Buffer must be big enough to hold
* the string plus the null termination byte
*/
@ -484,7 +527,7 @@ CgDoBuffer (
default:
printf ("Unknown buffer initializer opcode [%s]\n",
printf ("Unknown buffer initializer opcode [%s]\n",
UtGetOpName (InitializerNode->ParseOpcode));
return;
}
@ -507,7 +550,7 @@ CgDoBuffer (
}
/*
/*
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
@ -516,34 +559,33 @@ CgDoBuffer (
BufferLengthNode->AmlOpcode = AML_DWORD_OP;
BufferLengthNode->Value.Integer = BufferLength;
CgSetOptimalIntegerSize (BufferLengthNode);
OpcSetOptimalIntegerSize (BufferLengthNode);
/* Remaining nodes are handled via the tree walk */
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoPackage
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword.
*
******************************************************************************/
void
CgDoPackage (
OpnDoPackage (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *InitializerNode;
ASL_PARSE_NODE *PackageLengthNode;
/* Optional arguments for this opcode with defaults */
UINT32 PackageLength = 0;
@ -591,7 +633,7 @@ CgDoPackage (
}
/*
/*
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
@ -605,31 +647,29 @@ CgDoPackage (
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnDoDefinitionBlock
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Construct the AML operands for the DEFINTIONBLOCK ASL keyword
*
******************************************************************************/
void
CgDoDefinitionBlock (
OpnDoDefinitionBlock (
ASL_PARSE_NODE *Node)
{
ASL_PARSE_NODE *Child;
/*
/*
* These nodes get stuffed into the table header. They are special
* cased when the table is written to the output file.
*
*
* Mark all of these nodes as non-usable so they won't get output
* as AML opcodes!
*/
@ -671,18 +711,16 @@ CgDoDefinitionBlock (
}
/*******************************************************************************
*
* FUNCTION: AcpiPsGetArg
* FUNCTION: UtGetArg
*
* PARAMETERS: Op - Get an argument for this op
* Argn - Nth argument to get
*
* RETURN: The argument (as an Op object). NULL if argument does not exist
*
* DESCRIPTION: Get the specified op's argument.
* DESCRIPTION: Get the specified op's argument (peer)
*
******************************************************************************/
@ -694,7 +732,6 @@ UtGetArg (
ASL_PARSE_NODE *Arg = NULL;
/* Get the requested argument object */
Arg = Op->Child;
@ -708,22 +745,22 @@ UtGetArg (
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnAttachNameToNode
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: For the named ASL/AML operators, get the actual name from the
* argument list and attach it to the parent node so that we
* can get to it quickly later.
*
******************************************************************************/
void
CgAttachNameToNode (
OpnAttachNameToNode (
ASL_PARSE_NODE *PsNode)
{
ASL_PARSE_NODE *Child = NULL;
@ -765,13 +802,13 @@ CgAttachNameToNode (
case AML_WORD_FIELD_OP:
case AML_DWORD_FIELD_OP:
case AML_QWORD_FIELD_OP:
Child = UtGetArg (PsNode, 2);
break;
case AML_CREATE_FIELD_OP:
Child = UtGetArg (PsNode, 3);
break;
@ -801,21 +838,22 @@ CgAttachNameToNode (
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: OpnGenerateAmlOperands
*
* PARAMETERS:
* PARAMETERS: Node - The parent parse node
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
* complex AML opcodes require processing of the child nodes
* (arguments/operands).
*
******************************************************************************/
void
CgGenerateAmlOperands (
OpnGenerateAmlOperands (
ASL_PARSE_NODE *Node)
{
@ -829,35 +867,35 @@ CgGenerateAmlOperands (
switch (Node->ParseOpcode)
{
case DEFINITIONBLOCK:
CgDoDefinitionBlock (Node);
OpnDoDefinitionBlock (Node);
break;
case METHOD:
CgDoMethod (Node);
OpnDoMethod (Node);
break;
case FIELD:
CgDoField (Node);
OpnDoField (Node);
break;
case INDEXFIELD:
CgDoIndexField (Node);
OpnDoIndexField (Node);
break;
case BANKFIELD:
CgDoBankField (Node);
OpnDoBankField (Node);
break;
case BUFFER:
CgDoBuffer (Node);
OpnDoBuffer (Node);
break;
case PACKAGE:
CgDoPackage (Node);
OpnDoPackage (Node);
break;
case RESOURCETEMPLATE:
CgDoResourceTemplate (Node);
RsDoResourceTemplate (Node);
break;
case NAMESEG:
@ -871,14 +909,9 @@ CgGenerateAmlOperands (
}
/* TBD: move */
CgAttachNameToNode (Node);
OpnAttachNameToNode (Node);
}