dsfield.c revision 167802
167754Smsmith/****************************************************************************** 267754Smsmith * 367754Smsmith * Module Name: dsfield - Dispatcher field routines 4167802Sjkim * $Revision: 1.84 $ 567754Smsmith * 667754Smsmith *****************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12167802Sjkim * Some or all of this work - Copyright (c) 1999 - 2007, 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 119151600Sobrien#include <contrib/dev/acpica/acpi.h> 120151600Sobrien#include <contrib/dev/acpica/amlcode.h> 121151600Sobrien#include <contrib/dev/acpica/acdispat.h> 122151600Sobrien#include <contrib/dev/acpica/acinterp.h> 123151600Sobrien#include <contrib/dev/acpica/acnamesp.h> 124151600Sobrien#include <contrib/dev/acpica/acparser.h> 12567754Smsmith 12667754Smsmith 12777424Smsmith#define _COMPONENT ACPI_DISPATCHER 12891116Smsmith ACPI_MODULE_NAME ("dsfield") 12967754Smsmith 130151937Sjkim/* Local prototypes */ 13167754Smsmith 132151937Sjkimstatic ACPI_STATUS 133151937SjkimAcpiDsGetFieldNames ( 134151937Sjkim ACPI_CREATE_FIELD_INFO *Info, 135151937Sjkim ACPI_WALK_STATE *WalkState, 136151937Sjkim ACPI_PARSE_OBJECT *Arg); 137151937Sjkim 138151937Sjkim 13967754Smsmith/******************************************************************************* 14067754Smsmith * 14185756Smsmith * FUNCTION: AcpiDsCreateBufferField 14267754Smsmith * 143151937Sjkim * PARAMETERS: Op - Current parse op (CreateXXField) 14485756Smsmith * WalkState - Current state 14567754Smsmith * 14667754Smsmith * RETURN: Status 14767754Smsmith * 14887031Smsmith * DESCRIPTION: Execute the CreateField operators: 14985756Smsmith * CreateBitFieldOp, 15087031Smsmith * CreateByteFieldOp, 15187031Smsmith * CreateWordFieldOp, 15285756Smsmith * CreateDWordFieldOp, 15385756Smsmith * CreateQWordFieldOp, 154151937Sjkim * CreateFieldOp (all of which define a field in a buffer) 15567754Smsmith * 15667754Smsmith ******************************************************************************/ 15767754Smsmith 15867754SmsmithACPI_STATUS 15985756SmsmithAcpiDsCreateBufferField ( 16067754Smsmith ACPI_PARSE_OBJECT *Op, 16167754Smsmith ACPI_WALK_STATE *WalkState) 16267754Smsmith{ 16367754Smsmith ACPI_PARSE_OBJECT *Arg; 16467754Smsmith ACPI_NAMESPACE_NODE *Node; 16585756Smsmith ACPI_STATUS Status; 16685756Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 16787031Smsmith ACPI_OPERAND_OBJECT *SecondDesc = NULL; 16887031Smsmith UINT32 Flags; 16967754Smsmith 17067754Smsmith 171167802Sjkim ACPI_FUNCTION_TRACE (DsCreateBufferField); 17267754Smsmith 17367754Smsmith 17485756Smsmith /* Get the NameString argument */ 17567754Smsmith 17699679Siwasaki if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 17767754Smsmith { 17885756Smsmith Arg = AcpiPsGetArg (Op, 3); 17967754Smsmith } 18085756Smsmith else 18185756Smsmith { 18285756Smsmith /* Create Bit/Byte/Word/Dword field */ 18367754Smsmith 18485756Smsmith Arg = AcpiPsGetArg (Op, 2); 18585756Smsmith } 18667754Smsmith 18785756Smsmith if (!Arg) 18885756Smsmith { 18985756Smsmith return_ACPI_STATUS (AE_AML_NO_OPERAND); 19085756Smsmith } 19167754Smsmith 192123315Snjl if (WalkState->DeferredNode) 19387031Smsmith { 194123315Snjl Node = WalkState->DeferredNode; 195123315Snjl Status = AE_OK; 19687031Smsmith } 19787031Smsmith else 19887031Smsmith { 199123315Snjl /* 200123315Snjl * During the load phase, we want to enter the name of the field into 201123315Snjl * the namespace. During the execute phase (when we evaluate the size 202123315Snjl * operand), we want to lookup the name 203123315Snjl */ 204123315Snjl if (WalkState->ParseFlags & ACPI_PARSE_EXECUTE) 205123315Snjl { 206123315Snjl Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; 207123315Snjl } 208123315Snjl else 209123315Snjl { 210151937Sjkim Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 211151937Sjkim ACPI_NS_ERROR_IF_FOUND; 212123315Snjl } 21387031Smsmith 214123315Snjl /* 215123315Snjl * Enter the NameString into the namespace 216123315Snjl */ 217123315Snjl Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 218123315Snjl ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, 219123315Snjl Flags, WalkState, &(Node)); 220123315Snjl if (ACPI_FAILURE (Status)) 221123315Snjl { 222167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 223123315Snjl return_ACPI_STATUS (Status); 224123315Snjl } 22585756Smsmith } 22667754Smsmith 227167802Sjkim /* 228167802Sjkim * We could put the returned object (Node) on the object stack for later, 229151937Sjkim * but for now, we will put it in the "op" object that the parser uses, 230151937Sjkim * so we can get it again at the end of this scope 23185756Smsmith */ 23299679Siwasaki Op->Common.Node = Node; 23385756Smsmith 23485756Smsmith /* 235151937Sjkim * If there is no object attached to the node, this node was just created 236151937Sjkim * and we need to create the field object. Otherwise, this was a lookup 237151937Sjkim * of an existing node and we don't want to create the field object again. 23885756Smsmith */ 23987031Smsmith ObjDesc = AcpiNsGetAttachedObject (Node); 24087031Smsmith if (ObjDesc) 24185756Smsmith { 24285756Smsmith return_ACPI_STATUS (AE_OK); 24385756Smsmith } 24485756Smsmith 24585756Smsmith /* 24685756Smsmith * The Field definition is not fully parsed at this time. 24785756Smsmith * (We must save the address of the AML for the buffer and index operands) 24885756Smsmith */ 24985756Smsmith 25085756Smsmith /* Create the buffer field object */ 25185756Smsmith 25285756Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); 25385756Smsmith if (!ObjDesc) 25485756Smsmith { 25585756Smsmith Status = AE_NO_MEMORY; 25685756Smsmith goto Cleanup; 25785756Smsmith } 25885756Smsmith 25985756Smsmith /* 26085756Smsmith * Remember location in AML stream of the field unit 26185756Smsmith * opcode and operands -- since the buffer and index 26285756Smsmith * operands must be evaluated. 26385756Smsmith */ 26487031Smsmith SecondDesc = ObjDesc->Common.NextObject; 26599679Siwasaki SecondDesc->Extra.AmlStart = Op->Named.Data; 26699679Siwasaki SecondDesc->Extra.AmlLength = Op->Named.Length; 26787031Smsmith ObjDesc->BufferField.Node = Node; 26885756Smsmith 26987031Smsmith /* Attach constructed field descriptors to parent node */ 27085756Smsmith 27185756Smsmith Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); 27287031Smsmith if (ACPI_FAILURE (Status)) 27387031Smsmith { 27487031Smsmith goto Cleanup; 27587031Smsmith } 27685756Smsmith 27785756Smsmith 27885756SmsmithCleanup: 27985756Smsmith 28085756Smsmith /* Remove local reference to the object */ 28185756Smsmith 28285756Smsmith AcpiUtRemoveReference (ObjDesc); 28385756Smsmith return_ACPI_STATUS (Status); 28485756Smsmith} 28585756Smsmith 28685756Smsmith 28785756Smsmith/******************************************************************************* 28885756Smsmith * 28985756Smsmith * FUNCTION: AcpiDsGetFieldNames 29085756Smsmith * 29185756Smsmith * PARAMETERS: Info - CreateField info structure 29285756Smsmith * ` WalkState - Current method state 29385756Smsmith * Arg - First parser arg for the field name list 29485756Smsmith * 29585756Smsmith * RETURN: Status 29685756Smsmith * 29785756Smsmith * DESCRIPTION: Process all named fields in a field declaration. Names are 29885756Smsmith * entered into the namespace. 29985756Smsmith * 30085756Smsmith ******************************************************************************/ 30185756Smsmith 302151937Sjkimstatic ACPI_STATUS 30385756SmsmithAcpiDsGetFieldNames ( 30485756Smsmith ACPI_CREATE_FIELD_INFO *Info, 30585756Smsmith ACPI_WALK_STATE *WalkState, 30685756Smsmith ACPI_PARSE_OBJECT *Arg) 30785756Smsmith{ 30885756Smsmith ACPI_STATUS Status; 30999679Siwasaki ACPI_INTEGER Position; 31085756Smsmith 31185756Smsmith 312167802Sjkim ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); 31385756Smsmith 31485756Smsmith 31585756Smsmith /* First field starts at bit zero */ 31685756Smsmith 31785756Smsmith Info->FieldBitPosition = 0; 31885756Smsmith 31985756Smsmith /* Process all elements in the field list (of parse nodes) */ 32085756Smsmith 32167754Smsmith while (Arg) 32267754Smsmith { 32385756Smsmith /* 32485756Smsmith * Three types of field elements are handled: 32585756Smsmith * 1) Offset - specifies a bit offset 32685756Smsmith * 2) AccessAs - changes the access mode 32785756Smsmith * 3) Name - Enters a new named field into the namespace 32885756Smsmith */ 32999679Siwasaki switch (Arg->Common.AmlOpcode) 33067754Smsmith { 33177424Smsmith case AML_INT_RESERVEDFIELD_OP: 33267754Smsmith 333102550Siwasaki Position = (ACPI_INTEGER) Info->FieldBitPosition 33499679Siwasaki + (ACPI_INTEGER) Arg->Common.Value.Size; 33599679Siwasaki 33699679Siwasaki if (Position > ACPI_UINT32_MAX) 33791116Smsmith { 338167802Sjkim ACPI_ERROR ((AE_INFO, 339167802Sjkim "Bit offset within field too large (> 0xFFFFFFFF)")); 34091116Smsmith return_ACPI_STATUS (AE_SUPPORT); 34191116Smsmith } 34291116Smsmith 34399679Siwasaki Info->FieldBitPosition = (UINT32) Position; 34467754Smsmith break; 34567754Smsmith 34667754Smsmith 34777424Smsmith case AML_INT_ACCESSFIELD_OP: 34867754Smsmith 34967754Smsmith /* 35087031Smsmith * Get a new AccessType and AccessAttribute -- to be used for all 351151937Sjkim * field units that follow, until field end or another AccessAs 352151937Sjkim * keyword. 35387031Smsmith * 354151937Sjkim * In FieldFlags, preserve the flag bits other than the 355151937Sjkim * ACCESS_TYPE bits 35667754Smsmith */ 357151937Sjkim Info->FieldFlags = (UINT8) 358151937Sjkim ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | 359151937Sjkim ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); 36087031Smsmith 361117521Snjl Info->Attribute = (UINT8) (Arg->Common.Value.Integer); 36267754Smsmith break; 36367754Smsmith 36467754Smsmith 36577424Smsmith case AML_INT_NAMEDFIELD_OP: 36667754Smsmith 36787031Smsmith /* Lookup the name */ 36885756Smsmith 36967754Smsmith Status = AcpiNsLookup (WalkState->ScopeInfo, 370114237Snjl (char *) &Arg->Named.Name, 371151937Sjkim Info->FieldType, ACPI_IMODE_EXECUTE, 372151937Sjkim ACPI_NS_DONT_OPEN_SCOPE, 37391116Smsmith WalkState, &Info->FieldNode); 37467754Smsmith if (ACPI_FAILURE (Status)) 37567754Smsmith { 376167802Sjkim ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); 37787031Smsmith if (Status != AE_ALREADY_EXISTS) 37887031Smsmith { 37987031Smsmith return_ACPI_STATUS (Status); 38087031Smsmith } 38187031Smsmith 382104470Siwasaki /* Already exists, ignore error */ 38367754Smsmith } 38487031Smsmith else 38587031Smsmith { 38699679Siwasaki Arg->Common.Node = Info->FieldNode; 38799679Siwasaki Info->FieldBitLength = Arg->Common.Value.Size; 38867754Smsmith 38987031Smsmith /* Create and initialize an object for the new Field Node */ 39085756Smsmith 39187031Smsmith Status = AcpiExPrepFieldValue (Info); 39287031Smsmith if (ACPI_FAILURE (Status)) 39387031Smsmith { 39487031Smsmith return_ACPI_STATUS (Status); 39587031Smsmith } 39667754Smsmith } 39767754Smsmith 39885756Smsmith /* Keep track of bit position for the next field */ 39967754Smsmith 400102550Siwasaki Position = (ACPI_INTEGER) Info->FieldBitPosition 40199679Siwasaki + (ACPI_INTEGER) Arg->Common.Value.Size; 40299679Siwasaki 40399679Siwasaki if (Position > ACPI_UINT32_MAX) 40491116Smsmith { 405167802Sjkim ACPI_ERROR ((AE_INFO, 406167802Sjkim "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", 407167802Sjkim ACPI_CAST_PTR (char, &Info->FieldNode->Name))); 40891116Smsmith return_ACPI_STATUS (AE_SUPPORT); 40991116Smsmith } 41091116Smsmith 41185756Smsmith Info->FieldBitPosition += Info->FieldBitLength; 41267754Smsmith break; 41385756Smsmith 41485756Smsmith 41585756Smsmith default: 41685756Smsmith 417167802Sjkim ACPI_ERROR ((AE_INFO, 418167802Sjkim "Invalid opcode in field list: %X", 41999679Siwasaki Arg->Common.AmlOpcode)); 42099679Siwasaki return_ACPI_STATUS (AE_AML_BAD_OPCODE); 42167754Smsmith } 42267754Smsmith 42399679Siwasaki Arg = Arg->Common.Next; 42467754Smsmith } 42567754Smsmith 42685756Smsmith return_ACPI_STATUS (AE_OK); 42785756Smsmith} 42885756Smsmith 42985756Smsmith 43085756Smsmith/******************************************************************************* 43185756Smsmith * 43285756Smsmith * FUNCTION: AcpiDsCreateField 43385756Smsmith * 43485756Smsmith * PARAMETERS: Op - Op containing the Field definition and args 43585756Smsmith * RegionNode - Object for the containing Operation Region 43685756Smsmith * ` WalkState - Current method state 43785756Smsmith * 43885756Smsmith * RETURN: Status 43985756Smsmith * 44085756Smsmith * DESCRIPTION: Create a new field in the specified operation region 44185756Smsmith * 44285756Smsmith ******************************************************************************/ 44385756Smsmith 44485756SmsmithACPI_STATUS 44585756SmsmithAcpiDsCreateField ( 44685756Smsmith ACPI_PARSE_OBJECT *Op, 44785756Smsmith ACPI_NAMESPACE_NODE *RegionNode, 44885756Smsmith ACPI_WALK_STATE *WalkState) 44985756Smsmith{ 45099679Siwasaki ACPI_STATUS Status; 45185756Smsmith ACPI_PARSE_OBJECT *Arg; 45285756Smsmith ACPI_CREATE_FIELD_INFO Info; 45385756Smsmith 45485756Smsmith 455167802Sjkim ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op); 45685756Smsmith 45785756Smsmith 45885756Smsmith /* First arg is the name of the parent OpRegion (must already exist) */ 45985756Smsmith 46099679Siwasaki Arg = Op->Common.Value.Arg; 46185756Smsmith if (!RegionNode) 46285756Smsmith { 46399679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, 46491116Smsmith ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 46591116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); 46685756Smsmith if (ACPI_FAILURE (Status)) 46785756Smsmith { 468167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); 46985756Smsmith return_ACPI_STATUS (Status); 47085756Smsmith } 47185756Smsmith } 47285756Smsmith 47385756Smsmith /* Second arg is the field flags */ 47485756Smsmith 47599679Siwasaki Arg = Arg->Common.Next; 476117521Snjl Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; 47787031Smsmith Info.Attribute = 0; 47885756Smsmith 47985756Smsmith /* Each remaining arg is a Named Field */ 48085756Smsmith 481107325Siwasaki Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD; 48285756Smsmith Info.RegionNode = RegionNode; 48385756Smsmith 48499679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 48585756Smsmith 48667754Smsmith return_ACPI_STATUS (Status); 48767754Smsmith} 48867754Smsmith 48967754Smsmith 49067754Smsmith/******************************************************************************* 49167754Smsmith * 49287031Smsmith * FUNCTION: AcpiDsInitFieldObjects 49387031Smsmith * 49487031Smsmith * PARAMETERS: Op - Op containing the Field definition and args 49587031Smsmith * ` WalkState - Current method state 49687031Smsmith * 49787031Smsmith * RETURN: Status 49887031Smsmith * 49987031Smsmith * DESCRIPTION: For each "Field Unit" name in the argument list that is 50087031Smsmith * part of the field declaration, enter the name into the 50187031Smsmith * namespace. 50287031Smsmith * 50387031Smsmith ******************************************************************************/ 50487031Smsmith 50587031SmsmithACPI_STATUS 50687031SmsmithAcpiDsInitFieldObjects ( 50787031Smsmith ACPI_PARSE_OBJECT *Op, 50887031Smsmith ACPI_WALK_STATE *WalkState) 50987031Smsmith{ 51099679Siwasaki ACPI_STATUS Status; 51187031Smsmith ACPI_PARSE_OBJECT *Arg = NULL; 51287031Smsmith ACPI_NAMESPACE_NODE *Node; 51387031Smsmith UINT8 Type = 0; 51487031Smsmith 51587031Smsmith 516167802Sjkim ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op); 51787031Smsmith 51887031Smsmith 51987031Smsmith switch (WalkState->Opcode) 52087031Smsmith { 52187031Smsmith case AML_FIELD_OP: 52287031Smsmith Arg = AcpiPsGetArg (Op, 2); 523107325Siwasaki Type = ACPI_TYPE_LOCAL_REGION_FIELD; 52487031Smsmith break; 52587031Smsmith 52687031Smsmith case AML_BANK_FIELD_OP: 52787031Smsmith Arg = AcpiPsGetArg (Op, 4); 528107325Siwasaki Type = ACPI_TYPE_LOCAL_BANK_FIELD; 52987031Smsmith break; 53087031Smsmith 53187031Smsmith case AML_INDEX_FIELD_OP: 53287031Smsmith Arg = AcpiPsGetArg (Op, 3); 533107325Siwasaki Type = ACPI_TYPE_LOCAL_INDEX_FIELD; 53487031Smsmith break; 53599679Siwasaki 53699679Siwasaki default: 53799679Siwasaki return_ACPI_STATUS (AE_BAD_PARAMETER); 53887031Smsmith } 53987031Smsmith 54087031Smsmith /* 54187031Smsmith * Walk the list of entries in the FieldList 54287031Smsmith */ 54387031Smsmith while (Arg) 54487031Smsmith { 54587031Smsmith /* Ignore OFFSET and ACCESSAS terms here */ 54687031Smsmith 54799679Siwasaki if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 54887031Smsmith { 54987031Smsmith Status = AcpiNsLookup (WalkState->ScopeInfo, 550114237Snjl (char *) &Arg->Named.Name, 55191116Smsmith Type, ACPI_IMODE_LOAD_PASS1, 552151937Sjkim ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 553151937Sjkim ACPI_NS_ERROR_IF_FOUND, 55491116Smsmith WalkState, &Node); 55587031Smsmith if (ACPI_FAILURE (Status)) 55687031Smsmith { 557167802Sjkim ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); 55887031Smsmith if (Status != AE_ALREADY_EXISTS) 55987031Smsmith { 56087031Smsmith return_ACPI_STATUS (Status); 56187031Smsmith } 56287031Smsmith 56399679Siwasaki /* Name already exists, just ignore this error */ 56499679Siwasaki 56599679Siwasaki Status = AE_OK; 56687031Smsmith } 56787031Smsmith 56899679Siwasaki Arg->Common.Node = Node; 56987031Smsmith } 57087031Smsmith 57191116Smsmith /* Move to next field in the list */ 57287031Smsmith 57399679Siwasaki Arg = Arg->Common.Next; 57487031Smsmith } 57587031Smsmith 57699679Siwasaki return_ACPI_STATUS (AE_OK); 57787031Smsmith} 57887031Smsmith 57987031Smsmith 58087031Smsmith/******************************************************************************* 58187031Smsmith * 58267754Smsmith * FUNCTION: AcpiDsCreateBankField 58367754Smsmith * 58467754Smsmith * PARAMETERS: Op - Op containing the Field definition and args 58577424Smsmith * RegionNode - Object for the containing Operation Region 58677424Smsmith * ` WalkState - Current method state 58767754Smsmith * 58867754Smsmith * RETURN: Status 58967754Smsmith * 59067754Smsmith * DESCRIPTION: Create a new bank field in the specified operation region 59167754Smsmith * 59267754Smsmith ******************************************************************************/ 59367754Smsmith 59467754SmsmithACPI_STATUS 59567754SmsmithAcpiDsCreateBankField ( 59667754Smsmith ACPI_PARSE_OBJECT *Op, 59767754Smsmith ACPI_NAMESPACE_NODE *RegionNode, 59867754Smsmith ACPI_WALK_STATE *WalkState) 59967754Smsmith{ 60099679Siwasaki ACPI_STATUS Status; 60167754Smsmith ACPI_PARSE_OBJECT *Arg; 60285756Smsmith ACPI_CREATE_FIELD_INFO Info; 60367754Smsmith 60467754Smsmith 605167802Sjkim ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op); 60667754Smsmith 60767754Smsmith 60885756Smsmith /* First arg is the name of the parent OpRegion (must already exist) */ 60967754Smsmith 61099679Siwasaki Arg = Op->Common.Value.Arg; 61167754Smsmith if (!RegionNode) 61267754Smsmith { 61399679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, 61491116Smsmith ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, 61591116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); 61667754Smsmith if (ACPI_FAILURE (Status)) 61767754Smsmith { 618167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); 61967754Smsmith return_ACPI_STATUS (Status); 62067754Smsmith } 62167754Smsmith } 62267754Smsmith 623107325Siwasaki /* Second arg is the Bank Register (Field) (must already exist) */ 62467754Smsmith 62599679Siwasaki Arg = Arg->Common.Next; 62699679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 627107325Siwasaki ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 62891116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); 62967754Smsmith if (ACPI_FAILURE (Status)) 63067754Smsmith { 631167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 63267754Smsmith return_ACPI_STATUS (Status); 63367754Smsmith } 63467754Smsmith 63567754Smsmith /* Third arg is the BankValue */ 63667754Smsmith 637167802Sjkim /* TBD: This arg is a TermArg, not a constant, and must be evaluated */ 638167802Sjkim 63999679Siwasaki Arg = Arg->Common.Next; 64067754Smsmith 641167802Sjkim /* Currently, only the following constants are supported */ 642167802Sjkim 643167802Sjkim switch (Arg->Common.AmlOpcode) 644167802Sjkim { 645167802Sjkim case AML_ZERO_OP: 646167802Sjkim Info.BankValue = 0; 647167802Sjkim break; 648167802Sjkim 649167802Sjkim case AML_ONE_OP: 650167802Sjkim Info.BankValue = 1; 651167802Sjkim break; 652167802Sjkim 653167802Sjkim case AML_BYTE_OP: 654167802Sjkim case AML_WORD_OP: 655167802Sjkim case AML_DWORD_OP: 656167802Sjkim case AML_QWORD_OP: 657167802Sjkim Info.BankValue = (UINT32) Arg->Common.Value.Integer; 658167802Sjkim break; 659167802Sjkim 660167802Sjkim default: 661167802Sjkim Info.BankValue = 0; 662167802Sjkim ACPI_ERROR ((AE_INFO, "Non-constant BankValue for BankField is not implemented")); 663167802Sjkim } 664167802Sjkim 66585756Smsmith /* Fourth arg is the field flags */ 66667754Smsmith 66799679Siwasaki Arg = Arg->Common.Next; 668117521Snjl Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; 66967754Smsmith 67067754Smsmith /* Each remaining arg is a Named Field */ 67167754Smsmith 672107325Siwasaki Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD; 67385756Smsmith Info.RegionNode = RegionNode; 67467754Smsmith 67599679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 67667754Smsmith 67767754Smsmith return_ACPI_STATUS (Status); 67867754Smsmith} 67967754Smsmith 68067754Smsmith 68167754Smsmith/******************************************************************************* 68267754Smsmith * 68367754Smsmith * FUNCTION: AcpiDsCreateIndexField 68467754Smsmith * 68567754Smsmith * PARAMETERS: Op - Op containing the Field definition and args 68677424Smsmith * RegionNode - Object for the containing Operation Region 68777424Smsmith * ` WalkState - Current method state 68867754Smsmith * 68967754Smsmith * RETURN: Status 69067754Smsmith * 69167754Smsmith * DESCRIPTION: Create a new index field in the specified operation region 69267754Smsmith * 69367754Smsmith ******************************************************************************/ 69467754Smsmith 69567754SmsmithACPI_STATUS 69667754SmsmithAcpiDsCreateIndexField ( 69767754Smsmith ACPI_PARSE_OBJECT *Op, 69877424Smsmith ACPI_NAMESPACE_NODE *RegionNode, 69967754Smsmith ACPI_WALK_STATE *WalkState) 70067754Smsmith{ 70167754Smsmith ACPI_STATUS Status; 70267754Smsmith ACPI_PARSE_OBJECT *Arg; 70385756Smsmith ACPI_CREATE_FIELD_INFO Info; 70467754Smsmith 70567754Smsmith 706167802Sjkim ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op); 70767754Smsmith 70867754Smsmith 70985756Smsmith /* First arg is the name of the Index register (must already exist) */ 71085756Smsmith 71199679Siwasaki Arg = Op->Common.Value.Arg; 71299679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 71391116Smsmith ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 71491116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); 71567754Smsmith if (ACPI_FAILURE (Status)) 71667754Smsmith { 717167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 71867754Smsmith return_ACPI_STATUS (Status); 71967754Smsmith } 72067754Smsmith 72185756Smsmith /* Second arg is the data register (must already exist) */ 72267754Smsmith 72399679Siwasaki Arg = Arg->Common.Next; 72499679Siwasaki Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, 725107325Siwasaki ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 72691116Smsmith ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); 72767754Smsmith if (ACPI_FAILURE (Status)) 72867754Smsmith { 729167802Sjkim ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); 73067754Smsmith return_ACPI_STATUS (Status); 73167754Smsmith } 73267754Smsmith 73367754Smsmith /* Next arg is the field flags */ 73467754Smsmith 73599679Siwasaki Arg = Arg->Common.Next; 736117521Snjl Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; 73767754Smsmith 73867754Smsmith /* Each remaining arg is a Named Field */ 73967754Smsmith 740107325Siwasaki Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD; 74185756Smsmith Info.RegionNode = RegionNode; 74267754Smsmith 74399679Siwasaki Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); 74467754Smsmith 74567754Smsmith return_ACPI_STATUS (Status); 74667754Smsmith} 74767754Smsmith 74867754Smsmith 749