Merge from vendor branch OPENSSH:
[dragonfly.git] / sys / contrib / dev / acpica / dsfield.c
1 /******************************************************************************
2  *
3  * Module Name: dsfield - Dispatcher field routines
4  *              $Revision: 71 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dsfield.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
117
118 #define __DSFIELD_C__
119
120 #include "acpi.h"
121 #include "amlcode.h"
122 #include "acdispat.h"
123 #include "acinterp.h"
124 #include "acnamesp.h"
125 #include "acparser.h"
126
127
128 #define _COMPONENT          ACPI_DISPATCHER
129         ACPI_MODULE_NAME    ("dsfield")
130
131
132 /*******************************************************************************
133  *
134  * FUNCTION:    AcpiDsCreateBufferField
135  *
136  * PARAMETERS:  Opcode              - The opcode to be executed
137  *              Operands            - List of operands for the opcode
138  *              WalkState           - Current state
139  *
140  * RETURN:      Status
141  *
142  * DESCRIPTION: Execute the CreateField operators:
143  *              CreateBitFieldOp,
144  *              CreateByteFieldOp,
145  *              CreateWordFieldOp,
146  *              CreateDWordFieldOp,
147  *              CreateQWordFieldOp,
148  *              CreateFieldOp       (all of which define fields in buffers)
149  *
150  ******************************************************************************/
151
152 ACPI_STATUS
153 AcpiDsCreateBufferField (
154     ACPI_PARSE_OBJECT       *Op,
155     ACPI_WALK_STATE         *WalkState)
156 {
157     ACPI_PARSE_OBJECT       *Arg;
158     ACPI_NAMESPACE_NODE     *Node;
159     ACPI_STATUS             Status;
160     ACPI_OPERAND_OBJECT     *ObjDesc;
161     ACPI_OPERAND_OBJECT     *SecondDesc = NULL;
162     UINT32                  Flags;
163
164
165     ACPI_FUNCTION_TRACE ("DsCreateBufferField");
166
167
168     /* Get the NameString argument */
169
170     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
171     {
172         Arg = AcpiPsGetArg (Op, 3);
173     }
174     else
175     {
176         /* Create Bit/Byte/Word/Dword field */
177
178         Arg = AcpiPsGetArg (Op, 2);
179     }
180
181     if (!Arg)
182     {
183         return_ACPI_STATUS (AE_AML_NO_OPERAND);
184     }
185
186     /*
187      * During the load phase, we want to enter the name of the field into
188      * the namespace.  During the execute phase (when we evaluate the size
189      * operand), we want to lookup the name
190      */
191     if (WalkState->ParseFlags & ACPI_PARSE_EXECUTE)
192     {
193         Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
194     }
195     else
196     {
197         Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
198     }
199
200     /*
201      * Enter the NameString into the namespace
202      */
203     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
204                             ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
205                             Flags, WalkState, &(Node));
206     if (ACPI_FAILURE (Status))
207     {
208         ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
209         return_ACPI_STATUS (Status);
210     }
211
212     /* We could put the returned object (Node) on the object stack for later, but
213      * for now, we will put it in the "op" object that the parser uses, so we
214      * can get it again at the end of this scope
215      */
216     Op->Common.Node = Node;
217
218     /*
219      * If there is no object attached to the node, this node was just created and
220      * we need to create the field object.  Otherwise, this was a lookup of an
221      * existing node and we don't want to create the field object again.
222      */
223     ObjDesc = AcpiNsGetAttachedObject (Node);
224     if (ObjDesc)
225     {
226         return_ACPI_STATUS (AE_OK);
227     }
228
229     /*
230      * The Field definition is not fully parsed at this time.
231      * (We must save the address of the AML for the buffer and index operands)
232      */
233
234     /* Create the buffer field object */
235
236     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
237     if (!ObjDesc)
238     {
239         Status = AE_NO_MEMORY;
240         goto Cleanup;
241     }
242
243     /*
244      * Remember location in AML stream of the field unit
245      * opcode and operands -- since the buffer and index
246      * operands must be evaluated.
247      */
248     SecondDesc                  = ObjDesc->Common.NextObject;
249     SecondDesc->Extra.AmlStart  = Op->Named.Data;
250     SecondDesc->Extra.AmlLength = Op->Named.Length;
251     ObjDesc->BufferField.Node   = Node;
252
253     /* Attach constructed field descriptors to parent node */
254
255     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD);
256     if (ACPI_FAILURE (Status))
257     {
258         goto Cleanup;
259     }
260
261
262 Cleanup:
263
264     /* Remove local reference to the object */
265
266     AcpiUtRemoveReference (ObjDesc);
267     return_ACPI_STATUS (Status);
268 }
269
270
271 /*******************************************************************************
272  *
273  * FUNCTION:    AcpiDsGetFieldNames
274  *
275  * PARAMETERS:  Info            - CreateField info structure
276  *  `           WalkState       - Current method state
277  *              Arg             - First parser arg for the field name list
278  *
279  * RETURN:      Status
280  *
281  * DESCRIPTION: Process all named fields in a field declaration.  Names are
282  *              entered into the namespace.
283  *
284  ******************************************************************************/
285
286 ACPI_STATUS
287 AcpiDsGetFieldNames (
288     ACPI_CREATE_FIELD_INFO  *Info,
289     ACPI_WALK_STATE         *WalkState,
290     ACPI_PARSE_OBJECT       *Arg)
291 {
292     ACPI_STATUS             Status;
293     ACPI_INTEGER            Position;
294
295
296     ACPI_FUNCTION_TRACE_PTR ("DsGetFieldNames", Info);
297
298
299     /* First field starts at bit zero */
300
301     Info->FieldBitPosition = 0;
302
303     /* Process all elements in the field list (of parse nodes) */
304
305     while (Arg)
306     {
307         /*
308          * Three types of field elements are handled:
309          * 1) Offset - specifies a bit offset
310          * 2) AccessAs - changes the access mode
311          * 3) Name - Enters a new named field into the namespace
312          */
313         switch (Arg->Common.AmlOpcode)
314         {
315         case AML_INT_RESERVEDFIELD_OP:
316
317             Position = (ACPI_INTEGER) Info->FieldBitPosition
318                         + (ACPI_INTEGER) Arg->Common.Value.Size;
319
320             if (Position > ACPI_UINT32_MAX)
321             {
322                 ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n"));
323                 return_ACPI_STATUS (AE_SUPPORT);
324             }
325
326             Info->FieldBitPosition = (UINT32) Position;
327             break;
328
329
330         case AML_INT_ACCESSFIELD_OP:
331
332             /*
333              * Get a new AccessType and AccessAttribute -- to be used for all
334              * field units that follow, until field end or another AccessAs keyword.
335              *
336              * In FieldFlags, preserve the flag bits other than the ACCESS_TYPE bits
337              */
338             Info->FieldFlags = (UINT8) ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
339                                         ((UINT8) (Arg->Common.Value.Integer32 >> 8)));
340
341             Info->Attribute = (UINT8) (Arg->Common.Value.Integer32);
342             break;
343
344
345         case AML_INT_NAMEDFIELD_OP:
346
347             /* Lookup the name */
348
349             Status = AcpiNsLookup (WalkState->ScopeInfo,
350                             (char *) &Arg->Named.Name,
351                             Info->FieldType, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
352                             WalkState, &Info->FieldNode);
353             if (ACPI_FAILURE (Status))
354             {
355                 ACPI_REPORT_NSERROR ((char *) &Arg->Named.Name, Status);
356                 if (Status != AE_ALREADY_EXISTS)
357                 {
358                     return_ACPI_STATUS (Status);
359                 }
360
361                 /* Already exists, ignore error */
362             }
363             else
364             {
365                 Arg->Common.Node = Info->FieldNode;
366                 Info->FieldBitLength = Arg->Common.Value.Size;
367
368                 /* Create and initialize an object for the new Field Node */
369
370                 Status = AcpiExPrepFieldValue (Info);
371                 if (ACPI_FAILURE (Status))
372                 {
373                     return_ACPI_STATUS (Status);
374                 }
375             }
376
377             /* Keep track of bit position for the next field */
378
379             Position = (ACPI_INTEGER) Info->FieldBitPosition
380                         + (ACPI_INTEGER) Arg->Common.Value.Size;
381
382             if (Position > ACPI_UINT32_MAX)
383             {
384                 ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
385                         (char *) &Info->FieldNode->Name));
386                 return_ACPI_STATUS (AE_SUPPORT);
387             }
388
389             Info->FieldBitPosition += Info->FieldBitLength;
390             break;
391
392
393         default:
394
395             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",
396                 Arg->Common.AmlOpcode));
397             return_ACPI_STATUS (AE_AML_BAD_OPCODE);
398         }
399
400         Arg = Arg->Common.Next;
401     }
402
403     return_ACPI_STATUS (AE_OK);
404 }
405
406
407 /*******************************************************************************
408  *
409  * FUNCTION:    AcpiDsCreateField
410  *
411  * PARAMETERS:  Op              - Op containing the Field definition and args
412  *              RegionNode      - Object for the containing Operation Region
413  *  `           WalkState       - Current method state
414  *
415  * RETURN:      Status
416  *
417  * DESCRIPTION: Create a new field in the specified operation region
418  *
419  ******************************************************************************/
420
421 ACPI_STATUS
422 AcpiDsCreateField (
423     ACPI_PARSE_OBJECT       *Op,
424     ACPI_NAMESPACE_NODE     *RegionNode,
425     ACPI_WALK_STATE         *WalkState)
426 {
427     ACPI_STATUS             Status;
428     ACPI_PARSE_OBJECT       *Arg;
429     ACPI_CREATE_FIELD_INFO  Info;
430
431
432     ACPI_FUNCTION_TRACE_PTR ("DsCreateField", Op);
433
434
435     /* First arg is the name of the parent OpRegion (must already exist) */
436
437     Arg = Op->Common.Value.Arg;
438     if (!RegionNode)
439     {
440         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
441                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
442                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
443         if (ACPI_FAILURE (Status))
444         {
445             ACPI_REPORT_NSERROR (Arg->Common.Value.Name, Status);
446             return_ACPI_STATUS (Status);
447         }
448     }
449
450     /* Second arg is the field flags */
451
452     Arg = Arg->Common.Next;
453     Info.FieldFlags = Arg->Common.Value.Integer8;
454     Info.Attribute = 0;
455
456     /* Each remaining arg is a Named Field */
457
458     Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
459     Info.RegionNode = RegionNode;
460
461     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
462
463     return_ACPI_STATUS (Status);
464 }
465
466
467 /*******************************************************************************
468  *
469  * FUNCTION:    AcpiDsInitFieldObjects
470  *
471  * PARAMETERS:  Op              - Op containing the Field definition and args
472  *  `           WalkState       - Current method state
473  *
474  * RETURN:      Status
475  *
476  * DESCRIPTION: For each "Field Unit" name in the argument list that is
477  *              part of the field declaration, enter the name into the
478  *              namespace.
479  *
480  ******************************************************************************/
481
482 ACPI_STATUS
483 AcpiDsInitFieldObjects (
484     ACPI_PARSE_OBJECT       *Op,
485     ACPI_WALK_STATE         *WalkState)
486 {
487     ACPI_STATUS             Status;
488     ACPI_PARSE_OBJECT       *Arg = NULL;
489     ACPI_NAMESPACE_NODE     *Node;
490     UINT8                   Type = 0;
491
492
493     ACPI_FUNCTION_TRACE_PTR ("DsInitFieldObjects", Op);
494
495
496     switch (WalkState->Opcode)
497     {
498     case AML_FIELD_OP:
499         Arg = AcpiPsGetArg (Op, 2);
500         Type = ACPI_TYPE_LOCAL_REGION_FIELD;
501         break;
502
503     case AML_BANK_FIELD_OP:
504         Arg = AcpiPsGetArg (Op, 4);
505         Type = ACPI_TYPE_LOCAL_BANK_FIELD;
506         break;
507
508     case AML_INDEX_FIELD_OP:
509         Arg = AcpiPsGetArg (Op, 3);
510         Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
511         break;
512
513     default:
514         return_ACPI_STATUS (AE_BAD_PARAMETER);
515     }
516
517     /*
518      * Walk the list of entries in the FieldList
519      */
520     while (Arg)
521     {
522         /* Ignore OFFSET and ACCESSAS terms here */
523
524         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
525         {
526             Status = AcpiNsLookup (WalkState->ScopeInfo,
527                             (char *) &Arg->Named.Name,
528                             Type, ACPI_IMODE_LOAD_PASS1,
529                             ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
530                             WalkState, &Node);
531             if (ACPI_FAILURE (Status))
532             {
533                 ACPI_REPORT_NSERROR ((char *) &Arg->Named.Name, Status);
534                 if (Status != AE_ALREADY_EXISTS)
535                 {
536                     return_ACPI_STATUS (Status);
537                 }
538
539                 /* Name already exists, just ignore this error */
540
541                 Status = AE_OK;
542             }
543
544             Arg->Common.Node = Node;
545         }
546
547         /* Move to next field in the list */
548
549         Arg = Arg->Common.Next;
550     }
551
552     return_ACPI_STATUS (AE_OK);
553 }
554
555
556 /*******************************************************************************
557  *
558  * FUNCTION:    AcpiDsCreateBankField
559  *
560  * PARAMETERS:  Op              - Op containing the Field definition and args
561  *              RegionNode      - Object for the containing Operation Region
562  *  `           WalkState       - Current method state
563  *
564  * RETURN:      Status
565  *
566  * DESCRIPTION: Create a new bank field in the specified operation region
567  *
568  ******************************************************************************/
569
570 ACPI_STATUS
571 AcpiDsCreateBankField (
572     ACPI_PARSE_OBJECT       *Op,
573     ACPI_NAMESPACE_NODE     *RegionNode,
574     ACPI_WALK_STATE         *WalkState)
575 {
576     ACPI_STATUS             Status;
577     ACPI_PARSE_OBJECT       *Arg;
578     ACPI_CREATE_FIELD_INFO  Info;
579
580
581     ACPI_FUNCTION_TRACE_PTR ("DsCreateBankField", Op);
582
583
584     /* First arg is the name of the parent OpRegion (must already exist) */
585
586     Arg = Op->Common.Value.Arg;
587     if (!RegionNode)
588     {
589         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
590                         ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
591                         ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
592         if (ACPI_FAILURE (Status))
593         {
594             ACPI_REPORT_NSERROR (Arg->Common.Value.Name, Status);
595             return_ACPI_STATUS (Status);
596         }
597     }
598
599     /* Second arg is the Bank Register (Field) (must already exist) */
600
601     Arg = Arg->Common.Next;
602     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
603                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
604                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
605     if (ACPI_FAILURE (Status))
606     {
607         ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
608         return_ACPI_STATUS (Status);
609     }
610
611     /* Third arg is the BankValue */
612
613     Arg = Arg->Common.Next;
614     Info.BankValue = Arg->Common.Value.Integer32;
615
616     /* Fourth arg is the field flags */
617
618     Arg = Arg->Common.Next;
619     Info.FieldFlags = Arg->Common.Value.Integer8;
620
621     /* Each remaining arg is a Named Field */
622
623     Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
624     Info.RegionNode = RegionNode;
625
626     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
627
628     return_ACPI_STATUS (Status);
629 }
630
631
632 /*******************************************************************************
633  *
634  * FUNCTION:    AcpiDsCreateIndexField
635  *
636  * PARAMETERS:  Op              - Op containing the Field definition and args
637  *              RegionNode      - Object for the containing Operation Region
638  *  `           WalkState       - Current method state
639  *
640  * RETURN:      Status
641  *
642  * DESCRIPTION: Create a new index field in the specified operation region
643  *
644  ******************************************************************************/
645
646 ACPI_STATUS
647 AcpiDsCreateIndexField (
648     ACPI_PARSE_OBJECT       *Op,
649     ACPI_NAMESPACE_NODE     *RegionNode,
650     ACPI_WALK_STATE         *WalkState)
651 {
652     ACPI_STATUS             Status;
653     ACPI_PARSE_OBJECT       *Arg;
654     ACPI_CREATE_FIELD_INFO  Info;
655
656
657     ACPI_FUNCTION_TRACE_PTR ("DsCreateIndexField", Op);
658
659
660     /* First arg is the name of the Index register (must already exist) */
661
662     Arg = Op->Common.Value.Arg;
663     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
664                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
665                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
666     if (ACPI_FAILURE (Status))
667     {
668         ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
669         return_ACPI_STATUS (Status);
670     }
671
672     /* Second arg is the data register (must already exist) */
673
674     Arg = Arg->Common.Next;
675     Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
676                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
677                     ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
678     if (ACPI_FAILURE (Status))
679     {
680         ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status);
681         return_ACPI_STATUS (Status);
682     }
683
684     /* Next arg is the field flags */
685
686     Arg = Arg->Common.Next;
687     Info.FieldFlags = Arg->Common.Value.Integer8;
688
689     /* Each remaining arg is a Named Field */
690
691     Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
692     Info.RegionNode = RegionNode;
693
694     Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
695
696     return_ACPI_STATUS (Status);
697 }
698
699