/******************************************************************************
*
* Module Name: dsfield - Dispatcher field routines
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, 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 "acpi.h"
#include "accommon.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acparser.h"
ACPI_MODULE_NAME ("dsfield")
/* Local prototypes */
#ifdef ACPI_ASL_COMPILER
#include "acdisasm.h"
static ACPI_STATUS
char *Path,
#endif
static ACPI_STATUS
#ifdef ACPI_ASL_COMPILER
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateExternalRegion (iASL Disassembler only)
*
* PARAMETERS: LookupStatus - Status from NsLookup operation
* Op - Op containing the Field definition and args
* Path - Pathname of the region
* ` WalkState - Current method state
* Node - Where the new region node is returned
*
* RETURN: Status
*
* DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
*
******************************************************************************/
static ACPI_STATUS
char *Path,
{
if (LookupStatus != AE_NOT_FOUND)
{
return (LookupStatus);
}
/*
* Table disassembly:
* OperationRegion not found. Generate an External for it, and
* insert the name into the namespace.
*/
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Must create and install a region object for the new node */
if (!ObjDesc)
{
return (AE_NO_MEMORY);
}
return (Status);
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateBufferField
*
* PARAMETERS: Op - Current parse op (CreateXXField)
* WalkState - Current state
*
* RETURN: Status
*
* DESCRIPTION: Execute the CreateField operators:
* CreateBitFieldOp,
* CreateByteFieldOp,
* CreateWordFieldOp,
* CreateDwordFieldOp,
* CreateQwordFieldOp,
* CreateFieldOp (all of which define a field in a buffer)
*
******************************************************************************/
{
/*
* Get the NameString argument (name of the new BufferField)
*/
{
/* For CreateField, name is the 4th argument */
}
else
{
/* For all other CreateXXXField operators, name is the 3rd argument */
}
if (!Arg)
{
}
if (WalkState->DeferredNode)
{
}
else
{
/* Execute flag should always be set when this function is entered */
{
}
/* Creating new namespace node, should not already exist */
/*
* Mark node temporary if we are executing a normal control
* method. (Don't mark if this is a module-level code method)
*/
if (WalkState->MethodNode &&
{
}
/* Enter the NameString into the namespace */
if (ACPI_FAILURE (Status))
{
}
}
/*
* 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.
*/
/*
* If there is no object attached to the node, this node was just created
* and we need to create the field object. Otherwise, this was a lookup
* of an existing node and we don't want to create the field object again.
*/
if (ObjDesc)
{
}
/*
* The Field definition is not fully parsed at this time.
* (We must save the address of the AML for the buffer and index operands)
*/
/* Create the buffer field object */
if (!ObjDesc)
{
goto Cleanup;
}
/*
* Remember location in AML stream of the field unit opcode and operands
* -- since the buffer and index operands must be evaluated.
*/
/* Attach constructed field descriptors to parent node */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Remove local reference to the object */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsGetFieldNames
*
* PARAMETERS: Info - CreateField info structure
* ` WalkState - Current method state
* Arg - First parser arg for the field name list
*
* RETURN: Status
*
* DESCRIPTION: Process all named fields in a field declaration. Names are
* entered into the namespace.
*
******************************************************************************/
static ACPI_STATUS
{
/* First field starts at bit zero */
Info->FieldBitPosition = 0;
/* Process all elements in the field list (of parse nodes) */
while (Arg)
{
/*
* Four types of field elements are handled:
* 1) Name - Enters a new named field into the namespace
* 2) Offset - specifies a bit offset
* 3) AccessAs - changes the access mode/attributes
* 4) Connection - Associate a resource template with the field
*/
{
case AML_INT_RESERVEDFIELD_OP:
if (Position > ACPI_UINT32_MAX)
{
"Bit offset within field too large (> 0xFFFFFFFF)"));
}
break;
case AML_INT_ACCESSFIELD_OP:
/*
* Get new AccessType, AccessAttribute, and AccessLength fields
* -- to be used for all field units that follow, until the
* end-of-field or another AccessAs keyword is encountered.
* NOTE. These three bytes are encoded in the integer value
* of the parseop for convenience.
*
* In FieldFlags, preserve the flag bits other than the
* ACCESS_TYPE bits.
*/
/* AccessType (ByteAcc, WordAcc, etc.) */
/* AccessAttribute (AttribQuick, AttribByte, etc.) */
break;
case AML_INT_CONNECTION_OP:
/*
* Clear any previous connection. New connection is used for all
* fields that follow, similar to AccessAs
*/
Info->PinNumberIndex = 0;
/*
* A Connection() is either an actual resource descriptor (buffer)
* or a named reference to a resource template
*/
{
}
else
{
/* Lookup the Connection() namepath, it should already exist */
if (ACPI_FAILURE (Status))
{
}
}
break;
case AML_INT_NAMEDFIELD_OP:
/* Lookup the name, it should already exist */
if (ACPI_FAILURE (Status))
{
}
else
{
/*
* If there is no object attached to the node, this node was
* just created and we need to create the field object.
* Otherwise, this was a lookup of an existing node and we
* don't want to create the field object again.
*/
{
if (ACPI_FAILURE (Status))
{
}
}
}
/* Keep track of bit position for the next field */
if (Position > ACPI_UINT32_MAX)
{
"Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
}
break;
default:
"Invalid opcode in field list: 0x%X",
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateField
*
* PARAMETERS: Op - Op containing the Field definition and args
* RegionNode - Object for the containing Operation Region
* ` WalkState - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new field in the specified operation region
*
******************************************************************************/
{
/* First arg is the name of the parent OpRegion (must already exist) */
if (!RegionNode)
{
#ifdef ACPI_ASL_COMPILER
#endif
if (ACPI_FAILURE (Status))
{
}
}
/* Second arg is the field flags */
/* Each remaining arg is a Named Field */
}
/*******************************************************************************
*
* FUNCTION: AcpiDsInitFieldObjects
*
* PARAMETERS: Op - Op containing the Field definition and args
* ` WalkState - Current method state
*
* RETURN: Status
*
* DESCRIPTION: For each "Field Unit" name in the argument list that is
* part of the field declaration, enter the name into the
* namespace.
*
******************************************************************************/
{
/* Execute flag should always be set when this function is entered */
{
{
/* BankField Op is deferred, just return OK */
}
}
/*
* Get the FieldList argument for this opcode. This is the start of the
* list of field elements.
*/
{
case AML_FIELD_OP:
break;
case AML_BANK_FIELD_OP:
break;
case AML_INDEX_FIELD_OP:
break;
default:
}
/* Creating new namespace node(s), should not already exist */
/*
* Mark node(s) temporary if we are executing a normal control
* method. (Don't mark if this is a module-level code method)
*/
if (WalkState->MethodNode &&
{
}
/*
* Walk the list of entries in the FieldList
* Note: FieldList can be of zero length. In this case, Arg will be NULL.
*/
while (Arg)
{
/*
* Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
* in the field names in order to enter them into the namespace.
*/
{
if (ACPI_FAILURE (Status))
{
if (Status != AE_ALREADY_EXISTS)
{
}
/* Name already exists, just ignore this error */
}
}
/* Get the next field element in the list */
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateBankField
*
* PARAMETERS: Op - Op containing the Field definition and args
* RegionNode - Object for the containing Operation Region
* WalkState - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new bank field in the specified operation region
*
******************************************************************************/
{
/* First arg is the name of the parent OpRegion (must already exist) */
if (!RegionNode)
{
#ifdef ACPI_ASL_COMPILER
#endif
if (ACPI_FAILURE (Status))
{
}
}
/* Second arg is the Bank Register (Field) (must already exist) */
if (ACPI_FAILURE (Status))
{
}
/*
* Third arg is the BankValue
* This arg is a TermArg, not a constant
* It will be evaluated later, by AcpiDsEvalBankFieldOperands
*/
/* Fourth arg is the field flags */
/* Each remaining arg is a Named Field */
/*
* Use Info.DataRegisterNode to store BankField Op
* It's safe because DataRegisterNode will never be used when create
* bank field \we store AmlStart and AmlLength in the BankField Op for
* late evaluation. Used in AcpiExPrepFieldValue(Info)
*
* TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like
* "void *ParentOp"?
*/
}
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateIndexField
*
* PARAMETERS: Op - Op containing the Field definition and args
* RegionNode - Object for the containing Operation Region
* ` WalkState - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new index field in the specified operation region
*
******************************************************************************/
{
/* First arg is the name of the Index register (must already exist) */
if (ACPI_FAILURE (Status))
{
}
/* Second arg is the data register (must already exist) */
if (ACPI_FAILURE (Status))
{
}
/* Next arg is the field flags */
/* Each remaining arg is a Named Field */
}