mirror of
https://github.com/acpica/acpica/
synced 2025-01-18 15:39:18 +03:00
Prefixed component IDs with "ACPI_"
date 2001.03.07.19.29.00; author rmoore1; state Exp;
This commit is contained in:
parent
ff82fdf81d
commit
bb1d5aae7b
@ -1,6 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* Module Name: psutils - Parser miscellaneous utilities (Parser only)
|
||||
* $Revision: 1.33 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -8,8 +9,8 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
|
||||
* reserved.
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
*
|
||||
@ -37,9 +38,9 @@
|
||||
* The above copyright and patent license is granted only if the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 3. Conditions
|
||||
* 3. Conditions
|
||||
*
|
||||
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
||||
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
||||
* Redistribution of source code of any substantial portion of the Covered
|
||||
* Code or modification with rights to further distribute source must include
|
||||
* the above Copyright Notice, the above License, this list of Conditions,
|
||||
@ -47,11 +48,11 @@
|
||||
* Licensee must cause all Covered Code to which Licensee contributes to
|
||||
* contain a file documenting the changes Licensee made to create that Covered
|
||||
* Code and the date of any change. Licensee must include in that file the
|
||||
* documentation of any changes made by any predecessor Licensee. Licensee
|
||||
* documentation of any changes made by any predecessor Licensee. Licensee
|
||||
* must include a prominent statement that the modification is derived,
|
||||
* directly or indirectly, from Original Intel Code.
|
||||
*
|
||||
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
||||
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
||||
* Redistribution of source code of any substantial portion of the Covered
|
||||
* Code or modification without rights to further distribute source must
|
||||
* include the following Disclaimer and Export Compliance provision in the
|
||||
@ -85,7 +86,7 @@
|
||||
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
||||
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE.
|
||||
* PARTICULAR PURPOSE.
|
||||
*
|
||||
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
||||
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
||||
@ -114,151 +115,197 @@
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#include <acpi.h>
|
||||
#include <parser.h>
|
||||
#include "acpi.h"
|
||||
#include "acparser.h"
|
||||
#include "amlcode.h"
|
||||
|
||||
#define _COMPONENT PARSER
|
||||
MODULE_NAME ("psutils");
|
||||
#define _COMPONENT ACPI_PARSER
|
||||
MODULE_NAME ("psutils")
|
||||
|
||||
|
||||
#define PARSEOP_GENERIC 1
|
||||
#define PARSEOP_NAMED 2
|
||||
#define PARSEOP_DEFERRED 3
|
||||
#define PARSEOP_BYTELIST 4
|
||||
|
||||
#define PARSEOP_GENERIC 0x01
|
||||
#define PARSEOP_NAMED 0x02
|
||||
#define PARSEOP_DEFERRED 0x03
|
||||
#define PARSEOP_BYTELIST 0x04
|
||||
#define PARSEOP_IN_CACHE 0x80
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: PsInitOp
|
||||
* FUNCTION: AcpiPsInitOp
|
||||
*
|
||||
* PARAMETERS: Op - A newly allocated Op object
|
||||
* Opcode - Opcode to store in the Op
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on opcode
|
||||
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
|
||||
* opcode
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
PsInitOp (
|
||||
ACPI_GENERIC_OP *Op,
|
||||
AcpiPsInitOp (
|
||||
ACPI_PARSE_OBJECT *Op,
|
||||
UINT16 Opcode)
|
||||
{
|
||||
ACPI_OP_INFO *AmlOp;
|
||||
ACPI_OPCODE_INFO *AmlOp;
|
||||
|
||||
|
||||
Op->DataType = DESC_TYPE_PARSER;
|
||||
Op->DataType = ACPI_DESC_TYPE_PARSER;
|
||||
Op->Opcode = Opcode;
|
||||
|
||||
AmlOp = AcpiPsGetOpcodeInfo (Opcode);
|
||||
|
||||
AmlOp = PsGetOpcodeInfo (Opcode);
|
||||
if (AmlOp)
|
||||
{
|
||||
/* Debug only! */
|
||||
|
||||
DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name, sizeof (Op->OpName)));
|
||||
}
|
||||
DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name,
|
||||
sizeof (Op->OpName)));
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: PsAllocOp
|
||||
* FUNCTION: AcpiPsAllocOp
|
||||
*
|
||||
* PARAMETERS: Opcode - Opcode that will be stored in the new Op
|
||||
*
|
||||
* RETURN: Pointer to the new Op.
|
||||
*
|
||||
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on opcode
|
||||
* A cache of opcodes is available for the pure GENERIC_OP, since this
|
||||
* is by far the most commonly used.
|
||||
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
|
||||
* opcode. A cache of opcodes is available for the pure
|
||||
* GENERIC_OP, since this is by far the most commonly used.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_GENERIC_OP*
|
||||
PsAllocOp (
|
||||
ACPI_PARSE_OBJECT*
|
||||
AcpiPsAllocOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
ACPI_GENERIC_OP *Op = NULL;
|
||||
ACPI_PARSE_OBJECT *Op = NULL;
|
||||
UINT32 Size;
|
||||
UINT8 Flags;
|
||||
|
||||
|
||||
/* Allocate the minimum required size object */
|
||||
|
||||
if (PsIsDeferredOp (Opcode))
|
||||
if (AcpiPsIsDeferredOp (Opcode))
|
||||
{
|
||||
Size = sizeof (ACPI_DEFERRED_OP);
|
||||
Size = sizeof (ACPI_PARSE2_OBJECT);
|
||||
Flags = PARSEOP_DEFERRED;
|
||||
}
|
||||
|
||||
else if (PsIsNamedOp (Opcode))
|
||||
else if (AcpiPsIsNamedOp (Opcode))
|
||||
{
|
||||
Size = sizeof (ACPI_NAMED_OP);
|
||||
Size = sizeof (ACPI_PARSE2_OBJECT);
|
||||
Flags = PARSEOP_NAMED;
|
||||
}
|
||||
|
||||
else if (PsIsBytelistOp (Opcode))
|
||||
|
||||
else if (AcpiPsIsBytelistOp (Opcode))
|
||||
{
|
||||
Size = sizeof (ACPI_BYTELIST_OP);
|
||||
Size = sizeof (ACPI_PARSE2_OBJECT);
|
||||
Flags = PARSEOP_BYTELIST;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Size = sizeof (ACPI_GENERIC_OP);
|
||||
Size = sizeof (ACPI_PARSE_OBJECT);
|
||||
Flags = PARSEOP_GENERIC;
|
||||
}
|
||||
|
||||
|
||||
if (Size == sizeof (ACPI_PARSE_OBJECT))
|
||||
{
|
||||
/*
|
||||
* The generic op is by far the most common (16 to 1), and therefore the op cache is
|
||||
* implemented with this type.
|
||||
* The generic op is by far the most common (16 to 1), and therefore
|
||||
* the op cache is implemented with this type.
|
||||
*
|
||||
* Check if there is an Op already available in the cache
|
||||
*/
|
||||
|
||||
CmAcquireMutex (MTX_CACHES);
|
||||
Gbl_ParseCacheRequests++;
|
||||
if (Gbl_ParseCache)
|
||||
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
|
||||
AcpiGbl_ParseCacheRequests++;
|
||||
if (AcpiGbl_ParseCache)
|
||||
{
|
||||
/* Extract an op from the front of the cache list */
|
||||
|
||||
Gbl_ParseCacheDepth--;
|
||||
Gbl_ParseCacheHits++;
|
||||
|
||||
Op = Gbl_ParseCache;
|
||||
Gbl_ParseCache = Op->Next;
|
||||
AcpiGbl_ParseCacheDepth--;
|
||||
AcpiGbl_ParseCacheHits++;
|
||||
|
||||
Op = AcpiGbl_ParseCache;
|
||||
AcpiGbl_ParseCache = Op->Next;
|
||||
|
||||
if (Op->DataType == 0xFF)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op));
|
||||
}
|
||||
|
||||
/* Clear the previously used Op */
|
||||
|
||||
MEMSET (Op, 0, sizeof (ACPI_GENERIC_OP));
|
||||
MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT));
|
||||
|
||||
DEBUG_PRINT (TRACE_PARSE,
|
||||
("PsAllocOp: Op %p from Parse Cache\n", Op));
|
||||
}
|
||||
CmReleaseMutex (MTX_CACHES);
|
||||
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/*
|
||||
* The generic op is by far the most common (16 to 1), and therefore
|
||||
* the op cache is implemented with this type.
|
||||
*
|
||||
* Check if there is an Op already available in the cache
|
||||
*/
|
||||
|
||||
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
|
||||
AcpiGbl_ExtParseCacheRequests++;
|
||||
if (AcpiGbl_ExtParseCache)
|
||||
{
|
||||
/* Extract an op from the front of the cache list */
|
||||
|
||||
AcpiGbl_ExtParseCacheDepth--;
|
||||
AcpiGbl_ExtParseCacheHits++;
|
||||
|
||||
Op = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache;
|
||||
AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op->Next;
|
||||
|
||||
if (Op->DataType == 0xFF)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op));
|
||||
}
|
||||
|
||||
/* Clear the previously used Op */
|
||||
|
||||
MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT));
|
||||
|
||||
DEBUG_PRINT (TRACE_PARSE,
|
||||
("PsAllocOp: Op %p from ExtParse Cache\n", Op));
|
||||
}
|
||||
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a new Op if necessary */
|
||||
|
||||
|
||||
if (!Op)
|
||||
{
|
||||
Op = CmCallocate (Size);
|
||||
Op = AcpiCmCallocate (Size);
|
||||
}
|
||||
|
||||
/* Initialize the Op */
|
||||
if (Op)
|
||||
{
|
||||
PsInitOp (Op, Opcode);
|
||||
AcpiPsInitOp (Op, Opcode);
|
||||
Op->Flags = Flags;
|
||||
}
|
||||
|
||||
return Op;
|
||||
return (Op);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: PsFreeOp
|
||||
* FUNCTION: AcpiPsFreeOp
|
||||
*
|
||||
* PARAMETERS: Op - Op to be freed
|
||||
*
|
||||
@ -270,42 +317,76 @@ PsAllocOp (
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
PsFreeOp (
|
||||
ACPI_GENERIC_OP *Op)
|
||||
AcpiPsFreeOp (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
|
||||
|
||||
if (Op->Opcode == AML_RETURN_VALUE_OP)
|
||||
{
|
||||
DEBUG_PRINT (ACPI_INFO, ("Free retval op: %p\n", Op));
|
||||
}
|
||||
|
||||
if (Op->Flags == PARSEOP_GENERIC)
|
||||
{
|
||||
/* Is the cache full? */
|
||||
|
||||
if (Gbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH)
|
||||
if (AcpiGbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH)
|
||||
{
|
||||
/* Put a GENERIC_OP back into the cache */
|
||||
|
||||
CmAcquireMutex (MTX_CACHES);
|
||||
Gbl_ParseCacheDepth++;
|
||||
/* Clear the previously used Op */
|
||||
|
||||
Op->Next = Gbl_ParseCache;
|
||||
Gbl_ParseCache = Op;
|
||||
MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT));
|
||||
Op->Flags = PARSEOP_IN_CACHE;
|
||||
|
||||
CmReleaseMutex (MTX_CACHES);
|
||||
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
|
||||
AcpiGbl_ParseCacheDepth++;
|
||||
|
||||
Op->Next = AcpiGbl_ParseCache;
|
||||
AcpiGbl_ParseCache = Op;
|
||||
|
||||
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Is the cache full? */
|
||||
|
||||
if (AcpiGbl_ExtParseCacheDepth < MAX_EXTPARSE_CACHE_DEPTH)
|
||||
{
|
||||
/* Put a GENERIC_OP back into the cache */
|
||||
|
||||
/* Clear the previously used Op */
|
||||
|
||||
MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT));
|
||||
Op->Flags = PARSEOP_IN_CACHE;
|
||||
|
||||
AcpiCmAcquireMutex (ACPI_MTX_CACHES);
|
||||
AcpiGbl_ExtParseCacheDepth++;
|
||||
|
||||
Op->Next = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache;
|
||||
AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op;
|
||||
|
||||
AcpiCmReleaseMutex (ACPI_MTX_CACHES);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Not a GENERIC OP, or the cache is full, just free the Op
|
||||
* Not a GENERIC OP, or the cache is full, just free the Op
|
||||
*/
|
||||
|
||||
CmFree (Op);
|
||||
AcpiCmFree (Op);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: PsDeleteParseCache
|
||||
* FUNCTION: AcpiPsDeleteParseCache
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
@ -316,10 +397,10 @@ PsFreeOp (
|
||||
******************************************************************************/
|
||||
|
||||
void
|
||||
PsDeleteParseCache (
|
||||
AcpiPsDeleteParseCache (
|
||||
void)
|
||||
{
|
||||
ACPI_GENERIC_OP *Next;
|
||||
ACPI_PARSE_OBJECT *Next;
|
||||
|
||||
|
||||
FUNCTION_TRACE ("PsDeleteParseCache");
|
||||
@ -327,22 +408,32 @@ PsDeleteParseCache (
|
||||
|
||||
/* Traverse the global cache list */
|
||||
|
||||
while (Gbl_ParseCache)
|
||||
while (AcpiGbl_ParseCache)
|
||||
{
|
||||
/* Delete one cached state object */
|
||||
|
||||
Next = Gbl_ParseCache->Next;
|
||||
CmFree (Gbl_ParseCache);
|
||||
Gbl_ParseCache = Next;
|
||||
Next = AcpiGbl_ParseCache->Next;
|
||||
AcpiCmFree (AcpiGbl_ParseCache);
|
||||
AcpiGbl_ParseCache = Next;
|
||||
AcpiGbl_ParseCacheDepth--;
|
||||
}
|
||||
|
||||
/* Traverse the global cache list */
|
||||
|
||||
while (AcpiGbl_ExtParseCache)
|
||||
{
|
||||
/* Delete one cached state object */
|
||||
|
||||
Next = AcpiGbl_ExtParseCache->Next;
|
||||
AcpiCmFree (AcpiGbl_ExtParseCache);
|
||||
AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Next;
|
||||
AcpiGbl_ExtParseCacheDepth--;
|
||||
}
|
||||
|
||||
return_VOID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: Utility functions
|
||||
@ -356,15 +447,14 @@ PsDeleteParseCache (
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Is "c" a namestring lead character?
|
||||
*/
|
||||
|
||||
|
||||
BOOLEAN
|
||||
PsIsLeadingChar (
|
||||
INT32 c)
|
||||
AcpiPsIsLeadingChar (
|
||||
UINT32 c)
|
||||
{
|
||||
return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
|
||||
}
|
||||
@ -374,67 +464,65 @@ PsIsLeadingChar (
|
||||
* Is "c" a namestring prefix character?
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsPrefixChar (
|
||||
INT32 c)
|
||||
AcpiPsIsPrefixChar (
|
||||
UINT32 c)
|
||||
{
|
||||
return ((BOOLEAN) (c == '\\' || c == '^'));
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
PsIsNamespaceObjectOp (
|
||||
AcpiPsIsNamespaceObjectOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_ScopeOp ||
|
||||
Opcode == AML_DeviceOp ||
|
||||
Opcode == AML_ThermalZoneOp ||
|
||||
Opcode == AML_MethodOp ||
|
||||
Opcode == AML_PowerResOp ||
|
||||
Opcode == AML_ProcessorOp ||
|
||||
Opcode == AML_DefFieldOp ||
|
||||
Opcode == AML_IndexFieldOp ||
|
||||
Opcode == AML_BankFieldOp ||
|
||||
Opcode == AML_NAMEDFIELD_OP ||
|
||||
Opcode == AML_NameOp ||
|
||||
Opcode == AML_AliasOp ||
|
||||
Opcode == AML_MutexOp ||
|
||||
Opcode == AML_EventOp ||
|
||||
Opcode == AML_RegionOp ||
|
||||
Opcode == AML_CreateFieldOp ||
|
||||
Opcode == AML_BitFieldOp ||
|
||||
Opcode == AML_ByteFieldOp ||
|
||||
Opcode == AML_WordFieldOp ||
|
||||
Opcode == AML_DWordFieldOp ||
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_SCOPE_OP ||
|
||||
Opcode == AML_DEVICE_OP ||
|
||||
Opcode == AML_THERMAL_ZONE_OP ||
|
||||
Opcode == AML_METHOD_OP ||
|
||||
Opcode == AML_POWER_RES_OP ||
|
||||
Opcode == AML_PROCESSOR_OP ||
|
||||
Opcode == AML_DEF_FIELD_OP ||
|
||||
Opcode == AML_INDEX_FIELD_OP ||
|
||||
Opcode == AML_BANK_FIELD_OP ||
|
||||
Opcode == AML_NAMEDFIELD_OP ||
|
||||
Opcode == AML_NAME_OP ||
|
||||
Opcode == AML_ALIAS_OP ||
|
||||
Opcode == AML_MUTEX_OP ||
|
||||
Opcode == AML_EVENT_OP ||
|
||||
Opcode == AML_REGION_OP ||
|
||||
Opcode == AML_CREATE_FIELD_OP ||
|
||||
Opcode == AML_BIT_FIELD_OP ||
|
||||
Opcode == AML_BYTE_FIELD_OP ||
|
||||
Opcode == AML_WORD_FIELD_OP ||
|
||||
Opcode == AML_DWORD_FIELD_OP ||
|
||||
Opcode == AML_METHODCALL_OP ||
|
||||
Opcode == AML_NAMEPATH_OP));
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
PsIsNamespaceOp (
|
||||
AcpiPsIsNamespaceOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_ScopeOp ||
|
||||
Opcode == AML_DeviceOp ||
|
||||
Opcode == AML_ThermalZoneOp ||
|
||||
Opcode == AML_MethodOp ||
|
||||
Opcode == AML_PowerResOp ||
|
||||
Opcode == AML_ProcessorOp ||
|
||||
Opcode == AML_DefFieldOp ||
|
||||
Opcode == AML_IndexFieldOp ||
|
||||
Opcode == AML_BankFieldOp ||
|
||||
Opcode == AML_NameOp ||
|
||||
Opcode == AML_AliasOp ||
|
||||
Opcode == AML_MutexOp ||
|
||||
Opcode == AML_EventOp ||
|
||||
Opcode == AML_RegionOp ||
|
||||
Opcode == AML_NAMEDFIELD_OP));
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_SCOPE_OP ||
|
||||
Opcode == AML_DEVICE_OP ||
|
||||
Opcode == AML_THERMAL_ZONE_OP ||
|
||||
Opcode == AML_METHOD_OP ||
|
||||
Opcode == AML_POWER_RES_OP ||
|
||||
Opcode == AML_PROCESSOR_OP ||
|
||||
Opcode == AML_DEF_FIELD_OP ||
|
||||
Opcode == AML_INDEX_FIELD_OP ||
|
||||
Opcode == AML_BANK_FIELD_OP ||
|
||||
Opcode == AML_NAME_OP ||
|
||||
Opcode == AML_ALIAS_OP ||
|
||||
Opcode == AML_MUTEX_OP ||
|
||||
Opcode == AML_EVENT_OP ||
|
||||
Opcode == AML_REGION_OP ||
|
||||
Opcode == AML_NAMEDFIELD_OP));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Is opcode for a named object Op?
|
||||
* (Includes all named object opcodes)
|
||||
@ -442,29 +530,29 @@ PsIsNamespaceOp (
|
||||
* TBD: [Restructure] Need a better way than this brute force approach!
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsNamedObjectOp (
|
||||
AcpiPsIsNodeOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_ScopeOp ||
|
||||
Opcode == AML_DeviceOp ||
|
||||
Opcode == AML_ThermalZoneOp ||
|
||||
Opcode == AML_MethodOp ||
|
||||
Opcode == AML_PowerResOp ||
|
||||
Opcode == AML_ProcessorOp ||
|
||||
Opcode == AML_NAMEDFIELD_OP ||
|
||||
Opcode == AML_NameOp ||
|
||||
Opcode == AML_AliasOp ||
|
||||
Opcode == AML_MutexOp ||
|
||||
Opcode == AML_EventOp ||
|
||||
Opcode == AML_RegionOp ||
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_SCOPE_OP ||
|
||||
Opcode == AML_DEVICE_OP ||
|
||||
Opcode == AML_THERMAL_ZONE_OP ||
|
||||
Opcode == AML_METHOD_OP ||
|
||||
Opcode == AML_POWER_RES_OP ||
|
||||
Opcode == AML_PROCESSOR_OP ||
|
||||
Opcode == AML_NAMEDFIELD_OP ||
|
||||
Opcode == AML_NAME_OP ||
|
||||
Opcode == AML_ALIAS_OP ||
|
||||
Opcode == AML_MUTEX_OP ||
|
||||
Opcode == AML_EVENT_OP ||
|
||||
Opcode == AML_REGION_OP ||
|
||||
|
||||
|
||||
Opcode == AML_CreateFieldOp ||
|
||||
Opcode == AML_BitFieldOp ||
|
||||
Opcode == AML_ByteFieldOp ||
|
||||
Opcode == AML_WordFieldOp ||
|
||||
Opcode == AML_DWordFieldOp ||
|
||||
Opcode == AML_CREATE_FIELD_OP ||
|
||||
Opcode == AML_BIT_FIELD_OP ||
|
||||
Opcode == AML_BYTE_FIELD_OP ||
|
||||
Opcode == AML_WORD_FIELD_OP ||
|
||||
Opcode == AML_DWORD_FIELD_OP ||
|
||||
Opcode == AML_METHODCALL_OP ||
|
||||
Opcode == AML_NAMEPATH_OP));
|
||||
}
|
||||
@ -474,32 +562,37 @@ PsIsNamedObjectOp (
|
||||
* Is opcode for a named Op?
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsNamedOp (
|
||||
AcpiPsIsNamedOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_ScopeOp ||
|
||||
Opcode == AML_DeviceOp ||
|
||||
Opcode == AML_ThermalZoneOp ||
|
||||
Opcode == AML_MethodOp ||
|
||||
Opcode == AML_PowerResOp ||
|
||||
Opcode == AML_ProcessorOp ||
|
||||
Opcode == AML_NameOp ||
|
||||
Opcode == AML_AliasOp ||
|
||||
Opcode == AML_MutexOp ||
|
||||
Opcode == AML_EventOp ||
|
||||
Opcode == AML_RegionOp ||
|
||||
Opcode == AML_NAMEDFIELD_OP));
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_SCOPE_OP ||
|
||||
Opcode == AML_DEVICE_OP ||
|
||||
Opcode == AML_THERMAL_ZONE_OP ||
|
||||
Opcode == AML_METHOD_OP ||
|
||||
Opcode == AML_POWER_RES_OP ||
|
||||
Opcode == AML_PROCESSOR_OP ||
|
||||
Opcode == AML_NAME_OP ||
|
||||
Opcode == AML_ALIAS_OP ||
|
||||
Opcode == AML_MUTEX_OP ||
|
||||
Opcode == AML_EVENT_OP ||
|
||||
Opcode == AML_REGION_OP ||
|
||||
Opcode == AML_NAMEDFIELD_OP));
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
PsIsDeferredOp (
|
||||
AcpiPsIsDeferredOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_MethodOp ||
|
||||
Opcode == AML_RegionOp));
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_METHOD_OP ||
|
||||
Opcode == AML_CREATE_FIELD_OP ||
|
||||
Opcode == AML_BIT_FIELD_OP ||
|
||||
Opcode == AML_BYTE_FIELD_OP ||
|
||||
Opcode == AML_WORD_FIELD_OP ||
|
||||
Opcode == AML_DWORD_FIELD_OP ||
|
||||
Opcode == AML_REGION_OP));
|
||||
}
|
||||
|
||||
|
||||
@ -507,7 +600,7 @@ PsIsDeferredOp (
|
||||
* Is opcode for a bytelist?
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsBytelistOp (
|
||||
AcpiPsIsBytelistOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN) (Opcode == AML_BYTELIST_OP));
|
||||
@ -518,14 +611,14 @@ PsIsBytelistOp (
|
||||
* Is opcode for a Field, IndexField, or BankField
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsFieldOp (
|
||||
AcpiPsIsFieldOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_CreateFieldOp
|
||||
|| Opcode == AML_DefFieldOp
|
||||
|| Opcode == AML_IndexFieldOp
|
||||
|| Opcode == AML_BankFieldOp));
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_CREATE_FIELD_OP
|
||||
|| Opcode == AML_DEF_FIELD_OP
|
||||
|| Opcode == AML_INDEX_FIELD_OP
|
||||
|| Opcode == AML_BANK_FIELD_OP));
|
||||
}
|
||||
|
||||
|
||||
@ -533,52 +626,29 @@ PsIsFieldOp (
|
||||
* Is field creation op
|
||||
*/
|
||||
BOOLEAN
|
||||
PsIsCreateFieldOp (
|
||||
AcpiPsIsCreateFieldOp (
|
||||
UINT16 Opcode)
|
||||
{
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_CreateFieldOp ||
|
||||
Opcode == AML_BitFieldOp ||
|
||||
Opcode == AML_ByteFieldOp ||
|
||||
Opcode == AML_WordFieldOp ||
|
||||
Opcode == AML_DWordFieldOp));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Cast an acpi_op to an acpi_deferred_op if possible
|
||||
*/
|
||||
ACPI_DEFERRED_OP *
|
||||
PsToDeferredOp (
|
||||
ACPI_GENERIC_OP *Op)
|
||||
{
|
||||
return (PsIsDeferredOp (Op->Opcode)
|
||||
? ( (ACPI_DEFERRED_OP *) Op) : NULL);
|
||||
return ((BOOLEAN)
|
||||
(Opcode == AML_CREATE_FIELD_OP ||
|
||||
Opcode == AML_BIT_FIELD_OP ||
|
||||
Opcode == AML_BYTE_FIELD_OP ||
|
||||
Opcode == AML_WORD_FIELD_OP ||
|
||||
Opcode == AML_DWORD_FIELD_OP));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cast an acpi_op to an acpi_named_op if possible
|
||||
* Cast an acpi_op to an acpi_extended_op if possible
|
||||
*/
|
||||
ACPI_NAMED_OP*
|
||||
PsToNamedOp (
|
||||
ACPI_GENERIC_OP *Op)
|
||||
{
|
||||
return (PsIsNamedOp (Op->Opcode)
|
||||
? ( (ACPI_NAMED_OP *) Op) : NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cast an acpi_op to an acpi_bytelist_op if possible
|
||||
*/
|
||||
ACPI_BYTELIST_OP*
|
||||
PsToBytelistOp (
|
||||
ACPI_GENERIC_OP *Op)
|
||||
/* TBD: This is very inefficient, fix */
|
||||
ACPI_PARSE2_OBJECT *
|
||||
AcpiPsToExtendedOp (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
return (PsIsBytelistOp (Op->Opcode)
|
||||
? ( (ACPI_BYTELIST_OP*) Op) : NULL);
|
||||
return ((AcpiPsIsDeferredOp (Op->Opcode) || AcpiPsIsNamedOp (Op->Opcode) || AcpiPsIsBytelistOp (Op->Opcode))
|
||||
? ( (ACPI_PARSE2_OBJECT *) Op) : NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -586,10 +656,10 @@ PsToBytelistOp (
|
||||
* Get op's name (4-byte name segment) or 0 if unnamed
|
||||
*/
|
||||
UINT32
|
||||
PsGetName (
|
||||
ACPI_GENERIC_OP *Op)
|
||||
AcpiPsGetName (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
ACPI_NAMED_OP *Named = PsToNamedOp (Op);
|
||||
ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op);
|
||||
|
||||
return (Named ? Named->Name : 0);
|
||||
}
|
||||
@ -599,11 +669,11 @@ PsGetName (
|
||||
* Set op's name
|
||||
*/
|
||||
void
|
||||
PsSetName (
|
||||
ACPI_GENERIC_OP *Op,
|
||||
AcpiPsSetName (
|
||||
ACPI_PARSE_OBJECT *Op,
|
||||
UINT32 name)
|
||||
{
|
||||
ACPI_NAMED_OP *Named = PsToNamedOp (Op);
|
||||
ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op);
|
||||
|
||||
if (Named)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: pswalk - Parser routines to walk parsed op tree(s)
|
||||
* $Revision: 1.75 $
|
||||
* $Revision: 1.54 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -116,10 +116,206 @@
|
||||
|
||||
|
||||
#include "acpi.h"
|
||||
#include "amlcode.h"
|
||||
#include "acparser.h"
|
||||
#include "acdispat.h"
|
||||
#include "acnamesp.h"
|
||||
#include "acinterp.h"
|
||||
|
||||
#define _COMPONENT ACPI_PARSER
|
||||
ACPI_MODULE_NAME ("pswalk")
|
||||
MODULE_NAME ("pswalk")
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiPsGetNextWalkOp
|
||||
*
|
||||
* PARAMETERS: WalkState - Current state of the walk
|
||||
* Op - Current Op to be walked
|
||||
* AscendingCallback - Procedure called when Op is complete
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Get the next Op in a walk of the parse tree.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiPsGetNextWalkOp (
|
||||
ACPI_WALK_STATE *WalkState,
|
||||
ACPI_PARSE_OBJECT *Op,
|
||||
ACPI_PARSE_UPWARDS AscendingCallback)
|
||||
{
|
||||
ACPI_PARSE_OBJECT *Next;
|
||||
ACPI_PARSE_OBJECT *Parent;
|
||||
ACPI_PARSE_OBJECT *GrandParent;
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op);
|
||||
|
||||
|
||||
/* Check for a argument only if we are descending in the tree */
|
||||
|
||||
if (WalkState->NextOpInfo != NEXT_OP_UPWARD)
|
||||
{
|
||||
/* Look for an argument or child of the current op */
|
||||
|
||||
Next = AcpiPsGetArg (Op, 0);
|
||||
if (Next)
|
||||
{
|
||||
/* Still going downward in tree (Op is not completed yet) */
|
||||
|
||||
WalkState->PrevOp = Op;
|
||||
WalkState->NextOp = Next;
|
||||
WalkState->NextOpInfo = NEXT_OP_DOWNWARD;
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* No more children, this Op is complete. Save Next and Parent
|
||||
* in case the Op object gets deleted by the callback routine
|
||||
*/
|
||||
|
||||
Next = Op->Next;
|
||||
Parent = Op->Parent;
|
||||
|
||||
Status = AscendingCallback (WalkState, Op);
|
||||
|
||||
/*
|
||||
* If we are back to the starting point, the walk is complete.
|
||||
*/
|
||||
if (Op == WalkState->Origin)
|
||||
{
|
||||
/* Reached the point of origin, the walk is complete */
|
||||
|
||||
WalkState->PrevOp = Op;
|
||||
WalkState->NextOp = NULL;
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a sibling to the current op. A sibling means
|
||||
* we are still going "downward" in the tree.
|
||||
*/
|
||||
|
||||
if (Next)
|
||||
{
|
||||
/* There is a sibling, it will be next */
|
||||
|
||||
WalkState->PrevOp = Op;
|
||||
WalkState->NextOp = Next;
|
||||
WalkState->NextOpInfo = NEXT_OP_DOWNWARD;
|
||||
|
||||
/* Continue downward */
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Drop into the loop below because we are moving upwards in
|
||||
* the tree
|
||||
*/
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We are resuming a walk, and we were (are) going upward in the tree.
|
||||
* So, we want to drop into the parent loop below.
|
||||
*/
|
||||
|
||||
Parent = Op;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Look for a sibling of the current Op's parent
|
||||
* Continue moving up the tree until we find a node that has not been
|
||||
* visited, or we get back to where we started.
|
||||
*/
|
||||
while (Parent)
|
||||
{
|
||||
/* We are moving up the tree, therefore this parent Op is complete */
|
||||
|
||||
GrandParent = Parent->Parent;
|
||||
Next = Parent->Next;
|
||||
|
||||
Status = AscendingCallback (WalkState, Parent);
|
||||
|
||||
/*
|
||||
* If we are back to the starting point, the walk is complete.
|
||||
*/
|
||||
if (Parent == WalkState->Origin)
|
||||
{
|
||||
/* Reached the point of origin, the walk is complete */
|
||||
|
||||
WalkState->PrevOp = Parent;
|
||||
WalkState->NextOp = NULL;
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is a sibling to this parent (it is not the starting point
|
||||
* Op), then we will visit it.
|
||||
*/
|
||||
if (Next)
|
||||
{
|
||||
/* found sibling of parent */
|
||||
|
||||
WalkState->PrevOp = Parent;
|
||||
WalkState->NextOp = Next;
|
||||
WalkState->NextOpInfo = NEXT_OP_DOWNWARD;
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/* No siblings, no errors, just move up one more level in the tree */
|
||||
|
||||
Op = Parent;
|
||||
Parent = GrandParent;
|
||||
WalkState->PrevOp = Op;
|
||||
}
|
||||
|
||||
|
||||
/* Got all the way to the top of the tree, we must be done! */
|
||||
/* However, the code should have terminated in the loop above */
|
||||
|
||||
WalkState->NextOp = NULL;
|
||||
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiPsDeleteCompletedOp
|
||||
*
|
||||
* PARAMETERS: State - Walk state
|
||||
* Op - Completed op
|
||||
*
|
||||
* RETURN: AE_OK
|
||||
*
|
||||
* DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during
|
||||
* AcpiPsDeleteParse tree to delete Op objects when all sub-objects
|
||||
* have been visited (and deleted.)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static ACPI_STATUS
|
||||
AcpiPsDeleteCompletedOp (
|
||||
ACPI_WALK_STATE *State,
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
|
||||
AcpiPsFreeOp (Op);
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -138,56 +334,58 @@ void
|
||||
AcpiPsDeleteParseTree (
|
||||
ACPI_PARSE_OBJECT *SubtreeRoot)
|
||||
{
|
||||
ACPI_PARSE_OBJECT *Op = SubtreeRoot;
|
||||
ACPI_PARSE_OBJECT *Next = NULL;
|
||||
ACPI_PARSE_OBJECT *Parent = NULL;
|
||||
ACPI_WALK_STATE *WalkState;
|
||||
ACPI_WALK_LIST WalkList;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot);
|
||||
FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot);
|
||||
|
||||
|
||||
if (!SubtreeRoot)
|
||||
{
|
||||
return_VOID;
|
||||
}
|
||||
|
||||
/* Create and initialize a new walk list */
|
||||
|
||||
WalkList.WalkState = NULL;
|
||||
WalkList.AcquiredMutexList.Prev = NULL;
|
||||
WalkList.AcquiredMutexList.Next = NULL;
|
||||
|
||||
WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList);
|
||||
if (!WalkState)
|
||||
{
|
||||
return_VOID;
|
||||
}
|
||||
|
||||
WalkState->ParserState = NULL;
|
||||
WalkState->ParseFlags = 0;
|
||||
WalkState->DescendingCallback = NULL;
|
||||
WalkState->AscendingCallback = NULL;
|
||||
|
||||
|
||||
WalkState->Origin = SubtreeRoot;
|
||||
WalkState->NextOp = SubtreeRoot;
|
||||
|
||||
|
||||
/* Head downward in the tree */
|
||||
|
||||
WalkState->NextOpInfo = NEXT_OP_DOWNWARD;
|
||||
|
||||
/* Visit all nodes in the subtree */
|
||||
|
||||
while (Op)
|
||||
while (WalkState->NextOp)
|
||||
{
|
||||
/* Check if we are not ascending */
|
||||
|
||||
if (Op != Parent)
|
||||
{
|
||||
/* Look for an argument or child of the current op */
|
||||
|
||||
Next = AcpiPsGetArg (Op, 0);
|
||||
if (Next)
|
||||
{
|
||||
/* Still going downward in tree (Op is not completed yet) */
|
||||
|
||||
Op = Next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* No more children, this Op is complete. */
|
||||
|
||||
Next = Op->Common.Next;
|
||||
Parent = Op->Common.Parent;
|
||||
|
||||
AcpiPsFreeOp (Op);
|
||||
|
||||
/* If we are back to the starting point, the walk is complete. */
|
||||
|
||||
if (Op == SubtreeRoot)
|
||||
{
|
||||
return_VOID;
|
||||
}
|
||||
if (Next)
|
||||
{
|
||||
Op = Next;
|
||||
}
|
||||
else
|
||||
{
|
||||
Op = Parent;
|
||||
}
|
||||
AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp,
|
||||
AcpiPsDeleteCompletedOp);
|
||||
}
|
||||
|
||||
/* We are done with this walk */
|
||||
|
||||
AcpiAmlReleaseAllMutexes ((ACPI_OPERAND_OBJECT *) &WalkList.AcquiredMutexList);
|
||||
AcpiDsDeleteWalkState (WalkState);
|
||||
|
||||
return_VOID;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: psxface - Parser external interfaces
|
||||
* $Revision: 1.78 $
|
||||
* $Revision: 1.42 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -120,56 +120,55 @@
|
||||
#include "acparser.h"
|
||||
#include "acdispat.h"
|
||||
#include "acinterp.h"
|
||||
#include "amlcode.h"
|
||||
#include "acnamesp.h"
|
||||
|
||||
|
||||
#define _COMPONENT ACPI_PARSER
|
||||
ACPI_MODULE_NAME ("psxface")
|
||||
MODULE_NAME ("psxface")
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
/*****************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiPsxExecute
|
||||
*
|
||||
* PARAMETERS: Info - Method info block, contains:
|
||||
* Node - Method Node to execute
|
||||
* Parameters - List of parameters to pass to the method,
|
||||
* PARAMETERS: MethodNode - A method object containing both the AML
|
||||
* address and length.
|
||||
* **Params - List of parameters to pass to method,
|
||||
* terminated by NULL. Params itself may be
|
||||
* NULL if no parameters are being passed.
|
||||
* ReturnObject - Where to put method's return value (if
|
||||
* any). If NULL, no value is returned.
|
||||
* ParameterType - Type of Parameter list
|
||||
* ReturnObject - Where to put method's return value (if
|
||||
* any). If NULL, no value is returned.
|
||||
* **ReturnObjDesc - Return object from execution of the
|
||||
* method.
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Execute a control method
|
||||
*
|
||||
******************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiPsxExecute (
|
||||
ACPI_PARAMETER_INFO *Info)
|
||||
ACPI_NAMESPACE_NODE *MethodNode,
|
||||
ACPI_OPERAND_OBJECT **Params,
|
||||
ACPI_OPERAND_OBJECT **ReturnObjDesc)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_OPERAND_OBJECT *ObjDesc;
|
||||
UINT32 i;
|
||||
ACPI_PARSE_OBJECT *Op;
|
||||
ACPI_WALK_STATE *WalkState;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE ("PsxExecute");
|
||||
FUNCTION_TRACE ("PsxExecute");
|
||||
|
||||
|
||||
/* Validate the Node and get the attached object */
|
||||
|
||||
if (!Info || !Info->Node)
|
||||
if (!MethodNode)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NULL_ENTRY);
|
||||
}
|
||||
|
||||
ObjDesc = AcpiNsGetAttachedObject (Info->Node);
|
||||
ObjDesc = AcpiNsGetAttachedObject (MethodNode);
|
||||
if (!ObjDesc)
|
||||
{
|
||||
return_ACPI_STATUS (AE_NULL_OBJECT);
|
||||
@ -177,159 +176,100 @@ AcpiPsxExecute (
|
||||
|
||||
/* Init for new method, wait on concurrency semaphore */
|
||||
|
||||
Status = AcpiDsBeginMethodExecution (Info->Node, ObjDesc, NULL);
|
||||
Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
if ((Info->ParameterType == ACPI_PARAM_ARGS) &&
|
||||
(Info->Parameters))
|
||||
if (Params)
|
||||
{
|
||||
/*
|
||||
* The caller "owns" the parameters, so give each one an extra
|
||||
* reference
|
||||
*/
|
||||
for (i = 0; Info->Parameters[i]; i++)
|
||||
|
||||
for (i = 0; Params[i]; i++)
|
||||
{
|
||||
AcpiUtAddReference (Info->Parameters[i]);
|
||||
AcpiCmAddReference (Params[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 1) Perform the first pass parse of the method to enter any
|
||||
* Perform the first pass parse of the method to enter any
|
||||
* named objects that it creates into the namespace
|
||||
*/
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
||||
"**** Begin Method Parse **** Entry=%p obj=%p\n",
|
||||
Info->Node, ObjDesc));
|
||||
|
||||
DEBUG_PRINT (ACPI_INFO,
|
||||
("PsxExecute: **** Begin Method Execution **** Entry=%p obj=%p\n",
|
||||
MethodNode, ObjDesc));
|
||||
|
||||
/* Create and init a Root Node */
|
||||
|
||||
Op = AcpiPsCreateScopeOp ();
|
||||
Op = AcpiPsAllocOp (AML_SCOPE_OP);
|
||||
if (!Op)
|
||||
{
|
||||
Status = AE_NO_MEMORY;
|
||||
goto Cleanup1;
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a new OwnerId for objects created by this method. Namespace
|
||||
* objects (such as Operation Regions) can be created during the
|
||||
* first pass parse.
|
||||
*/
|
||||
ObjDesc->Method.OwningId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD);
|
||||
|
||||
/* Create and initialize a new walk state */
|
||||
|
||||
WalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId,
|
||||
NULL, NULL, NULL);
|
||||
if (!WalkState)
|
||||
{
|
||||
Status = AE_NO_MEMORY;
|
||||
goto Cleanup2;
|
||||
}
|
||||
|
||||
Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
|
||||
ObjDesc->Method.AmlStart,
|
||||
ObjDesc->Method.AmlLength, NULL, 1);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
goto Cleanup3;
|
||||
}
|
||||
|
||||
/* Parse the AML */
|
||||
|
||||
Status = AcpiPsParseAml (WalkState);
|
||||
Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode,
|
||||
ObjDesc->Method.PcodeLength,
|
||||
ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE,
|
||||
MethodNode, Params, ReturnObjDesc,
|
||||
AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp);
|
||||
AcpiPsDeleteParseTree (Op);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
goto Cleanup1; /* Walk state is already deleted */
|
||||
}
|
||||
|
||||
/*
|
||||
* 2) Execute the method. Performs second pass parse simultaneously
|
||||
*/
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
||||
"**** Begin Method Execution **** Entry=%p obj=%p\n",
|
||||
Info->Node, ObjDesc));
|
||||
|
||||
/* Create and init a Root Node */
|
||||
|
||||
Op = AcpiPsCreateScopeOp ();
|
||||
Op = AcpiPsAllocOp (AML_SCOPE_OP);
|
||||
if (!Op)
|
||||
{
|
||||
Status = AE_NO_MEMORY;
|
||||
goto Cleanup1;
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
|
||||
/* Init new op with the method name and pointer back to the NS node */
|
||||
|
||||
AcpiPsSetName (Op, Info->Node->Name.Integer);
|
||||
Op->Common.Node = Info->Node;
|
||||
AcpiPsSetName (Op, MethodNode->Name);
|
||||
Op->Node = MethodNode;
|
||||
|
||||
/* Create and initialize a new walk state */
|
||||
|
||||
WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
|
||||
if (!WalkState)
|
||||
{
|
||||
Status = AE_NO_MEMORY;
|
||||
goto Cleanup2;
|
||||
}
|
||||
|
||||
Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
|
||||
ObjDesc->Method.AmlStart,
|
||||
ObjDesc->Method.AmlLength, Info, 3);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
goto Cleanup3;
|
||||
}
|
||||
|
||||
/* The walk of the parse tree is where we actually execute the method */
|
||||
|
||||
Status = AcpiPsParseAml (WalkState);
|
||||
goto Cleanup2; /* Walk state already deleted */
|
||||
|
||||
|
||||
Cleanup3:
|
||||
AcpiDsDeleteWalkState (WalkState);
|
||||
|
||||
Cleanup2:
|
||||
/*
|
||||
* The walk of the parse tree is where we actually execute the method
|
||||
*/
|
||||
Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode,
|
||||
ObjDesc->Method.PcodeLength,
|
||||
ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE,
|
||||
MethodNode, Params, ReturnObjDesc,
|
||||
AcpiDsExecBeginOp, AcpiDsExecEndOp);
|
||||
AcpiPsDeleteParseTree (Op);
|
||||
|
||||
Cleanup1:
|
||||
if ((Info->ParameterType == ACPI_PARAM_ARGS) &&
|
||||
(Info->Parameters))
|
||||
if (Params)
|
||||
{
|
||||
/* Take away the extra reference that we gave the parameters above */
|
||||
|
||||
for (i = 0; Info->Parameters[i]; i++)
|
||||
for (i = 0; Params[i]; i++)
|
||||
{
|
||||
/* Ignore errors, just do them all */
|
||||
|
||||
(void) AcpiUtUpdateObjectReference (
|
||||
Info->Parameters[i], REF_DECREMENT);
|
||||
AcpiCmUpdateObjectReference (Params[i], REF_DECREMENT);
|
||||
}
|
||||
}
|
||||
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the method has returned an object, signal this to the caller with
|
||||
* a control exception code
|
||||
* Normal exit is with Status == AE_RETURN_VALUE when a ReturnOp has been
|
||||
* executed, or with Status == AE_PENDING at end of AML block (end of
|
||||
* Method code)
|
||||
*/
|
||||
if (Info->ReturnObject)
|
||||
|
||||
if (*ReturnObjDesc)
|
||||
{
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
|
||||
Info->ReturnObject));
|
||||
ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
|
||||
DEBUG_PRINT (ACPI_INFO, ("Method returned ObjDesc=%X\n",
|
||||
*ReturnObjDesc));
|
||||
DUMP_STACK_ENTRY (*ReturnObjDesc);
|
||||
|
||||
Status = AE_CTRL_RETURN_VALUE;
|
||||
}
|
||||
|
||||
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user