xref: /titanic_51/usr/src/uts/intel/io/acpica/dispatcher/dsfield.c (revision d74f5eca2277b6a0ce0e8757a5a4b41f4dcbf8ba)
1 /******************************************************************************
2  *
3  * Module Name: dsfield - Dispatcher field routines
4  *              $Revision: 1.87 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #define __DSFIELD_C__
118 
119 #include "acpi.h"
120 #include "amlcode.h"
121 #include "acdispat.h"
122 #include "acinterp.h"
123 #include "acnamesp.h"
124 #include "acparser.h"
125 
126 
127 #define _COMPONENT          ACPI_DISPATCHER
128         ACPI_MODULE_NAME    ("dsfield")
129 
130 /* Local prototypes */
131 
132 static ACPI_STATUS
133 AcpiDsGetFieldNames (
134     ACPI_CREATE_FIELD_INFO  *Info,
135     ACPI_WALK_STATE         *WalkState,
136     ACPI_PARSE_OBJECT       *Arg);
137 
138 
139 /*******************************************************************************
140  *
141  * FUNCTION:    AcpiDsCreateBufferField
142  *
143  * PARAMETERS:  Op                  - Current parse op (CreateXXField)
144  *              WalkState           - Current state
145  *
146  * RETURN:      Status
147  *
148  * DESCRIPTION: Execute the CreateField operators:
149  *              CreateBitFieldOp,
150  *              CreateByteFieldOp,
151  *              CreateWordFieldOp,
152  *              CreateDWordFieldOp,
153  *              CreateQWordFieldOp,
154  *              CreateFieldOp       (all of which define a field in a buffer)
155  *
156  ******************************************************************************/
157 
158 ACPI_STATUS
159 AcpiDsCreateBufferField (
160     ACPI_PARSE_OBJECT       *Op,
161     ACPI_WALK_STATE         *WalkState)
162 {
163     ACPI_PARSE_OBJECT       *Arg;
164     ACPI_NAMESPACE_NODE     *Node;
165     ACPI_STATUS             Status;
166     ACPI_OPERAND_OBJECT     *ObjDesc;
167     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
168     UINT32                  Flags;
169 
170 
171     ACPI_FUNCTION_TRACE (DsCreateBufferField);
172 
173 
174     /*
175      * Get the NameString argument (name of the new BufferField)
176      */
177     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
178     {
179         /* For CreateField, name is the 4th argument */
180 
181         Arg = AcpiPsGetArg (Op, 3);
182     }
183     else
184     {
185         /* For all other CreateXXXField operators, name is the 3rd argument */
186 
187         Arg = AcpiPsGetArg (Op, 2);
188     }
189 
190     if (!Arg)
191     {
192         return_ACPI_STATUS (AE_AML_NO_OPERAND);
193     }
194 
195     if (WalkState->DeferredNode)
196     {
197         Node = WalkState->DeferredNode;
198         Status = AE_OK;
199     }
200     else
201     {
202         /* Execute flag should always be set when this function is entered */
203 
204         if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
205         {
206             return_ACPI_STATUS (AE_AML_INTERNAL);
207         }
208 
209         /* Creating new namespace node, should not already exist */
210 
211         Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
212                 ACPI_NS_ERROR_IF_FOUND;
213 
214         /* Mark node temporary if we are executing a method */
215 
216         if (WalkState->MethodNode)
217         {
218             Flags |= ACPI_NS_TEMPORARY;
219         }
220 
221         /* Enter the NameString into the namespace */
222 
223         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
224                     ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
225                     Flags, WalkState, &Node);
226         if (ACPI_FAILURE (Status))
227         {
228             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
229             return_ACPI_STATUS (Status);
230         }
231     }
232 
233     /*
234      * We could put the returned object (Node) on the object stack for later,
235      * but for now, we will put it in the "op" object that the parser uses,
236      * so we can get it again at the end of this scope.
237      */
238     Op->Common.Node = Node;
239 
240     /*
241      * If there is no object attached to the node, this node was just created
242      * and we need to create the field object. Otherwise, this was a lookup
243      * of an existing node and we don't want to create the field object again.
244      */
245     ObjDesc = AcpiNsGetAttachedObject (Node);
246     if (ObjDesc)
247     {
248         return_ACPI_STATUS (AE_OK);
249     }
250 
251     /*
252      * The Field definition is not fully parsed at this time.
253      * (We must save the address of the AML for the buffer and index operands)
254      */
255 
256     /* Create the buffer field object */
257 
258     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
259     if (!ObjDesc)
260     {
261         Status = AE_NO_MEMORY;
262         goto Cleanup;
263     }
264 
265     /*
266      * Remember location in AML stream of the field unit opcode and operands --
267      * since the buffer and index operands must be evaluated.
268      */
269     SecondDesc                  = ObjDesc->Common.NextObject;
270     SecondDesc->Extra.AmlStart  = Op->Named.Data;
271     SecondDesc->Extra.AmlLength = Op->Named.Length;
272     ObjDesc->BufferField.Node   = Node;
273 
274     /* Attach constructed field descriptors to parent node */
275 
276     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD);
277     if (ACPI_FAILURE (Status))
278     {
279         goto Cleanup;
280     }
281 
282 
283 Cleanup:
284 
285     /* Remove local reference to the object */
286 
287     AcpiUtRemoveReference (ObjDesc);
288     return_ACPI_STATUS (Status);
289 }
290 
291 
292 /*******************************************************************************
293  *
294  * FUNCTION:    AcpiDsGetFieldNames
295  *
296  * PARAMETERS:  Info            - CreateField info structure
297  *  `           WalkState       - Current method state
298  *              Arg             - First parser arg for the field name list
299  *
300  * RETURN:      Status
301  *
302  * DESCRIPTION: Process all named fields in a field declaration.  Names are
303  *              entered into the namespace.
304  *
305  ******************************************************************************/
306 
307 static ACPI_STATUS
308 AcpiDsGetFieldNames (
309     ACPI_CREATE_FIELD_INFO  *Info,
310     ACPI_WALK_STATE         *WalkState,
311     ACPI_PARSE_OBJECT       *Arg)
312 {
313     ACPI_STATUS             Status;
314     ACPI_INTEGER            Position;
315 
316 
317     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
318 
319 
320     /* First field starts at bit zero */
321 
322     Info->FieldBitPosition = 0;
323 
324     /* Process all elements in the field list (of parse nodes) */
325 
326     while (Arg)
327     {
328         /*
329          * Three types of field elements are handled:
330          * 1) Offset - specifies a bit offset
331          * 2) AccessAs - changes the access mode
332          * 3) Name - Enters a new named field into the namespace
333          */
334         switch (Arg->Common.AmlOpcode)
335         {
336         case AML_INT_RESERVEDFIELD_OP:
337 
338             Position = (ACPI_INTEGER) Info->FieldBitPosition
339                         + (ACPI_INTEGER) Arg->Common.Value.Size;
340 
341             if (Position > ACPI_UINT32_MAX)
342             {
343                 ACPI_ERROR ((AE_INFO,
344                     "Bit offset within field too large (> 0xFFFFFFFF)"));
345                 return_ACPI_STATUS (AE_SUPPORT);
346             }
347 
348             Info->FieldBitPosition = (UINT32) Position;
349             break;
350 
351 
352         case AML_INT_ACCESSFIELD_OP:
353 
354             /*
355              * Get a new AccessType and AccessAttribute -- to be used for all
356              * field units that follow, until field end or another AccessAs
357              * keyword.
358              *
359              * In FieldFlags, preserve the flag bits other than the
360              * ACCESS_TYPE bits
361              */
362             Info->FieldFlags = (UINT8)
363                 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
364                 ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8)));
365 
366             Info->Attribute = (UINT8) (Arg->Common.Value.Integer);
367             break;
368 
369 
370         case AML_INT_NAMEDFIELD_OP:
371 
372             /* Lookup the name, it should already exist */
373 
374             Status = AcpiNsLookup (WalkState->ScopeInfo,
375                         (char *) &Arg->Named.Name, Info->FieldType,
376                         ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
377                         WalkState, &Info->FieldNode);
378             if (ACPI_FAILURE (Status))
379             {
380                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
381                 return_ACPI_STATUS (Status);
382             }
383             else
384             {
385                 Arg->Common.Node = Info->FieldNode;
386                 Info->FieldBitLength = Arg->Common.Value.Size;
387 
388                 /*
389                  * If there is no object attached to the node, this node was
390                  * just created and we need to create the field object.
391                  * Otherwise, this was a lookup of an existing node and we
392                  * don't want to create the field object again.
393                  */
394                 if (!AcpiNsGetAttachedObject (Info->FieldNode))
395                 {
396                     Status = AcpiExPrepFieldValue (Info);
397                     if (ACPI_FAILURE (Status))
398                     {
399                         return_ACPI_STATUS (Status);
400                     }
401                 }
402             }
403 
404             /* Keep track of bit position for the next field */
405 
406             Position = (ACPI_INTEGER) Info->FieldBitPosition
407                         + (ACPI_INTEGER) Arg->Common.Value.Size;
408 
409             if (Position > ACPI_UINT32_MAX)
410             {
411                 ACPI_ERROR ((AE_INFO,
412                     "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
413                     ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
414                 return_ACPI_STATUS (AE_SUPPORT);
415             }
416 
417             Info->FieldBitPosition += Info->FieldBitLength;
418             break;
419 
420 
421         default:
422 
423             ACPI_ERROR ((AE_INFO,
424                 "Invalid opcode in field list: %X", Arg->Common.AmlOpcode));
425             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
426         }
427 
428         Arg = Arg->Common.Next;
429     }
430 
431     return_ACPI_STATUS (AE_OK);
432 }
433 
434 
435 /*******************************************************************************
436  *
437  * FUNCTION:    AcpiDsCreateField
438  *
439  * PARAMETERS:  Op              - Op containing the Field definition and args
440  *              RegionNode      - Object for the containing Operation Region
441  *  `           WalkState       - Current method state
442  *
443  * RETURN:      Status
444  *
445  * DESCRIPTION: Create a new field in the specified operation region
446  *
447  ******************************************************************************/
448 
449 ACPI_STATUS
450 AcpiDsCreateField (
451     ACPI_PARSE_OBJECT       *Op,
452     ACPI_NAMESPACE_NODE     *RegionNode,
453     ACPI_WALK_STATE         *WalkState)
454 {
455     ACPI_STATUS             Status;
456     ACPI_PARSE_OBJECT       *Arg;
457     ACPI_CREATE_FIELD_INFO  Info;
458 
459 
460     ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
461 
462 
463     /* First arg is the name of the parent OpRegion (must already exist) */
464 
465     Arg = Op->Common.Value.Arg;
466     if (!RegionNode)
467     {
468         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
469                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
470                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
471         if (ACPI_FAILURE (Status))
472         {
473             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
474             return_ACPI_STATUS (Status);
475         }
476     }
477 
478     /* Second arg is the field flags */
479 
480     Arg = Arg->Common.Next;
481     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
482     Info.Attribute = 0;
483 
484     /* Each remaining arg is a Named Field */
485 
486     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
487     Info.RegionNode = RegionNode;
488 
489     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
490 
491     return_ACPI_STATUS (Status);
492 }
493 
494 
495 /*******************************************************************************
496  *
497  * FUNCTION:    AcpiDsInitFieldObjects
498  *
499  * PARAMETERS:  Op              - Op containing the Field definition and args
500  *  `           WalkState       - Current method state
501  *
502  * RETURN:      Status
503  *
504  * DESCRIPTION: For each "Field Unit" name in the argument list that is
505  *              part of the field declaration, enter the name into the
506  *              namespace.
507  *
508  ******************************************************************************/
509 
510 ACPI_STATUS
511 AcpiDsInitFieldObjects (
512     ACPI_PARSE_OBJECT       *Op,
513     ACPI_WALK_STATE         *WalkState)
514 {
515     ACPI_STATUS             Status;
516     ACPI_PARSE_OBJECT       *Arg = NULL;
517     ACPI_NAMESPACE_NODE     *Node;
518     UINT8                   Type = 0;
519     UINT32                  Flags;
520 
521 
522     ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
523 
524 
525     /* Execute flag should always be set when this function is entered */
526 
527     if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
528     {
529         if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
530         {
531             /* BankField Op is deferred, just return OK */
532 
533             return_ACPI_STATUS (AE_OK);
534         }
535 
536         return_ACPI_STATUS (AE_AML_INTERNAL);
537     }
538 
539     /*
540      * Get the FieldList argument for this opcode. This is the start of the
541      * list of field elements.
542      */
543     switch (WalkState->Opcode)
544     {
545     case AML_FIELD_OP:
546         Arg = AcpiPsGetArg (Op, 2);
547         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
548         break;
549 
550     case AML_BANK_FIELD_OP:
551         Arg = AcpiPsGetArg (Op, 4);
552         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
553         break;
554 
555     case AML_INDEX_FIELD_OP:
556         Arg = AcpiPsGetArg (Op, 3);
557         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
558         break;
559 
560     default:
561         return_ACPI_STATUS (AE_BAD_PARAMETER);
562     }
563 
564     /* Creating new namespace node(s), should not already exist */
565 
566     Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
567             ACPI_NS_ERROR_IF_FOUND;
568 
569     /* Mark node(s) temporary if we are executing a method */
570 
571     if (WalkState->MethodNode)
572     {
573         Flags |= ACPI_NS_TEMPORARY;
574     }
575 
576     /*
577      * Walk the list of entries in the FieldList
578      * Note: FieldList can be of zero length. In this case, Arg will be NULL.
579      */
580     while (Arg)
581     {
582         /*
583          * Ignore OFFSET and ACCESSAS terms here; we are only interested in the
584          * field names in order to enter them into the namespace.
585          */
586         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
587         {
588             Status = AcpiNsLookup (WalkState->ScopeInfo,
589                         (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
590                         Flags, WalkState, &Node);
591             if (ACPI_FAILURE (Status))
592             {
593                 ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
594                 if (Status != AE_ALREADY_EXISTS)
595                 {
596                     return_ACPI_STATUS (Status);
597                 }
598 
599                 /* Name already exists, just ignore this error */
600 
601                 Status = AE_OK;
602             }
603 
604             Arg->Common.Node = Node;
605         }
606 
607         /* Get the next field element in the list */
608 
609         Arg = Arg->Common.Next;
610     }
611 
612     return_ACPI_STATUS (AE_OK);
613 }
614 
615 
616 /*******************************************************************************
617  *
618  * FUNCTION:    AcpiDsCreateBankField
619  *
620  * PARAMETERS:  Op              - Op containing the Field definition and args
621  *              RegionNode      - Object for the containing Operation Region
622  *              WalkState       - Current method state
623  *
624  * RETURN:      Status
625  *
626  * DESCRIPTION: Create a new bank field in the specified operation region
627  *
628  ******************************************************************************/
629 
630 ACPI_STATUS
631 AcpiDsCreateBankField (
632     ACPI_PARSE_OBJECT       *Op,
633     ACPI_NAMESPACE_NODE     *RegionNode,
634     ACPI_WALK_STATE         *WalkState)
635 {
636     ACPI_STATUS             Status;
637     ACPI_PARSE_OBJECT       *Arg;
638     ACPI_CREATE_FIELD_INFO  Info;
639 
640 
641     ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
642 
643 
644     /* First arg is the name of the parent OpRegion (must already exist) */
645 
646     Arg = Op->Common.Value.Arg;
647     if (!RegionNode)
648     {
649         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
650                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
651                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
652         if (ACPI_FAILURE (Status))
653         {
654             ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
655             return_ACPI_STATUS (Status);
656         }
657     }
658 
659     /* Second arg is the Bank Register (Field) (must already exist) */
660 
661     Arg = Arg->Common.Next;
662     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
663                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
664                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
665     if (ACPI_FAILURE (Status))
666     {
667         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
668         return_ACPI_STATUS (Status);
669     }
670 
671     /*
672      * Third arg is the BankValue
673      * This arg is a TermArg, not a constant
674      * It will be evaluated later, by AcpiDsEvalBankFieldOperands
675      */
676     Arg = Arg->Common.Next;
677 
678     /* Fourth arg is the field flags */
679 
680     Arg = Arg->Common.Next;
681     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
682 
683     /* Each remaining arg is a Named Field */
684 
685     Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
686     Info.RegionNode = RegionNode;
687 
688     /*
689      * Use Info.DataRegisterNode to store BankField Op
690      * It's safe because DataRegisterNode will never be used when create bank field
691      * We store AmlStart and AmlLength in the BankField Op for late evaluation
692      * Used in AcpiExPrepFieldValue(Info)
693      *
694      * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"?
695      */
696     Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
697 
698     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
699     return_ACPI_STATUS (Status);
700 }
701 
702 
703 /*******************************************************************************
704  *
705  * FUNCTION:    AcpiDsCreateIndexField
706  *
707  * PARAMETERS:  Op              - Op containing the Field definition and args
708  *              RegionNode      - Object for the containing Operation Region
709  *  `           WalkState       - Current method state
710  *
711  * RETURN:      Status
712  *
713  * DESCRIPTION: Create a new index field in the specified operation region
714  *
715  ******************************************************************************/
716 
717 ACPI_STATUS
718 AcpiDsCreateIndexField (
719     ACPI_PARSE_OBJECT       *Op,
720     ACPI_NAMESPACE_NODE     *RegionNode,
721     ACPI_WALK_STATE         *WalkState)
722 {
723     ACPI_STATUS             Status;
724     ACPI_PARSE_OBJECT       *Arg;
725     ACPI_CREATE_FIELD_INFO  Info;
726 
727 
728     ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op);
729 
730 
731     /* First arg is the name of the Index register (must already exist) */
732 
733     Arg = Op->Common.Value.Arg;
734     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
735                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
736                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
737     if (ACPI_FAILURE (Status))
738     {
739         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
740         return_ACPI_STATUS (Status);
741     }
742 
743     /* Second arg is the data register (must already exist) */
744 
745     Arg = Arg->Common.Next;
746     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
747                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
748                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
749     if (ACPI_FAILURE (Status))
750     {
751         ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
752         return_ACPI_STATUS (Status);
753     }
754 
755     /* Next arg is the field flags */
756 
757     Arg = Arg->Common.Next;
758     Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
759 
760     /* Each remaining arg is a Named Field */
761 
762     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
763     Info.RegionNode = RegionNode;
764 
765     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
766 
767     return_ACPI_STATUS (Status);
768 }
769 
770 
771