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 - 2018, 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 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acparser.h>
155 #include <contrib/dev/acpica/include/amlcode.h>
156 #include <contrib/dev/acpica/include/acdispat.h>
157 #include <contrib/dev/acpica/include/acinterp.h>
158 #include <contrib/dev/acpica/include/acnamesp.h>
159 #include <contrib/dev/acpica/include/acevents.h>
160 #include <contrib/dev/acpica/include/actables.h>
161
162 #define _COMPONENT ACPI_DISPATCHER
163 ACPI_MODULE_NAME ("dsopcode")
164
165 /* Local prototypes */
166
167 static ACPI_STATUS
168 AcpiDsInitBufferField (
169 UINT16 AmlOpcode,
170 ACPI_OPERAND_OBJECT *ObjDesc,
171 ACPI_OPERAND_OBJECT *BufferDesc,
172 ACPI_OPERAND_OBJECT *OffsetDesc,
173 ACPI_OPERAND_OBJECT *LengthDesc,
174 ACPI_OPERAND_OBJECT *ResultDesc);
175
176
177 /*******************************************************************************
178 *
179 * FUNCTION: AcpiDsInitializeRegion
180 *
181 * PARAMETERS: ObjHandle - Region namespace node
182 *
183 * RETURN: Status
184 *
185 * DESCRIPTION: Front end to EvInitializeRegion
186 *
187 ******************************************************************************/
188
189 ACPI_STATUS
AcpiDsInitializeRegion(ACPI_HANDLE ObjHandle)190 AcpiDsInitializeRegion (
191 ACPI_HANDLE ObjHandle)
192 {
193 ACPI_OPERAND_OBJECT *ObjDesc;
194 ACPI_STATUS Status;
195
196
197 ObjDesc = AcpiNsGetAttachedObject (ObjHandle);
198
199 /* Namespace is NOT locked */
200
201 Status = AcpiEvInitializeRegion (ObjDesc);
202 return (Status);
203 }
204
205
206 /*******************************************************************************
207 *
208 * FUNCTION: AcpiDsInitBufferField
209 *
210 * PARAMETERS: AmlOpcode - CreateXxxField
211 * ObjDesc - BufferField object
212 * BufferDesc - Host Buffer
213 * OffsetDesc - Offset into buffer
214 * LengthDesc - Length of field (CREATE_FIELD_OP only)
215 * ResultDesc - Where to store the result
216 *
217 * RETURN: Status
218 *
219 * DESCRIPTION: Perform actual initialization of a buffer field
220 *
221 ******************************************************************************/
222
223 static ACPI_STATUS
AcpiDsInitBufferField(UINT16 AmlOpcode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_OPERAND_OBJECT * BufferDesc,ACPI_OPERAND_OBJECT * OffsetDesc,ACPI_OPERAND_OBJECT * LengthDesc,ACPI_OPERAND_OBJECT * ResultDesc)224 AcpiDsInitBufferField (
225 UINT16 AmlOpcode,
226 ACPI_OPERAND_OBJECT *ObjDesc,
227 ACPI_OPERAND_OBJECT *BufferDesc,
228 ACPI_OPERAND_OBJECT *OffsetDesc,
229 ACPI_OPERAND_OBJECT *LengthDesc,
230 ACPI_OPERAND_OBJECT *ResultDesc)
231 {
232 UINT32 Offset;
233 UINT32 BitOffset;
234 UINT32 BitCount;
235 UINT8 FieldFlags;
236 ACPI_STATUS Status;
237
238
239 ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc);
240
241
242 /* Host object must be a Buffer */
243
244 if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER)
245 {
246 ACPI_ERROR ((AE_INFO,
247 "Target of Create Field is not a Buffer object - %s",
248 AcpiUtGetObjectTypeName (BufferDesc)));
249
250 Status = AE_AML_OPERAND_TYPE;
251 goto Cleanup;
252 }
253
254 /*
255 * The last parameter to all of these opcodes (ResultDesc) started
256 * out as a NameString, and should therefore now be a NS node
257 * after resolution in AcpiExResolveOperands().
258 */
259 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED)
260 {
261 ACPI_ERROR ((AE_INFO,
262 "(%s) destination not a NS Node [%s]",
263 AcpiPsGetOpcodeName (AmlOpcode),
264 AcpiUtGetDescriptorName (ResultDesc)));
265
266 Status = AE_AML_OPERAND_TYPE;
267 goto Cleanup;
268 }
269
270 Offset = (UINT32) OffsetDesc->Integer.Value;
271
272 /*
273 * Setup the Bit offsets and counts, according to the opcode
274 */
275 switch (AmlOpcode)
276 {
277 case AML_CREATE_FIELD_OP:
278
279 /* Offset is in bits, count is in bits */
280
281 FieldFlags = AML_FIELD_ACCESS_BYTE;
282 BitOffset = Offset;
283 BitCount = (UINT32) LengthDesc->Integer.Value;
284
285 /* Must have a valid (>0) bit count */
286
287 if (BitCount == 0)
288 {
289 ACPI_ERROR ((AE_INFO,
290 "Attempt to CreateField of length zero"));
291 Status = AE_AML_OPERAND_VALUE;
292 goto Cleanup;
293 }
294 break;
295
296 case AML_CREATE_BIT_FIELD_OP:
297
298 /* Offset is in bits, Field is one bit */
299
300 BitOffset = Offset;
301 BitCount = 1;
302 FieldFlags = AML_FIELD_ACCESS_BYTE;
303 break;
304
305 case AML_CREATE_BYTE_FIELD_OP:
306
307 /* Offset is in bytes, field is one byte */
308
309 BitOffset = 8 * Offset;
310 BitCount = 8;
311 FieldFlags = AML_FIELD_ACCESS_BYTE;
312 break;
313
314 case AML_CREATE_WORD_FIELD_OP:
315
316 /* Offset is in bytes, field is one word */
317
318 BitOffset = 8 * Offset;
319 BitCount = 16;
320 FieldFlags = AML_FIELD_ACCESS_WORD;
321 break;
322
323 case AML_CREATE_DWORD_FIELD_OP:
324
325 /* Offset is in bytes, field is one dword */
326
327 BitOffset = 8 * Offset;
328 BitCount = 32;
329 FieldFlags = AML_FIELD_ACCESS_DWORD;
330 break;
331
332 case AML_CREATE_QWORD_FIELD_OP:
333
334 /* Offset is in bytes, field is one qword */
335
336 BitOffset = 8 * Offset;
337 BitCount = 64;
338 FieldFlags = AML_FIELD_ACCESS_QWORD;
339 break;
340
341 default:
342
343 ACPI_ERROR ((AE_INFO,
344 "Unknown field creation opcode 0x%02X",
345 AmlOpcode));
346 Status = AE_AML_BAD_OPCODE;
347 goto Cleanup;
348 }
349
350 /* Entire field must fit within the current length of the buffer */
351
352 if ((BitOffset + BitCount) >
353 (8 * (UINT32) BufferDesc->Buffer.Length))
354 {
355 ACPI_ERROR ((AE_INFO,
356 "Field [%4.4s] at bit offset/length %u/%u "
357 "exceeds size of target Buffer (%u bits)",
358 AcpiUtGetNodeName (ResultDesc), BitOffset, BitCount,
359 8 * (UINT32) BufferDesc->Buffer.Length));
360 Status = AE_AML_BUFFER_LIMIT;
361 goto Cleanup;
362 }
363
364 /*
365 * Initialize areas of the field object that are common to all fields
366 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK),
367 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
368 */
369 Status = AcpiExPrepCommonFieldObject (
370 ObjDesc, FieldFlags, 0, BitOffset, BitCount);
371 if (ACPI_FAILURE (Status))
372 {
373 goto Cleanup;
374 }
375
376 ObjDesc->BufferField.BufferObj = BufferDesc;
377
378 /* Reference count for BufferDesc inherits ObjDesc count */
379
380 BufferDesc->Common.ReferenceCount = (UINT16)
381 (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount);
382
383
384 Cleanup:
385
386 /* Always delete the operands */
387
388 AcpiUtRemoveReference (OffsetDesc);
389 AcpiUtRemoveReference (BufferDesc);
390
391 if (AmlOpcode == AML_CREATE_FIELD_OP)
392 {
393 AcpiUtRemoveReference (LengthDesc);
394 }
395
396 /* On failure, delete the result descriptor */
397
398 if (ACPI_FAILURE (Status))
399 {
400 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */
401 }
402 else
403 {
404 /* Now the address and length are valid for this BufferField */
405
406 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID;
407 }
408
409 return_ACPI_STATUS (Status);
410 }
411
412
413 /*******************************************************************************
414 *
415 * FUNCTION: AcpiDsEvalBufferFieldOperands
416 *
417 * PARAMETERS: WalkState - Current walk
418 * Op - A valid BufferField Op object
419 *
420 * RETURN: Status
421 *
422 * DESCRIPTION: Get BufferField Buffer and Index
423 * Called from AcpiDsExecEndOp during BufferField parse tree walk
424 *
425 ******************************************************************************/
426
427 ACPI_STATUS
AcpiDsEvalBufferFieldOperands(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)428 AcpiDsEvalBufferFieldOperands (
429 ACPI_WALK_STATE *WalkState,
430 ACPI_PARSE_OBJECT *Op)
431 {
432 ACPI_STATUS Status;
433 ACPI_OPERAND_OBJECT *ObjDesc;
434 ACPI_NAMESPACE_NODE *Node;
435 ACPI_PARSE_OBJECT *NextOp;
436
437
438 ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op);
439
440
441 /*
442 * This is where we evaluate the address and length fields of the
443 * CreateXxxField declaration
444 */
445 Node = Op->Common.Node;
446
447 /* NextOp points to the op that holds the Buffer */
448
449 NextOp = Op->Common.Value.Arg;
450
451 /* Evaluate/create the address and length operands */
452
453 Status = AcpiDsCreateOperands (WalkState, NextOp);
454 if (ACPI_FAILURE (Status))
455 {
456 return_ACPI_STATUS (Status);
457 }
458
459 ObjDesc = AcpiNsGetAttachedObject (Node);
460 if (!ObjDesc)
461 {
462 return_ACPI_STATUS (AE_NOT_EXIST);
463 }
464
465 /* Resolve the operands */
466
467 Status = AcpiExResolveOperands (
468 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
469 if (ACPI_FAILURE (Status))
470 {
471 ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",
472 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status));
473
474 return_ACPI_STATUS (Status);
475 }
476
477 /* Initialize the Buffer Field */
478
479 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
480 {
481 /* NOTE: Slightly different operands for this opcode */
482
483 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
484 WalkState->Operands[0], WalkState->Operands[1],
485 WalkState->Operands[2], WalkState->Operands[3]);
486 }
487 else
488 {
489 /* All other, CreateXxxField opcodes */
490
491 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc,
492 WalkState->Operands[0], WalkState->Operands[1],
493 NULL, WalkState->Operands[2]);
494 }
495
496 return_ACPI_STATUS (Status);
497 }
498
499
500 /*******************************************************************************
501 *
502 * FUNCTION: AcpiDsEvalRegionOperands
503 *
504 * PARAMETERS: WalkState - Current walk
505 * Op - A valid region Op object
506 *
507 * RETURN: Status
508 *
509 * DESCRIPTION: Get region address and length
510 * Called from AcpiDsExecEndOp during OpRegion parse tree walk
511 *
512 ******************************************************************************/
513
514 ACPI_STATUS
AcpiDsEvalRegionOperands(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)515 AcpiDsEvalRegionOperands (
516 ACPI_WALK_STATE *WalkState,
517 ACPI_PARSE_OBJECT *Op)
518 {
519 ACPI_STATUS Status;
520 ACPI_OPERAND_OBJECT *ObjDesc;
521 ACPI_OPERAND_OBJECT *OperandDesc;
522 ACPI_NAMESPACE_NODE *Node;
523 ACPI_PARSE_OBJECT *NextOp;
524
525
526 ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op);
527
528
529 /*
530 * This is where we evaluate the address and length fields of the
531 * OpRegion declaration
532 */
533 Node = Op->Common.Node;
534
535 /* NextOp points to the op that holds the SpaceID */
536
537 NextOp = Op->Common.Value.Arg;
538
539 /* NextOp points to address op */
540
541 NextOp = NextOp->Common.Next;
542
543 /* Evaluate/create the address and length operands */
544
545 Status = AcpiDsCreateOperands (WalkState, NextOp);
546 if (ACPI_FAILURE (Status))
547 {
548 return_ACPI_STATUS (Status);
549 }
550
551 /* Resolve the length and address operands to numbers */
552
553 Status = AcpiExResolveOperands (
554 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
555 if (ACPI_FAILURE (Status))
556 {
557 return_ACPI_STATUS (Status);
558 }
559
560 ObjDesc = AcpiNsGetAttachedObject (Node);
561 if (!ObjDesc)
562 {
563 return_ACPI_STATUS (AE_NOT_EXIST);
564 }
565
566 /*
567 * Get the length operand and save it
568 * (at Top of stack)
569 */
570 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1];
571
572 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value;
573 AcpiUtRemoveReference (OperandDesc);
574
575 /*
576 * Get the address and save it
577 * (at top of stack - 1)
578 */
579 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2];
580
581 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS)
582 OperandDesc->Integer.Value;
583 AcpiUtRemoveReference (OperandDesc);
584
585 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
586 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
587 ObjDesc->Region.Length));
588
589 Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId,
590 ObjDesc->Region.Address, ObjDesc->Region.Length, Node);
591
592 /* Now the address and length are valid for this opregion */
593
594 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
595 return_ACPI_STATUS (Status);
596 }
597
598
599 /*******************************************************************************
600 *
601 * FUNCTION: AcpiDsEvalTableRegionOperands
602 *
603 * PARAMETERS: WalkState - Current walk
604 * Op - A valid region Op object
605 *
606 * RETURN: Status
607 *
608 * DESCRIPTION: Get region address and length.
609 * Called from AcpiDsExecEndOp during DataTableRegion parse
610 * tree walk.
611 *
612 ******************************************************************************/
613
614 ACPI_STATUS
AcpiDsEvalTableRegionOperands(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)615 AcpiDsEvalTableRegionOperands (
616 ACPI_WALK_STATE *WalkState,
617 ACPI_PARSE_OBJECT *Op)
618 {
619 ACPI_STATUS Status;
620 ACPI_OPERAND_OBJECT *ObjDesc;
621 ACPI_OPERAND_OBJECT **Operand;
622 ACPI_NAMESPACE_NODE *Node;
623 ACPI_PARSE_OBJECT *NextOp;
624 ACPI_TABLE_HEADER *Table;
625 UINT32 TableIndex;
626
627
628 ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);
629
630
631 /*
632 * This is where we evaluate the Signature string, OemId string,
633 * and OemTableId string of the Data Table Region declaration
634 */
635 Node = Op->Common.Node;
636
637 /* NextOp points to Signature string op */
638
639 NextOp = Op->Common.Value.Arg;
640
641 /*
642 * Evaluate/create the Signature string, OemId string,
643 * and OemTableId string operands
644 */
645 Status = AcpiDsCreateOperands (WalkState, NextOp);
646 if (ACPI_FAILURE (Status))
647 {
648 return_ACPI_STATUS (Status);
649 }
650
651 Operand = &WalkState->Operands[0];
652
653 /*
654 * Resolve the Signature string, OemId string,
655 * and OemTableId string operands
656 */
657 Status = AcpiExResolveOperands (
658 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState);
659 if (ACPI_FAILURE (Status))
660 {
661 goto Cleanup;
662 }
663
664 /* Find the ACPI table */
665
666 Status = AcpiTbFindTable (
667 Operand[0]->String.Pointer,
668 Operand[1]->String.Pointer,
669 Operand[2]->String.Pointer, &TableIndex);
670 if (ACPI_FAILURE (Status))
671 {
672 if (Status == AE_NOT_FOUND)
673 {
674 ACPI_ERROR ((AE_INFO,
675 "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",
676 Operand[0]->String.Pointer,
677 Operand[1]->String.Pointer,
678 Operand[2]->String.Pointer));
679 }
680 goto Cleanup;
681 }
682
683 Status = AcpiGetTableByIndex (TableIndex, &Table);
684 if (ACPI_FAILURE (Status))
685 {
686 goto Cleanup;
687 }
688
689 ObjDesc = AcpiNsGetAttachedObject (Node);
690 if (!ObjDesc)
691 {
692 Status = AE_NOT_EXIST;
693 goto Cleanup;
694 }
695
696 ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);
697 ObjDesc->Region.Length = Table->Length;
698
699 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
700 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
701 ObjDesc->Region.Length));
702
703 /* Now the address and length are valid for this opregion */
704
705 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID;
706
707 Cleanup:
708 AcpiUtRemoveReference (Operand[0]);
709 AcpiUtRemoveReference (Operand[1]);
710 AcpiUtRemoveReference (Operand[2]);
711
712 return_ACPI_STATUS (Status);
713 }
714
715
716 /*******************************************************************************
717 *
718 * FUNCTION: AcpiDsEvalDataObjectOperands
719 *
720 * PARAMETERS: WalkState - Current walk
721 * Op - A valid DataObject Op object
722 * ObjDesc - DataObject
723 *
724 * RETURN: Status
725 *
726 * DESCRIPTION: Get the operands and complete the following data object types:
727 * Buffer, Package.
728 *
729 ******************************************************************************/
730
731 ACPI_STATUS
AcpiDsEvalDataObjectOperands(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op,ACPI_OPERAND_OBJECT * ObjDesc)732 AcpiDsEvalDataObjectOperands (
733 ACPI_WALK_STATE *WalkState,
734 ACPI_PARSE_OBJECT *Op,
735 ACPI_OPERAND_OBJECT *ObjDesc)
736 {
737 ACPI_STATUS Status;
738 ACPI_OPERAND_OBJECT *ArgDesc;
739 UINT32 Length;
740
741
742 ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands);
743
744
745 /* The first operand (for all of these data objects) is the length */
746
747 /*
748 * Set proper index into operand stack for AcpiDsObjStackPush
749 * invoked inside AcpiDsCreateOperand.
750 */
751 WalkState->OperandIndex = WalkState->NumOperands;
752
753 /* Ignore if child is not valid */
754
755 if (!Op->Common.Value.Arg)
756 {
757 ACPI_ERROR ((AE_INFO,
758 "Missing child while evaluating opcode %4.4X, Op %p",
759 Op->Common.AmlOpcode, Op));
760 return_ACPI_STATUS (AE_OK);
761 }
762
763 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1);
764 if (ACPI_FAILURE (Status))
765 {
766 return_ACPI_STATUS (Status);
767 }
768
769 Status = AcpiExResolveOperands (WalkState->Opcode,
770 &(WalkState->Operands [WalkState->NumOperands -1]),
771 WalkState);
772 if (ACPI_FAILURE (Status))
773 {
774 return_ACPI_STATUS (Status);
775 }
776
777 /* Extract length operand */
778
779 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1];
780 Length = (UINT32) ArgDesc->Integer.Value;
781
782 /* Cleanup for length operand */
783
784 Status = AcpiDsObjStackPop (1, WalkState);
785 if (ACPI_FAILURE (Status))
786 {
787 return_ACPI_STATUS (Status);
788 }
789
790 AcpiUtRemoveReference (ArgDesc);
791
792 /*
793 * Create the actual data object
794 */
795 switch (Op->Common.AmlOpcode)
796 {
797 case AML_BUFFER_OP:
798
799 Status = AcpiDsBuildInternalBufferObj (
800 WalkState, Op, Length, &ObjDesc);
801 break;
802
803 case AML_PACKAGE_OP:
804 case AML_VARIABLE_PACKAGE_OP:
805
806 Status = AcpiDsBuildInternalPackageObj (
807 WalkState, Op, Length, &ObjDesc);
808 break;
809
810 default:
811
812 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
813 }
814
815 if (ACPI_SUCCESS (Status))
816 {
817 /*
818 * Return the object in the WalkState, unless the parent is a package -
819 * in this case, the return object will be stored in the parse tree
820 * for the package.
821 */
822 if ((!Op->Common.Parent) ||
823 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
824 (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&
825 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
826 {
827 WalkState->ResultObj = ObjDesc;
828 }
829 }
830
831 return_ACPI_STATUS (Status);
832 }
833
834
835 /*******************************************************************************
836 *
837 * FUNCTION: AcpiDsEvalBankFieldOperands
838 *
839 * PARAMETERS: WalkState - Current walk
840 * Op - A valid BankField Op object
841 *
842 * RETURN: Status
843 *
844 * DESCRIPTION: Get BankField BankValue
845 * Called from AcpiDsExecEndOp during BankField parse tree walk
846 *
847 ******************************************************************************/
848
849 ACPI_STATUS
AcpiDsEvalBankFieldOperands(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)850 AcpiDsEvalBankFieldOperands (
851 ACPI_WALK_STATE *WalkState,
852 ACPI_PARSE_OBJECT *Op)
853 {
854 ACPI_STATUS Status;
855 ACPI_OPERAND_OBJECT *ObjDesc;
856 ACPI_OPERAND_OBJECT *OperandDesc;
857 ACPI_NAMESPACE_NODE *Node;
858 ACPI_PARSE_OBJECT *NextOp;
859 ACPI_PARSE_OBJECT *Arg;
860
861
862 ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);
863
864
865 /*
866 * This is where we evaluate the BankValue field of the
867 * BankField declaration
868 */
869
870 /* NextOp points to the op that holds the Region */
871
872 NextOp = Op->Common.Value.Arg;
873
874 /* NextOp points to the op that holds the Bank Register */
875
876 NextOp = NextOp->Common.Next;
877
878 /* NextOp points to the op that holds the Bank Value */
879
880 NextOp = NextOp->Common.Next;
881
882 /*
883 * Set proper index into operand stack for AcpiDsObjStackPush
884 * invoked inside AcpiDsCreateOperand.
885 *
886 * We use WalkState->Operands[0] to store the evaluated BankValue
887 */
888 WalkState->OperandIndex = 0;
889
890 Status = AcpiDsCreateOperand (WalkState, NextOp, 0);
891 if (ACPI_FAILURE (Status))
892 {
893 return_ACPI_STATUS (Status);
894 }
895
896 Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);
897 if (ACPI_FAILURE (Status))
898 {
899 return_ACPI_STATUS (Status);
900 }
901
902 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS,
903 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);
904 /*
905 * Get the BankValue operand and save it
906 * (at Top of stack)
907 */
908 OperandDesc = WalkState->Operands[0];
909
910 /* Arg points to the start Bank Field */
911
912 Arg = AcpiPsGetArg (Op, 4);
913 while (Arg)
914 {
915 /* Ignore OFFSET and ACCESSAS terms here */
916
917 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
918 {
919 Node = Arg->Common.Node;
920
921 ObjDesc = AcpiNsGetAttachedObject (Node);
922 if (!ObjDesc)
923 {
924 return_ACPI_STATUS (AE_NOT_EXIST);
925 }
926
927 ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;
928 }
929
930 /* Move to next field in the list */
931
932 Arg = Arg->Common.Next;
933 }
934
935 AcpiUtRemoveReference (OperandDesc);
936 return_ACPI_STATUS (Status);
937 }
938