OSDN Git Service

klibc基本機能実装. ACPICAの準備
[vaneos/DivergeMirror.git] / drivers / acpi / components / dispatcher / dsopcode.c
1 /******************************************************************************
2  *
3  * Module Name: dsopcode - Dispatcher support for regions and fields
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************/
115
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acparser.h"
119 #include "amlcode.h"
120 #include "acdispat.h"
121 #include "acinterp.h"
122 #include "acnamesp.h"
123 #include "acevents.h"
124 #include "actables.h"
125
126 #define _COMPONENT          ACPI_DISPATCHER
127         ACPI_MODULE_NAME    ("dsopcode")
128
129 /* Local prototypes */
130
131 static ACPI_STATUS
132 AcpiDsInitBufferField (
133     UINT16                  AmlOpcode,
134     ACPI_OPERAND_OBJECT     *ObjDesc,
135     ACPI_OPERAND_OBJECT     *BufferDesc,
136     ACPI_OPERAND_OBJECT     *OffsetDesc,
137     ACPI_OPERAND_OBJECT     *LengthDesc,
138     ACPI_OPERAND_OBJECT     *ResultDesc);
139
140
141 /*******************************************************************************
142  *
143  * FUNCTION:    AcpiDsInitializeRegion
144  *
145  * PARAMETERS:  ObjHandle       - Region namespace node
146  *
147  * RETURN:      Status
148  *
149  * DESCRIPTION: Front end to EvInitializeRegion
150  *
151  ******************************************************************************/
152
153 ACPI_STATUS
154 AcpiDsInitializeRegion (
155     ACPI_HANDLE             ObjHandle)
156 {
157     ACPI_OPERAND_OBJECT     *ObjDesc;
158     ACPI_STATUS             Status;
159
160
161     ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
162
163     /* Namespace is NOT locked */
164
165     Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
166     return (Status);
167 }
168
169
170 /*******************************************************************************
171  *
172  * FUNCTION:    AcpiDsInitBufferField
173  *
174  * PARAMETERS:  AmlOpcode       - CreateXxxField
175  *              ObjDesc         - BufferField object
176  *              BufferDesc      - Host Buffer
177  *              OffsetDesc      - Offset into buffer
178  *              LengthDesc      - Length of field (CREATE_FIELD_OP only)
179  *              ResultDesc      - Where to store the result
180  *
181  * RETURN:      Status
182  *
183  * DESCRIPTION: Perform actual initialization of a buffer field
184  *
185  ******************************************************************************/
186
187 static ACPI_STATUS
188 AcpiDsInitBufferField (
189     UINT16                  AmlOpcode,
190     ACPI_OPERAND_OBJECT     *ObjDesc,
191     ACPI_OPERAND_OBJECT     *BufferDesc,
192     ACPI_OPERAND_OBJECT     *OffsetDesc,
193     ACPI_OPERAND_OBJECT     *LengthDesc,
194     ACPI_OPERAND_OBJECT     *ResultDesc)
195 {
196     UINT32                  Offset;
197     UINT32                  BitOffset;
198     UINT32                  BitCount;
199     UINT8                   FieldFlags;
200     ACPI_STATUS             Status;
201
202
203     ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc);
204
205
206     /* Host object must be a Buffer */
207
208     if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER)
209     {
210         ACPI_ERROR ((AE_INFO,
211             "Target of Create Field is not a Buffer object - %s",
212             AcpiUtGetObjectTypeName (BufferDesc)));
213
214         Status = AE_AML_OPERAND_TYPE;
215         goto Cleanup;
216     }
217
218     /*
219      * The last parameter to all of these opcodes (ResultDesc) started
220      * out as a NameString, and should therefore now be a NS node
221      * after resolution in AcpiExResolveOperands().
222      */
223     if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
224     {
225         ACPI_ERROR ((AE_INFO,
226             "(%s) destination not a NS Node [%s]",
227             AcpiPsGetOpcodeName (AmlOpcode),
228             AcpiUtGetDescriptorName (ResultDesc)));
229
230         Status = AE_AML_OPERAND_TYPE;
231         goto Cleanup;
232     }
233
234     Offset = (UINT32) OffsetDesc->Integer.Value;
235
236     /*
237      * Setup the Bit offsets and counts, according to the opcode
238      */
239     switch (AmlOpcode)
240     {
241     case AML_CREATE_FIELD_OP:
242
243         /* Offset is in bits, count is in bits */
244
245         FieldFlags = AML_FIELD_ACCESS_BYTE;
246         BitOffset  = Offset;
247         BitCount   = (UINT32) LengthDesc->Integer.Value;
248
249         /* Must have a valid (>0) bit count */
250
251         if (BitCount == 0)
252         {
253             ACPI_ERROR ((AE_INFO,
254                 "Attempt to CreateField of length zero"));
255             Status = AE_AML_OPERAND_VALUE;
256             goto Cleanup;
257         }
258         break;
259
260     case AML_CREATE_BIT_FIELD_OP:
261
262         /* Offset is in bits, Field is one bit */
263
264         BitOffset  = Offset;
265         BitCount   = 1;
266         FieldFlags = AML_FIELD_ACCESS_BYTE;
267         break;
268
269     case AML_CREATE_BYTE_FIELD_OP:
270
271         /* Offset is in bytes, field is one byte */
272
273         BitOffset  = 8 * Offset;
274         BitCount   = 8;
275         FieldFlags = AML_FIELD_ACCESS_BYTE;
276         break;
277
278     case AML_CREATE_WORD_FIELD_OP:
279
280         /* Offset is in bytes, field is one word */
281
282         BitOffset  = 8 * Offset;
283         BitCount   = 16;
284         FieldFlags = AML_FIELD_ACCESS_WORD;
285         break;
286
287     case AML_CREATE_DWORD_FIELD_OP:
288
289         /* Offset is in bytes, field is one dword */
290
291         BitOffset  = 8 * Offset;
292         BitCount   = 32;
293         FieldFlags = AML_FIELD_ACCESS_DWORD;
294         break;
295
296     case AML_CREATE_QWORD_FIELD_OP:
297
298         /* Offset is in bytes, field is one qword */
299
300         BitOffset  = 8 * Offset;
301         BitCount   = 64;
302         FieldFlags = AML_FIELD_ACCESS_QWORD;
303         break;
304
305     default:
306
307         ACPI_ERROR ((AE_INFO,
308             "Unknown field creation opcode 0x%02X",
309             AmlOpcode));
310         Status = AE_AML_BAD_OPCODE;
311         goto Cleanup;
312     }
313
314     /* Entire field must fit within the current length of the buffer */
315
316     if ((BitOffset + BitCount) >
317         (8 * (UINT32) BufferDesc->Buffer.Length))
318     {
319         ACPI_ERROR ((AE_INFO,
320             "Field [%4.4s] at %u exceeds Buffer [%4.4s] size %u (bits)",
321             AcpiUtGetNodeName (ResultDesc),
322             BitOffset + BitCount,
323             AcpiUtGetNodeName (BufferDesc->Buffer.Node),
324             8 * (UINT32) BufferDesc->Buffer.Length));
325         Status = AE_AML_BUFFER_LIMIT;
326         goto Cleanup;
327     }
328
329     /*
330      * Initialize areas of the field object that are common to all fields
331      * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK),
332      * UPDATE_RULE = 0 (UPDATE_PRESERVE)
333      */
334     Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
335                                             BitOffset, BitCount);
336     if (ACPI_FAILURE (Status))
337     {
338         goto Cleanup;
339     }
340
341     ObjDesc->BufferField.BufferObj = BufferDesc;
342
343     /* Reference count for BufferDesc inherits ObjDesc count */
344
345     BufferDesc->Common.ReferenceCount = (UINT16)
346         (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount);
347
348
349 Cleanup:
350
351     /* Always delete the operands */
352
353     AcpiUtRemoveReference (OffsetDesc);
354     AcpiUtRemoveReference (BufferDesc);
355
356     if (AmlOpcode == AML_CREATE_FIELD_OP)
357     {
358         AcpiUtRemoveReference (LengthDesc);
359     }
360
361     /* On failure, delete the result descriptor */
362
363     if (ACPI_FAILURE (Status))
364     {
365         AcpiUtRemoveReference (ResultDesc);     /* Result descriptor */
366     }
367     else
368     {
369         /* Now the address and length are valid for this BufferField */
370
371         ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
372     }
373
374     return_ACPI_STATUS (Status);
375 }
376
377
378 /*******************************************************************************
379  *
380  * FUNCTION:    AcpiDsEvalBufferFieldOperands
381  *
382  * PARAMETERS:  WalkState       - Current walk
383  *              Op              - A valid BufferField Op object
384  *
385  * RETURN:      Status
386  *
387  * DESCRIPTION: Get BufferField Buffer and Index
388  *              Called from AcpiDsExecEndOp during BufferField parse tree walk
389  *
390  ******************************************************************************/
391
392 ACPI_STATUS
393 AcpiDsEvalBufferFieldOperands (
394     ACPI_WALK_STATE         *WalkState,
395     ACPI_PARSE_OBJECT       *Op)
396 {
397     ACPI_STATUS             Status;
398     ACPI_OPERAND_OBJECT     *ObjDesc;
399     ACPI_NAMESPACE_NODE     *Node;
400     ACPI_PARSE_OBJECT       *NextOp;
401
402
403     ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op);
404
405
406     /*
407      * This is where we evaluate the address and length fields of the
408      * CreateXxxField declaration
409      */
410     Node =  Op->Common.Node;
411
412     /* NextOp points to the op that holds the Buffer */
413
414     NextOp = Op->Common.Value.Arg;
415
416     /* Evaluate/create the address and length operands */
417
418     Status = AcpiDsCreateOperands (WalkState, NextOp);
419     if (ACPI_FAILURE (Status))
420     {
421         return_ACPI_STATUS (Status);
422     }
423
424     ObjDesc = AcpiNsGetAttachedObject (Node);
425     if (!ObjDesc)
426     {
427         return_ACPI_STATUS (AE_NOT_EXIST);
428     }
429
430     /* Resolve the operands */
431
432     Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
433                     ACPI_WALK_OPERANDS, WalkState);
434     if (ACPI_FAILURE (Status))
435     {
436         ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",
437             AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
438
439         return_ACPI_STATUS (Status);
440     }
441
442     /* Initialize the Buffer Field */
443
444     if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
445     {
446         /* NOTE: Slightly different operands for this opcode */
447
448         Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
449                     WalkState->Operands[0], WalkState->Operands[1],
450                     WalkState->Operands[2], WalkState->Operands[3]);
451     }
452     else
453     {
454         /* All other, CreateXxxField opcodes */
455
456         Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
457                     WalkState->Operands[0], WalkState->Operands[1],
458                                       NULL, WalkState->Operands[2]);
459     }
460
461     return_ACPI_STATUS (Status);
462 }
463
464
465 /*******************************************************************************
466  *
467  * FUNCTION:    AcpiDsEvalRegionOperands
468  *
469  * PARAMETERS:  WalkState       - Current walk
470  *              Op              - A valid region Op object
471  *
472  * RETURN:      Status
473  *
474  * DESCRIPTION: Get region address and length
475  *              Called from AcpiDsExecEndOp during OpRegion parse tree walk
476  *
477  ******************************************************************************/
478
479 ACPI_STATUS
480 AcpiDsEvalRegionOperands (
481     ACPI_WALK_STATE         *WalkState,
482     ACPI_PARSE_OBJECT       *Op)
483 {
484     ACPI_STATUS             Status;
485     ACPI_OPERAND_OBJECT     *ObjDesc;
486     ACPI_OPERAND_OBJECT     *OperandDesc;
487     ACPI_NAMESPACE_NODE     *Node;
488     ACPI_PARSE_OBJECT       *NextOp;
489
490
491     ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op);
492
493
494     /*
495      * This is where we evaluate the address and length fields of the
496      * OpRegion declaration
497      */
498     Node =  Op->Common.Node;
499
500     /* NextOp points to the op that holds the SpaceID */
501
502     NextOp = Op->Common.Value.Arg;
503
504     /* NextOp points to address op */
505
506     NextOp = NextOp->Common.Next;
507
508     /* Evaluate/create the address and length operands */
509
510     Status = AcpiDsCreateOperands (WalkState, NextOp);
511     if (ACPI_FAILURE (Status))
512     {
513         return_ACPI_STATUS (Status);
514     }
515
516     /* Resolve the length and address operands to numbers */
517
518     Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
519                 ACPI_WALK_OPERANDS, WalkState);
520     if (ACPI_FAILURE (Status))
521     {
522         return_ACPI_STATUS (Status);
523     }
524
525     ObjDesc = AcpiNsGetAttachedObject (Node);
526     if (!ObjDesc)
527     {
528         return_ACPI_STATUS (AE_NOT_EXIST);
529     }
530
531     /*
532      * Get the length operand and save it
533      * (at Top of stack)
534      */
535     OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
536
537     ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
538     AcpiUtRemoveReference (OperandDesc);
539
540     /*
541      * Get the address and save it
542      * (at top of stack - 1)
543      */
544     OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
545
546     ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS)
547                                 OperandDesc->Integer.Value;
548     AcpiUtRemoveReference (OperandDesc);
549
550     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
551         ObjDesc,
552         ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
553         ObjDesc->Region.Length));
554
555     /* Now the address and length are valid for this opregion */
556
557     ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
558
559     return_ACPI_STATUS (Status);
560 }
561
562
563 /*******************************************************************************
564  *
565  * FUNCTION:    AcpiDsEvalTableRegionOperands
566  *
567  * PARAMETERS:  WalkState       - Current walk
568  *              Op              - A valid region Op object
569  *
570  * RETURN:      Status
571  *
572  * DESCRIPTION: Get region address and length.
573  *              Called from AcpiDsExecEndOp during DataTableRegion parse
574  *              tree walk.
575  *
576  ******************************************************************************/
577
578 ACPI_STATUS
579 AcpiDsEvalTableRegionOperands (
580     ACPI_WALK_STATE         *WalkState,
581     ACPI_PARSE_OBJECT       *Op)
582 {
583     ACPI_STATUS             Status;
584     ACPI_OPERAND_OBJECT     *ObjDesc;
585     ACPI_OPERAND_OBJECT     **Operand;
586     ACPI_NAMESPACE_NODE     *Node;
587     ACPI_PARSE_OBJECT       *NextOp;
588     UINT32                  TableIndex;
589     ACPI_TABLE_HEADER       *Table;
590
591
592     ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);
593
594
595     /*
596      * This is where we evaluate the Signature string, OemId string,
597      * and OemTableId string of the Data Table Region declaration
598      */
599     Node =  Op->Common.Node;
600
601     /* NextOp points to Signature string op */
602
603     NextOp = Op->Common.Value.Arg;
604
605     /*
606      * Evaluate/create the Signature string, OemId string,
607      * and OemTableId string operands
608      */
609     Status = AcpiDsCreateOperands (WalkState, NextOp);
610     if (ACPI_FAILURE (Status))
611     {
612         return_ACPI_STATUS (Status);
613     }
614
615     /*
616      * Resolve the Signature string, OemId string,
617      * and OemTableId string operands
618      */
619     Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
620                 ACPI_WALK_OPERANDS, WalkState);
621     if (ACPI_FAILURE (Status))
622     {
623         return_ACPI_STATUS (Status);
624     }
625
626     Operand = &WalkState->Operands[0];
627
628     /* Find the ACPI table */
629
630     Status = AcpiTbFindTable (Operand[0]->String.Pointer,
631                 Operand[1]->String.Pointer, Operand[2]->String.Pointer,
632                 &TableIndex);
633     if (ACPI_FAILURE (Status))
634     {
635         return_ACPI_STATUS (Status);
636     }
637
638     AcpiUtRemoveReference (Operand[0]);
639     AcpiUtRemoveReference (Operand[1]);
640     AcpiUtRemoveReference (Operand[2]);
641
642     Status = AcpiGetTableByIndex (TableIndex, &Table);
643     if (ACPI_FAILURE (Status))
644     {
645         return_ACPI_STATUS (Status);
646     }
647
648     ObjDesc = AcpiNsGetAttachedObject (Node);
649     if (!ObjDesc)
650     {
651         return_ACPI_STATUS (AE_NOT_EXIST);
652     }
653
654     ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);
655     ObjDesc->Region.Length = Table->Length;
656
657     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
658         ObjDesc,
659         ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
660         ObjDesc->Region.Length));
661
662     /* Now the address and length are valid for this opregion */
663
664     ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
665
666     return_ACPI_STATUS (Status);
667 }
668
669
670 /*******************************************************************************
671  *
672  * FUNCTION:    AcpiDsEvalDataObjectOperands
673  *
674  * PARAMETERS:  WalkState       - Current walk
675  *              Op              - A valid DataObject Op object
676  *              ObjDesc         - DataObject
677  *
678  * RETURN:      Status
679  *
680  * DESCRIPTION: Get the operands and complete the following data object types:
681  *              Buffer, Package.
682  *
683  ******************************************************************************/
684
685 ACPI_STATUS
686 AcpiDsEvalDataObjectOperands (
687     ACPI_WALK_STATE         *WalkState,
688     ACPI_PARSE_OBJECT       *Op,
689     ACPI_OPERAND_OBJECT     *ObjDesc)
690 {
691     ACPI_STATUS             Status;
692     ACPI_OPERAND_OBJECT     *ArgDesc;
693     UINT32                  Length;
694
695
696     ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands);
697
698
699     /* The first operand (for all of these data objects) is the length */
700
701     /*
702      * Set proper index into operand stack for AcpiDsObjStackPush
703      * invoked inside AcpiDsCreateOperand.
704      */
705     WalkState->OperandIndex = WalkState->NumOperands;
706
707     Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
708     if (ACPI_FAILURE (Status))
709     {
710         return_ACPI_STATUS (Status);
711     }
712
713     Status = AcpiExResolveOperands (WalkState->Opcode,
714                     &(WalkState->Operands [WalkState->NumOperands -1]),
715                     WalkState);
716     if (ACPI_FAILURE (Status))
717     {
718         return_ACPI_STATUS (Status);
719     }
720
721     /* Extract length operand */
722
723     ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
724     Length = (UINT32) ArgDesc->Integer.Value;
725
726     /* Cleanup for length operand */
727
728     Status = AcpiDsObjStackPop (1, WalkState);
729     if (ACPI_FAILURE (Status))
730     {
731         return_ACPI_STATUS (Status);
732     }
733
734     AcpiUtRemoveReference (ArgDesc);
735
736     /*
737      * Create the actual data object
738      */
739     switch (Op->Common.AmlOpcode)
740     {
741     case AML_BUFFER_OP:
742
743         Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc);
744         break;
745
746     case AML_PACKAGE_OP:
747     case AML_VAR_PACKAGE_OP:
748
749         Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc);
750         break;
751
752     default:
753
754         return_ACPI_STATUS (AE_AML_BAD_OPCODE);
755     }
756
757     if (ACPI_SUCCESS (Status))
758     {
759         /*
760          * Return the object in the WalkState, unless the parent is a package -
761          * in this case, the return object will be stored in the parse tree
762          * for the package.
763          */
764         if ((!Op->Common.Parent) ||
765             ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
766              (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
767              (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
768         {
769             WalkState->ResultObj = ObjDesc;
770         }
771     }
772
773     return_ACPI_STATUS (Status);
774 }
775
776
777 /*******************************************************************************
778  *
779  * FUNCTION:    AcpiDsEvalBankFieldOperands
780  *
781  * PARAMETERS:  WalkState       - Current walk
782  *              Op              - A valid BankField Op object
783  *
784  * RETURN:      Status
785  *
786  * DESCRIPTION: Get BankField BankValue
787  *              Called from AcpiDsExecEndOp during BankField parse tree walk
788  *
789  ******************************************************************************/
790
791 ACPI_STATUS
792 AcpiDsEvalBankFieldOperands (
793     ACPI_WALK_STATE         *WalkState,
794     ACPI_PARSE_OBJECT       *Op)
795 {
796     ACPI_STATUS             Status;
797     ACPI_OPERAND_OBJECT     *ObjDesc;
798     ACPI_OPERAND_OBJECT     *OperandDesc;
799     ACPI_NAMESPACE_NODE     *Node;
800     ACPI_PARSE_OBJECT       *NextOp;
801     ACPI_PARSE_OBJECT       *Arg;
802
803
804     ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);
805
806
807     /*
808      * This is where we evaluate the BankValue field of the
809      * BankField declaration
810      */
811
812     /* NextOp points to the op that holds the Region */
813
814     NextOp = Op->Common.Value.Arg;
815
816     /* NextOp points to the op that holds the Bank Register */
817
818     NextOp = NextOp->Common.Next;
819
820     /* NextOp points to the op that holds the Bank Value */
821
822     NextOp = NextOp->Common.Next;
823
824     /*
825      * Set proper index into operand stack for AcpiDsObjStackPush
826      * invoked inside AcpiDsCreateOperand.
827      *
828      * We use WalkState->Operands[0] to store the evaluated BankValue
829      */
830     WalkState->OperandIndex = 0;
831
832     Status = AcpiDsCreateOperand (WalkState, NextOp, 0);
833     if (ACPI_FAILURE (Status))
834     {
835         return_ACPI_STATUS (Status);
836     }
837
838     Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);
839     if (ACPI_FAILURE (Status))
840     {
841         return_ACPI_STATUS (Status);
842     }
843
844     ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS,
845         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);
846     /*
847      * Get the BankValue operand and save it
848      * (at Top of stack)
849      */
850     OperandDesc = WalkState->Operands[0];
851
852     /* Arg points to the start Bank Field */
853
854     Arg = AcpiPsGetArg (Op, 4);
855     while (Arg)
856     {
857         /* Ignore OFFSET and ACCESSAS terms here */
858
859         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
860         {
861             Node = Arg->Common.Node;
862
863             ObjDesc = AcpiNsGetAttachedObject (Node);
864             if (!ObjDesc)
865             {
866                 return_ACPI_STATUS (AE_NOT_EXIST);
867             }
868
869             ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;
870         }
871
872         /* Move to next field in the list */
873
874         Arg = Arg->Common.Next;
875     }
876
877     AcpiUtRemoveReference (OperandDesc);
878     return_ACPI_STATUS (Status);
879 }