dsfield.c revision 102550
167754Smsmith/****************************************************************************** 267754Smsmith * 367754Smsmith * Module Name: dsfield - Dispatcher field routines 4102550Siwasaki * $Revision: 66 $ 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 1291116Smsmith * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith#define __DSFIELD_C__ 11867754Smsmith 11967754Smsmith#include "acpi.h" 12067754Smsmith#include "amlcode.h" 12167754Smsmith#include "acdispat.h" 12267754Smsmith#include "acinterp.h" 12367754Smsmith#include "acnamesp.h" 12485756Smsmith#include "acparser.h" 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_DISPATCHER 12891116Smsmith ACPI_MODULE_NAME ("dsfield") 12967754Smsmith 13067754Smsmith 13167754Smsmith/******************************************************************************* 13267754Smsmith * 13385756Smsmith * FUNCTION: AcpiDsCreateBufferField 13467754Smsmith * 13585756Smsmith * PARAMETERS: Opcode - The opcode to be executed 13685756Smsmith * Operands - List of operands for the opcode 13785756Smsmith * WalkState - Current state 13867754Smsmith * 13967754Smsmith * RETURN: Status 14067754Smsmith * 14187031Smsmith * DESCRIPTION: Execute the CreateField operators: 14285756Smsmith * CreateBitFieldOp, 14387031Smsmith * CreateByteFieldOp, 14487031Smsmith * CreateWordFieldOp, 14585756Smsmith * CreateDWordFieldOp, 14685756Smsmith * CreateQWordFieldOp, 14785756Smsmith * CreateFieldOp (all of which define fields in buffers) 14867754Smsmith * 14967754Smsmith ******************************************************************************/ 15067754Smsmith 15167754SmsmithACPI_STATUS 15285756SmsmithAcpiDsCreateBufferField ( 15367754Smsmith ACPI_PARSE_OBJECT *Op, 15467754Smsmith ACPI_WALK_STATE *WalkState) 15567754Smsmith{ 15667754Smsmith ACPI_PARSE_OBJECT *Arg; 15767754Smsmith ACPI_NAMESPACE_NODE *Node; 15885756Smsmith ACPI_STATUS Status; 15985756Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 16087031Smsmith ACPI_OPERAND_OBJECT *SecondDesc = NULL; 16187031Smsmith UINT32 Flags; 16267754Smsmith 16367754Smsmith 16491116Smsmith ACPI_FUNCTION_TRACE ("DsCreateBufferField"); 16567754Smsmith 16667754Smsmith 16785756Smsmith /* Get the NameString argument */ 16867754Smsmith 16999679Siwasaki if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 17067754Smsmith { 17185756Smsmith Arg = AcpiPsGetArg (Op, 3); 17267754Smsmith } 17385756Smsmith else 17485756Smsmith { 17585756Smsmith /* Create Bit/Byte/Word/Dword field */ 17667754Smsmith 17785756Smsmith Arg = AcpiPsGetArg (Op, 2); 17885756Smsmith } 17967754Smsmith 18085756Smsmith if (!Arg) 18185756Smsmith { 18285756Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 18385756Smsmith } 18467754Smsmith 18585756Smsmith /* 18687031Smsmith * During the load phase, we want to enter the name of the field into 18787031Smsmith * the namespace. During the execute phase (when we evaluate the size 18887031Smsmith * operand), we want to lookup the name 18987031Smsmith */ 19087031Smsmith if (WalkState->ParseFlags & ACPI_PARSE_EXECUTE) 19187031Smsmith { 19291116Smsmith Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; 19387031Smsmith } 19487031Smsmith else 19587031Smsmith { 19691116Smsmith Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; 19787031Smsmith } 19887031Smsmith 19987031Smsmith /* 20085756Smsmith * Enter the NameString into the namespace 20185756Smsmith */ 20299679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 20391116Smsmith INTERNAL_TYPE_DEF_ANY, ACPI_IMODE_LOAD_PASS1, 20491116Smsmith Flags, WalkState, &(Node)); 20585756Smsmith if (ACPI_FAILURE (Status)) 20685756Smsmith { 20785756Smsmith return_ACPI_STATUS (Status); 20885756Smsmith } 20967754Smsmith 21085756Smsmith /* We could put the returned object (Node) on the object stack for later, but 21185756Smsmith * for now, we will put it in the "op" object that the parser uses, so we 21285756Smsmith * can get it again at the end of this scope 21385756Smsmith */ 21499679Siwasaki Op->Common.Node = Node; 21585756Smsmith 21685756Smsmith /* 21785756Smsmith * If there is no object attached to the node, this node was just created and 21885756Smsmith * we need to create the field object. Otherwise, this was a lookup of an 21985756Smsmith * existing node and we don't want to create the field object again. 22085756Smsmith */ 22187031Smsmith ObjDesc = AcpiNsGetAttachedObject (Node); 22287031Smsmith if (ObjDesc) 22385756Smsmith { 22485756Smsmith return_ACPI_STATUS (AE_OK); 22585756Smsmith } 22685756Smsmith 22785756Smsmith /* 22885756Smsmith * The Field definition is not fully parsed at this time. 22985756Smsmith * (We must save the address of the AML for the buffer and index operands) 23085756Smsmith */ 23185756Smsmith 23285756Smsmith /* Create the buffer field object */ 23385756Smsmith 23485756Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); 23585756Smsmith if (!ObjDesc) 23685756Smsmith { 23785756Smsmith Status = AE_NO_MEMORY; 23885756Smsmith goto Cleanup; 23985756Smsmith } 24085756Smsmith 24185756Smsmith /* 24285756Smsmith * Remember location in AML stream of the field unit 24385756Smsmith * opcode and operands -- since the buffer and index 24485756Smsmith * operands must be evaluated. 24585756Smsmith */ 24687031Smsmith SecondDesc = ObjDesc->Common.NextObject; 24799679Siwasaki SecondDesc->Extra.AmlStart = Op->Named.Data; 24899679Siwasaki SecondDesc->Extra.AmlLength = Op->Named.Length; 24987031Smsmith ObjDesc->BufferField.Node = Node; 25085756Smsmith 25187031Smsmith /* Attach constructed field descriptors to parent node */ 25285756Smsmith 25385756Smsmith Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); 25487031Smsmith if (ACPI_FAILURE (Status)) 25587031Smsmith { 25687031Smsmith goto Cleanup; 25787031Smsmith } 25885756Smsmith 25985756Smsmith 26085756SmsmithCleanup: 26185756Smsmith 26285756Smsmith /* Remove local reference to the object */ 26385756Smsmith 26485756Smsmith AcpiUtRemoveReference (ObjDesc); 26585756Smsmith return_ACPI_STATUS (Status); 26685756Smsmith} 26785756Smsmith 26885756Smsmith 26985756Smsmith/******************************************************************************* 27085756Smsmith * 27185756Smsmith * FUNCTION: AcpiDsGetFieldNames 27285756Smsmith * 27385756Smsmith * PARAMETERS: Info - CreateField info structure 27485756Smsmith * ` WalkState - Current method state 27585756Smsmith * Arg - First parser arg for the field name list 27685756Smsmith * 27785756Smsmith * RETURN: Status 27885756Smsmith * 27985756Smsmith * DESCRIPTION: Process all named fields in a field declaration. Names are 28085756Smsmith * entered into the namespace. 28185756Smsmith * 28285756Smsmith ******************************************************************************/ 28385756Smsmith 28485756SmsmithACPI_STATUS 28585756SmsmithAcpiDsGetFieldNames ( 28685756Smsmith ACPI_CREATE_FIELD_INFO *Info, 28785756Smsmith ACPI_WALK_STATE *WalkState, 28885756Smsmith ACPI_PARSE_OBJECT *Arg) 28985756Smsmith{ 29085756Smsmith ACPI_STATUS Status; 29199679Siwasaki ACPI_INTEGER Position; 29285756Smsmith 29385756Smsmith 29491116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsGetFieldNames", Info); 29585756Smsmith 29685756Smsmith 29785756Smsmith /* First field starts at bit zero */ 29885756Smsmith 29985756Smsmith Info->FieldBitPosition = 0; 30085756Smsmith 30185756Smsmith /* Process all elements in the field list (of parse nodes) */ 30285756Smsmith 30367754Smsmith while (Arg) 30467754Smsmith { 30585756Smsmith /* 30685756Smsmith * Three types of field elements are handled: 30785756Smsmith * 1) Offset - specifies a bit offset 30885756Smsmith * 2) AccessAs - changes the access mode 30985756Smsmith * 3) Name - Enters a new named field into the namespace 31085756Smsmith */ 31199679Siwasaki switch (Arg->Common.AmlOpcode) 31267754Smsmith { 31377424Smsmith case AML_INT_RESERVEDFIELD_OP: 31467754Smsmith 315102550Siwasaki Position = (ACPI_INTEGER) Info->FieldBitPosition 31699679Siwasaki + (ACPI_INTEGER) Arg->Common.Value.Size; 31799679Siwasaki 31899679Siwasaki if (Position > ACPI_UINT32_MAX) 31991116Smsmith { 32091116Smsmith ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n")); 32191116Smsmith return_ACPI_STATUS (AE_SUPPORT); 32291116Smsmith } 32391116Smsmith 32499679Siwasaki Info->FieldBitPosition = (UINT32) Position; 32567754Smsmith break; 32667754Smsmith 32767754Smsmith 32877424Smsmith case AML_INT_ACCESSFIELD_OP: 32967754Smsmith 33067754Smsmith /* 33187031Smsmith * Get a new AccessType and AccessAttribute -- to be used for all 33287031Smsmith * field units that follow, until field end or another AccessAs keyword. 33387031Smsmith * 33487031Smsmith * In FieldFlags, preserve the flag bits other than the ACCESS_TYPE bits 33567754Smsmith */ 33687031Smsmith Info->FieldFlags = (UINT8) ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | 33799679Siwasaki ((UINT8) (Arg->Common.Value.Integer32 >> 8))); 33887031Smsmith 33999679Siwasaki Info->Attribute = (UINT8) (Arg->Common.Value.Integer32); 34067754Smsmith break; 34167754Smsmith 34267754Smsmith 34377424Smsmith case AML_INT_NAMEDFIELD_OP: 34467754Smsmith 34587031Smsmith /* Lookup the name */ 34685756Smsmith 34767754Smsmith Status = AcpiNsLookup (WalkState->ScopeInfo, 34899679Siwasaki (NATIVE_CHAR *) &Arg->Named.Name, 34991116Smsmith Info->FieldType, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, 35091116Smsmith WalkState, &Info->FieldNode); 35167754Smsmith if (ACPI_FAILURE (Status)) 35267754Smsmith { 35387031Smsmith if (Status != AE_ALREADY_EXISTS) 35487031Smsmith { 35587031Smsmith return_ACPI_STATUS (Status); 35687031Smsmith } 35787031Smsmith 35891116Smsmith ACPI_REPORT_ERROR (("Field name [%4.4s] already exists in current scope\n", 35999679Siwasaki &Arg->Named.Name)); 36067754Smsmith } 36187031Smsmith else 36287031Smsmith { 36399679Siwasaki Arg->Common.Node = Info->FieldNode; 36499679Siwasaki Info->FieldBitLength = Arg->Common.Value.Size; 36567754Smsmith 36687031Smsmith /* Create and initialize an object for the new Field Node */ 36785756Smsmith 36887031Smsmith Status = AcpiExPrepFieldValue (Info); 36987031Smsmith if (ACPI_FAILURE (Status)) 37087031Smsmith { 37187031Smsmith return_ACPI_STATUS (Status); 37287031Smsmith } 37367754Smsmith } 37467754Smsmith 37585756Smsmith /* Keep track of bit position for the next field */ 37667754Smsmith 377102550Siwasaki Position = (ACPI_INTEGER) Info->FieldBitPosition 37899679Siwasaki + (ACPI_INTEGER) Arg->Common.Value.Size; 37999679Siwasaki 38099679Siwasaki if (Position > ACPI_UINT32_MAX) 38191116Smsmith { 38291116Smsmith ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", 38391116Smsmith &Info->FieldNode->Name)); 38491116Smsmith return_ACPI_STATUS (AE_SUPPORT); 38591116Smsmith } 38691116Smsmith 38785756Smsmith Info->FieldBitPosition += Info->FieldBitLength; 38867754Smsmith break; 38985756Smsmith 39085756Smsmith 39185756Smsmith default: 39285756Smsmith 39385756Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", 39499679Siwasaki Arg->Common.AmlOpcode)); 39599679Siwasaki return_ACPI_STATUS (AE_AML_BAD_OPCODE); 39667754Smsmith } 39767754Smsmith 39899679Siwasaki Arg = Arg->Common.Next; 39967754Smsmith } 40067754Smsmith 40185756Smsmith return_ACPI_STATUS (AE_OK); 40285756Smsmith} 40385756Smsmith 40485756Smsmith 40585756Smsmith/******************************************************************************* 40685756Smsmith * 40785756Smsmith * FUNCTION: AcpiDsCreateField 40885756Smsmith * 40985756Smsmith * PARAMETERS: Op - Op containing the Field definition and args 41085756Smsmith * RegionNode - Object for the containing Operation Region 41185756Smsmith * ` WalkState - Current method state 41285756Smsmith * 41385756Smsmith * RETURN: Status 41485756Smsmith * 41585756Smsmith * DESCRIPTION: Create a new field in the specified operation region 41685756Smsmith * 41785756Smsmith ******************************************************************************/ 41885756Smsmith 41985756SmsmithACPI_STATUS 42085756SmsmithAcpiDsCreateField ( 42185756Smsmith ACPI_PARSE_OBJECT *Op, 42285756Smsmith ACPI_NAMESPACE_NODE *RegionNode, 42385756Smsmith ACPI_WALK_STATE *WalkState) 42485756Smsmith{ 42599679Siwasaki ACPI_STATUS Status; 42685756Smsmith ACPI_PARSE_OBJECT *Arg; 42785756Smsmith ACPI_CREATE_FIELD_INFO Info; 42885756Smsmith 42985756Smsmith 43091116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsCreateField", Op); 43185756Smsmith 43285756Smsmith 43385756Smsmith /* First arg is the name of the parent OpRegion (must already exist) */ 43485756Smsmith 43599679Siwasaki Arg = Op->Common.Value.Arg; 43685756Smsmith if (!RegionNode) 43785756Smsmith { 43899679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, 43991116Smsmith ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 44091116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); 44185756Smsmith if (ACPI_FAILURE (Status)) 44285756Smsmith { 44385756Smsmith return_ACPI_STATUS (Status); 44485756Smsmith } 44585756Smsmith } 44685756Smsmith 44785756Smsmith /* Second arg is the field flags */ 44885756Smsmith 44999679Siwasaki Arg = Arg->Common.Next; 45099679Siwasaki Info.FieldFlags = Arg->Common.Value.Integer8; 45187031Smsmith Info.Attribute = 0; 45285756Smsmith 45385756Smsmith /* Each remaining arg is a Named Field */ 45485756Smsmith 45585756Smsmith Info.FieldType = INTERNAL_TYPE_REGION_FIELD; 45685756Smsmith Info.RegionNode = RegionNode; 45785756Smsmith 45899679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 45985756Smsmith 46067754Smsmith return_ACPI_STATUS (Status); 46167754Smsmith} 46267754Smsmith 46367754Smsmith 46467754Smsmith/******************************************************************************* 46567754Smsmith * 46687031Smsmith * FUNCTION: AcpiDsInitFieldObjects 46787031Smsmith * 46887031Smsmith * PARAMETERS: Op - Op containing the Field definition and args 46987031Smsmith * ` WalkState - Current method state 47087031Smsmith * 47187031Smsmith * RETURN: Status 47287031Smsmith * 47387031Smsmith * DESCRIPTION: For each "Field Unit" name in the argument list that is 47487031Smsmith * part of the field declaration, enter the name into the 47587031Smsmith * namespace. 47687031Smsmith * 47787031Smsmith ******************************************************************************/ 47887031Smsmith 47987031SmsmithACPI_STATUS 48087031SmsmithAcpiDsInitFieldObjects ( 48187031Smsmith ACPI_PARSE_OBJECT *Op, 48287031Smsmith ACPI_WALK_STATE *WalkState) 48387031Smsmith{ 48499679Siwasaki ACPI_STATUS Status; 48587031Smsmith ACPI_PARSE_OBJECT *Arg = NULL; 48687031Smsmith ACPI_NAMESPACE_NODE *Node; 48787031Smsmith UINT8 Type = 0; 48887031Smsmith 48987031Smsmith 49091116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsInitFieldObjects", Op); 49187031Smsmith 49287031Smsmith 49387031Smsmith switch (WalkState->Opcode) 49487031Smsmith { 49587031Smsmith case AML_FIELD_OP: 49687031Smsmith Arg = AcpiPsGetArg (Op, 2); 49787031Smsmith Type = INTERNAL_TYPE_REGION_FIELD; 49887031Smsmith break; 49987031Smsmith 50087031Smsmith case AML_BANK_FIELD_OP: 50187031Smsmith Arg = AcpiPsGetArg (Op, 4); 50287031Smsmith Type = INTERNAL_TYPE_BANK_FIELD; 50387031Smsmith break; 50487031Smsmith 50587031Smsmith case AML_INDEX_FIELD_OP: 50687031Smsmith Arg = AcpiPsGetArg (Op, 3); 50787031Smsmith Type = INTERNAL_TYPE_INDEX_FIELD; 50887031Smsmith break; 50999679Siwasaki 51099679Siwasaki default: 51199679Siwasaki return_ACPI_STATUS (AE_BAD_PARAMETER); 51287031Smsmith } 51387031Smsmith 51487031Smsmith /* 51587031Smsmith * Walk the list of entries in the FieldList 51687031Smsmith */ 51787031Smsmith while (Arg) 51887031Smsmith { 51987031Smsmith /* Ignore OFFSET and ACCESSAS terms here */ 52087031Smsmith 52199679Siwasaki if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 52287031Smsmith { 52387031Smsmith Status = AcpiNsLookup (WalkState->ScopeInfo, 52499679Siwasaki (NATIVE_CHAR *) &Arg->Named.Name, 52591116Smsmith Type, ACPI_IMODE_LOAD_PASS1, 52691116Smsmith ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, 52791116Smsmith WalkState, &Node); 52887031Smsmith if (ACPI_FAILURE (Status)) 52987031Smsmith { 53087031Smsmith if (Status != AE_ALREADY_EXISTS) 53187031Smsmith { 53287031Smsmith return_ACPI_STATUS (Status); 53387031Smsmith } 53487031Smsmith 53591116Smsmith ACPI_REPORT_ERROR (("Field name [%4.4s] already exists in current scope\n", 53699679Siwasaki &Arg->Named.Name)); 53799679Siwasaki 53899679Siwasaki /* Name already exists, just ignore this error */ 53999679Siwasaki 54099679Siwasaki Status = AE_OK; 54187031Smsmith } 54287031Smsmith 54399679Siwasaki Arg->Common.Node = Node; 54487031Smsmith } 54587031Smsmith 54691116Smsmith /* Move to next field in the list */ 54787031Smsmith 54899679Siwasaki Arg = Arg->Common.Next; 54987031Smsmith } 55087031Smsmith 55199679Siwasaki return_ACPI_STATUS (AE_OK); 55287031Smsmith} 55387031Smsmith 55487031Smsmith 55587031Smsmith/******************************************************************************* 55687031Smsmith * 55767754Smsmith * FUNCTION: AcpiDsCreateBankField 55867754Smsmith * 55967754Smsmith * PARAMETERS: Op - Op containing the Field definition and args 56077424Smsmith * RegionNode - Object for the containing Operation Region 56177424Smsmith * ` WalkState - Current method state 56267754Smsmith * 56367754Smsmith * RETURN: Status 56467754Smsmith * 56567754Smsmith * DESCRIPTION: Create a new bank field in the specified operation region 56667754Smsmith * 56767754Smsmith ******************************************************************************/ 56867754Smsmith 56967754SmsmithACPI_STATUS 57067754SmsmithAcpiDsCreateBankField ( 57167754Smsmith ACPI_PARSE_OBJECT *Op, 57267754Smsmith ACPI_NAMESPACE_NODE *RegionNode, 57367754Smsmith ACPI_WALK_STATE *WalkState) 57467754Smsmith{ 57599679Siwasaki ACPI_STATUS Status; 57667754Smsmith ACPI_PARSE_OBJECT *Arg; 57785756Smsmith ACPI_CREATE_FIELD_INFO Info; 57867754Smsmith 57967754Smsmith 58091116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsCreateBankField", Op); 58167754Smsmith 58267754Smsmith 58385756Smsmith /* First arg is the name of the parent OpRegion (must already exist) */ 58467754Smsmith 58599679Siwasaki Arg = Op->Common.Value.Arg; 58667754Smsmith if (!RegionNode) 58767754Smsmith { 58899679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, 58991116Smsmith ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 59091116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); 59167754Smsmith if (ACPI_FAILURE (Status)) 59267754Smsmith { 59367754Smsmith return_ACPI_STATUS (Status); 59467754Smsmith } 59567754Smsmith } 59667754Smsmith 59785756Smsmith /* Second arg is the Bank Register (must already exist) */ 59867754Smsmith 59999679Siwasaki Arg = Arg->Common.Next; 60099679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 60191116Smsmith INTERNAL_TYPE_BANK_FIELD_DEFN, ACPI_IMODE_EXECUTE, 60291116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); 60367754Smsmith if (ACPI_FAILURE (Status)) 60467754Smsmith { 60567754Smsmith return_ACPI_STATUS (Status); 60667754Smsmith } 60767754Smsmith 60867754Smsmith /* Third arg is the BankValue */ 60967754Smsmith 61099679Siwasaki Arg = Arg->Common.Next; 61199679Siwasaki Info.BankValue = Arg->Common.Value.Integer32; 61267754Smsmith 61385756Smsmith /* Fourth arg is the field flags */ 61467754Smsmith 61599679Siwasaki Arg = Arg->Common.Next; 61699679Siwasaki Info.FieldFlags = Arg->Common.Value.Integer8; 61767754Smsmith 61867754Smsmith /* Each remaining arg is a Named Field */ 61967754Smsmith 62085756Smsmith Info.FieldType = INTERNAL_TYPE_BANK_FIELD; 62185756Smsmith Info.RegionNode = RegionNode; 62267754Smsmith 62399679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 62467754Smsmith 62567754Smsmith return_ACPI_STATUS (Status); 62667754Smsmith} 62767754Smsmith 62867754Smsmith 62967754Smsmith/******************************************************************************* 63067754Smsmith * 63167754Smsmith * FUNCTION: AcpiDsCreateIndexField 63267754Smsmith * 63367754Smsmith * PARAMETERS: Op - Op containing the Field definition and args 63477424Smsmith * RegionNode - Object for the containing Operation Region 63577424Smsmith * ` WalkState - Current method state 63667754Smsmith * 63767754Smsmith * RETURN: Status 63867754Smsmith * 63967754Smsmith * DESCRIPTION: Create a new index field in the specified operation region 64067754Smsmith * 64167754Smsmith ******************************************************************************/ 64267754Smsmith 64367754SmsmithACPI_STATUS 64467754SmsmithAcpiDsCreateIndexField ( 64567754Smsmith ACPI_PARSE_OBJECT *Op, 64677424Smsmith ACPI_NAMESPACE_NODE *RegionNode, 64767754Smsmith ACPI_WALK_STATE *WalkState) 64867754Smsmith{ 64967754Smsmith ACPI_STATUS Status; 65067754Smsmith ACPI_PARSE_OBJECT *Arg; 65185756Smsmith ACPI_CREATE_FIELD_INFO Info; 65267754Smsmith 65367754Smsmith 65491116Smsmith ACPI_FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); 65567754Smsmith 65667754Smsmith 65785756Smsmith /* First arg is the name of the Index register (must already exist) */ 65885756Smsmith 65999679Siwasaki Arg = Op->Common.Value.Arg; 66099679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 66191116Smsmith ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 66291116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); 66367754Smsmith if (ACPI_FAILURE (Status)) 66467754Smsmith { 66567754Smsmith return_ACPI_STATUS (Status); 66667754Smsmith } 66767754Smsmith 66885756Smsmith /* Second arg is the data register (must already exist) */ 66967754Smsmith 67099679Siwasaki Arg = Arg->Common.Next; 67199679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 67291116Smsmith INTERNAL_TYPE_INDEX_FIELD_DEFN, ACPI_IMODE_EXECUTE, 67391116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); 67467754Smsmith if (ACPI_FAILURE (Status)) 67567754Smsmith { 67667754Smsmith return_ACPI_STATUS (Status); 67767754Smsmith } 67867754Smsmith 67967754Smsmith /* Next arg is the field flags */ 68067754Smsmith 68199679Siwasaki Arg = Arg->Common.Next; 68299679Siwasaki Info.FieldFlags = Arg->Common.Value.Integer8; 68367754Smsmith 68467754Smsmith 68567754Smsmith /* Each remaining arg is a Named Field */ 68667754Smsmith 68785756Smsmith Info.FieldType = INTERNAL_TYPE_INDEX_FIELD; 68885756Smsmith Info.RegionNode = RegionNode; 68967754Smsmith 69099679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 69167754Smsmith 69267754Smsmith return_ACPI_STATUS (Status); 69367754Smsmith} 69467754Smsmith 69567754Smsmith 696