Merge ACPICA 20110211.

This commit is contained in:
Jung-uk Kim 2011-02-12 01:03:15 +00:00
commit 0b94ba42b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=218590
51 changed files with 7178 additions and 5526 deletions

View File

@ -161,6 +161,8 @@ contrib/dev/acpica/debugger/dbexec.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbfileio.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbhistry.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbinput.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbmethod.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbnames.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbstats.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbutils.c optional acpi acpi_debug
contrib/dev/acpica/debugger/dbxface.c optional acpi acpi_debug
@ -173,6 +175,8 @@ contrib/dev/acpica/disassembler/dmresrcl.c optional acpi acpi_debug
contrib/dev/acpica/disassembler/dmresrcs.c optional acpi acpi_debug
contrib/dev/acpica/disassembler/dmutils.c optional acpi acpi_debug
contrib/dev/acpica/disassembler/dmwalk.c optional acpi acpi_debug
contrib/dev/acpica/dispatcher/dsargs.c optional acpi
contrib/dev/acpica/dispatcher/dscontrol.c optional acpi
contrib/dev/acpica/dispatcher/dsfield.c optional acpi
contrib/dev/acpica/dispatcher/dsinit.c optional acpi
contrib/dev/acpica/dispatcher/dsmethod.c optional acpi
@ -182,6 +186,7 @@ contrib/dev/acpica/dispatcher/dsopcode.c optional acpi
contrib/dev/acpica/dispatcher/dsutils.c optional acpi
contrib/dev/acpica/dispatcher/dswexec.c optional acpi
contrib/dev/acpica/dispatcher/dswload.c optional acpi
contrib/dev/acpica/dispatcher/dswload2.c optional acpi
contrib/dev/acpica/dispatcher/dswscope.c optional acpi
contrib/dev/acpica/dispatcher/dswstate.c optional acpi
contrib/dev/acpica/events/evevent.c optional acpi
@ -278,6 +283,7 @@ contrib/dev/acpica/utilities/utalloc.c optional acpi
contrib/dev/acpica/utilities/utcache.c optional acpi
contrib/dev/acpica/utilities/utcopy.c optional acpi
contrib/dev/acpica/utilities/utdebug.c optional acpi
contrib/dev/acpica/utilities/utdecode.c optional acpi
contrib/dev/acpica/utilities/utdelete.c optional acpi
contrib/dev/acpica/utilities/uteval.c optional acpi
contrib/dev/acpica/utilities/utglobal.c optional acpi

File diff suppressed because it is too large Load Diff

View File

@ -641,6 +641,7 @@ AcpiDmDumpTable (
ByteLength = 6;
break;
case ACPI_DMT_UINT56:
case ACPI_DMT_BUF7:
ByteLength = 7;
break;
case ACPI_DMT_UINT64:
@ -751,16 +752,19 @@ AcpiDmDumpTable (
ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
break;
case ACPI_DMT_BUF7:
case ACPI_DMT_BUF16:
/* Buffer of length 16 */
for (Temp8 = 0; Temp8 < 16; Temp8++)
/*
* Buffer: Size depends on the opcode and was set above.
* Each hex byte is separated with a space.
*/
for (Temp8 = 0; Temp8 < ByteLength; Temp8++)
{
AcpiOsPrintf ("%2.2X", Target[Temp8]);
if ((Temp8 + 1) < 16)
if ((UINT32) (Temp8 + 1) < ByteLength)
{
AcpiOsPrintf (",");
AcpiOsPrintf (" ");
}
}
AcpiOsPrintf ("\n");

View File

@ -52,6 +52,12 @@
ACPI_MODULE_NAME ("dmtbdump")
static void
AcpiDmValidateFadtLength (
UINT32 Revision,
UINT32 Length);
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpRsdp
@ -201,6 +207,10 @@ AcpiDmDumpXsdt (
*
* DESCRIPTION: Format the contents of a FADT
*
* NOTE: We cannot depend on the FADT version to indicate the actual
* contents of the FADT because of BIOS bugs. The table length
* is the only reliable indicator.
*
******************************************************************************/
void
@ -208,20 +218,21 @@ AcpiDmDumpFadt (
ACPI_TABLE_HEADER *Table)
{
/* Common ACPI 1.0 portion of FADT */
/* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt1);
/* Check for ACPI 1.0B MS extensions (FADT revision 2) */
/* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
if (Table->Revision == 2)
if ((Table->Length > ACPI_FADT_V1_SIZE) &&
(Table->Length <= ACPI_FADT_V2_SIZE))
{
AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt2);
}
/* Check for ACPI 2.0+ extended data (FADT revision 3+) */
/* Check for FADT revision 3 fields and up (ACPI 2.0+ extended data) */
else if (Table->Length >= sizeof (ACPI_TABLE_FADT))
else if (Table->Length > ACPI_FADT_V2_SIZE)
{
AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt3);
}
@ -229,6 +240,68 @@ AcpiDmDumpFadt (
/* Validate various fields in the FADT, including length */
AcpiTbCreateLocalFadt (Table, Table->Length);
/* Validate FADT length against the revision */
AcpiDmValidateFadtLength (Table->Revision, Table->Length);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmValidateFadtLength
*
* PARAMETERS: Revision - FADT revision (Header->Revision)
* Length - FADT length (Header->Length
*
* RETURN: None
*
* DESCRIPTION: Check the FADT revision against the expected table length for
* that revision. Issue a warning if the length is not what was
* expected. This seems to be such a common BIOS bug that the
* FADT revision has been rendered virtually meaningless.
*
******************************************************************************/
static void
AcpiDmValidateFadtLength (
UINT32 Revision,
UINT32 Length)
{
UINT32 ExpectedLength;
switch (Revision)
{
case 0:
AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
return;
case 1:
ExpectedLength = ACPI_FADT_V1_SIZE;
break;
case 2:
ExpectedLength = ACPI_FADT_V2_SIZE;
break;
case 3:
case 4:
ExpectedLength = ACPI_FADT_V3_SIZE;
break;
default:
return;
}
if (Length == ExpectedLength)
{
return;
}
AcpiOsPrintf (
"\n// ACPI Warning: FADT revision %X does not match length: found %X expected %X\n",
Revision, Length, ExpectedLength);
}

View File

@ -477,7 +477,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[] =
{
{ACPI_DMT_UINT56, ACPI_ASF3_OFFSET (Capabilities[0]), "Capabilities", 0},
{ACPI_DMT_BUF7, ACPI_ASF3_OFFSET (Capabilities[0]), "Capabilities", 0},
{ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (CompletionCode), "Completion Code", 0},
{ACPI_DMT_UINT32, ACPI_ASF3_OFFSET (EnterpriseId), "Enterprise ID", 0},
{ACPI_DMT_UINT8, ACPI_ASF3_OFFSET (Command), "Command", 0},
@ -1588,5 +1588,6 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2] =
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_BUFFER, "Buffer"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UUID, "GUID"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_STRING, "DevicePath"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_LABEL, "Label"),
{ACPI_DMT_TERMINATOR}
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,525 @@
/******************************************************************************
*
* Module Name: aslbtypes - Support for bitfield types
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
#include <contrib/dev/acpica/include/amlcode.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslbtypes")
/* Local prototypes */
static UINT32
AnMapEtypeToBtype (
UINT32 Etype);
/*******************************************************************************
*
* FUNCTION: AnMapArgTypeToBtype
*
* PARAMETERS: ArgType - The ARGI required type(s) for this
* argument, from the opcode info table
*
* RETURN: The corresponding Bit-encoded types
*
* DESCRIPTION: Convert an encoded ARGI required argument type code into a
* bitfield type code. Implements the implicit source conversion
* rules.
*
******************************************************************************/
UINT32
AnMapArgTypeToBtype (
UINT32 ArgType)
{
switch (ArgType)
{
/* Simple types */
case ARGI_ANYTYPE:
return (ACPI_BTYPE_OBJECTS_AND_REFS);
case ARGI_PACKAGE:
return (ACPI_BTYPE_PACKAGE);
case ARGI_EVENT:
return (ACPI_BTYPE_EVENT);
case ARGI_MUTEX:
return (ACPI_BTYPE_MUTEX);
case ARGI_DDBHANDLE:
/*
* DDBHandleObject := SuperName
* ACPI_BTYPE_REFERENCE: Index reference as parameter of Load/Unload
*/
return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE);
/* Interchangeable types */
/*
* Source conversion rules:
* Integer, String, and Buffer are all interchangeable
*/
case ARGI_INTEGER:
case ARGI_STRING:
case ARGI_BUFFER:
case ARGI_BUFFER_OR_STRING:
case ARGI_COMPUTEDATA:
return (ACPI_BTYPE_COMPUTE_DATA);
/* References */
case ARGI_INTEGER_REF:
return (ACPI_BTYPE_INTEGER);
case ARGI_OBJECT_REF:
return (ACPI_BTYPE_ALL_OBJECTS);
case ARGI_DEVICE_REF:
return (ACPI_BTYPE_DEVICE_OBJECTS);
case ARGI_REFERENCE:
return (ACPI_BTYPE_REFERENCE);
case ARGI_TARGETREF:
case ARGI_FIXED_TARGET:
case ARGI_SIMPLE_TARGET:
return (ACPI_BTYPE_OBJECTS_AND_REFS);
/* Complex types */
case ARGI_DATAOBJECT:
/*
* Buffer, string, package or reference to a Op -
* Used only by SizeOf operator
*/
return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE);
case ARGI_COMPLEXOBJ:
/* Buffer, String, or package */
return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE);
case ARGI_REF_OR_STRING:
return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE);
case ARGI_REGION_OR_BUFFER:
/* Used by Load() only. Allow buffers in addition to regions/fields */
return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT);
case ARGI_DATAREFOBJ:
return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE);
default:
break;
}
return (ACPI_BTYPE_OBJECTS_AND_REFS);
}
/*******************************************************************************
*
* FUNCTION: AnMapEtypeToBtype
*
* PARAMETERS: Etype - Encoded ACPI Type
*
* RETURN: Btype corresponding to the Etype
*
* DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the
* operand conversion rules. In other words, returns the type(s)
* this Etype is implicitly converted to during interpretation.
*
******************************************************************************/
static UINT32
AnMapEtypeToBtype (
UINT32 Etype)
{
if (Etype == ACPI_TYPE_ANY)
{
return (ACPI_BTYPE_OBJECTS_AND_REFS);
}
/* Try the standard ACPI data types */
if (Etype <= ACPI_TYPE_EXTERNAL_MAX)
{
/*
* This switch statement implements the allowed operand conversion
* rules as per the "ASL Data Types" section of the ACPI
* specification.
*/
switch (Etype)
{
case ACPI_TYPE_INTEGER:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE);
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
return (ACPI_BTYPE_COMPUTE_DATA);
case ACPI_TYPE_PACKAGE:
return (ACPI_BTYPE_PACKAGE);
case ACPI_TYPE_FIELD_UNIT:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
case ACPI_TYPE_BUFFER_FIELD:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD);
case ACPI_TYPE_DDB_HANDLE:
return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE);
case ACPI_BTYPE_DEBUG_OBJECT:
/* Cannot be used as a source operand */
return (0);
default:
return (1 << (Etype - 1));
}
}
/* Try the internal data types */
switch (Etype)
{
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
/* Named fields can be either Integer/Buffer/String */
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
case ACPI_TYPE_LOCAL_ALIAS:
return (ACPI_BTYPE_INTEGER);
case ACPI_TYPE_LOCAL_RESOURCE:
case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
return (ACPI_BTYPE_REFERENCE);
default:
printf ("Unhandled encoded type: %X\n", Etype);
return (0);
}
}
/*******************************************************************************
*
* FUNCTION: AnFormatBtype
*
* PARAMETERS: Btype - Bitfield of ACPI types
* Buffer - Where to put the ascii string
*
* RETURN: None.
*
* DESCRIPTION: Convert a Btype to a string of ACPI types
*
******************************************************************************/
void
AnFormatBtype (
char *Buffer,
UINT32 Btype)
{
UINT32 Type;
BOOLEAN First = TRUE;
*Buffer = 0;
if (Btype == 0)
{
strcat (Buffer, "NoReturnValue");
return;
}
for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++)
{
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
First = FALSE;
strcat (Buffer, AcpiUtGetTypeName (Type));
}
Btype >>= 1;
}
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
First = FALSE;
strcat (Buffer, "Reference");
}
Btype >>= 1;
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
First = FALSE;
strcat (Buffer, "Resource");
}
}
/*******************************************************************************
*
* FUNCTION: AnGetBtype
*
* PARAMETERS: Op - Parse node whose type will be returned.
*
* RETURN: The Btype associated with the Op.
*
* DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node.
* Handles the case where the node is a name or method call and
* the actual type must be obtained from the namespace node.
*
******************************************************************************/
UINT32
AnGetBtype (
ACPI_PARSE_OBJECT *Op)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *ReferencedNode;
UINT32 ThisNodeBtype = 0;
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
Node = Op->Asl.Node;
if (!Node)
{
DbgPrint (ASL_DEBUG_OUTPUT,
"No attached Nsnode: [%s] at line %u name [%s], ignoring typecheck\n",
Op->Asl.ParseOpName, Op->Asl.LineNumber,
Op->Asl.ExternalName);
return (ACPI_UINT32_MAX);
}
ThisNodeBtype = AnMapEtypeToBtype (Node->Type);
if (!ThisNodeBtype)
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
"could not map type");
}
/*
* Since it was a named reference, enable the
* reference bit also
*/
ThisNodeBtype |= ACPI_BTYPE_REFERENCE;
if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
{
ReferencedNode = Node->Op;
if (!ReferencedNode)
{
/* Check for an internal method */
if (AnIsInternalMethod (Op))
{
return (AnGetInternalMethodReturnType (Op));
}
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
"null Op pointer");
return (ACPI_UINT32_MAX);
}
if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED)
{
ThisNodeBtype = ReferencedNode->Asl.AcpiBtype;
}
else
{
return (ACPI_UINT32_MAX -1);
}
}
}
else
{
ThisNodeBtype = Op->Asl.AcpiBtype;
}
return (ThisNodeBtype);
}
/*******************************************************************************
*
* FUNCTION: AnMapObjTypeToBtype
*
* PARAMETERS: Op - A parse node
*
* RETURN: A Btype
*
* DESCRIPTION: Map object to the associated "Btype"
*
******************************************************************************/
UINT32
AnMapObjTypeToBtype (
ACPI_PARSE_OBJECT *Op)
{
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */
return (ACPI_BTYPE_BUFFER_FIELD);
case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */
return (ACPI_BTYPE_BUFFER);
case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */
return (ACPI_BTYPE_DDB_HANDLE);
case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */
return (ACPI_BTYPE_DEVICE);
case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */
return (ACPI_BTYPE_EVENT);
case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */
return (ACPI_BTYPE_FIELD_UNIT);
case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */
return (ACPI_BTYPE_INTEGER);
case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */
return (ACPI_BTYPE_METHOD);
case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */
return (ACPI_BTYPE_MUTEX);
case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */
return (ACPI_BTYPE_REGION);
case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */
return (ACPI_BTYPE_PACKAGE);
case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */
return (ACPI_BTYPE_POWER);
case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */
return (ACPI_BTYPE_STRING);
case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */
return (ACPI_BTYPE_THERMAL);
case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */
return (ACPI_BTYPE_OBJECTS_AND_REFS);
default:
return (0);
}
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
* FUNCTION: AnMapBtypeToEtype
*
* PARAMETERS: Btype - Bitfield of ACPI types
*
* RETURN: The Etype corresponding the the Btype
*
* DESCRIPTION: Convert a bitfield type to an encoded type
*
******************************************************************************/
UINT32
AnMapBtypeToEtype (
UINT32 Btype)
{
UINT32 i;
UINT32 Etype;
if (Btype == 0)
{
return (0);
}
Etype = 1;
for (i = 1; i < Btype; i *= 2)
{
Etype++;
}
return (Etype);
}
#endif

View File

@ -600,27 +600,25 @@ CmDoCompile (
Event = UtBeginEvent ("Determine object types returned by methods");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
AnMethodTypingWalkBegin,
AnMethodTypingWalkEnd, NULL);
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
NULL, AnMethodTypingWalkEnd, NULL);
UtEndEvent (Event);
/* Semantic error checking part three - operand type checking */
Event = UtBeginEvent ("Analyze AML operand types");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
AnOperandTypecheckWalkBegin,
AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
UtEndEvent (Event);
/* Semantic error checking part four - other miscellaneous checks */
Event = UtBeginEvent ("Miscellaneous analysis");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
AnOtherSemanticAnalysisWalkBegin,
AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
NULL, &AnalysisWalkInfo);
UtEndEvent (Event);
/* Calculate all AML package lengths */

View File

@ -164,7 +164,7 @@ FlCheckForAscii (
/*
* aslanalyze - semantic analysis
* aslwalks - semantic analysis and parse tree walks
*/
ACPI_STATUS
AnOtherSemanticAnalysisWalkBegin (
@ -178,12 +178,6 @@ AnOtherSemanticAnalysisWalkEnd (
UINT32 Level,
void *Context);
ACPI_STATUS
AnOperandTypecheckWalkBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
ACPI_STATUS
AnOperandTypecheckWalkEnd (
ACPI_PARSE_OBJECT *Op,
@ -202,12 +196,6 @@ AnMethodAnalysisWalkEnd (
UINT32 Level,
void *Context);
ACPI_STATUS
AnMethodTypingWalkBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
ACPI_STATUS
AnMethodTypingWalkEnd (
ACPI_PARSE_OBJECT *Op,
@ -215,6 +203,69 @@ AnMethodTypingWalkEnd (
void *Context);
/*
* aslbtypes - bitfield data types
*/
UINT32
AnMapObjTypeToBtype (
ACPI_PARSE_OBJECT *Op);
UINT32
AnMapArgTypeToBtype (
UINT32 ArgType);
UINT32
AnGetBtype (
ACPI_PARSE_OBJECT *Op);
void
AnFormatBtype (
char *Buffer,
UINT32 Btype);
/*
* aslanalyze - Support functions for parse tree walks
*/
void
AnCheckId (
ACPI_PARSE_OBJECT *Op,
ACPI_NAME Type);
/* Values for Type argument above */
#define ASL_TYPE_HID 0
#define ASL_TYPE_CID 1
BOOLEAN
AnIsInternalMethod (
ACPI_PARSE_OBJECT *Op);
UINT32
AnGetInternalMethodReturnType (
ACPI_PARSE_OBJECT *Op);
BOOLEAN
AnLastStatementIsReturn (
ACPI_PARSE_OBJECT *Op);
void
AnCheckMethodReturnValue (
ACPI_PARSE_OBJECT *Op,
const ACPI_OPCODE_INFO *OpInfo,
ACPI_PARSE_OBJECT *ArgOp,
UINT32 RequiredBtypes,
UINT32 ThisNodeBtype);
BOOLEAN
AnIsResultUsed (
ACPI_PARSE_OBJECT *Op);
void
ApCheckForGpeNameConflict (
ACPI_PARSE_OBJECT *Op);
/*
* aslerror - error handling/reporting
*/
@ -487,6 +538,10 @@ TrCreateValuedLeafNode (
UINT32 ParseOpcode,
UINT64 Value);
ACPI_PARSE_OBJECT *
TrCreateConstantLeafNode (
UINT32 ParseOpcode);
ACPI_PARSE_OBJECT *
TrLinkChildren (
ACPI_PARSE_OBJECT *Op,

View File

@ -392,6 +392,9 @@ NamePathTail [.]{NameSeg}
"AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
"AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
"__DATE__" { count (0); return (PARSEOP___DATE__); }
"__FILE__" { count (0); return (PARSEOP___FILE__); }
"__LINE__" { count (0); return (PARSEOP___LINE__); }
"{" { count (0); return('{'); }
"}" { count (0); return('}'); }

View File

@ -392,6 +392,13 @@ AslLocalAllocate (unsigned int Size);
%token <i> PARSEOP_XOR
%token <i> PARSEOP_ZERO
/*
* Special functions. These should probably stay at the end of this
* table.
*/
%token <i> PARSEOP___DATE__
%token <i> PARSEOP___FILE__
%token <i> PARSEOP___LINE__
/*
* Production names
@ -695,7 +702,6 @@ AslLocalAllocate (unsigned int Size);
%type <n> OptionalReference
%type <n> OptionalAccessSize
%type <n> TermArgItem
%type <n> NameStringItem
@ -2317,6 +2323,9 @@ ConstExprTerm
: PARSEOP_ZERO {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);}
| PARSEOP_ONE {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);}
| PARSEOP_ONES {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);}
| PARSEOP___DATE__ {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);}
| PARSEOP___FILE__ {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);}
| PARSEOP___LINE__ {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);}
;
/* OptionalCount must appear before ByteList or an incorrect reduction will result */
@ -3070,7 +3079,6 @@ NameStringItem
| ',' error {$$ = AslDoError (); yyclearin;}
;
%%

View File

@ -188,6 +188,8 @@ typedef enum
ASL_MSG_HID_LENGTH,
ASL_MSG_NULL_STRING,
ASL_MSG_LEADING_ASTERISK,
ASL_MSG_RESERVED_NO_RETURN_VAL,
ASL_MSG_GPE_NAME_CONFLICT,
ASL_MSG_INVALID_FIELD_NAME,
ASL_MSG_INTEGER_SIZE,
@ -198,7 +200,10 @@ typedef enum
ASL_MSG_ZERO_VALUE,
ASL_MSG_UNKNOWN_TABLE,
ASL_MSG_UNKNOWN_SUBTABLE,
ASL_MSG_OEM_TABLE
ASL_MSG_OEM_TABLE,
ASL_MSG_UNKNOWN_LABEL,
ASL_MSG_INVALID_EXPRESSION,
ASL_MSG_DIVIDE_BY_ZERO
} ASL_MESSAGE_IDS;
@ -336,6 +341,8 @@ char *AslMessages [] = {
/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters",
/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string",
/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk",
/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value",
/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method",
/* These messages are used by the data table compiler only */
@ -348,7 +355,10 @@ char *AslMessages [] = {
/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero",
/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature",
/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type",
/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents"
/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents",
/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined",
/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression",
/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero"
};

View File

@ -54,6 +54,11 @@
/* Local prototypes */
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo);
static UINT32
ApCheckForSpecialName (
ACPI_PARSE_OBJECT *Op,
@ -236,6 +241,53 @@ ApCheckForPredefinedMethod (
}
/*******************************************************************************
*
* FUNCTION: ApCheckForUnexpectedReturnValue
*
* PARAMETERS: Op - A parse node of type "RETURN".
* MethodInfo - Saved info about this method
*
* RETURN: None
*
* DESCRIPTION: Check for an unexpected return value from a predefined method.
* Invoked for predefined methods that are defined to not return
* any value. If there is a return value, issue a remark, since
* the ASL writer may be confused as to the method definition
* and/or functionality.
*
* Note: We ignore all return values of "Zero", since this is what a standalone
* Return() statement will always generate -- so we ignore it here --
* i.e., there is no difference between Return() and Return(Zero).
* Also, a null Return() will be disassembled to return(Zero) -- so, we
* don't want to generate extraneous remarks/warnings for a disassembled
* ASL file.
*
******************************************************************************/
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
{
ACPI_PARSE_OBJECT *ReturnValueOp;
/* Ignore Return() and Return(Zero) (they are the same) */
ReturnValueOp = Op->Asl.Child;
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
{
return;
}
/* We have a valid return value, but the reserved name did not expect it */
AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
Op, MethodInfo->Op->Asl.ExternalName);
}
/*******************************************************************************
*
* FUNCTION: ApCheckPredefinedReturnValue
@ -249,7 +301,9 @@ ApCheckForPredefinedMethod (
* value. Only "static" types can be validated - a simple return
* of an integer/string/buffer/package or a named reference to
* a static object. Values such as a Localx or Argx or a control
* method invocation are not checked.
* method invocation are not checked. Issue a warning if there is
* a valid return value, but the reserved method defines no
* return value.
*
******************************************************************************/
@ -269,20 +323,27 @@ ApCheckPredefinedReturnValue (
switch (Index)
{
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/* Just return, nothing to do */
return;
default: /* A standard predefined ACPI name */
/* Exit if no return value expected */
if (!PredefinedNames[Index].Info.ExpectedBtypes)
{
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
}

View File

@ -45,6 +45,7 @@
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include "aslcompiler.y.h"
#include <time.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asltree")
@ -401,6 +402,75 @@ TrCreateLeafNode (
}
/*******************************************************************************
*
* FUNCTION: TrCreateConstantLeafNode
*
* PARAMETERS: ParseOpcode - The constant opcode
*
* RETURN: Pointer to the new node. Aborts on allocation failure
*
* DESCRIPTION: Create a leaf node (no children or peers) for one of the
* special constants - __LINE__, __FILE__, and __DATE__.
*
* Note: An implemenation of __FUNC__ cannot happen here because we don't
* have a full parse tree at this time and cannot find the parent control
* method. If it is ever needed, __FUNC__ must be implemented later, after
* the parse tree has been fully constructed.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateConstantLeafNode (
UINT32 ParseOpcode)
{
ACPI_PARSE_OBJECT *Op = NULL;
time_t CurrentTime;
char *StaticTimeString;
char *TimeString;
switch (ParseOpcode)
{
case PARSEOP___LINE__:
Op = TrAllocateNode (PARSEOP_INTEGER);
Op->Asl.Value.Integer = Op->Asl.LineNumber;
break;
case PARSEOP___FILE__:
Op = TrAllocateNode (PARSEOP_STRING_LITERAL);
/* Op.Asl.Filename contains the full pathname to the file */
Op->Asl.Value.String = Op->Asl.Filename;
break;
case PARSEOP___DATE__:
Op = TrAllocateNode (PARSEOP_STRING_LITERAL);
/* Get a copy of the current time */
CurrentTime = time (NULL);
StaticTimeString = ctime (&CurrentTime);
TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
strcpy (TimeString, StaticTimeString);
TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
Op->Asl.Value.String = TimeString;
break;
default: /* This would be an internal error */
return (NULL);
}
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateConstantLeafNode Ln/Col %u/%u NewNode %p Op %s Value %8.8X%8.8X ",
Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode),
ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateValuedLeafNode

File diff suppressed because it is too large Load Diff

View File

@ -426,7 +426,10 @@ DtCompileTable (
Length = DtGetSubtableLength (*Field, Info);
Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE));
Subtable->Buffer = UtLocalCalloc (Length);
if (Length > 0)
{
Subtable->Buffer = UtLocalCalloc (Length);
}
Subtable->Length = Length;
Subtable->TotalLength = Length;
Buffer = Subtable->Buffer;
@ -470,7 +473,12 @@ DtCompileTable (
}
}
/* Maintain table offsets */
LocalField->TableOffset = Gbl_CurrentTableOffset;
FieldLength = DtGetFieldLength (LocalField, Info);
Gbl_CurrentTableOffset += FieldLength;
FieldType = DtGetFieldType (Info);
Gbl_InputFieldCount++;
@ -537,6 +545,12 @@ DtCompileTable (
LocalField = *Field;
break;
case DT_FIELD_TYPE_LABEL:
DtWriteFieldToListing (Buffer, LocalField, 0);
LocalField = LocalField->Next;
break;
default:
/* Normal case for most field types (Integer, String, etc.) */

View File

@ -73,6 +73,7 @@
#define DT_FIELD_TYPE_UUID 7
#define DT_FIELD_TYPE_UNICODE 8
#define DT_FIELD_TYPE_DEVICE_PATH 9
#define DT_FIELD_TYPE_LABEL 10
/*
@ -80,13 +81,15 @@
*/
typedef struct dt_field
{
char *Name;
char *Value;
struct dt_field *Next;
char *Name; /* Field name (from name : value) */
char *Value; /* Field value (from name : value) */
struct dt_field *Next; /* Next field */
struct dt_field *NextLabel; /* If field is a label, next label */
UINT32 Line; /* Line number for this field */
UINT32 ByteOffset; /* Offset in source file for field */
UINT32 NameColumn; /* Start column for field name */
UINT32 Column; /* Start column for field value */
UINT32 TableOffset;/* Binary offset within ACPI table */
UINT8 Flags;
} DT_FIELD;
@ -131,6 +134,14 @@ DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_RootTable, NULL);
DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableStack, NULL);
/* List for defined labels */
DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL);
/* Current offset within the binary output table */
DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0);
/* dtcompiler - main module */
@ -207,6 +218,17 @@ DtGetParentSubtable (
DT_SUBTABLE *Subtable);
/* dtexpress - Integer expressions and labels */
UINT64
DtResolveIntegerExpression (
DT_FIELD *Field);
void
DtDetectAllLabels (
DT_FIELD *FieldList);
/* dtfield - Compile individual fields within a table */
void
@ -391,6 +413,10 @@ ACPI_STATUS
DtCompileXsdt (
void **PFieldList);
ACPI_DMTABLE_INFO *
DtGetGenericTableInfo (
char *Name);
/* ACPI Table templates */
extern const unsigned char TemplateAsf[];

View File

@ -0,0 +1,390 @@
/******************************************************************************
*
* Module Name: dtexpress.c - Support for integer expressions and labels
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define __DTEXPRESS_C__
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include <contrib/dev/acpica/compiler/dtcompiler.h>
#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtexpress")
/* Local prototypes */
static UINT64
DtResolveInteger (
DT_FIELD *Field,
char *IntegerString);
static void
DtInsertLabelField (
DT_FIELD *Field);
static DT_FIELD *
DtLookupLabel (
char *Name);
/******************************************************************************
*
* FUNCTION: DtResolveIntegerExpression
*
* PARAMETERS: Field - Field object with Integer expression
*
* RETURN: A 64-bit integer value
*
* DESCRIPTION: Resolve an integer expression to a single value. Supports
* both integer constants and labels. Supported operators are:
* +,-,*,/,%,|,&,^
*
*****************************************************************************/
UINT64
DtResolveIntegerExpression (
DT_FIELD *Field)
{
char *IntegerString;
char *Operator;
UINT64 Value;
UINT64 Value2;
DbgPrint (ASL_DEBUG_OUTPUT, "Full Integer expression: %s\n",
Field->Value);
strcpy (MsgBuffer, Field->Value); /* Must take a copy for strtok() */
/* Obtain and resolve the first operand */
IntegerString = strtok (MsgBuffer, " ");
if (!IntegerString)
{
DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
return (0);
}
Value = DtResolveInteger (Field, IntegerString);
DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V1: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (Value));
/*
* Consume the entire expression string. For the rest of the
* expression string, values are of the form:
* <operator> <integer>
*/
while (1)
{
Operator = strtok (NULL, " ");
if (!Operator)
{
/* Normal exit */
DbgPrint (ASL_DEBUG_OUTPUT, "Expression Resolved to: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (Value));
return (Value);
}
IntegerString = strtok (NULL, " ");
if (!IntegerString ||
(strlen (Operator) > 1))
{
/* No corresponding operand for operator or invalid operator */
DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
return (0);
}
Value2 = DtResolveInteger (Field, IntegerString);
DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V2: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (Value2));
/* Perform the requested operation */
switch (*Operator)
{
case '-':
Value -= Value2;
break;
case '+':
Value += Value2;
break;
case '*':
Value *= Value2;
break;
case '|':
Value |= Value2;
break;
case '&':
Value &= Value2;
break;
case '^':
Value ^= Value2;
break;
case '/':
if (!Value2)
{
DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value);
return (0);
}
Value /= Value2;
break;
case '%':
if (!Value2)
{
DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value);
return (0);
}
Value %= Value2;
break;
default:
/* Unknown operator */
DtFatal (ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
break;
}
}
return (Value);
}
/******************************************************************************
*
* FUNCTION: DtResolveInteger
*
* PARAMETERS: Field - Field object with string to be resolved
* IntegerString - Integer to be resolved
*
* RETURN: A 64-bit integer value
*
* DESCRIPTION: Resolve a single integer string to a value. Supports both
* integer constants and labels.
*
* NOTE: References to labels must begin with a dollar sign ($)
*
*****************************************************************************/
static UINT64
DtResolveInteger (
DT_FIELD *Field,
char *IntegerString)
{
DT_FIELD *LabelField;
UINT64 Value = 0;
char *Message = NULL;
ACPI_STATUS Status;
DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Integer: %s\n", IntegerString);
/* Resolve a label reference to an integer (table offset) */
if (*IntegerString == '$')
{
LabelField = DtLookupLabel (IntegerString);
if (!LabelField)
{
DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL, Field, IntegerString);
return (0);
}
/* All we need from the label is the offset in the table */
Value = LabelField->TableOffset;
return (Value);
}
/* Convert string to an actual integer */
Status = DtStrtoul64 (IntegerString, &Value);
if (ACPI_FAILURE (Status))
{
if (Status == AE_LIMIT)
{
Message = "Constant larger than 64 bits";
}
else if (Status == AE_BAD_CHARACTER)
{
Message = "Invalid character in constant";
}
DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, Message);
}
return (Value);
}
/******************************************************************************
*
* FUNCTION: DtDetectAllLabels
*
* PARAMETERS: FieldList - Field object at start of generic list
*
* RETURN: None
*
* DESCRIPTION: Detect all labels in a list of "generic" opcodes (such as
* a UEFI table.) and insert them into the global label list.
*
*****************************************************************************/
void
DtDetectAllLabels (
DT_FIELD *FieldList)
{
ACPI_DMTABLE_INFO *Info;
DT_FIELD *GenericField;
UINT32 TableOffset;
TableOffset = Gbl_CurrentTableOffset;
GenericField = FieldList;
/*
* Process all "Label:" fields within the parse tree. We need
* to know the offsets for all labels before we can compile
* the parse tree in order to handle forward references. Traverse
* tree and get/set all field lengths of all operators in order to
* determine the label offsets.
*/
while (GenericField)
{
Info = DtGetGenericTableInfo (GenericField->Name);
if (Info)
{
/* Maintain table offsets */
GenericField->TableOffset = TableOffset;
TableOffset += DtGetFieldLength (GenericField, Info);
/* Insert all labels in the global label list */
if (Info->Opcode == ACPI_DMT_LABEL)
{
DtInsertLabelField (GenericField);
}
}
GenericField = GenericField->Next;
}
}
/******************************************************************************
*
* FUNCTION: DtInsertLabelField
*
* PARAMETERS: Field - Field object with Label to be inserted
*
* RETURN: None
*
* DESCRIPTION: Insert a label field into the global label list
*
*****************************************************************************/
static void
DtInsertLabelField (
DT_FIELD *Field)
{
DbgPrint (ASL_DEBUG_OUTPUT,
"DtInsertLabelField: Found Label : %s at output table offset %X\n",
Field->Value, Field->TableOffset);
Field->NextLabel = Gbl_LabelList;
Gbl_LabelList = Field;
}
/******************************************************************************
*
* FUNCTION: DtLookupLabel
*
* PARAMETERS: Name - Label to be resolved
*
* RETURN: Field object associated with the label
*
* DESCRIPTION: Lookup a label in the global label list. Used during the
* resolution of integer expressions.
*
*****************************************************************************/
static DT_FIELD *
DtLookupLabel (
char *Name)
{
DT_FIELD *LabelField;
/* Skip a leading $ */
if (*Name == '$')
{
Name++;
}
/* Search global list */
LabelField = Gbl_LabelList;
while (LabelField)
{
if (!ACPI_STRCMP (Name, LabelField->Value))
{
return (LabelField);
}
LabelField = LabelField->NextLabel;
}
return (NULL);
}

View File

@ -266,10 +266,12 @@ DtCompileUuid (
* PARAMETERS: Buffer - Output buffer
* Field - Field obj with Integer to be compiled
* ByteLength - Byte length of the integer
* Flags - Additional compile info
*
* RETURN: None
*
* DESCRIPTION: Compile an integer
* DESCRIPTION: Compile an integer. Supports integer expressions with C-style
* operators.
*
*****************************************************************************/
@ -280,15 +282,11 @@ DtCompileInteger (
UINT32 ByteLength,
UINT8 Flags)
{
UINT64 Value = 0;
UINT64 Value;
UINT64 MaxValue;
UINT8 *Hex;
char *Message = NULL;
ACPI_STATUS Status;
int i;
/* Byte length must be in range 1-8 */
/* Output buffer byte length must be in range 1-8 */
if ((ByteLength > 8) || (ByteLength == 0))
{
@ -297,23 +295,9 @@ DtCompileInteger (
return;
}
/* Convert string to an actual integer */
/* Resolve integer expression to a single integer value */
Status = DtStrtoul64 (Field->Value, &Value);
if (ACPI_FAILURE (Status))
{
if (Status == AE_LIMIT)
{
Message = "Constant larger than 64 bits";
}
else if (Status == AE_BAD_CHARACTER)
{
Message = "Invalid character in constant";
}
DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, Message);
goto Exit;
}
Value = DtResolveIntegerExpression (Field);
/* Ensure that reserved fields are set to zero */
/* TBD: should we set to zero, or just make this an ERROR? */
@ -344,29 +328,10 @@ DtCompileInteger (
if (Value > MaxValue)
{
sprintf (MsgBuffer, "Maximum %u bytes", ByteLength);
sprintf (MsgBuffer, "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Value));
DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer);
}
/*
* TBD: hard code for ASF! Capabilites field.
*
* This field is actually a buffer, not a 56-bit integer --
* so, the ordering is reversed. Something should be fixed
* so we don't need this code.
*/
if (ByteLength == 7)
{
Hex = ACPI_CAST_PTR (UINT8, &Value);
for (i = 6; i >= 0; i--)
{
Buffer[i] = *Hex;
Hex++;
}
return;
}
Exit:
ACPI_MEMCPY (Buffer, &Value, ByteLength);
return;
}

View File

@ -66,7 +66,7 @@ DtParseLine (
UINT32 Line,
UINT32 Offset);
static UINT32
UINT32
DtGetNextLine (
FILE *Handle);
@ -80,8 +80,10 @@ static void
DtDumpBuffer (
UINT32 FileId,
UINT8 *Buffer,
UINT32 Offset,
UINT32 Length);
/* States for DtGetNextLine */
#define DT_NORMAL_TEXT 0
@ -324,7 +326,7 @@ DtParseLine (
if (*End == '"')
{
End++;
while (*End && *End != '"')
while (*End && (*End != '"'))
{
End++;
}
@ -333,9 +335,16 @@ DtParseLine (
break;
}
/*
* Special "comment" fields at line end, ignore them.
* Note: normal slash-slash and slash-asterisk comments are
* stripped already by the DtGetNextLine parser.
*
* TBD: Perhaps DtGetNextLine should parse the following type
* of comments also.
*/
if (*End == '(' ||
*End == '<' ||
*End == '/')
*End == '<')
{
break;
}
@ -385,7 +394,7 @@ DtParseLine (
*
*****************************************************************************/
static UINT32
UINT32
DtGetNextLine (
FILE *Handle)
{
@ -400,6 +409,19 @@ DtGetNextLine (
c = (char) getc (Handle);
if (c == EOF)
{
switch (State)
{
case DT_START_QUOTED_STRING:
case DT_SLASH_ASTERISK_COMMENT:
case DT_SLASH_SLASH_COMMENT:
AcpiOsPrintf ("**** EOF within comment/string %u\n", State);
break;
default:
break;
}
return (0);
}
@ -520,6 +542,16 @@ DtGetNextLine (
State = DT_NORMAL_TEXT;
break;
case '\n':
CurrentLineOffset = Gbl_NextLineOffset;
Gbl_NextLineOffset = (UINT32) ftell (Handle);
Gbl_CurrentLineNumber++;
break;
case '*':
/* Consume all adjacent asterisks */
break;
default:
State = DT_SLASH_ASTERISK_COMMENT;
break;
@ -653,6 +685,7 @@ DtOutputBinary (
*
* PARAMETERS: FileID - Where to write buffer data
* Buffer - Buffer to dump
* Offset - Offset in current table
* Length - Buffer Length
*
* RETURN: None
@ -667,6 +700,7 @@ static void
DtDumpBuffer (
UINT32 FileId,
UINT8 *Buffer,
UINT32 Offset,
UINT32 Length)
{
UINT32 i;
@ -674,12 +708,18 @@ DtDumpBuffer (
UINT8 BufChar;
FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ",
Offset, Offset, Length);
i = 0;
while (i < Length)
{
/* Print 16 hex chars */
if (i >= 16)
{
FlPrintFile (FileId, "%23s", "");
}
FlPrintFile (FileId, "Output: [%.3d] ", Length);
/* Print 16 hex chars */
for (j = 0; j < 16;)
{
@ -773,17 +813,9 @@ DtWriteFieldToListing (
FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n",
Field->Column-4, Field->Name, Field->Value);
#if 0
/* TBD Dump the length and AML offset */
FlPrintFile (ASL_FILE_LISTING_OUTPUT,
"Output: Length %d(0x%X) Offset %d(0x%X)\n",
Field->Column-4, Field->Name, Field->Value);
#endif
/* Dump the hex data that will be output for this field */
DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Length);
DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
}

View File

@ -1278,7 +1278,7 @@ DtCompileSrat (
/******************************************************************************
*
* FUNCTION: DtTableInfoGeneric
* FUNCTION: DtGetGenericTableInfo
*
* PARAMETERS: Name - Generic type name
*
@ -1288,8 +1288,8 @@ DtCompileSrat (
*
*****************************************************************************/
static ACPI_DMTABLE_INFO *
DtTableInfoGeneric (
ACPI_DMTABLE_INFO *
DtGetGenericTableInfo (
char *Name)
{
ACPI_DMTABLE_INFO *Info;
@ -1346,6 +1346,8 @@ DtCompileUefi (
UINT16 *DataOffset;
/* Compile the predefined portion of the UEFI table */
Status = DtCompileTable (PFieldList, AcpiDmTableInfoUefi,
&Subtable, TRUE);
if (ACPI_FAILURE (Status))
@ -1359,9 +1361,21 @@ DtCompileUefi (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
/*
* Compile the "generic" portion of the UEFI table. This
* part of the table is not predefined and any of the generic
* operators may be used.
*/
/* Find any and all labels in the entire generic portion */
DtDetectAllLabels (*PFieldList);
/* Now we can actually compile the parse tree */
while (*PFieldList)
{
Info = DtTableInfoGeneric ((*PFieldList)->Name);
Info = DtGetGenericTableInfo ((*PFieldList)->Name);
if (!Info)
{
sprintf (MsgBuffer, "Generic data type \"%s\" not found",

View File

@ -399,6 +399,7 @@ DtGetFieldType (
break;
case ACPI_DMT_BUFFER:
case ACPI_DMT_BUF7:
case ACPI_DMT_BUF16:
case ACPI_DMT_PCI_PATH:
Type = DT_FIELD_TYPE_BUFFER;
@ -421,6 +422,10 @@ DtGetFieldType (
Type = DT_FIELD_TYPE_DEVICE_PATH;
break;
case ACPI_DMT_LABEL:
Type = DT_FIELD_TYPE_LABEL;
break;
default:
Type = DT_FIELD_TYPE_INTEGER;
break;
@ -507,6 +512,7 @@ DtGetFieldLength (
case ACPI_DMT_FLAG7:
case ACPI_DMT_FLAGS0:
case ACPI_DMT_FLAGS2:
case ACPI_DMT_LABEL:
ByteLength = 0;
break;
@ -549,6 +555,7 @@ DtGetFieldLength (
break;
case ACPI_DMT_UINT56:
case ACPI_DMT_BUF7:
ByteLength = 7;
break;

File diff suppressed because it is too large Load Diff

View File

@ -887,5 +887,140 @@ AcpiDbDisplayGpes (
}
}
#endif /* ACPI_DEBUGGER */
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayHandlers
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display the currently installed global handlers
*
******************************************************************************/
#define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
#define ACPI_HANDLER_NAME_STRING "%30s : "
#define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
#define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
/* All predefined Space IDs */
static ACPI_ADR_SPACE_TYPE SpaceIdList[] =
{
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_ADR_SPACE_EC,
ACPI_ADR_SPACE_SMBUS,
ACPI_ADR_SPACE_CMOS,
ACPI_ADR_SPACE_PCI_BAR_TARGET,
ACPI_ADR_SPACE_IPMI,
ACPI_ADR_SPACE_DATA_TABLE,
ACPI_ADR_SPACE_FIXED_HARDWARE
};
/* Global handler information */
typedef struct acpi_handler_info
{
void *Handler;
char *Name;
} ACPI_HANDLER_INFO;
ACPI_HANDLER_INFO HandlerList[] =
{
{&AcpiGbl_SystemNotify.Handler, "System Notifications"},
{&AcpiGbl_DeviceNotify.Handler, "Device Notifications"},
{&AcpiGbl_TableHandler, "ACPI Table Events"},
{&AcpiGbl_ExceptionHandler, "Control Method Exceptions"},
{&AcpiGbl_InterfaceHandler, "OSI Invocations"}
};
void
AcpiDbDisplayHandlers (
void)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *HandlerObj;
ACPI_ADR_SPACE_TYPE SpaceId;
UINT32 i;
/* Operation region handlers */
AcpiOsPrintf ("\nOperation Region Handlers:\n");
ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
if (ObjDesc)
{
for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++)
{
SpaceId = SpaceIdList[i];
HandlerObj = ObjDesc->Device.Handler;
AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
while (HandlerObj)
{
if (i == HandlerObj->AddressSpace.SpaceId)
{
AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
(HandlerObj->AddressSpace.HandlerFlags &
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
HandlerObj->AddressSpace.Handler);
goto FoundHandler;
}
HandlerObj = HandlerObj->AddressSpace.Next;
}
/* There is no handler for this SpaceId */
AcpiOsPrintf ("None\n");
FoundHandler:;
}
}
/* Fixed event handlers */
AcpiOsPrintf ("\nFixed Event Handlers:\n");
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
{
AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
if (AcpiGbl_FixedEventHandlers[i].Handler)
{
AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
AcpiGbl_FixedEventHandlers[i].Handler);
}
else
{
AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
}
}
/* Miscellaneous global handlers */
AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
for (i = 0; i < ACPI_ARRAY_LENGTH (HandlerList); i++)
{
AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, HandlerList[i].Name);
if (HandlerList[i].Handler)
{
AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
HandlerList[i].Handler);
}
else
{
AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
}
}
}
#endif /* ACPI_DEBUGGER */

View File

@ -73,7 +73,7 @@ AcpiDbSingleThread (
static void
AcpiDbDisplayHelp (
char *HelpType);
void);
/*
@ -104,6 +104,7 @@ enum AcpiExDebuggerCommands
CMD_GO,
CMD_GPE,
CMD_GPES,
CMD_HANDLERS,
CMD_HELP,
CMD_HELP2,
CMD_HISTORY,
@ -171,6 +172,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] =
{"GO", 0},
{"GPE", 2},
{"GPES", 0},
{"HANDLERS", 0},
{"HELP", 0},
{"?", 0},
{"HISTORY", 0},
@ -216,7 +218,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] =
*
* FUNCTION: AcpiDbDisplayHelp
*
* PARAMETERS: HelpType - Subcommand (optional)
* PARAMETERS: None
*
* RETURN: None
*
@ -226,120 +228,80 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] =
static void
AcpiDbDisplayHelp (
char *HelpType)
void)
{
AcpiUtStrupr (HelpType);
AcpiOsPrintf ("\nGeneral-Purpose Commands:\n");
AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
AcpiOsPrintf (" Dump <Address>|<Namepath>\n");
AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
AcpiOsPrintf (" EnableAcpi Enable ACPI (hardware) mode\n");
AcpiOsPrintf (" Handlers Info about global handlers\n");
AcpiOsPrintf (" Help This help screen\n");
AcpiOsPrintf (" History Display command history buffer\n");
AcpiOsPrintf (" Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
AcpiOsPrintf (" Locks Current status of internal mutexes\n");
AcpiOsPrintf (" Osi [Install|Remove <name>] Display or modify global _OSI list\n");
AcpiOsPrintf (" Quit or Exit Exit this command\n");
AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n");
AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
AcpiOsPrintf (" Memory Dump internal memory lists\n");
AcpiOsPrintf (" Misc Namespace search and mutex stats\n");
AcpiOsPrintf (" Objects Summary of namespace objects\n");
AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n");
AcpiOsPrintf (" Stack Display CPU stack usage\n");
AcpiOsPrintf (" Tables Info about current ACPI table(s)\n");
AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n");
AcpiOsPrintf (" Unload <TableSig> [Instance] Unload an ACPI table\n");
AcpiOsPrintf (" ! <CommandNumber> Execute command from history buffer\n");
AcpiOsPrintf (" !! Execute last command again\n");
/* No parameter, just give the overview */
AcpiOsPrintf ("\nNamespace Access Commands:\n");
AcpiOsPrintf (" Businfo Display system bus info\n");
AcpiOsPrintf (" Disassemble <Method> Disassemble a control method\n");
AcpiOsPrintf (" Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
AcpiOsPrintf (" Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
AcpiOsPrintf (" Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
AcpiOsPrintf (" Gpes Display info on all GPEs\n");
AcpiOsPrintf (" Integrity Validate namespace integrity\n");
AcpiOsPrintf (" Methods Display list of loaded control methods\n");
AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
AcpiOsPrintf (" Notify <Object> <Value> Send a notification on Object\n");
AcpiOsPrintf (" Objects <ObjectType> Display all objects of the given type\n");
AcpiOsPrintf (" Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
AcpiOsPrintf (" Predefined Check all predefined names\n");
AcpiOsPrintf (" Prefix [<NamePath>] Set or Get current execution prefix\n");
AcpiOsPrintf (" References <Addr> Find all references to object at addr\n");
AcpiOsPrintf (" Resources <Device> Get and display Device resources\n");
AcpiOsPrintf (" Set N <NamedObject> <Value> Set value for named integer\n");
AcpiOsPrintf (" Sleep <SleepState> Simulate sleep/wake sequence\n");
AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n");
AcpiOsPrintf (" Type <Object> Display object type\n");
if (!HelpType)
{
AcpiOsPrintf ("ACPI CA Debugger Commands\n\n");
AcpiOsPrintf ("The following classes of commands are available. Help is available for\n");
AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n");
AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n");
AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n");
AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n");
AcpiOsPrintf (" [STATISTICS] Statistical Information\n");
AcpiOsPrintf (" [FILE] File I/O Commands\n");
return;
}
AcpiOsPrintf ("\nControl Method Execution Commands:\n");
AcpiOsPrintf (" Arguments (or Args) Display method arguments\n");
AcpiOsPrintf (" Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
AcpiOsPrintf (" Call Run to next control method invocation\n");
AcpiOsPrintf (" Debug <Namepath> [Arguments] Single Step a control method\n");
AcpiOsPrintf (" Execute <Namepath> [Arguments] Execute control method\n");
AcpiOsPrintf (" Go Allow method to run to completion\n");
AcpiOsPrintf (" Information Display info about the current method\n");
AcpiOsPrintf (" Into Step into (not over) a method call\n");
AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n");
AcpiOsPrintf (" Locals Display method local variables\n");
AcpiOsPrintf (" Results Display method result stack\n");
AcpiOsPrintf (" Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
AcpiOsPrintf (" Stop Terminate control method\n");
AcpiOsPrintf (" Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
AcpiOsPrintf (" Trace <method name> Trace method execution\n");
AcpiOsPrintf (" Tree Display control method calling tree\n");
AcpiOsPrintf (" <Enter> Single step next AML opcode (over calls)\n");
/*
* Parameter is the command class
*
* The idea here is to keep each class of commands smaller than a screenful
*/
switch (HelpType[0])
{
case 'G':
AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n");
AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
AcpiOsPrintf ("Dump <Address>|<Namepath>\n");
AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n");
AcpiOsPrintf ("Help This help screen\n");
AcpiOsPrintf ("History Display command history buffer\n");
AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
AcpiOsPrintf ("Locks Current status of internal mutexes\n");
AcpiOsPrintf ("Osi [Install|Remove <name>] Display or modify global _OSI list\n");
AcpiOsPrintf ("Quit or Exit Exit this command\n");
AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n");
AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n");
AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n");
AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n");
AcpiOsPrintf ("!! Execute last command again\n");
return;
case 'S':
AcpiOsPrintf ("\nStats Subcommands\n\n");
AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
AcpiOsPrintf ("Memory Dump internal memory lists\n");
AcpiOsPrintf ("Misc Namespace search and mutex stats\n");
AcpiOsPrintf ("Objects Summary of namespace objects\n");
AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n");
AcpiOsPrintf ("Stack Display CPU stack usage\n");
AcpiOsPrintf ("Tables Info about current ACPI table(s)\n");
return;
case 'N':
AcpiOsPrintf ("\nNamespace Access Commands\n\n");
AcpiOsPrintf ("Businfo Display system bus info\n");
AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n");
AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
AcpiOsPrintf ("Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
AcpiOsPrintf ("Gpes Display info on all GPEs\n");
AcpiOsPrintf ("Integrity Validate namespace integrity\n");
AcpiOsPrintf ("Methods Display list of loaded control methods\n");
AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
AcpiOsPrintf ("Notify <Object> <Value> Send a notification on Object\n");
AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n");
AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
AcpiOsPrintf ("Predefined Check all predefined names\n");
AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n");
AcpiOsPrintf ("References <Addr> Find all references to object at addr\n");
AcpiOsPrintf ("Resources <Device> Get and display Device resources\n");
AcpiOsPrintf ("Set N <NamedObject> <Value> Set value for named integer\n");
AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n");
AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n");
AcpiOsPrintf ("Type <Object> Display object type\n");
return;
case 'M':
AcpiOsPrintf ("\nControl Method Execution Commands\n\n");
AcpiOsPrintf ("Arguments (or Args) Display method arguments\n");
AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
AcpiOsPrintf ("Call Run to next control method invocation\n");
AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n");
AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n");
AcpiOsPrintf ("Go Allow method to run to completion\n");
AcpiOsPrintf ("Information Display info about the current method\n");
AcpiOsPrintf ("Into Step into (not over) a method call\n");
AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n");
AcpiOsPrintf ("Locals Display method local variables\n");
AcpiOsPrintf ("Results Display method result stack\n");
AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
AcpiOsPrintf ("Stop Terminate control method\n");
AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
AcpiOsPrintf ("Trace <method name> Trace method execution\n");
AcpiOsPrintf ("Tree Display control method calling tree\n");
AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n");
return;
case 'F':
AcpiOsPrintf ("\nFile I/O Commands\n\n");
AcpiOsPrintf ("Close Close debug output file\n");
AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n");
AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n");
return;
default:
AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType);
return;
}
AcpiOsPrintf ("\nFile I/O Commands:\n");
AcpiOsPrintf (" Close Close debug output file\n");
AcpiOsPrintf (" Load <Input Filename> Load ACPI table from a file\n");
AcpiOsPrintf (" Open <Output Filename> Open a file for debug output\n");
}
@ -658,9 +620,13 @@ AcpiDbCommandDispatch (
AcpiDbDisplayGpes ();
break;
case CMD_HANDLERS:
AcpiDbDisplayHandlers ();
break;
case CMD_HELP:
case CMD_HELP2:
AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
AcpiDbDisplayHelp ();
break;
case CMD_HISTORY:

View File

@ -0,0 +1,529 @@
/*******************************************************************************
*
* Module Name: dbmethod - Debug commands for control methods
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acdispat.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acdebug.h>
#include <contrib/dev/acpica/include/acdisasm.h>
#include <contrib/dev/acpica/include/acparser.h>
#ifdef ACPI_DEBUGGER
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME ("dbmethod")
/* Local prototypes */
static ACPI_STATUS
AcpiDbWalkForExecute (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
/*******************************************************************************
*
* FUNCTION: AcpiDbSetMethodBreakpoint
*
* PARAMETERS: Location - AML offset of breakpoint
* WalkState - Current walk info
* Op - Current Op (from parse walk)
*
* RETURN: None
*
* DESCRIPTION: Set a breakpoint in a control method at the specified
* AML offset
*
******************************************************************************/
void
AcpiDbSetMethodBreakpoint (
char *Location,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
UINT32 Address;
if (!Op)
{
AcpiOsPrintf ("There is no method currently executing\n");
return;
}
/* Get and verify the breakpoint address */
Address = ACPI_STRTOUL (Location, NULL, 16);
if (Address <= Op->Common.AmlOffset)
{
AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
Address, Op->Common.AmlOffset);
}
/* Save breakpoint in current walk */
WalkState->UserBreakpoint = Address;
AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSetMethodCallBreakpoint
*
* PARAMETERS: Op - Current Op (from parse walk)
*
* RETURN: None
*
* DESCRIPTION: Set a breakpoint in a control method at the specified
* AML offset
*
******************************************************************************/
void
AcpiDbSetMethodCallBreakpoint (
ACPI_PARSE_OBJECT *Op)
{
if (!Op)
{
AcpiOsPrintf ("There is no method currently executing\n");
return;
}
AcpiGbl_StepToNextCall = TRUE;
}
/*******************************************************************************
*
* FUNCTION: AcpiDbSetMethodData
*
* PARAMETERS: TypeArg - L for local, A for argument
* IndexArg - which one
* ValueArg - Value to set.
*
* RETURN: None
*
* DESCRIPTION: Set a local or argument for the running control method.
* NOTE: only object supported is Number.
*
******************************************************************************/
void
AcpiDbSetMethodData (
char *TypeArg,
char *IndexArg,
char *ValueArg)
{
char Type;
UINT32 Index;
UINT32 Value;
ACPI_WALK_STATE *WalkState;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
/* Validate TypeArg */
AcpiUtStrupr (TypeArg);
Type = TypeArg[0];
if ((Type != 'L') &&
(Type != 'A') &&
(Type != 'N'))
{
AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
return;
}
Value = ACPI_STRTOUL (ValueArg, NULL, 16);
if (Type == 'N')
{
Node = AcpiDbConvertToNode (IndexArg);
if (Node->Type != ACPI_TYPE_INTEGER)
{
AcpiOsPrintf ("Can only set Integer nodes\n");
return;
}
ObjDesc = Node->Object;
ObjDesc->Integer.Value = Value;
return;
}
/* Get the index and value */
Index = ACPI_STRTOUL (IndexArg, NULL, 16);
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
if (!WalkState)
{
AcpiOsPrintf ("There is no method currently executing\n");
return;
}
/* Create and initialize the new object */
ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
if (!ObjDesc)
{
AcpiOsPrintf ("Could not create an internal object\n");
return;
}
/* Store the new object into the target */
switch (Type)
{
case 'A':
/* Set a method argument */
if (Index > ACPI_METHOD_MAX_ARG)
{
AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index);
goto Cleanup;
}
Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
ObjDesc = WalkState->Arguments[Index].Object;
AcpiOsPrintf ("Arg%u: ", Index);
AcpiDmDisplayInternalObject (ObjDesc, WalkState);
break;
case 'L':
/* Set a method local */
if (Index > ACPI_METHOD_MAX_LOCAL)
{
AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index);
goto Cleanup;
}
Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
ObjDesc = WalkState->LocalVariables[Index].Object;
AcpiOsPrintf ("Local%u: ", Index);
AcpiDmDisplayInternalObject (ObjDesc, WalkState);
break;
default:
break;
}
Cleanup:
AcpiUtRemoveReference (ObjDesc);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisassembleAml
*
* PARAMETERS: Statements - Number of statements to disassemble
* Op - Current Op (from parse walk)
*
* RETURN: None
*
* DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
* of statements specified.
*
******************************************************************************/
void
AcpiDbDisassembleAml (
char *Statements,
ACPI_PARSE_OBJECT *Op)
{
UINT32 NumStatements = 8;
if (!Op)
{
AcpiOsPrintf ("There is no method currently executing\n");
return;
}
if (Statements)
{
NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
}
#ifdef ACPI_DISASSEMBLER
AcpiDmDisassemble (NULL, Op, NumStatements);
#endif
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisassembleMethod
*
* PARAMETERS: Name - Name of control method
*
* RETURN: None
*
* DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
* of statements specified.
*
******************************************************************************/
ACPI_STATUS
AcpiDbDisassembleMethod (
char *Name)
{
ACPI_STATUS Status;
ACPI_PARSE_OBJECT *Op;
ACPI_WALK_STATE *WalkState;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_NAMESPACE_NODE *Method;
Method = AcpiDbConvertToNode (Name);
if (!Method)
{
return (AE_BAD_PARAMETER);
}
ObjDesc = Method->Object;
Op = AcpiPsCreateScopeOp ();
if (!Op)
{
return (AE_NO_MEMORY);
}
/* Create and initialize a new walk state */
WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
if (!WalkState)
{
return (AE_NO_MEMORY);
}
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
ObjDesc->Method.AmlStart,
ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Parse the AML */
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
Status = AcpiPsParseAml (WalkState);
#ifdef ACPI_DISASSEMBLER
AcpiDmDisassemble (NULL, Op, 0);
#endif
AcpiPsDeleteParseTree (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForExecute
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Batch execution module. Currently only executes predefined
* ACPI names.
*
******************************************************************************/
static ACPI_STATUS
AcpiDbWalkForExecute (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context;
ACPI_BUFFER ReturnObj;
ACPI_STATUS Status;
char *Pathname;
UINT32 i;
ACPI_DEVICE_INFO *ObjInfo;
ACPI_OBJECT_LIST ParamObjects;
ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
const ACPI_PREDEFINED_INFO *Predefined;
Predefined = AcpiNsCheckForPredefinedName (Node);
if (!Predefined)
{
return (AE_OK);
}
if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
{
return (AE_OK);
}
Pathname = AcpiNsGetExternalPathname (Node);
if (!Pathname)
{
return (AE_OK);
}
/* Get the object info for number of method parameters */
Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
if (ACPI_FAILURE (Status))
{
return (Status);
}
ParamObjects.Pointer = NULL;
ParamObjects.Count = 0;
if (ObjInfo->Type == ACPI_TYPE_METHOD)
{
/* Setup default parameters */
for (i = 0; i < ObjInfo->ParamCount; i++)
{
Params[i].Type = ACPI_TYPE_INTEGER;
Params[i].Integer.Value = 1;
}
ParamObjects.Pointer = Params;
ParamObjects.Count = ObjInfo->ParamCount;
}
ACPI_FREE (ObjInfo);
ReturnObj.Pointer = NULL;
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
/* Do the actual method execution */
AcpiGbl_MethodExecuting = TRUE;
Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
AcpiGbl_MethodExecuting = FALSE;
ACPI_FREE (Pathname);
/* Ignore status from method execution */
Status = AE_OK;
/* Update count, check if we have executed enough methods */
Info->Count++;
if (Info->Count >= Info->MaxCount)
{
Status = AE_CTRL_TERMINATE;
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbBatchExecute
*
* PARAMETERS: CountArg - Max number of methods to execute
*
* RETURN: None
*
* DESCRIPTION: Namespace batch execution. Execute predefined names in the
* namespace, up to the max count, if specified.
*
******************************************************************************/
void
AcpiDbBatchExecute (
char *CountArg)
{
ACPI_EXECUTE_WALK Info;
Info.Count = 0;
Info.MaxCount = ACPI_UINT32_MAX;
if (CountArg)
{
Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
}
/* Search all nodes in namespace */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count);
}
#endif /* ACPI_DEBUGGER */

View File

@ -0,0 +1,934 @@
/*******************************************************************************
*
* Module Name: dbnames - Debugger commands for the acpi namespace
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acdebug.h>
#ifdef ACPI_DEBUGGER
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME ("dbnames")
/* Local prototypes */
static ACPI_STATUS
AcpiDbWalkAndMatchName (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static ACPI_STATUS
AcpiDbWalkForPredefinedNames (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static ACPI_STATUS
AcpiDbWalkForSpecificObjects (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static ACPI_STATUS
AcpiDbIntegrityWalk (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static ACPI_STATUS
AcpiDbWalkForReferences (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static ACPI_STATUS
AcpiDbBusWalk (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
/*
* Arguments for the Objects command
* These object types map directly to the ACPI_TYPES
*/
static ARGUMENT_INFO AcpiDbObjectTypes [] =
{
{"ANY"},
{"INTEGERS"},
{"STRINGS"},
{"BUFFERS"},
{"PACKAGES"},
{"FIELDS"},
{"DEVICES"},
{"EVENTS"},
{"METHODS"},
{"MUTEXES"},
{"REGIONS"},
{"POWERRESOURCES"},
{"PROCESSORS"},
{"THERMALZONES"},
{"BUFFERFIELDS"},
{"DDBHANDLES"},
{"DEBUG"},
{"REGIONFIELDS"},
{"BANKFIELDS"},
{"INDEXFIELDS"},
{"REFERENCES"},
{"ALIAS"},
{NULL} /* Must be null terminated */
};
/*******************************************************************************
*
* FUNCTION: AcpiDbSetScope
*
* PARAMETERS: Name - New scope path
*
* RETURN: Status
*
* DESCRIPTION: Set the "current scope" as maintained by this utility.
* The scope is used as a prefix to ACPI paths.
*
******************************************************************************/
void
AcpiDbSetScope (
char *Name)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
if (!Name || Name[0] == 0)
{
AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
return;
}
AcpiDbPrepNamestring (Name);
if (Name[0] == '\\')
{
/* Validate new scope from the root */
Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
&Node);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
}
else
{
/* Validate new scope relative to old scope */
Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
&Node);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
}
AcpiGbl_DbScopeNode = Node;
AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
return;
ErrorExit:
AcpiOsPrintf ("Could not attach scope: %s, %s\n",
Name, AcpiFormatException (Status));
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDumpNamespace
*
* PARAMETERS: StartArg - Node to begin namespace dump
* DepthArg - Maximum tree depth to be dumped
*
* RETURN: None
*
* DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
* with type and other information.
*
******************************************************************************/
void
AcpiDbDumpNamespace (
char *StartArg,
char *DepthArg)
{
ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
UINT32 MaxDepth = ACPI_UINT32_MAX;
/* No argument given, just start at the root and dump entire namespace */
if (StartArg)
{
SubtreeEntry = AcpiDbConvertToNode (StartArg);
if (!SubtreeEntry)
{
return;
}
/* Now we can check for the depth argument */
if (DepthArg)
{
MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
}
}
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
/* Display the subtree */
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
ACPI_OWNER_ID_MAX, SubtreeEntry);
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDumpNamespaceByOwner
*
* PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
* DepthArg - Maximum tree depth to be dumped
*
* RETURN: None
*
* DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
*
******************************************************************************/
void
AcpiDbDumpNamespaceByOwner (
char *OwnerArg,
char *DepthArg)
{
ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
UINT32 MaxDepth = ACPI_UINT32_MAX;
ACPI_OWNER_ID OwnerId;
OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
/* Now we can check for the depth argument */
if (DepthArg)
{
MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
}
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
/* Display the subtree */
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
SubtreeEntry);
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbWalkAndMatchName
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Find a particular name/names within the namespace. Wildcards
* are supported -- '?' matches any character.
*
******************************************************************************/
static ACPI_STATUS
AcpiDbWalkAndMatchName (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_STATUS Status;
char *RequestedName = (char *) Context;
UINT32 i;
ACPI_BUFFER Buffer;
ACPI_WALK_INFO Info;
/* Check for a name match */
for (i = 0; i < 4; i++)
{
/* Wildcard support */
if ((RequestedName[i] != '?') &&
(RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
{
/* No match, just exit */
return (AE_OK);
}
}
/* Get the full pathname to this object */
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
}
else
{
Info.OwnerId = ACPI_OWNER_ID_MAX;
Info.DebugLevel = ACPI_UINT32_MAX;
Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
ACPI_FREE (Buffer.Pointer);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbFindNameInNamespace
*
* PARAMETERS: NameArg - The 4-character ACPI name to find.
* wildcards are supported.
*
* RETURN: None
*
* DESCRIPTION: Search the namespace for a given name (with wildcards)
*
******************************************************************************/
ACPI_STATUS
AcpiDbFindNameInNamespace (
char *NameArg)
{
char AcpiName[5] = "____";
char *AcpiNamePtr = AcpiName;
if (ACPI_STRLEN (NameArg) > 4)
{
AcpiOsPrintf ("Name must be no longer than 4 characters\n");
return (AE_OK);
}
/* Pad out name with underscores as necessary to create a 4-char name */
AcpiUtStrupr (NameArg);
while (*NameArg)
{
*AcpiNamePtr = *NameArg;
AcpiNamePtr++;
NameArg++;
}
/* Walk the namespace from the root */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForPredefinedNames
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Detect and display predefined ACPI names (names that start with
* an underscore)
*
******************************************************************************/
static ACPI_STATUS
AcpiDbWalkForPredefinedNames (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
UINT32 *Count = (UINT32 *) Context;
const ACPI_PREDEFINED_INFO *Predefined;
const ACPI_PREDEFINED_INFO *Package = NULL;
char *Pathname;
Predefined = AcpiNsCheckForPredefinedName (Node);
if (!Predefined)
{
return (AE_OK);
}
Pathname = AcpiNsGetExternalPathname (Node);
if (!Pathname)
{
return (AE_OK);
}
/* If method returns a package, the info is in the next table entry */
if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
{
Package = Predefined + 1;
}
AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
if (Package)
{
AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
Package->RetInfo.Type, Package->RetInfo.ObjectType1,
Package->RetInfo.Count1);
}
AcpiOsPrintf("\n");
AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
ACPI_FREE (Pathname);
(*Count)++;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbCheckPredefinedNames
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Validate all predefined names in the namespace
*
******************************************************************************/
void
AcpiDbCheckPredefinedNames (
void)
{
UINT32 Count = 0;
/* Search all nodes in namespace */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL);
AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForSpecificObjects
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/
static ACPI_STATUS
AcpiDbWalkForSpecificObjects (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
ACPI_BUFFER Buffer;
ACPI_STATUS Status;
Info->Count++;
/* Get and display the full pathname to this object */
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
return (AE_OK);
}
AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
ACPI_FREE (Buffer.Pointer);
/* Dump short info about the object */
(void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayObjects
*
* PARAMETERS: ObjTypeArg - Type of object to display
* DisplayCountArg - Max depth to display
*
* RETURN: None
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
******************************************************************************/
ACPI_STATUS
AcpiDbDisplayObjects (
char *ObjTypeArg,
char *DisplayCountArg)
{
ACPI_WALK_INFO Info;
ACPI_OBJECT_TYPE Type;
/* Get the object type */
Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
if (Type == ACPI_TYPE_NOT_FOUND)
{
AcpiOsPrintf ("Invalid or unsupported argument\n");
return (AE_OK);
}
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
AcpiOsPrintf (
"Objects of type [%s] defined in the current ACPI Namespace:\n",
AcpiUtGetTypeName (Type));
AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
Info.Count = 0;
Info.OwnerId = ACPI_OWNER_ID_MAX;
Info.DebugLevel = ACPI_UINT32_MAX;
Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
/* Walk the namespace from the root */
(void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
AcpiOsPrintf (
"\nFound %u objects of type [%s] in the current ACPI Namespace\n",
Info.Count, AcpiUtGetTypeName (Type));
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbIntegrityWalk
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Examine one NS node for valid values.
*
******************************************************************************/
static ACPI_STATUS
AcpiDbIntegrityWalk (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_OPERAND_OBJECT *Object;
BOOLEAN Alias = TRUE;
Info->Nodes++;
/* Verify the NS node, and dereference aliases */
while (Alias)
{
if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
{
AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
ACPI_DESC_TYPE_NAMED);
return (AE_OK);
}
if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||
(Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
{
Node = (ACPI_NAMESPACE_NODE *) Node->Object;
}
else
{
Alias = FALSE;
}
}
if (Node->Type > ACPI_TYPE_LOCAL_MAX)
{
AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
Node, Node->Type);
return (AE_OK);
}
if (!AcpiUtValidAcpiName (Node->Name.Integer))
{
AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
return (AE_OK);
}
Object = AcpiNsGetAttachedObject (Node);
if (Object)
{
Info->Objects++;
if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
{
AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
Object, AcpiUtGetDescriptorName (Object));
}
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbCheckIntegrity
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Check entire namespace for data structure integrity
*
******************************************************************************/
void
AcpiDbCheckIntegrity (
void)
{
ACPI_INTEGRITY_INFO Info = {0,0};
/* Search all nodes in namespace */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
Info.Nodes, Info.Objects);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForReferences
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Check if this namespace object refers to the target object
* that is passed in as the context value.
*
* Note: Currently doesn't check subobjects within the Node's object
*
******************************************************************************/
static ACPI_STATUS
AcpiDbWalkForReferences (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
/* Check for match against the namespace node itself */
if (Node == (void *) ObjDesc)
{
AcpiOsPrintf ("Object is a Node [%4.4s]\n",
AcpiUtGetNodeName (Node));
}
/* Check for match against the object attached to the node */
if (AcpiNsGetAttachedObject (Node) == ObjDesc)
{
AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
Node, AcpiUtGetNodeName (Node));
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbFindReferences
*
* PARAMETERS: ObjectArg - String with hex value of the object
*
* RETURN: None
*
* DESCRIPTION: Search namespace for all references to the input object
*
******************************************************************************/
void
AcpiDbFindReferences (
char *ObjectArg)
{
ACPI_OPERAND_OBJECT *ObjDesc;
/* Convert string to object pointer */
ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
/* Search all nodes in namespace */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbBusWalk
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Display info about device objects that have a corresponding
* _PRT method.
*
******************************************************************************/
static ACPI_STATUS
AcpiDbBusWalk (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_STATUS Status;
ACPI_BUFFER Buffer;
ACPI_NAMESPACE_NODE *TempNode;
ACPI_DEVICE_INFO *Info;
UINT32 i;
if ((Node->Type != ACPI_TYPE_DEVICE) &&
(Node->Type != ACPI_TYPE_PROCESSOR))
{
return (AE_OK);
}
/* Exit if there is no _PRT under this device */
Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
if (ACPI_FAILURE (Status))
{
return (AE_OK);
}
/* Get the full path to this device object */
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
return (AE_OK);
}
Status = AcpiGetObjectInfo (ObjHandle, &Info);
if (ACPI_FAILURE (Status))
{
return (AE_OK);
}
/* Display the full path */
AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
ACPI_FREE (Buffer.Pointer);
if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
{
AcpiOsPrintf (" - Is PCI Root Bridge");
}
AcpiOsPrintf ("\n");
/* _PRT info */
AcpiOsPrintf ("_PRT: %p\n", TempNode);
/* Dump _ADR, _HID, _UID, _CID */
if (Info->Valid & ACPI_VALID_ADR)
{
AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
}
else
{
AcpiOsPrintf ("_ADR: <Not Present>\n");
}
if (Info->Valid & ACPI_VALID_HID)
{
AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
}
else
{
AcpiOsPrintf ("_HID: <Not Present>\n");
}
if (Info->Valid & ACPI_VALID_UID)
{
AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
}
else
{
AcpiOsPrintf ("_UID: <Not Present>\n");
}
if (Info->Valid & ACPI_VALID_CID)
{
for (i = 0; i < Info->CompatibleIdList.Count; i++)
{
AcpiOsPrintf ("_CID: %s\n",
Info->CompatibleIdList.Ids[i].String);
}
}
else
{
AcpiOsPrintf ("_CID: <Not Present>\n");
}
ACPI_FREE (Info);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbGetBusInfo
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display info about system busses.
*
******************************************************************************/
void
AcpiDbGetBusInfo (
void)
{
/* Search all nodes in namespace */
(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
AcpiDbBusWalk, NULL, NULL, NULL);
}
#endif /* ACPI_DEBUGGER */

View File

@ -0,0 +1,430 @@
/******************************************************************************
*
* Module Name: dsargs - Support for execution of dynamic arguments for static
* objects (regions, fields, buffer fields, etc.)
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define __DSARGS_C__
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acparser.h>
#include <contrib/dev/acpica/include/amlcode.h>
#include <contrib/dev/acpica/include/acdispat.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsargs")
/* Local prototypes */
static ACPI_STATUS
AcpiDsExecuteArguments (
ACPI_NAMESPACE_NODE *Node,
ACPI_NAMESPACE_NODE *ScopeNode,
UINT32 AmlLength,
UINT8 *AmlStart);
/*******************************************************************************
*
* FUNCTION: AcpiDsExecuteArguments
*
* PARAMETERS: Node - Object NS node
* ScopeNode - Parent NS node
* AmlLength - Length of executable AML
* AmlStart - Pointer to the AML
*
* RETURN: Status.
*
* DESCRIPTION: Late (deferred) execution of region or field arguments
*
******************************************************************************/
static ACPI_STATUS
AcpiDsExecuteArguments (
ACPI_NAMESPACE_NODE *Node,
ACPI_NAMESPACE_NODE *ScopeNode,
UINT32 AmlLength,
UINT8 *AmlStart)
{
ACPI_STATUS Status;
ACPI_PARSE_OBJECT *Op;
ACPI_WALK_STATE *WalkState;
ACPI_FUNCTION_TRACE (DsExecuteArguments);
/* Allocate a new parser op to be the root of the parsed tree */
Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Save the Node for use in AcpiPsParseAml */
Op->Common.Node = ScopeNode;
/* Create and initialize a new parser state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
/* Mark this parse as a deferred opcode */
WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
WalkState->DeferredNode = Node;
/* Pass1: Parse the entire declaration */
Status = AcpiPsParseAml (WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Get and init the Op created above */
Op->Common.Node = Node;
AcpiPsDeleteParseTree (Op);
/* Evaluate the deferred arguments */
Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Op->Common.Node = ScopeNode;
/* Create and initialize a new parser state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
/* Execute the opcode and arguments */
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
AmlLength, NULL, ACPI_IMODE_EXECUTE);
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
/* Mark this execution as a deferred opcode */
WalkState->DeferredNode = Node;
Status = AcpiPsParseAml (WalkState);
Cleanup:
AcpiPsDeleteParseTree (Op);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferFieldArguments
*
* PARAMETERS: ObjDesc - A valid BufferField object
*
* RETURN: Status.
*
* DESCRIPTION: Get BufferField Buffer and Index. This implements the late
* evaluation of these field attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBufferFieldArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the AML pointer (method object) and BufferField node */
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
Node = ObjDesc->BufferField.Node;
ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD,
Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
AcpiUtGetNodeName (Node)));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBankFieldArguments
*
* PARAMETERS: ObjDesc - A valid BankField object
*
* RETURN: Status.
*
* DESCRIPTION: Get BankField BankValue. This implements the late
* evaluation of these field attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBankFieldArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the AML pointer (method object) and BankField node */
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
Node = ObjDesc->BankField.Node;
ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD,
Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
AcpiUtGetNodeName (Node)));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferArguments
*
* PARAMETERS: ObjDesc - A valid Buffer object
*
* RETURN: Status.
*
* DESCRIPTION: Get Buffer length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBufferArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the Buffer node */
Node = ObjDesc->Buffer.Node;
if (!Node)
{
ACPI_ERROR ((AE_INFO,
"No pointer back to namespace node in buffer object %p", ObjDesc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node,
ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetPackageArguments
*
* PARAMETERS: ObjDesc - A valid Package object
*
* RETURN: Status.
*
* DESCRIPTION: Get Package length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetPackageArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the Package node */
Node = ObjDesc->Package.Node;
if (!Node)
{
ACPI_ERROR ((AE_INFO,
"No pointer back to namespace node in package %p", ObjDesc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n"));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node,
ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetRegionArguments
*
* PARAMETERS: ObjDesc - A valid region object
*
* RETURN: Status.
*
* DESCRIPTION: Get region address and length. This implements the late
* evaluation of these region attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetRegionArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc);
if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
if (!ExtraDesc)
{
return_ACPI_STATUS (AE_NOT_EXIST);
}
/* Get the Region node */
Node = ObjDesc->Region.Node;
ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
/* Execute the argument AML */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}

View File

@ -0,0 +1,424 @@
/******************************************************************************
*
* Module Name: dscontrol - Support for execution control opcodes -
* if/else/while/return
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define __DSCONTROL_C__
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/amlcode.h>
#include <contrib/dev/acpica/include/acdispat.h>
#include <contrib/dev/acpica/include/acinterp.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dscontrol")
/*******************************************************************************
*
* FUNCTION: AcpiDsExecBeginControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
ACPI_STATUS
AcpiDsExecBeginControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *ControlState;
ACPI_FUNCTION_NAME (DsExecBeginControlOp);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
Op, Op->Common.AmlOpcode, WalkState));
switch (Op->Common.AmlOpcode)
{
case AML_WHILE_OP:
/*
* If this is an additional iteration of a while loop, continue.
* There is no need to allocate a new control state.
*/
if (WalkState->ControlState)
{
if (WalkState->ControlState->Control.AmlPredicateStart ==
(WalkState->ParserState.Aml - 1))
{
/* Reset the state to start-of-loop */
WalkState->ControlState->Common.State =
ACPI_CONTROL_CONDITIONAL_EXECUTING;
break;
}
}
/*lint -fallthrough */
case AML_IF_OP:
/*
* IF/WHILE: Create a new control state to manage these
* constructs. We need to manage these as a stack, in order
* to handle nesting.
*/
ControlState = AcpiUtCreateControlState ();
if (!ControlState)
{
Status = AE_NO_MEMORY;
break;
}
/*
* Save a pointer to the predicate for multiple executions
* of a loop
*/
ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
ControlState->Control.Opcode = Op->Common.AmlOpcode;
/* Push the control state on this walk's control stack */
AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
break;
case AML_ELSE_OP:
/* Predicate is in the state object */
/* If predicate is true, the IF was executed, ignore ELSE part */
if (WalkState->LastPredicate)
{
Status = AE_CTRL_TRUE;
}
break;
case AML_RETURN_OP:
break;
default:
break;
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsExecEndControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
ACPI_STATUS
AcpiDsExecEndControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *ControlState;
ACPI_FUNCTION_NAME (DsExecEndControlOp);
switch (Op->Common.AmlOpcode)
{
case AML_IF_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
/*
* Save the result of the predicate in case there is an
* ELSE to come
*/
WalkState->LastPredicate =
(BOOLEAN) WalkState->ControlState->Common.Value;
/*
* Pop the control state that was created at the start
* of the IF and free it
*/
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
break;
case AML_ELSE_OP:
break;
case AML_WHILE_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
ControlState = WalkState->ControlState;
if (ControlState->Common.Value)
{
/* Predicate was true, the body of the loop was just executed */
/*
* This loop counter mechanism allows the interpreter to escape
* possibly infinite loops. This can occur in poorly written AML
* when the hardware does not respond within a while loop and the
* loop does not implement a timeout.
*/
ControlState->Control.LoopCount++;
if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS)
{
Status = AE_AML_INFINITE_LOOP;
break;
}
/*
* Go back and evaluate the predicate and maybe execute the loop
* another time
*/
Status = AE_CTRL_PENDING;
WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
break;
}
/* Predicate was false, terminate this while loop */
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"[WHILE_OP] termination! Op=%p\n",Op));
/* Pop this control state and free it */
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
break;
case AML_RETURN_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
/*
* One optional operand -- the return value
* It can be either an immediate operand or a result that
* has been bubbled up the tree
*/
if (Op->Common.Value.Arg)
{
/* Since we have a real Return(), delete any implicit return */
AcpiDsClearImplicitReturn (WalkState);
/* Return statement has an immediate operand */
Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*/
Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Get the return value and save as the last result
* value. This is the only place where WalkState->ReturnDesc
* is set to anything other than zero!
*/
WalkState->ReturnDesc = WalkState->Operands[0];
}
else if (WalkState->ResultCount)
{
/* Since we have a real Return(), delete any implicit return */
AcpiDsClearImplicitReturn (WalkState);
/*
* The return value has come from a previous calculation.
*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*
* Allow references created by the Index operator to return
* unchanged.
*/
if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX))
{
Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
}
else
{
/* No return operand */
if (WalkState->NumOperands)
{
AcpiUtRemoveReference (WalkState->Operands [0]);
}
WalkState->Operands [0] = NULL;
WalkState->NumOperands = 0;
WalkState->ReturnDesc = NULL;
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Completed RETURN_OP State=%p, RetVal=%p\n",
WalkState, WalkState->ReturnDesc));
/* End the control method execution right now */
Status = AE_CTRL_TERMINATE;
break;
case AML_NOOP_OP:
/* Just do nothing! */
break;
case AML_BREAK_POINT_OP:
/*
* Set the single-step flag. This will cause the debugger (if present)
* to break to the console within the AML debugger at the start of the
* next AML instruction.
*/
ACPI_DEBUGGER_EXEC (
AcpiGbl_CmSingleStep = TRUE);
ACPI_DEBUGGER_EXEC (
AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
/* Call to the OSL in case OS wants a piece of the action */
Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
"Executed AML Breakpoint opcode");
break;
case AML_BREAK_OP:
case AML_CONTINUE_OP: /* ACPI 2.0 */
/* Pop and delete control states until we find a while */
while (WalkState->ControlState &&
(WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
{
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
}
/* No while found? */
if (!WalkState->ControlState)
{
return (AE_AML_NO_WHILE);
}
/* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
/* Return status depending on opcode */
if (Op->Common.AmlOpcode == AML_BREAK_OP)
{
Status = AE_CTRL_BREAK;
}
else
{
Status = AE_CTRL_CONTINUE;
}
break;
default:
ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
Op->Common.AmlOpcode, Op));
Status = AE_AML_BAD_OPCODE;
break;
}
return (Status);
}

View File

@ -1,7 +1,6 @@
/******************************************************************************
*
* Module Name: dsopcode - Dispatcher Op Region support and handling of
* "control" opcodes
* Module Name: dsopcode - Dispatcher suport for regions and fields
*
*****************************************************************************/
@ -59,13 +58,6 @@
/* Local prototypes */
static ACPI_STATUS
AcpiDsExecuteArguments (
ACPI_NAMESPACE_NODE *Node,
ACPI_NAMESPACE_NODE *ScopeNode,
UINT32 AmlLength,
UINT8 *AmlStart);
static ACPI_STATUS
AcpiDsInitBufferField (
UINT16 AmlOpcode,
@ -76,369 +68,6 @@ AcpiDsInitBufferField (
ACPI_OPERAND_OBJECT *ResultDesc);
/*******************************************************************************
*
* FUNCTION: AcpiDsExecuteArguments
*
* PARAMETERS: Node - Object NS node
* ScopeNode - Parent NS node
* AmlLength - Length of executable AML
* AmlStart - Pointer to the AML
*
* RETURN: Status.
*
* DESCRIPTION: Late (deferred) execution of region or field arguments
*
******************************************************************************/
static ACPI_STATUS
AcpiDsExecuteArguments (
ACPI_NAMESPACE_NODE *Node,
ACPI_NAMESPACE_NODE *ScopeNode,
UINT32 AmlLength,
UINT8 *AmlStart)
{
ACPI_STATUS Status;
ACPI_PARSE_OBJECT *Op;
ACPI_WALK_STATE *WalkState;
ACPI_FUNCTION_TRACE (DsExecuteArguments);
/*
* Allocate a new parser op to be the root of the parsed tree
*/
Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Save the Node for use in AcpiPsParseAml */
Op->Common.Node = ScopeNode;
/* Create and initialize a new parser state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
/* Mark this parse as a deferred opcode */
WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
WalkState->DeferredNode = Node;
/* Pass1: Parse the entire declaration */
Status = AcpiPsParseAml (WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Get and init the Op created above */
Op->Common.Node = Node;
AcpiPsDeleteParseTree (Op);
/* Evaluate the deferred arguments */
Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
Op->Common.Node = ScopeNode;
/* Create and initialize a new parser state */
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
if (!WalkState)
{
Status = AE_NO_MEMORY;
goto Cleanup;
}
/* Execute the opcode and arguments */
Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
AmlLength, NULL, ACPI_IMODE_EXECUTE);
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
goto Cleanup;
}
/* Mark this execution as a deferred opcode */
WalkState->DeferredNode = Node;
Status = AcpiPsParseAml (WalkState);
Cleanup:
AcpiPsDeleteParseTree (Op);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferFieldArguments
*
* PARAMETERS: ObjDesc - A valid BufferField object
*
* RETURN: Status.
*
* DESCRIPTION: Get BufferField Buffer and Index. This implements the late
* evaluation of these field attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBufferFieldArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the AML pointer (method object) and BufferField node */
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
Node = ObjDesc->BufferField.Node;
ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
AcpiUtGetNodeName (Node)));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBankFieldArguments
*
* PARAMETERS: ObjDesc - A valid BankField object
*
* RETURN: Status.
*
* DESCRIPTION: Get BankField BankValue. This implements the late
* evaluation of these field attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBankFieldArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the AML pointer (method object) and BankField node */
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
Node = ObjDesc->BankField.Node;
ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD, Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
AcpiUtGetNodeName (Node)));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetBufferArguments
*
* PARAMETERS: ObjDesc - A valid Buffer object
*
* RETURN: Status.
*
* DESCRIPTION: Get Buffer length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetBufferArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the Buffer node */
Node = ObjDesc->Buffer.Node;
if (!Node)
{
ACPI_ERROR ((AE_INFO,
"No pointer back to namespace node in buffer object %p", ObjDesc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node,
ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetPackageArguments
*
* PARAMETERS: ObjDesc - A valid Package object
*
* RETURN: Status.
*
* DESCRIPTION: Get Package length and initializer byte list. This implements
* the late evaluation of these attributes.
*
******************************************************************************/
ACPI_STATUS
AcpiDsGetPackageArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc);
if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
/* Get the Package node */
Node = ObjDesc->Package.Node;
if (!Node)
{
ACPI_ERROR ((AE_INFO,
"No pointer back to namespace node in package %p", ObjDesc));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n"));
/* Execute the AML code for the TermArg arguments */
Status = AcpiDsExecuteArguments (Node, Node,
ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart);
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AcpiDsGetRegionArguments
*
* PARAMETERS: ObjDesc - A valid region object
*
* RETURN: Status.
*
* DESCRIPTION: Get region address and length. This implements the late
* evaluation of these region attributes.
*
****************************************************************************/
ACPI_STATUS
AcpiDsGetRegionArguments (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT *ExtraDesc;
ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc);
if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
{
return_ACPI_STATUS (AE_OK);
}
ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
if (!ExtraDesc)
{
return_ACPI_STATUS (AE_NOT_EXIST);
}
/* Get the Region node */
Node = ObjDesc->Region.Node;
ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL));
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
/* Execute the argument AML */
Status = AcpiDsExecuteArguments (Node, Node->Parent,
ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsInitializeRegion
@ -870,8 +499,9 @@ AcpiDsEvalRegionOperands (
*
* RETURN: Status
*
* DESCRIPTION: Get region address and length
* Called from AcpiDsExecEndOp during DataTableRegion parse tree walk
* DESCRIPTION: Get region address and length.
* Called from AcpiDsExecEndOp during DataTableRegion parse
* tree walk.
*
******************************************************************************/
@ -1177,371 +807,3 @@ AcpiDsEvalBankFieldOperands (
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsExecBeginControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
ACPI_STATUS
AcpiDsExecBeginControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *ControlState;
ACPI_FUNCTION_NAME (DsExecBeginControlOp);
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op,
Op->Common.AmlOpcode, WalkState));
switch (Op->Common.AmlOpcode)
{
case AML_WHILE_OP:
/*
* If this is an additional iteration of a while loop, continue.
* There is no need to allocate a new control state.
*/
if (WalkState->ControlState)
{
if (WalkState->ControlState->Control.AmlPredicateStart ==
(WalkState->ParserState.Aml - 1))
{
/* Reset the state to start-of-loop */
WalkState->ControlState->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING;
break;
}
}
/*lint -fallthrough */
case AML_IF_OP:
/*
* IF/WHILE: Create a new control state to manage these
* constructs. We need to manage these as a stack, in order
* to handle nesting.
*/
ControlState = AcpiUtCreateControlState ();
if (!ControlState)
{
Status = AE_NO_MEMORY;
break;
}
/*
* Save a pointer to the predicate for multiple executions
* of a loop
*/
ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1;
ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd;
ControlState->Control.Opcode = Op->Common.AmlOpcode;
/* Push the control state on this walk's control stack */
AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
break;
case AML_ELSE_OP:
/* Predicate is in the state object */
/* If predicate is true, the IF was executed, ignore ELSE part */
if (WalkState->LastPredicate)
{
Status = AE_CTRL_TRUE;
}
break;
case AML_RETURN_OP:
break;
default:
break;
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsExecEndControlOp
*
* PARAMETERS: WalkList - The list that owns the walk stack
* Op - The control Op
*
* RETURN: Status
*
* DESCRIPTION: Handles all control ops encountered during control method
* execution.
*
******************************************************************************/
ACPI_STATUS
AcpiDsExecEndControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *ControlState;
ACPI_FUNCTION_NAME (DsExecEndControlOp);
switch (Op->Common.AmlOpcode)
{
case AML_IF_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
/*
* Save the result of the predicate in case there is an
* ELSE to come
*/
WalkState->LastPredicate =
(BOOLEAN) WalkState->ControlState->Common.Value;
/*
* Pop the control state that was created at the start
* of the IF and free it
*/
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
break;
case AML_ELSE_OP:
break;
case AML_WHILE_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
ControlState = WalkState->ControlState;
if (ControlState->Common.Value)
{
/* Predicate was true, the body of the loop was just executed */
/*
* This loop counter mechanism allows the interpreter to escape
* possibly infinite loops. This can occur in poorly written AML
* when the hardware does not respond within a while loop and the
* loop does not implement a timeout.
*/
ControlState->Control.LoopCount++;
if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS)
{
Status = AE_AML_INFINITE_LOOP;
break;
}
/*
* Go back and evaluate the predicate and maybe execute the loop
* another time
*/
Status = AE_CTRL_PENDING;
WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
break;
}
/* Predicate was false, terminate this while loop */
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"[WHILE_OP] termination! Op=%p\n",Op));
/* Pop this control state and free it */
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
break;
case AML_RETURN_OP:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
/*
* One optional operand -- the return value
* It can be either an immediate operand or a result that
* has been bubbled up the tree
*/
if (Op->Common.Value.Arg)
{
/* Since we have a real Return(), delete any implicit return */
AcpiDsClearImplicitReturn (WalkState);
/* Return statement has an immediate operand */
Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*/
Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Get the return value and save as the last result
* value. This is the only place where WalkState->ReturnDesc
* is set to anything other than zero!
*/
WalkState->ReturnDesc = WalkState->Operands[0];
}
else if (WalkState->ResultCount)
{
/* Since we have a real Return(), delete any implicit return */
AcpiDsClearImplicitReturn (WalkState);
/*
* The return value has come from a previous calculation.
*
* If value being returned is a Reference (such as
* an arg or local), resolve it now because it may
* cease to exist at the end of the method.
*
* Allow references created by the Index operator to return unchanged.
*/
if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) &&
((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX))
{
Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
}
else
{
/* No return operand */
if (WalkState->NumOperands)
{
AcpiUtRemoveReference (WalkState->Operands [0]);
}
WalkState->Operands [0] = NULL;
WalkState->NumOperands = 0;
WalkState->ReturnDesc = NULL;
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Completed RETURN_OP State=%p, RetVal=%p\n",
WalkState, WalkState->ReturnDesc));
/* End the control method execution right now */
Status = AE_CTRL_TERMINATE;
break;
case AML_NOOP_OP:
/* Just do nothing! */
break;
case AML_BREAK_POINT_OP:
/*
* Set the single-step flag. This will cause the debugger (if present)
* to break to the console within the AML debugger at the start of the
* next AML instruction.
*/
ACPI_DEBUGGER_EXEC (
AcpiGbl_CmSingleStep = TRUE);
ACPI_DEBUGGER_EXEC (
AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
/* Call to the OSL in case OS wants a piece of the action */
Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
"Executed AML Breakpoint opcode");
break;
case AML_BREAK_OP:
case AML_CONTINUE_OP: /* ACPI 2.0 */
/* Pop and delete control states until we find a while */
while (WalkState->ControlState &&
(WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
{
ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
AcpiUtDeleteGenericState (ControlState);
}
/* No while found? */
if (!WalkState->ControlState)
{
return (AE_AML_NO_WHILE);
}
/* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd;
/* Return status depending on opcode */
if (Op->Common.AmlOpcode == AML_BREAK_OP)
{
Status = AE_CTRL_BREAK;
}
else
{
Status = AE_CTRL_CONTINUE;
}
break;
default:
ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
Op->Common.AmlOpcode, Op));
Status = AE_AML_BAD_OPCODE;
break;
}
return (Status);
}

View File

@ -1,6 +1,6 @@
/******************************************************************************
*
* Module Name: dswload - Dispatcher namespace load callbacks
* Module Name: dswload - Dispatcher first pass namespace load callbacks
*
*****************************************************************************/
@ -50,7 +50,6 @@
#include <contrib/dev/acpica/include/acdispat.h>
#include <contrib/dev/acpica/include/acinterp.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acevents.h>
#ifdef ACPI_ASL_COMPILER
#include <contrib/dev/acpica/include/acdisasm.h>
@ -550,695 +549,3 @@ AcpiDsLoad1EndOp (
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsLoad2BeginOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
* OutOp - Wher to return op if a new one is created
*
* RETURN: Status
*
* DESCRIPTION: Descending callback used during the loading of ACPI tables.
*
******************************************************************************/
ACPI_STATUS
AcpiDsLoad2BeginOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
ACPI_PARSE_OBJECT *Op;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE ObjectType;
char *BufferPtr;
UINT32 Flags;
ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
if (Op)
{
if ((WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
ACPI_CONTROL_CONDITIONAL_EXECUTING))
{
/* We are executing a while loop outside of a method */
Status = AcpiDsExecBeginOp (WalkState, OutOp);
return_ACPI_STATUS (Status);
}
/* We only care about Namespace opcodes here */
if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
(WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
(!(WalkState->OpInfo->Flags & AML_NAMED)))
{
return_ACPI_STATUS (AE_OK);
}
/* Get the name we are going to enter or lookup in the namespace */
if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
{
/* For Namepath op, get the path string */
BufferPtr = Op->Common.Value.String;
if (!BufferPtr)
{
/* No name, just exit */
return_ACPI_STATUS (AE_OK);
}
}
else
{
/* Get name from the op */
BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
}
}
else
{
/* Get the namestring from the raw AML */
BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
}
/* Map the opcode into an internal object type */
ObjectType = WalkState->OpInfo->ObjectType;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
switch (WalkState->Opcode)
{
case AML_FIELD_OP:
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
Node = NULL;
Status = AE_OK;
break;
case AML_INT_NAMEPATH_OP:
/*
* The NamePath is an object reference to an existing object.
* Don't enter the name into the namespace, but look it up
* for use later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
WalkState, &(Node));
break;
case AML_SCOPE_OP:
/* Special case for Scope(\) -> refers to the Root node */
if (Op && (Op->Named.Node == AcpiGbl_RootNode))
{
Node = Op->Named.Node;
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
else
{
/*
* The Path is an object reference to an existing object.
* Don't enter the name into the namespace, but look it up
* for use later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
#ifdef ACPI_ASL_COMPILER
if (Status == AE_NOT_FOUND)
{
Status = AE_OK;
}
else
{
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
}
#else
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
#endif
return_ACPI_STATUS (Status);
}
}
/*
* We must check to make sure that the target is
* one of the opcodes that actually opens a scope
*/
switch (Node->Type)
{
case ACPI_TYPE_ANY:
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
/* These are acceptable types */
break;
case ACPI_TYPE_INTEGER:
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:
*
* Name (DEB, 0)
* Scope (DEB) { ... }
*/
ACPI_WARNING ((AE_INFO,
"Type override - [%4.4s] had invalid type (%s) "
"for Scope operator, changed to type ANY\n",
AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
Node->Type = ACPI_TYPE_ANY;
WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
break;
default:
/* All other types are an error */
ACPI_ERROR ((AE_INFO,
"Invalid type (%s) for target of "
"Scope operator [%4.4s] (Cannot override)",
AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
return (AE_AML_OPERAND_TYPE);
}
break;
default:
/* All other opcodes */
if (Op && Op->Common.Node)
{
/* This op/node was previously entered into the namespace */
Node = Op->Common.Node;
if (AcpiNsOpensScope (ObjectType))
{
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
return_ACPI_STATUS (AE_OK);
}
/*
* Enter the named type into the internal namespace. We enter the name
* as we go downward in the parse tree. Any necessary subobjects that
* involve arguments to the opcode must be created as we go back up the
* parse tree later.
*
* Note: Name may already exist if we are executing a deferred opcode.
*/
if (WalkState->DeferredNode)
{
/* This name is already in the namespace, get the node */
Node = WalkState->DeferredNode;
Status = AE_OK;
break;
}
Flags = ACPI_NS_NO_UPSEARCH;
if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
{
/* Execution mode, node cannot already exist, node is temporary */
Flags |= ACPI_NS_ERROR_IF_FOUND;
if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
{
Flags |= ACPI_NS_TEMPORARY;
}
}
/* Add new entry or lookup existing entry */
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"***New Node [%4.4s] %p is temporary\n",
AcpiUtGetNodeName (Node), Node));
}
break;
}
if (ACPI_FAILURE (Status))
{
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
return_ACPI_STATUS (Status);
}
if (!Op)
{
/* Create a new op */
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Initialize the new op */
if (Node)
{
Op->Named.Name = Node->Name.Integer;
}
*OutOp = Op;
}
/*
* Put the Node in the "op" object that the parser uses, so we
* can get it again quickly when this scope is closed
*/
Op->Common.Node = Node;
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsLoad2EndOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback used during the loading of the namespace,
* both control methods and everything else.
*
******************************************************************************/
ACPI_STATUS
AcpiDsLoad2EndOp (
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_TYPE ObjectType;
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *Arg;
ACPI_NAMESPACE_NODE *NewNode;
#ifndef ACPI_NO_METHOD_EXECUTION
UINT32 i;
UINT8 RegionSpace;
#endif
ACPI_FUNCTION_TRACE (DsLoad2EndOp);
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
WalkState->OpInfo->Name, Op, WalkState));
/* Check if opcode had an associated namespace object */
if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
{
return_ACPI_STATUS (AE_OK);
}
if (Op->Common.AmlOpcode == AML_SCOPE_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Ending scope Op=%p State=%p\n", Op, WalkState));
}
ObjectType = WalkState->OpInfo->ObjectType;
/*
* Get the Node/name from the earlier lookup
* (It was saved in the *op structure)
*/
Node = Op->Common.Node;
/*
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
WalkState->Operands[0] = (void *) Node;
WalkState->NumOperands = 1;
/* Pop the scope stack */
if (AcpiNsOpensScope (ObjectType) &&
(Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
AcpiUtGetTypeName (ObjectType), Op));
Status = AcpiDsScopeStackPop (WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
}
/*
* Named operations are as follows:
*
* AML_ALIAS
* AML_BANKFIELD
* AML_CREATEBITFIELD
* AML_CREATEBYTEFIELD
* AML_CREATEDWORDFIELD
* AML_CREATEFIELD
* AML_CREATEQWORDFIELD
* AML_CREATEWORDFIELD
* AML_DATA_REGION
* AML_DEVICE
* AML_EVENT
* AML_FIELD
* AML_INDEXFIELD
* AML_METHOD
* AML_METHODCALL
* AML_MUTEX
* AML_NAME
* AML_NAMEDFIELD
* AML_OPREGION
* AML_POWERRES
* AML_PROCESSOR
* AML_SCOPE
* AML_THERMALZONE
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
/* Decode the opcode */
Arg = Op->Common.Value.Arg;
switch (WalkState->OpInfo->Type)
{
#ifndef ACPI_NO_METHOD_EXECUTION
case AML_TYPE_CREATE_FIELD:
/*
* Create the field object, but the field buffer and index must
* be evaluated later during the execution phase
*/
Status = AcpiDsCreateBufferField (Op, WalkState);
break;
case AML_TYPE_NAMED_FIELD:
/*
* If we are executing a method, initialize the field
*/
if (WalkState->MethodNode)
{
Status = AcpiDsInitFieldObjects (Op, WalkState);
}
switch (Op->Common.AmlOpcode)
{
case AML_INDEX_FIELD_OP:
Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
WalkState);
break;
case AML_BANK_FIELD_OP:
Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
break;
case AML_FIELD_OP:
Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
break;
default:
/* All NAMED_FIELD opcodes must be handled above */
break;
}
break;
case AML_TYPE_NAMED_SIMPLE:
Status = AcpiDsCreateOperands (WalkState, Arg);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
switch (Op->Common.AmlOpcode)
{
case AML_PROCESSOR_OP:
Status = AcpiExCreateProcessor (WalkState);
break;
case AML_POWER_RES_OP:
Status = AcpiExCreatePowerResource (WalkState);
break;
case AML_MUTEX_OP:
Status = AcpiExCreateMutex (WalkState);
break;
case AML_EVENT_OP:
Status = AcpiExCreateEvent (WalkState);
break;
case AML_ALIAS_OP:
Status = AcpiExCreateAlias (WalkState);
break;
default:
/* Unknown opcode */
Status = AE_OK;
goto Cleanup;
}
/* Delete operands */
for (i = 1; i < WalkState->NumOperands; i++)
{
AcpiUtRemoveReference (WalkState->Operands[i]);
WalkState->Operands[i] = NULL;
}
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
case AML_TYPE_NAMED_COMPLEX:
switch (Op->Common.AmlOpcode)
{
#ifndef ACPI_NO_METHOD_EXECUTION
case AML_REGION_OP:
case AML_DATA_REGION_OP:
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
RegionSpace = (ACPI_ADR_SPACE_TYPE)
((Op->Common.Value.Arg)->Common.Value.Integer);
}
else
{
RegionSpace = REGION_DATA_TABLE;
}
/*
* The OpRegion is not fully parsed at this time. The only valid
* argument is the SpaceId. (We must save the address of the
* AML of the address and length operands)
*
* If we have a valid region, initialize it. The namespace is
* unlocked at this point.
*
* Need to unlock interpreter if it is locked (if we are running
* a control method), in order to allow _REG methods to be run
* during AcpiEvInitializeRegion.
*/
if (WalkState->MethodNode)
{
/*
* Executing a method: initialize the region and unlock
* the interpreter
*/
Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
RegionSpace, WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiExExitInterpreter ();
}
Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
FALSE);
if (WalkState->MethodNode)
{
AcpiExEnterInterpreter ();
}
if (ACPI_FAILURE (Status))
{
/*
* If AE_NOT_EXIST is returned, it is not fatal
* because many regions get created before a handler
* is installed for said region.
*/
if (AE_NOT_EXIST == Status)
{
Status = AE_OK;
}
}
break;
case AML_NAME_OP:
Status = AcpiDsCreateNode (WalkState, Node, Op);
break;
case AML_METHOD_OP:
/*
* MethodOp PkgLength NameString MethodFlags TermList
*
* Note: We must create the method node/object pair as soon as we
* see the method declaration. This allows later pass1 parsing
* of invocations of the method (need to know the number of
* arguments.)
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"LOADING-Method: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Op->Named.Node));
if (!AcpiNsGetAttachedObject (Op->Named.Node))
{
WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
WalkState->NumOperands = 1;
Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
if (ACPI_SUCCESS (Status))
{
Status = AcpiExCreateMethod (Op->Named.Data,
Op->Named.Length, WalkState);
}
WalkState->Operands[0] = NULL;
WalkState->NumOperands = 0;
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
default:
/* All NAMED_COMPLEX opcodes must be handled above */
break;
}
break;
case AML_CLASS_INTERNAL:
/* case AML_INT_NAMEPATH_OP: */
break;
case AML_CLASS_METHOD_CALL:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Node));
/*
* Lookup the method name and save the Node
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
WalkState, &(NewNode));
if (ACPI_SUCCESS (Status))
{
/*
* Make sure that what we found is indeed a method
* We didn't search for a method on purpose, to see if the name
* would resolve
*/
if (NewNode->Type != ACPI_TYPE_METHOD)
{
Status = AE_AML_OPERAND_TYPE;
}
/* We could put the returned object (Node) on the object stack for
* later, but for now, we will put it in the "op" object that the
* parser uses, so we can get it again at the end of this scope
*/
Op->Common.Node = NewNode;
}
else
{
ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
}
break;
default:
break;
}
Cleanup:
/* Remove the Node pushed at the very beginning */
WalkState->Operands[0] = NULL;
WalkState->NumOperands = 0;
return_ACPI_STATUS (Status);
}

View File

@ -0,0 +1,747 @@
/******************************************************************************
*
* Module Name: dswload2 - Dispatcher second pass namespace load callbacks
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define __DSWLOAD2_C__
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acparser.h>
#include <contrib/dev/acpica/include/amlcode.h>
#include <contrib/dev/acpica/include/acdispat.h>
#include <contrib/dev/acpica/include/acinterp.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#include <contrib/dev/acpica/include/acevents.h>
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswload2")
/*******************************************************************************
*
* FUNCTION: AcpiDsLoad2BeginOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
* OutOp - Wher to return op if a new one is created
*
* RETURN: Status
*
* DESCRIPTION: Descending callback used during the loading of ACPI tables.
*
******************************************************************************/
ACPI_STATUS
AcpiDsLoad2BeginOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
ACPI_PARSE_OBJECT *Op;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_OBJECT_TYPE ObjectType;
char *BufferPtr;
UINT32 Flags;
ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
if (Op)
{
if ((WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
ACPI_CONTROL_CONDITIONAL_EXECUTING))
{
/* We are executing a while loop outside of a method */
Status = AcpiDsExecBeginOp (WalkState, OutOp);
return_ACPI_STATUS (Status);
}
/* We only care about Namespace opcodes here */
if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) &&
(WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
(!(WalkState->OpInfo->Flags & AML_NAMED)))
{
return_ACPI_STATUS (AE_OK);
}
/* Get the name we are going to enter or lookup in the namespace */
if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
{
/* For Namepath op, get the path string */
BufferPtr = Op->Common.Value.String;
if (!BufferPtr)
{
/* No name, just exit */
return_ACPI_STATUS (AE_OK);
}
}
else
{
/* Get name from the op */
BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name);
}
}
else
{
/* Get the namestring from the raw AML */
BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState);
}
/* Map the opcode into an internal object type */
ObjectType = WalkState->OpInfo->ObjectType;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType));
switch (WalkState->Opcode)
{
case AML_FIELD_OP:
case AML_BANK_FIELD_OP:
case AML_INDEX_FIELD_OP:
Node = NULL;
Status = AE_OK;
break;
case AML_INT_NAMEPATH_OP:
/*
* The NamePath is an object reference to an existing object.
* Don't enter the name into the namespace, but look it up
* for use later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
WalkState, &(Node));
break;
case AML_SCOPE_OP:
/* Special case for Scope(\) -> refers to the Root node */
if (Op && (Op->Named.Node == AcpiGbl_RootNode))
{
Node = Op->Named.Node;
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
else
{
/*
* The Path is an object reference to an existing object.
* Don't enter the name into the namespace, but look it up
* for use later.
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
#ifdef ACPI_ASL_COMPILER
if (Status == AE_NOT_FOUND)
{
Status = AE_OK;
}
else
{
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
}
#else
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
#endif
return_ACPI_STATUS (Status);
}
}
/*
* We must check to make sure that the target is
* one of the opcodes that actually opens a scope
*/
switch (Node->Type)
{
case ACPI_TYPE_ANY:
case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
/* These are acceptable types */
break;
case ACPI_TYPE_INTEGER:
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:
*
* Name (DEB, 0)
* Scope (DEB) { ... }
*/
ACPI_WARNING ((AE_INFO,
"Type override - [%4.4s] had invalid type (%s) "
"for Scope operator, changed to type ANY\n",
AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
Node->Type = ACPI_TYPE_ANY;
WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
break;
default:
/* All other types are an error */
ACPI_ERROR ((AE_INFO,
"Invalid type (%s) for target of "
"Scope operator [%4.4s] (Cannot override)",
AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
return (AE_AML_OPERAND_TYPE);
}
break;
default:
/* All other opcodes */
if (Op && Op->Common.Node)
{
/* This op/node was previously entered into the namespace */
Node = Op->Common.Node;
if (AcpiNsOpensScope (ObjectType))
{
Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
return_ACPI_STATUS (AE_OK);
}
/*
* Enter the named type into the internal namespace. We enter the name
* as we go downward in the parse tree. Any necessary subobjects that
* involve arguments to the opcode must be created as we go back up the
* parse tree later.
*
* Note: Name may already exist if we are executing a deferred opcode.
*/
if (WalkState->DeferredNode)
{
/* This name is already in the namespace, get the node */
Node = WalkState->DeferredNode;
Status = AE_OK;
break;
}
Flags = ACPI_NS_NO_UPSEARCH;
if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
{
/* Execution mode, node cannot already exist, node is temporary */
Flags |= ACPI_NS_ERROR_IF_FOUND;
if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
{
Flags |= ACPI_NS_TEMPORARY;
}
}
/* Add new entry or lookup existing entry */
Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"***New Node [%4.4s] %p is temporary\n",
AcpiUtGetNodeName (Node), Node));
}
break;
}
if (ACPI_FAILURE (Status))
{
ACPI_ERROR_NAMESPACE (BufferPtr, Status);
return_ACPI_STATUS (Status);
}
if (!Op)
{
/* Create a new op */
Op = AcpiPsAllocOp (WalkState->Opcode);
if (!Op)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Initialize the new op */
if (Node)
{
Op->Named.Name = Node->Name.Integer;
}
*OutOp = Op;
}
/*
* Put the Node in the "op" object that the parser uses, so we
* can get it again quickly when this scope is closed
*/
Op->Common.Node = Node;
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDsLoad2EndOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback used during the loading of the namespace,
* both control methods and everything else.
*
******************************************************************************/
ACPI_STATUS
AcpiDsLoad2EndOp (
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_TYPE ObjectType;
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *Arg;
ACPI_NAMESPACE_NODE *NewNode;
#ifndef ACPI_NO_METHOD_EXECUTION
UINT32 i;
UINT8 RegionSpace;
#endif
ACPI_FUNCTION_TRACE (DsLoad2EndOp);
Op = WalkState->Op;
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
WalkState->OpInfo->Name, Op, WalkState));
/* Check if opcode had an associated namespace object */
if (!(WalkState->OpInfo->Flags & AML_NSOBJECT))
{
return_ACPI_STATUS (AE_OK);
}
if (Op->Common.AmlOpcode == AML_SCOPE_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Ending scope Op=%p State=%p\n", Op, WalkState));
}
ObjectType = WalkState->OpInfo->ObjectType;
/*
* Get the Node/name from the earlier lookup
* (It was saved in the *op structure)
*/
Node = Op->Common.Node;
/*
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
WalkState->Operands[0] = (void *) Node;
WalkState->NumOperands = 1;
/* Pop the scope stack */
if (AcpiNsOpensScope (ObjectType) &&
(Op->Common.AmlOpcode != AML_INT_METHODCALL_OP))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
AcpiUtGetTypeName (ObjectType), Op));
Status = AcpiDsScopeStackPop (WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
}
/*
* Named operations are as follows:
*
* AML_ALIAS
* AML_BANKFIELD
* AML_CREATEBITFIELD
* AML_CREATEBYTEFIELD
* AML_CREATEDWORDFIELD
* AML_CREATEFIELD
* AML_CREATEQWORDFIELD
* AML_CREATEWORDFIELD
* AML_DATA_REGION
* AML_DEVICE
* AML_EVENT
* AML_FIELD
* AML_INDEXFIELD
* AML_METHOD
* AML_METHODCALL
* AML_MUTEX
* AML_NAME
* AML_NAMEDFIELD
* AML_OPREGION
* AML_POWERRES
* AML_PROCESSOR
* AML_SCOPE
* AML_THERMALZONE
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
/* Decode the opcode */
Arg = Op->Common.Value.Arg;
switch (WalkState->OpInfo->Type)
{
#ifndef ACPI_NO_METHOD_EXECUTION
case AML_TYPE_CREATE_FIELD:
/*
* Create the field object, but the field buffer and index must
* be evaluated later during the execution phase
*/
Status = AcpiDsCreateBufferField (Op, WalkState);
break;
case AML_TYPE_NAMED_FIELD:
/*
* If we are executing a method, initialize the field
*/
if (WalkState->MethodNode)
{
Status = AcpiDsInitFieldObjects (Op, WalkState);
}
switch (Op->Common.AmlOpcode)
{
case AML_INDEX_FIELD_OP:
Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
WalkState);
break;
case AML_BANK_FIELD_OP:
Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
break;
case AML_FIELD_OP:
Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
break;
default:
/* All NAMED_FIELD opcodes must be handled above */
break;
}
break;
case AML_TYPE_NAMED_SIMPLE:
Status = AcpiDsCreateOperands (WalkState, Arg);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
switch (Op->Common.AmlOpcode)
{
case AML_PROCESSOR_OP:
Status = AcpiExCreateProcessor (WalkState);
break;
case AML_POWER_RES_OP:
Status = AcpiExCreatePowerResource (WalkState);
break;
case AML_MUTEX_OP:
Status = AcpiExCreateMutex (WalkState);
break;
case AML_EVENT_OP:
Status = AcpiExCreateEvent (WalkState);
break;
case AML_ALIAS_OP:
Status = AcpiExCreateAlias (WalkState);
break;
default:
/* Unknown opcode */
Status = AE_OK;
goto Cleanup;
}
/* Delete operands */
for (i = 1; i < WalkState->NumOperands; i++)
{
AcpiUtRemoveReference (WalkState->Operands[i]);
WalkState->Operands[i] = NULL;
}
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
case AML_TYPE_NAMED_COMPLEX:
switch (Op->Common.AmlOpcode)
{
#ifndef ACPI_NO_METHOD_EXECUTION
case AML_REGION_OP:
case AML_DATA_REGION_OP:
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
RegionSpace = (ACPI_ADR_SPACE_TYPE)
((Op->Common.Value.Arg)->Common.Value.Integer);
}
else
{
RegionSpace = REGION_DATA_TABLE;
}
/*
* The OpRegion is not fully parsed at this time. The only valid
* argument is the SpaceId. (We must save the address of the
* AML of the address and length operands)
*
* If we have a valid region, initialize it. The namespace is
* unlocked at this point.
*
* Need to unlock interpreter if it is locked (if we are running
* a control method), in order to allow _REG methods to be run
* during AcpiEvInitializeRegion.
*/
if (WalkState->MethodNode)
{
/*
* Executing a method: initialize the region and unlock
* the interpreter
*/
Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
RegionSpace, WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiExExitInterpreter ();
}
Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
FALSE);
if (WalkState->MethodNode)
{
AcpiExEnterInterpreter ();
}
if (ACPI_FAILURE (Status))
{
/*
* If AE_NOT_EXIST is returned, it is not fatal
* because many regions get created before a handler
* is installed for said region.
*/
if (AE_NOT_EXIST == Status)
{
Status = AE_OK;
}
}
break;
case AML_NAME_OP:
Status = AcpiDsCreateNode (WalkState, Node, Op);
break;
case AML_METHOD_OP:
/*
* MethodOp PkgLength NameString MethodFlags TermList
*
* Note: We must create the method node/object pair as soon as we
* see the method declaration. This allows later pass1 parsing
* of invocations of the method (need to know the number of
* arguments.)
*/
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"LOADING-Method: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Op->Named.Node));
if (!AcpiNsGetAttachedObject (Op->Named.Node))
{
WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
WalkState->NumOperands = 1;
Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
if (ACPI_SUCCESS (Status))
{
Status = AcpiExCreateMethod (Op->Named.Data,
Op->Named.Length, WalkState);
}
WalkState->Operands[0] = NULL;
WalkState->NumOperands = 0;
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
break;
#endif /* ACPI_NO_METHOD_EXECUTION */
default:
/* All NAMED_COMPLEX opcodes must be handled above */
break;
}
break;
case AML_CLASS_INTERNAL:
/* case AML_INT_NAMEPATH_OP: */
break;
case AML_CLASS_METHOD_CALL:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
WalkState, Op, Node));
/*
* Lookup the method name and save the Node
*/
Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
WalkState, &(NewNode));
if (ACPI_SUCCESS (Status))
{
/*
* Make sure that what we found is indeed a method
* We didn't search for a method on purpose, to see if the name
* would resolve
*/
if (NewNode->Type != ACPI_TYPE_METHOD)
{
Status = AE_AML_OPERAND_TYPE;
}
/* We could put the returned object (Node) on the object stack for
* later, but for now, we will put it in the "op" object that the
* parser uses, so we can get it again at the end of this scope
*/
Op->Common.Node = NewNode;
}
else
{
ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
}
break;
default:
break;
}
Cleanup:
/* Remove the Node pushed at the very beginning */
WalkState->Operands[0] = NULL;
WalkState->NumOperands = 0;
return_ACPI_STATUS (Status);
}

View File

@ -422,6 +422,16 @@ AcpiEvGpeDetect (
GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
/*
* Optimization: If there are no GPEs enabled within this
* register, we can safely ignore the entire register.
*/
if (!(GpeRegisterInfo->EnableForRun |
GpeRegisterInfo->EnableForWake))
{
continue;
}
/* Read the Status Register */
Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);

View File

@ -262,6 +262,8 @@ AcpiEvInitializeOpRegions (
}
}
AcpiGbl_RegMethodsExecuted = TRUE;
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}

View File

@ -120,9 +120,41 @@ AcpiInstallAddressSpaceHandler (
goto UnlockAndExit;
}
/* Run all _REG methods for this address space */
/*
* For the default SpaceIDs, (the IDs for which there are default region handlers
* installed) Only execute the _REG methods if the global initialization _REG
* methods have already been run (via AcpiInitializeObjects). In other words,
* we will defer the execution of the _REG methods for these SpaceIDs until
* execution of AcpiInitializeObjects. This is done because we need the handlers
* for the default spaces (mem/io/pci/table) to be installed before we can run
* any control methods (or _REG methods). There is known BIOS code that depends
* on this.
*
* For all other SpaceIDs, we can safely execute the _REG methods immediately.
* This means that for IDs like EmbeddedController, this function should be called
* only after AcpiEnableSubsystem has been called.
*/
switch (SpaceId)
{
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
case ACPI_ADR_SPACE_PCI_CONFIG:
case ACPI_ADR_SPACE_DATA_TABLE:
if (AcpiGbl_RegMethodsExecuted)
{
/* Run all _REG methods for this address space */
Status = AcpiEvExecuteRegMethods (Node, SpaceId);
}
break;
default:
Status = AcpiEvExecuteRegMethods (Node, SpaceId);
break;
}
Status = AcpiEvExecuteRegMethods (Node, SpaceId);
UnlockAndExit:
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);

View File

@ -298,14 +298,14 @@ AcpiExAccessRegion (
if (Status == AE_NOT_IMPLEMENTED)
{
ACPI_ERROR ((AE_INFO,
"Region %s(0x%X) not implemented",
"Region %s (ID=%u) not implemented",
AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
RgnDesc->Region.SpaceId));
}
else if (Status == AE_NOT_EXIST)
{
ACPI_ERROR ((AE_INFO,
"Region %s(0x%X) has no handler",
"Region %s (ID=%u) has no handler",
AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
RgnDesc->Region.SpaceId));
}

View File

@ -98,9 +98,9 @@ AcpiDbSingleStep (
/*
* dbcmds - debug commands and output routines
*/
ACPI_STATUS
AcpiDbDisassembleMethod (
char *Name);
ACPI_NAMESPACE_NODE *
AcpiDbConvertToNode (
char *InString);
void
AcpiDbDisplayTableInfo (
@ -111,72 +111,20 @@ AcpiDbUnloadAcpiTable (
char *TableArg,
char *InstanceArg);
void
AcpiDbSetMethodBreakpoint (
char *Location,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
void
AcpiDbSetMethodCallBreakpoint (
ACPI_PARSE_OBJECT *Op);
void
AcpiDbGetBusInfo (
void);
void
AcpiDbDisassembleAml (
char *Statements,
ACPI_PARSE_OBJECT *Op);
void
AcpiDbDumpNamespace (
char *StartArg,
char *DepthArg);
void
AcpiDbDumpNamespaceByOwner (
char *OwnerArg,
char *DepthArg);
void
AcpiDbSendNotify (
char *Name,
UINT32 Value);
void
AcpiDbSetMethodData (
char *TypeArg,
char *IndexArg,
char *ValueArg);
ACPI_STATUS
AcpiDbDisplayObjects (
char *ObjTypeArg,
char *DisplayCountArg);
void
AcpiDbDisplayInterfaces (
char *ActionArg,
char *InterfaceNameArg);
ACPI_STATUS
AcpiDbFindNameInNamespace (
char *NameArg);
void
AcpiDbSetScope (
char *Name);
ACPI_STATUS
AcpiDbSleep (
char *ObjectArg);
void
AcpiDbFindReferences (
char *ObjectArg);
void
AcpiDbDisplayLocks (
void);
@ -190,7 +138,7 @@ AcpiDbDisplayGpes (
void);
void
AcpiDbCheckIntegrity (
AcpiDbDisplayHandlers (
void);
void
@ -198,14 +146,83 @@ AcpiDbGenerateGpe (
char *GpeArg,
char *BlockArg);
/*
* dbmethod - control method commands
*/
void
AcpiDbCheckPredefinedNames (
void);
AcpiDbSetMethodBreakpoint (
char *Location,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
void
AcpiDbSetMethodCallBreakpoint (
ACPI_PARSE_OBJECT *Op);
void
AcpiDbSetMethodData (
char *TypeArg,
char *IndexArg,
char *ValueArg);
ACPI_STATUS
AcpiDbDisassembleMethod (
char *Name);
void
AcpiDbDisassembleAml (
char *Statements,
ACPI_PARSE_OBJECT *Op);
void
AcpiDbBatchExecute (
char *CountArg);
/*
* dbnames - namespace commands
*/
void
AcpiDbSetScope (
char *Name);
void
AcpiDbDumpNamespace (
char *StartArg,
char *DepthArg);
void
AcpiDbDumpNamespaceByOwner (
char *OwnerArg,
char *DepthArg);
ACPI_STATUS
AcpiDbFindNameInNamespace (
char *NameArg);
void
AcpiDbCheckPredefinedNames (
void);
ACPI_STATUS
AcpiDbDisplayObjects (
char *ObjTypeArg,
char *DisplayCountArg);
void
AcpiDbCheckIntegrity (
void);
void
AcpiDbFindReferences (
char *ObjectArg);
void
AcpiDbGetBusInfo (
void);
/*
* dbdisply - debug display commands
*/

View File

@ -127,6 +127,8 @@ typedef const struct acpi_dmtable_info
#define ACPI_DMT_UNICODE 42
#define ACPI_DMT_UUID 43
#define ACPI_DMT_DEVICE_PATH 44
#define ACPI_DMT_LABEL 45
#define ACPI_DMT_BUF7 46
typedef

View File

@ -51,7 +51,7 @@
/*
* dsopcode - support for late evaluation
* dsargs - execution of dynamic arguments for static objects
*/
ACPI_STATUS
AcpiDsGetBufferFieldArguments (
@ -73,6 +73,24 @@ ACPI_STATUS
AcpiDsGetPackageArguments (
ACPI_OPERAND_OBJECT *ObjDesc);
/*
* dscontrol - support for execution control opcodes
*/
ACPI_STATUS
AcpiDsExecBeginControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
ACPI_STATUS
AcpiDsExecEndControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
/*
* dsopcode - support for late operand evaluation
*/
ACPI_STATUS
AcpiDsEvalBufferFieldOperands (
ACPI_WALK_STATE *WalkState,
@ -104,20 +122,6 @@ AcpiDsInitializeRegion (
ACPI_HANDLE ObjHandle);
/*
* dsctrl - Parser/Interpreter interface, control stack routines
*/
ACPI_STATUS
AcpiDsExecBeginControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
ACPI_STATUS
AcpiDsExecEndControlOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op);
/*
* dsexec - Parser/Interpreter interface, method execution callbacks
*/
@ -169,9 +173,14 @@ AcpiDsInitFieldObjects (
/*
* dsload - Parser/Interpreter interface, namespace load callbacks
* dsload - Parser/Interpreter interface, pass 1 namespace load callbacks
*/
ACPI_STATUS
AcpiDsInitCallbacks (
ACPI_WALK_STATE *WalkState,
UINT32 PassNumber);
ACPI_STATUS
AcpiDsLoad1BeginOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp);
@ -180,6 +189,10 @@ ACPI_STATUS
AcpiDsLoad1EndOp (
ACPI_WALK_STATE *WalkState);
/*
* dsload - Parser/Interpreter interface, pass 2 namespace load callbacks
*/
ACPI_STATUS
AcpiDsLoad2BeginOp (
ACPI_WALK_STATE *WalkState,
@ -189,11 +202,6 @@ ACPI_STATUS
AcpiDsLoad2EndOp (
ACPI_WALK_STATE *WalkState);
ACPI_STATUS
AcpiDsInitCallbacks (
ACPI_WALK_STATE *WalkState,
UINT32 PassNumber);
/*
* dsmthdat - method data (locals/args)

View File

@ -245,6 +245,10 @@ ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MAS
ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex;
ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset;
/* Initialization sequencing */
ACPI_EXTERN BOOLEAN AcpiGbl_RegMethodsExecuted;
/* Misc */
ACPI_EXTERN UINT32 AcpiGbl_OriginalMode;

View File

@ -93,25 +93,6 @@ union acpi_parse_object;
#define ACPI_MAX_MUTEX 7
#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
#ifdef DEFINE_ACPI_GLOBALS
/* Debug names for the mutexes above */
static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
{
"ACPI_MTX_Interpreter",
"ACPI_MTX_Namespace",
"ACPI_MTX_Tables",
"ACPI_MTX_Events",
"ACPI_MTX_Caches",
"ACPI_MTX_Memory",
"ACPI_MTX_CommandComplete",
"ACPI_MTX_CommandReady"
};
#endif
#endif
/* Lock structure for reader/writer interfaces */

View File

@ -186,13 +186,19 @@
#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
/*
* Module name is included in both debug and non-debug versions primarily for
* error messages. The __FILE__ macro is not very useful for this, because it
* often includes the entire pathname to the module
* The module name is used primarily for error and debug messages.
* The __FILE__ macro is not very useful for this, because it
* usually includes the entire pathname to the module making the
* debug output difficult to read.
*/
#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name;
#else
/*
* For the no-debug and no-error-msg cases, we must at least define
* a null module name.
*/
#define ACPI_MODULE_NAME(Name)
#define _AcpiModuleName ""
#endif
/*

View File

@ -48,7 +48,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
#define ACPI_CA_VERSION 0x20110112
#define ACPI_CA_VERSION 0x20110211
#include <contrib/dev/acpica/include/actypes.h>
#include <contrib/dev/acpica/include/actbl.h>

View File

@ -397,4 +397,20 @@ typedef struct acpi_table_desc
#define ACPI_FADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_FADT, f)
/*
* Sizes of the various flavors of FADT. We need to look closely
* at the FADT length because the version number essentially tells
* us nothing because of many BIOS bugs where the version does not
* match the expected length. In other words, the length of the
* FADT is the bottom line as to what the version really is.
*
* For reference, the values below are as follows:
* FADT V1 size: 0x74
* FADT V2 size: 0x84
* FADT V3+ size: 0xF4
*/
#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4)
#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (Reserved4[0]) + 3)
#define ACPI_FADT_V3_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT))
#endif /* __ACTBL_H__ */

View File

@ -410,8 +410,11 @@ AcpiTbConvertFadt (
*
* The ACPI 1.0 reserved fields that will be zeroed are the bytes located
* at offset 45, 55, 95, and the word located at offset 109, 110.
*
* Note: The FADT revision value is unreliable. Only the length can be
* trusted.
*/
if (AcpiGbl_FADT.Header.Revision < 3)
if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
{
AcpiGbl_FADT.PreferredProfile = 0;
AcpiGbl_FADT.PstateControl = 0;

View File

@ -160,7 +160,11 @@ AeDisplayAllMethods (
UINT32 DisplayCount);
ACPI_STATUS
AeInstallHandlers (
AeInstallEarlyHandlers (
void);
ACPI_STATUS
AeInstallLateHandlers (
void);
void

View File

@ -0,0 +1,627 @@
/******************************************************************************
*
* Module Name: utdecode - Utility decoding routines (value-to-string)
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define __UTDECODE_C__
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utdecode")
/*******************************************************************************
*
* FUNCTION: AcpiFormatException
*
* PARAMETERS: Status - The ACPI_STATUS code to be formatted
*
* RETURN: A string containing the exception text. A valid pointer is
* always returned.
*
* DESCRIPTION: This function translates an ACPI exception into an ASCII string
* It is here instead of utxface.c so it is always present.
*
******************************************************************************/
const char *
AcpiFormatException (
ACPI_STATUS Status)
{
const char *Exception = NULL;
ACPI_FUNCTION_ENTRY ();
Exception = AcpiUtValidateException (Status);
if (!Exception)
{
/* Exception code was not recognized */
ACPI_ERROR ((AE_INFO,
"Unknown exception code: 0x%8.8X", Status));
Exception = "UNKNOWN_STATUS_CODE";
}
return (ACPI_CAST_PTR (const char, Exception));
}
ACPI_EXPORT_SYMBOL (AcpiFormatException)
/*
* Properties of the ACPI Object Types, both internal and external.
* The table is indexed by values of ACPI_OBJECT_TYPE
*/
const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
{
ACPI_NS_NORMAL, /* 00 Any */
ACPI_NS_NORMAL, /* 01 Number */
ACPI_NS_NORMAL, /* 02 String */
ACPI_NS_NORMAL, /* 03 Buffer */
ACPI_NS_NORMAL, /* 04 Package */
ACPI_NS_NORMAL, /* 05 FieldUnit */
ACPI_NS_NEWSCOPE, /* 06 Device */
ACPI_NS_NORMAL, /* 07 Event */
ACPI_NS_NEWSCOPE, /* 08 Method */
ACPI_NS_NORMAL, /* 09 Mutex */
ACPI_NS_NORMAL, /* 10 Region */
ACPI_NS_NEWSCOPE, /* 11 Power */
ACPI_NS_NEWSCOPE, /* 12 Processor */
ACPI_NS_NEWSCOPE, /* 13 Thermal */
ACPI_NS_NORMAL, /* 14 BufferField */
ACPI_NS_NORMAL, /* 15 DdbHandle */
ACPI_NS_NORMAL, /* 16 Debug Object */
ACPI_NS_NORMAL, /* 17 DefField */
ACPI_NS_NORMAL, /* 18 BankField */
ACPI_NS_NORMAL, /* 19 IndexField */
ACPI_NS_NORMAL, /* 20 Reference */
ACPI_NS_NORMAL, /* 21 Alias */
ACPI_NS_NORMAL, /* 22 MethodAlias */
ACPI_NS_NORMAL, /* 23 Notify */
ACPI_NS_NORMAL, /* 24 Address Handler */
ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
ACPI_NS_NEWSCOPE, /* 27 Scope */
ACPI_NS_NORMAL, /* 28 Extra */
ACPI_NS_NORMAL, /* 29 Data */
ACPI_NS_NORMAL /* 30 Invalid */
};
/*******************************************************************************
*
* FUNCTION: AcpiUtHexToAsciiChar
*
* PARAMETERS: Integer - Contains the hex digit
* Position - bit position of the digit within the
* integer (multiple of 4)
*
* RETURN: The converted Ascii character
*
* DESCRIPTION: Convert a hex digit to an Ascii character
*
******************************************************************************/
/* Hex to ASCII conversion table */
static const char AcpiGbl_HexToAscii[] =
{
'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'
};
char
AcpiUtHexToAsciiChar (
UINT64 Integer,
UINT32 Position)
{
return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetRegionName
*
* PARAMETERS: Space ID - ID for the region
*
* RETURN: Decoded region SpaceId name
*
* DESCRIPTION: Translate a Space ID into a name string (Debug only)
*
******************************************************************************/
/* Region type decoding */
const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
{
"SystemMemory",
"SystemIO",
"PCI_Config",
"EmbeddedControl",
"SMBus",
"SystemCMOS",
"PCIBARTarget",
"IPMI",
"DataTable"
};
char *
AcpiUtGetRegionName (
UINT8 SpaceId)
{
if (SpaceId >= ACPI_USER_REGION_BEGIN)
{
return ("UserDefinedRegion");
}
else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
{
return ("FunctionalFixedHW");
}
else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
{
return ("InvalidSpaceId");
}
return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetEventName
*
* PARAMETERS: EventId - Fixed event ID
*
* RETURN: Decoded event ID name
*
* DESCRIPTION: Translate a Event ID into a name string (Debug only)
*
******************************************************************************/
/* Event type decoding */
static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
{
"PM_Timer",
"GlobalLock",
"PowerButton",
"SleepButton",
"RealTimeClock",
};
char *
AcpiUtGetEventName (
UINT32 EventId)
{
if (EventId > ACPI_EVENT_MAX)
{
return ("InvalidEventID");
}
return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetTypeName
*
* PARAMETERS: Type - An ACPI object type
*
* RETURN: Decoded ACPI object type name
*
* DESCRIPTION: Translate a Type ID into a name string (Debug only)
*
******************************************************************************/
/*
* Elements of AcpiGbl_NsTypeNames below must match
* one-to-one with values of ACPI_OBJECT_TYPE
*
* The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
* when stored in a table it really means that we have thus far seen no
* evidence to indicate what type is actually going to be stored for this entry.
*/
static const char AcpiGbl_BadType[] = "UNDEFINED";
/* Printable names of the ACPI object types */
static const char *AcpiGbl_NsTypeNames[] =
{
/* 00 */ "Untyped",
/* 01 */ "Integer",
/* 02 */ "String",
/* 03 */ "Buffer",
/* 04 */ "Package",
/* 05 */ "FieldUnit",
/* 06 */ "Device",
/* 07 */ "Event",
/* 08 */ "Method",
/* 09 */ "Mutex",
/* 10 */ "Region",
/* 11 */ "Power",
/* 12 */ "Processor",
/* 13 */ "Thermal",
/* 14 */ "BufferField",
/* 15 */ "DdbHandle",
/* 16 */ "DebugObject",
/* 17 */ "RegionField",
/* 18 */ "BankField",
/* 19 */ "IndexField",
/* 20 */ "Reference",
/* 21 */ "Alias",
/* 22 */ "MethodAlias",
/* 23 */ "Notify",
/* 24 */ "AddrHandler",
/* 25 */ "ResourceDesc",
/* 26 */ "ResourceFld",
/* 27 */ "Scope",
/* 28 */ "Extra",
/* 29 */ "Data",
/* 30 */ "Invalid"
};
char *
AcpiUtGetTypeName (
ACPI_OBJECT_TYPE Type)
{
if (Type > ACPI_TYPE_INVALID)
{
return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
}
return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
}
char *
AcpiUtGetObjectTypeName (
ACPI_OPERAND_OBJECT *ObjDesc)
{
if (!ObjDesc)
{
return ("[NULL Object Descriptor]");
}
return (AcpiUtGetTypeName (ObjDesc->Common.Type));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetNodeName
*
* PARAMETERS: Object - A namespace node
*
* RETURN: ASCII name of the node
*
* DESCRIPTION: Validate the node and return the node's ACPI name.
*
******************************************************************************/
char *
AcpiUtGetNodeName (
void *Object)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
/* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
if (!Object)
{
return ("NULL");
}
/* Check for Root node */
if ((Object == ACPI_ROOT_OBJECT) ||
(Object == AcpiGbl_RootNode))
{
return ("\"\\\" ");
}
/* Descriptor must be a namespace node */
if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
{
return ("####");
}
/*
* Ensure name is valid. The name was validated/repaired when the node
* was created, but make sure it has not been corrupted.
*/
AcpiUtRepairName (Node->Name.Ascii);
/* Return the name */
return (Node->Name.Ascii);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetDescriptorName
*
* PARAMETERS: Object - An ACPI object
*
* RETURN: Decoded name of the descriptor type
*
* DESCRIPTION: Validate object and return the descriptor type
*
******************************************************************************/
/* Printable names of object descriptor types */
static const char *AcpiGbl_DescTypeNames[] =
{
/* 00 */ "Not a Descriptor",
/* 01 */ "Cached",
/* 02 */ "State-Generic",
/* 03 */ "State-Update",
/* 04 */ "State-Package",
/* 05 */ "State-Control",
/* 06 */ "State-RootParseScope",
/* 07 */ "State-ParseScope",
/* 08 */ "State-WalkScope",
/* 09 */ "State-Result",
/* 10 */ "State-Notify",
/* 11 */ "State-Thread",
/* 12 */ "Walk",
/* 13 */ "Parser",
/* 14 */ "Operand",
/* 15 */ "Node"
};
char *
AcpiUtGetDescriptorName (
void *Object)
{
if (!Object)
{
return ("NULL OBJECT");
}
if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
{
return ("Not a Descriptor");
}
return (ACPI_CAST_PTR (char,
AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetReferenceName
*
* PARAMETERS: Object - An ACPI reference object
*
* RETURN: Decoded name of the type of reference
*
* DESCRIPTION: Decode a reference object sub-type to a string.
*
******************************************************************************/
/* Printable names of reference object sub-types */
static const char *AcpiGbl_RefClassNames[] =
{
/* 00 */ "Local",
/* 01 */ "Argument",
/* 02 */ "RefOf",
/* 03 */ "Index",
/* 04 */ "DdbHandle",
/* 05 */ "Named Object",
/* 06 */ "Debug"
};
const char *
AcpiUtGetReferenceName (
ACPI_OPERAND_OBJECT *Object)
{
if (!Object)
{
return ("NULL Object");
}
if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
{
return ("Not an Operand object");
}
if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
{
return ("Not a Reference object");
}
if (Object->Reference.Class > ACPI_REFCLASS_MAX)
{
return ("Unknown Reference class");
}
return (AcpiGbl_RefClassNames[Object->Reference.Class]);
}
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*
* Strings and procedures used for debug only
*/
/*******************************************************************************
*
* FUNCTION: AcpiUtGetMutexName
*
* PARAMETERS: MutexId - The predefined ID for this mutex.
*
* RETURN: Decoded name of the internal mutex
*
* DESCRIPTION: Translate a mutex ID into a name string (Debug only)
*
******************************************************************************/
/* Names for internal mutex objects, used for debug output */
static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
{
"ACPI_MTX_Interpreter",
"ACPI_MTX_Namespace",
"ACPI_MTX_Tables",
"ACPI_MTX_Events",
"ACPI_MTX_Caches",
"ACPI_MTX_Memory",
"ACPI_MTX_CommandComplete",
"ACPI_MTX_CommandReady"
};
char *
AcpiUtGetMutexName (
UINT32 MutexId)
{
if (MutexId > ACPI_MAX_MUTEX)
{
return ("Invalid Mutex ID");
}
return (AcpiGbl_MutexNames[MutexId]);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetNotifyName
*
* PARAMETERS: NotifyValue - Value from the Notify() request
*
* RETURN: Decoded name for the notify value
*
* DESCRIPTION: Translate a Notify Value to a notify namestring.
*
******************************************************************************/
/* Names for Notify() values, used for debug output */
static const char *AcpiGbl_NotifyValueNames[] =
{
"Bus Check",
"Device Check",
"Device Wake",
"Eject Request",
"Device Check Light",
"Frequency Mismatch",
"Bus Mode Mismatch",
"Power Fault",
"Capabilities Check",
"Device PLD Check",
"Reserved",
"System Locality Update"
};
const char *
AcpiUtGetNotifyName (
UINT32 NotifyValue)
{
if (NotifyValue <= ACPI_NOTIFY_MAX)
{
return (AcpiGbl_NotifyValueNames[NotifyValue]);
}
else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
{
return ("Reserved");
}
else /* Greater or equal to 0x80 */
{
return ("**Device Specific**");
}
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiUtValidObjectType
*
* PARAMETERS: Type - Object type to be validated
*
* RETURN: TRUE if valid object type, FALSE otherwise
*
* DESCRIPTION: Validate an object type
*
******************************************************************************/
BOOLEAN
AcpiUtValidObjectType (
ACPI_OBJECT_TYPE Type)
{
if (Type > ACPI_TYPE_LOCAL_MAX)
{
/* Note: Assumes all TYPEs are contiguous (external/local) */
return (FALSE);
}
return (TRUE);
}

View File

@ -46,7 +46,6 @@
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acnamesp.h>
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utglobal")
@ -118,47 +117,6 @@ const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] =
};
/*******************************************************************************
*
* FUNCTION: AcpiFormatException
*
* PARAMETERS: Status - The ACPI_STATUS code to be formatted
*
* RETURN: A string containing the exception text. A valid pointer is
* always returned.
*
* DESCRIPTION: This function translates an ACPI exception into an ASCII string
* It is here instead of utxface.c so it is always present.
*
******************************************************************************/
const char *
AcpiFormatException (
ACPI_STATUS Status)
{
const char *Exception = NULL;
ACPI_FUNCTION_ENTRY ();
Exception = AcpiUtValidateException (Status);
if (!Exception)
{
/* Exception code was not recognized */
ACPI_ERROR ((AE_INFO,
"Unknown exception code: 0x%8.8X", Status));
Exception = "UNKNOWN_STATUS_CODE";
}
return (ACPI_CAST_PTR (const char, Exception));
}
ACPI_EXPORT_SYMBOL (AcpiFormatException)
/*******************************************************************************
*
* Namespace globals
@ -196,78 +154,6 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] =
{NULL, ACPI_TYPE_ANY, NULL}
};
/*
* Properties of the ACPI Object Types, both internal and external.
* The table is indexed by values of ACPI_OBJECT_TYPE
*/
const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
{
ACPI_NS_NORMAL, /* 00 Any */
ACPI_NS_NORMAL, /* 01 Number */
ACPI_NS_NORMAL, /* 02 String */
ACPI_NS_NORMAL, /* 03 Buffer */
ACPI_NS_NORMAL, /* 04 Package */
ACPI_NS_NORMAL, /* 05 FieldUnit */
ACPI_NS_NEWSCOPE, /* 06 Device */
ACPI_NS_NORMAL, /* 07 Event */
ACPI_NS_NEWSCOPE, /* 08 Method */
ACPI_NS_NORMAL, /* 09 Mutex */
ACPI_NS_NORMAL, /* 10 Region */
ACPI_NS_NEWSCOPE, /* 11 Power */
ACPI_NS_NEWSCOPE, /* 12 Processor */
ACPI_NS_NEWSCOPE, /* 13 Thermal */
ACPI_NS_NORMAL, /* 14 BufferField */
ACPI_NS_NORMAL, /* 15 DdbHandle */
ACPI_NS_NORMAL, /* 16 Debug Object */
ACPI_NS_NORMAL, /* 17 DefField */
ACPI_NS_NORMAL, /* 18 BankField */
ACPI_NS_NORMAL, /* 19 IndexField */
ACPI_NS_NORMAL, /* 20 Reference */
ACPI_NS_NORMAL, /* 21 Alias */
ACPI_NS_NORMAL, /* 22 MethodAlias */
ACPI_NS_NORMAL, /* 23 Notify */
ACPI_NS_NORMAL, /* 24 Address Handler */
ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
ACPI_NS_NEWSCOPE, /* 27 Scope */
ACPI_NS_NORMAL, /* 28 Extra */
ACPI_NS_NORMAL, /* 29 Data */
ACPI_NS_NORMAL /* 30 Invalid */
};
/* Hex to ASCII conversion table */
static const char AcpiGbl_HexToAscii[] =
{
'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'
};
/*******************************************************************************
*
* FUNCTION: AcpiUtHexToAsciiChar
*
* PARAMETERS: Integer - Contains the hex digit
* Position - bit position of the digit within the
* integer (multiple of 4)
*
* RETURN: The converted Ascii character
*
* DESCRIPTION: Convert a hex digit to an Ascii character
*
******************************************************************************/
char
AcpiUtHexToAsciiChar (
UINT64 Integer,
UINT32 Position)
{
return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
}
/******************************************************************************
*
@ -314,451 +200,6 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
/* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
};
/*******************************************************************************
*
* FUNCTION: AcpiUtGetRegionName
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: Translate a Space ID into a name string (Debug only)
*
******************************************************************************/
/* Region type decoding */
const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
{
"SystemMemory",
"SystemIO",
"PCI_Config",
"EmbeddedControl",
"SMBus",
"SystemCMOS",
"PCIBARTarget",
"IPMI",
"DataTable"
};
char *
AcpiUtGetRegionName (
UINT8 SpaceId)
{
if (SpaceId >= ACPI_USER_REGION_BEGIN)
{
return ("UserDefinedRegion");
}
else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
{
return ("InvalidSpaceId");
}
return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetEventName
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: Translate a Event ID into a name string (Debug only)
*
******************************************************************************/
/* Event type decoding */
static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
{
"PM_Timer",
"GlobalLock",
"PowerButton",
"SleepButton",
"RealTimeClock",
};
char *
AcpiUtGetEventName (
UINT32 EventId)
{
if (EventId > ACPI_EVENT_MAX)
{
return ("InvalidEventID");
}
return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetTypeName
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: Translate a Type ID into a name string (Debug only)
*
******************************************************************************/
/*
* Elements of AcpiGbl_NsTypeNames below must match
* one-to-one with values of ACPI_OBJECT_TYPE
*
* The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
* when stored in a table it really means that we have thus far seen no
* evidence to indicate what type is actually going to be stored for this entry.
*/
static const char AcpiGbl_BadType[] = "UNDEFINED";
/* Printable names of the ACPI object types */
static const char *AcpiGbl_NsTypeNames[] =
{
/* 00 */ "Untyped",
/* 01 */ "Integer",
/* 02 */ "String",
/* 03 */ "Buffer",
/* 04 */ "Package",
/* 05 */ "FieldUnit",
/* 06 */ "Device",
/* 07 */ "Event",
/* 08 */ "Method",
/* 09 */ "Mutex",
/* 10 */ "Region",
/* 11 */ "Power",
/* 12 */ "Processor",
/* 13 */ "Thermal",
/* 14 */ "BufferField",
/* 15 */ "DdbHandle",
/* 16 */ "DebugObject",
/* 17 */ "RegionField",
/* 18 */ "BankField",
/* 19 */ "IndexField",
/* 20 */ "Reference",
/* 21 */ "Alias",
/* 22 */ "MethodAlias",
/* 23 */ "Notify",
/* 24 */ "AddrHandler",
/* 25 */ "ResourceDesc",
/* 26 */ "ResourceFld",
/* 27 */ "Scope",
/* 28 */ "Extra",
/* 29 */ "Data",
/* 30 */ "Invalid"
};
char *
AcpiUtGetTypeName (
ACPI_OBJECT_TYPE Type)
{
if (Type > ACPI_TYPE_INVALID)
{
return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
}
return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
}
char *
AcpiUtGetObjectTypeName (
ACPI_OPERAND_OBJECT *ObjDesc)
{
if (!ObjDesc)
{
return ("[NULL Object Descriptor]");
}
return (AcpiUtGetTypeName (ObjDesc->Common.Type));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetNodeName
*
* PARAMETERS: Object - A namespace node
*
* RETURN: Pointer to a string
*
* DESCRIPTION: Validate the node and return the node's ACPI name.
*
******************************************************************************/
char *
AcpiUtGetNodeName (
void *Object)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
/* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
if (!Object)
{
return ("NULL");
}
/* Check for Root node */
if ((Object == ACPI_ROOT_OBJECT) ||
(Object == AcpiGbl_RootNode))
{
return ("\"\\\" ");
}
/* Descriptor must be a namespace node */
if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
{
return ("####");
}
/*
* Ensure name is valid. The name was validated/repaired when the node
* was created, but make sure it has not been corrupted.
*/
AcpiUtRepairName (Node->Name.Ascii);
/* Return the name */
return (Node->Name.Ascii);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetDescriptorName
*
* PARAMETERS: Object - An ACPI object
*
* RETURN: Pointer to a string
*
* DESCRIPTION: Validate object and return the descriptor type
*
******************************************************************************/
/* Printable names of object descriptor types */
static const char *AcpiGbl_DescTypeNames[] =
{
/* 00 */ "Not a Descriptor",
/* 01 */ "Cached",
/* 02 */ "State-Generic",
/* 03 */ "State-Update",
/* 04 */ "State-Package",
/* 05 */ "State-Control",
/* 06 */ "State-RootParseScope",
/* 07 */ "State-ParseScope",
/* 08 */ "State-WalkScope",
/* 09 */ "State-Result",
/* 10 */ "State-Notify",
/* 11 */ "State-Thread",
/* 12 */ "Walk",
/* 13 */ "Parser",
/* 14 */ "Operand",
/* 15 */ "Node"
};
char *
AcpiUtGetDescriptorName (
void *Object)
{
if (!Object)
{
return ("NULL OBJECT");
}
if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
{
return ("Not a Descriptor");
}
return (ACPI_CAST_PTR (char,
AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetReferenceName
*
* PARAMETERS: Object - An ACPI reference object
*
* RETURN: Pointer to a string
*
* DESCRIPTION: Decode a reference object sub-type to a string.
*
******************************************************************************/
/* Printable names of reference object sub-types */
static const char *AcpiGbl_RefClassNames[] =
{
/* 00 */ "Local",
/* 01 */ "Argument",
/* 02 */ "RefOf",
/* 03 */ "Index",
/* 04 */ "DdbHandle",
/* 05 */ "Named Object",
/* 06 */ "Debug"
};
const char *
AcpiUtGetReferenceName (
ACPI_OPERAND_OBJECT *Object)
{
if (!Object)
{
return ("NULL Object");
}
if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
{
return ("Not an Operand object");
}
if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
{
return ("Not a Reference object");
}
if (Object->Reference.Class > ACPI_REFCLASS_MAX)
{
return ("Unknown Reference class");
}
return (AcpiGbl_RefClassNames[Object->Reference.Class]);
}
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*
* Strings and procedures used for debug only
*/
/*******************************************************************************
*
* FUNCTION: AcpiUtGetMutexName
*
* PARAMETERS: MutexId - The predefined ID for this mutex.
*
* RETURN: String containing the name of the mutex. Always returns a valid
* pointer.
*
* DESCRIPTION: Translate a mutex ID into a name string (Debug only)
*
******************************************************************************/
char *
AcpiUtGetMutexName (
UINT32 MutexId)
{
if (MutexId > ACPI_MAX_MUTEX)
{
return ("Invalid Mutex ID");
}
return (AcpiGbl_MutexNames[MutexId]);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtGetNotifyName
*
* PARAMETERS: NotifyValue - Value from the Notify() request
*
* RETURN: String corresponding to the Notify Value.
*
* DESCRIPTION: Translate a Notify Value to a notify namestring.
*
******************************************************************************/
/* Names for Notify() values, used for debug output */
static const char *AcpiGbl_NotifyValueNames[] =
{
"Bus Check",
"Device Check",
"Device Wake",
"Eject Request",
"Device Check Light",
"Frequency Mismatch",
"Bus Mode Mismatch",
"Power Fault",
"Capabilities Check",
"Device PLD Check",
"Reserved",
"System Locality Update"
};
const char *
AcpiUtGetNotifyName (
UINT32 NotifyValue)
{
if (NotifyValue <= ACPI_NOTIFY_MAX)
{
return (AcpiGbl_NotifyValueNames[NotifyValue]);
}
else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
{
return ("Reserved");
}
else /* Greater or equal to 0x80 */
{
return ("**Device Specific**");
}
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiUtValidObjectType
*
* PARAMETERS: Type - Object type to be validated
*
* RETURN: TRUE if valid object type, FALSE otherwise
*
* DESCRIPTION: Validate an object type
*
******************************************************************************/
BOOLEAN
AcpiUtValidObjectType (
ACPI_OBJECT_TYPE Type)
{
if (Type > ACPI_TYPE_LOCAL_MAX)
{
/* Note: Assumes all TYPEs are contiguous (external/local) */
return (FALSE);
}
return (TRUE);
}
/*******************************************************************************
*
@ -768,7 +209,7 @@ AcpiUtValidObjectType (
*
* RETURN: Status
*
* DESCRIPTION: Init library globals. All globals that require specific
* DESCRIPTION: Init ACPICA globals. All globals that require specific
* initialization should be initialized here!
*
******************************************************************************/
@ -865,6 +306,7 @@ AcpiUtInitGlobals (
AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
AcpiGbl_OsiData = 0;
AcpiGbl_OsiMutex = NULL;
AcpiGbl_RegMethodsExecuted = FALSE;
/* Hardware oriented */
@ -907,5 +349,3 @@ ACPI_EXPORT_SYMBOL (AcpiDbgLevel)
ACPI_EXPORT_SYMBOL (AcpiDbgLayer)
ACPI_EXPORT_SYMBOL (AcpiGpeCount)
ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount)

View File

@ -32,12 +32,13 @@
KMOD= acpi
# ACPI CA sources
SRCS+= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c dbinput.c dbstats.c
SRCS+= dbutils.c dbxface.c
SRCS+= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c dbinput.c dbmethod.c
SRCS+= dbnames.c dbstats.c dbutils.c dbxface.c
SRCS+= dmbuffer.c dmnames.c dmopcode.c dmobject.c dmresrc.c dmresrcl.c
SRCS+= dmresrcs.c dmutils.c dmwalk.c
SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c dsopcode.c
SRCS+= dsutils.c dswexec.c dswload.c dswscope.c dswstate.c
SRCS+= dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c dsmthdat.c
SRCS+= dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c dswload2.c
SRCS+= dswscope.c dswstate.c
SRCS+= evevent.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c evmisc.c
SRCS+= evregion.c evrgnini.c evsci.c evxface.c evxfevnt.c evxfgpe.c evxfregn.c
SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c exfield.c
@ -54,9 +55,9 @@ SRCS+= pswalk.c psxface.c
SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c rsio.c rsirq.c rslist.c
SRCS+= rsmemory.c rsmisc.c rsutils.c rsxface.c
SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c tbxfroot.c
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c uteval.c utglobal.c
SRCS+= utids.c utinit.c utlock.c utmath.c utmisc.c utmutex.c utobject.c
SRCS+= utosi.c utresrc.c utstate.c utxface.c utxferror.c
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdecode.c utdelete.c uteval.c
SRCS+= utglobal.c utids.c utinit.c utlock.c utmath.c utmisc.c utmutex.c
SRCS+= utobject.c utosi.c utresrc.c utstate.c utxface.c utxferror.c
# OSPM layer and core hardware drivers
SRCS+= acpi.c acpi_button.c acpi_isab.c acpi_package.c acpi_pci.c acpi_pcib.c

View File

@ -6,7 +6,8 @@ SRCS+= osunixxf.c
# debugger
SRCS+= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c \
dbinput.c dbstats.c dbutils.c dbxface.c
dbinput.c dbmethod.c dbnames.c dbstats.c dbutils.c \
dbxface.c
# disassembler
SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \
@ -22,9 +23,9 @@ SRCS+= hwacpi.c hwgpe.c hwpci.c hwregs.c hwsleep.c hwvalid.c \
hwxface.c
# interpreter/dispatcher
SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c \
dsopcode.c dsutils.c dswexec.c dswload.c dswscope.c \
dswstate.c
SRCS+= dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c \
dsmthdat.c dsobject.c dsopcode.c dsutils.c dswexec.c \
dswload.c dswload2.c dswscope.c dswstate.c
# interpreter/executer
SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c \
@ -53,10 +54,10 @@ SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c \
tbxfroot.c
# utilities
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
uteval.c utglobal.c utids.c utinit.c utlock.c utmath.c \
utmisc.c utmutex.c utobject.c utosi.c utresrc.c \
utstate.c uttrack.c utxface.c utxferror.c
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdecode.c \
utdelete.c uteval.c utglobal.c utids.c utinit.c \
utlock.c utmath.c utmisc.c utmutex.c utobject.c utosi.c \
utresrc.c utstate.c uttrack.c utxface.c utxferror.c
MAN= acpidb.8
WARNS?= 2

View File

@ -9,16 +9,17 @@ SRCS+= dmextern.c dmrestag.c dmtable.c dmtbdump.c dmtbinfo.c \
getopt.c
# compiler
SRCS+= aslanalyze.c aslcodegen.c aslcompile.c aslcompiler.y.h \
aslcompilerlex.l aslcompilerparse.y aslerror.c \
aslfiles.c aslfold.c asllength.c asllisting.c \
aslload.c asllookup.c aslmain.c aslmap.c aslopcodes.c \
asloperands.c aslopt.c aslpredef.c aslresource.c \
aslrestype1.c aslrestype1i.c aslrestype2.c \
aslrestype2d.c aslrestype2e.c aslrestype2q.c \
aslrestype2w.c aslstartup.c aslstubs.c asltransform.c \
asltree.c aslutils.c asluuid.c dtcompile.c dtfield.c \
dtio.c dtsubtable.c dttable.c dttemplate.c dtutils.c
SRCS+= aslanalyze.c aslbtypes.c aslcodegen.c aslcompile.c \
aslcompiler.y.h aslcompilerlex.l aslcompilerparse.y \
aslerror.c aslfiles.c aslfold.c asllength.c \
asllisting.c aslload.c asllookup.c aslmain.c aslmap.c \
aslopcodes.c asloperands.c aslopt.c aslpredef.c \
aslresource.c aslrestype1.c aslrestype1i.c \
aslrestype2.c aslrestype2d.c aslrestype2e.c \
aslrestype2q.c aslrestype2w.c aslstartup.c aslstubs.c \
asltransform.c asltree.c aslutils.c asluuid.c \
aslwalks.c dtcompile.c dtexpress.c dtfield.c dtio.c \
dtsubtable.c dttable.c dttemplate.c dtutils.c
# debugger
SRCS+= dbfileio.c
@ -28,8 +29,9 @@ SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \
dmresrcl.c dmresrcs.c dmutils.c dmwalk.c
# interpreter/dispatcher
SRCS+= dsfield.c dsobject.c dsopcode.c dsutils.c dswexec.c \
dswload.c dswscope.c dswstate.c
SRCS+= dsargs.c dscontrol.c dsfield.c dsobject.c dsopcode.c \
dsutils.c dswexec.c dswload.c dswload2.c dswscope.c \
dswstate.c
# interpreter/executer
SRCS+= exconvrt.c excreate.c exdump.c exmisc.c exmutex.c \
@ -49,10 +51,10 @@ SRCS+= nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \
SRCS+= tbfadt.c tbinstal.c tbutils.c tbxface.c
# utilities
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
utglobal.c utinit.c utlock.c utmath.c utmisc.c \
utmutex.c utobject.c utosi.c utresrc.c utstate.c \
utxface.c utxferror.c
SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdecode.c \
utdelete.c utglobal.c utinit.c utlock.c utmath.c \
utmisc.c utmutex.c utobject.c utosi.c utresrc.c \
utstate.c utxface.c utxferror.c
WARNS?= 2