Deleted Added
sdiff udiff text old ( 85756 ) new ( 87031 )
full compact
1/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
5 * $Revision: 66 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.

--- 113 unchanged lines hidden (view full) ---

127#include "actables.h"
128
129#define _COMPONENT ACPI_DISPATCHER
130 MODULE_NAME ("dsopcode")
131
132
133/*****************************************************************************
134 *
135 * FUNCTION: AcpiDsExecuteArguments
136 *
137 * PARAMETERS: Node - Parent NS node
138 * ExtraDesc - Has AML pointer and length
139 *
140 * RETURN: Status.
141 *
142 * DESCRIPTION: Late execution of region or field arguments
143 *
144 ****************************************************************************/
145
146ACPI_STATUS
147AcpiDsExecuteArguments (
148 ACPI_NAMESPACE_NODE *Node,
149 ACPI_OPERAND_OBJECT *ExtraDesc)
150{
151 ACPI_STATUS Status;
152 ACPI_PARSE_OBJECT *Op;
153 ACPI_WALK_STATE *WalkState;
154 ACPI_PARSE_OBJECT *Arg;
155
156
157 FUNCTION_TRACE ("AcpiDsExecuteArguments");
158
159
160 /*
161 * Allocate a new parser op to be the root of the parsed
162 * BufferField tree
163 */
164 Op = AcpiPsAllocOp (AML_SCOPE_OP);
165 if (!Op)
166 {
167 return_ACPI_STATUS (AE_NO_MEMORY);
168 }
169
170 /* Save the Node for use in AcpiPsParseAml */
171
172 Op->Node = AcpiNsGetParentObject (Node);
173
174 /* Create and initialize a new parser state */
175
176 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
177 if (!WalkState)
178 {
179 return_ACPI_STATUS (AE_NO_MEMORY);
180 }
181
182 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, ExtraDesc->Extra.AmlStart,
183 ExtraDesc->Extra.AmlLength, NULL, NULL, 1);
184 if (ACPI_FAILURE (Status))
185 {
186 AcpiDsDeleteWalkState (WalkState);
187 return_ACPI_STATUS (Status);
188 }
189
190 WalkState->ParseFlags = 0;
191
192 /* Pass1: Parse the entire BufferField declaration */
193
194 Status = AcpiPsParseAml (WalkState);
195 if (ACPI_FAILURE (Status))
196 {
197 AcpiPsDeleteParseTree (Op);
198 return_ACPI_STATUS (Status);
199 }
200
201 /* Get and init the actual FieldUnit Op created above */
202
203 Arg = Op->Value.Arg;
204 Op->Node = Node;
205 Arg->Node = Node;
206 AcpiPsDeleteParseTree (Op);
207
208 /* Evaluate the address and length arguments for the Buffer Field */
209
210 Op = AcpiPsAllocOp (AML_SCOPE_OP);
211 if (!Op)
212 {
213 return_ACPI_STATUS (AE_NO_MEMORY);
214 }
215
216 Op->Node = AcpiNsGetParentObject (Node);
217
218 /* Create and initialize a new parser state */
219
220 WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
221 if (!WalkState)
222 {
223 return_ACPI_STATUS (AE_NO_MEMORY);
224 }
225
226 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, ExtraDesc->Extra.AmlStart,
227 ExtraDesc->Extra.AmlLength, NULL, NULL, 3);
228 if (ACPI_FAILURE (Status))
229 {
230 AcpiDsDeleteWalkState (WalkState);
231 return_ACPI_STATUS (Status);
232 }
233
234 Status = AcpiPsParseAml (WalkState);
235 AcpiPsDeleteParseTree (Op);
236
237 return_ACPI_STATUS (Status);
238}
239
240
241/*****************************************************************************
242 *
243 * FUNCTION: AcpiDsGetBufferFieldArguments
244 *
245 * PARAMETERS: ObjDesc - A valid BufferField object
246 *
247 * RETURN: Status.
248 *
249 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
250 * evaluation of these field attributes.
251 *
252 ****************************************************************************/
253
254ACPI_STATUS
255AcpiDsGetBufferFieldArguments (
256 ACPI_OPERAND_OBJECT *ObjDesc)
257{
258 ACPI_OPERAND_OBJECT *ExtraDesc;
259 ACPI_NAMESPACE_NODE *Node;
260 ACPI_STATUS Status;
261
262
263 FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc);
264
265
266 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
267 {
268 return_ACPI_STATUS (AE_OK);
269 }
270
271 /* Get the AML pointer (method object) and BufferField node */
272
273 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
274 Node = ObjDesc->BufferField.Node;
275
276 DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]"));
277 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n",
278 (char *) &Node->Name));
279
280 /* Execute the AML code for the TermArg arguments */
281
282 Status = AcpiDsExecuteArguments (Node, ExtraDesc);
283 return_ACPI_STATUS (Status);
284}
285
286
287/*****************************************************************************
288 *
289 * FUNCTION: AcpiDsGetRegionArguments
290 *
291 * PARAMETERS: ObjDesc - A valid region object
292 *
293 * RETURN: Status.
294 *
295 * DESCRIPTION: Get region address and length. This implements the late
296 * evaluation of these region attributes.
297 *
298 ****************************************************************************/
299
300ACPI_STATUS
301AcpiDsGetRegionArguments (
302 ACPI_OPERAND_OBJECT *ObjDesc)
303{
304 ACPI_NAMESPACE_NODE *Node;
305 ACPI_STATUS Status;
306 ACPI_OPERAND_OBJECT *RegionObj2;
307
308
309 FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc);
310
311
312 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
313 {
314 return_ACPI_STATUS (AE_OK);
315 }
316
317 RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
318 if (!RegionObj2)
319 {
320 return_ACPI_STATUS (AE_NOT_EXIST);
321 }
322
323 /* Get the AML pointer (method object) and region node */
324
325 Node = ObjDesc->Region.Node;
326
327 DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]"));
328
329 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n",
330 (char *) &Node->Name, RegionObj2->Extra.AmlStart));
331
332
333 Status = AcpiDsExecuteArguments (Node, RegionObj2);
334
335 return_ACPI_STATUS (Status);
336}
337
338
339/*****************************************************************************
340 *
341 * FUNCTION: AcpiDsInitializeRegion
342 *

--- 29 unchanged lines hidden (view full) ---

372 *
373 * PARAMETERS: Op - A valid BufferField Op object
374 *
375 * RETURN: Status
376 *
377 * DESCRIPTION: Get BufferField Buffer and Index
378 * Called from AcpiDsExecEndOp during BufferField parse tree walk
379 *
380 ****************************************************************************/
381
382ACPI_STATUS
383AcpiDsEvalBufferFieldOperands (
384 ACPI_WALK_STATE *WalkState,
385 ACPI_PARSE_OBJECT *Op)
386{
387 ACPI_STATUS Status;

--- 32 unchanged lines hidden (view full) ---

420 }
421
422 ObjDesc = AcpiNsGetAttachedObject (Node);
423 if (!ObjDesc)
424 {
425 return_ACPI_STATUS (AE_NOT_EXIST);
426 }
427
428 /* Resolve the operands */
429
430 Status = AcpiExResolveOperands (Op->Opcode, WALK_OPERANDS, WalkState);
431 DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Opcode),
432 WalkState->NumOperands, "after AcpiExResolveOperands");
433
434 if (ACPI_FAILURE (Status))
435 {

--- 12 unchanged lines hidden (view full) ---

448 }
449 else
450 {
451 ResDesc = WalkState->Operands[2];
452 }
453
454 OffDesc = WalkState->Operands[1];
455 SrcDesc = WalkState->Operands[0];
456 Offset = (UINT32) OffDesc->Integer.Value;
457
458 /*
459 * If ResDesc is a Name, it will be a direct name pointer after
460 * AcpiExResolveOperands()
461 */
462 if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED))
463 {
464 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a Node\n",
465 AcpiPsGetOpcodeName (Op->Opcode)));
466
467 Status = AE_AML_OPERAND_TYPE;
468 goto Cleanup;
469 }
470
471 /*
472 * Setup the Bit offsets and counts, according to the opcode
473 */
474 switch (Op->Opcode)
475 {
476
477 case AML_CREATE_FIELD_OP:
478
479 /* Offset is in bits, count is in bits */
480
481 BitOffset = Offset;
482 BitCount = (UINT32) CntDesc->Integer.Value;
483 FieldFlags = AML_FIELD_ACCESS_BYTE;
484 break;
485
486 case AML_CREATE_BIT_FIELD_OP:
487
488 /* Offset is in bits, Field is one bit */
489
490 BitOffset = Offset;
491 BitCount = 1;
492 FieldFlags = AML_FIELD_ACCESS_BYTE;
493 break;
494
495 case AML_CREATE_BYTE_FIELD_OP:
496
497 /* Offset is in bytes, field is one byte */
498
499 BitOffset = 8 * Offset;
500 BitCount = 8;
501 FieldFlags = AML_FIELD_ACCESS_BYTE;
502 break;
503
504 case AML_CREATE_WORD_FIELD_OP:
505
506 /* Offset is in bytes, field is one word */
507
508 BitOffset = 8 * Offset;
509 BitCount = 16;
510 FieldFlags = AML_FIELD_ACCESS_WORD;
511 break;
512
513 case AML_CREATE_DWORD_FIELD_OP:
514
515 /* Offset is in bytes, field is one dword */
516
517 BitOffset = 8 * Offset;
518 BitCount = 32;
519 FieldFlags = AML_FIELD_ACCESS_DWORD;
520 break;
521
522 case AML_CREATE_QWORD_FIELD_OP:
523
524 /* Offset is in bytes, field is one qword */
525
526 BitOffset = 8 * Offset;
527 BitCount = 64;
528 FieldFlags = AML_FIELD_ACCESS_QWORD;
529 break;
530
531 default:
532
533 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
534 "Internal error - unknown field creation opcode %02x\n",
535 Op->Opcode));
536 Status = AE_AML_BAD_OPCODE;
537 goto Cleanup;
538 }
539
540 /*
541 * Setup field according to the object type
542 */
543 switch (SrcDesc->Common.Type)
544 {
545
546 /* SourceBuff := TermArg=>Buffer */
547

--- 4 unchanged lines hidden (view full) ---

552 {
553 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
554 "Field size %d exceeds Buffer size %d (bits)\n",
555 BitOffset + BitCount, 8 * (UINT32) SrcDesc->Buffer.Length));
556 Status = AE_AML_BUFFER_LIMIT;
557 goto Cleanup;
558 }
559
560 /*
561 * Initialize areas of the field object that are common to all fields
562 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
563 */
564 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0,
565 BitOffset, BitCount);
566 if (ACPI_FAILURE (Status))
567 {
568 return_ACPI_STATUS (Status);
569 }
570
571 ObjDesc->BufferField.BufferObj = SrcDesc;
572
573 /* Reference count for SrcDesc inherits ObjDesc count */
574
575 SrcDesc->Common.ReferenceCount = (UINT16) (SrcDesc->Common.ReferenceCount +
576 ObjDesc->Common.ReferenceCount);
577 break;
578
579
580 /* Improper object type */
581
582 default:
583
584 if ((SrcDesc->Common.Type > (UINT8) INTERNAL_TYPE_REFERENCE) || !AcpiUtValidObjectType (SrcDesc->Common.Type)) /* This line MUST be a single line until AcpiSrc can handle it (block deletion) */
585 {
586 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
587 "Tried to create field in invalid object type %X\n",
588 SrcDesc->Common.Type));
589 }
590
591 else
592 {

--- 194 unchanged lines hidden (view full) ---

787 AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
788
789 /*
790 * Save a pointer to the predicate for multiple executions
791 * of a loop
792 */
793 WalkState->ControlState->Control.AmlPredicateStart =
794 WalkState->ParserState.Aml - 1;
795 break;
796
797 case AML_ELSE_OP:
798
799 /* Predicate is in the state object */
800 /* If predicate is true, the IF was executed, ignore ELSE part */
801
802 if (WalkState->LastPredicate)
803 {
804 Status = AE_CTRL_TRUE;
805 }
806
807 break;
808
809 case AML_RETURN_OP:
810
811 break;
812
813 default:
814 break;
815 }
816
817 return (Status);
818}
819
820

--- 4 unchanged lines hidden (view full) ---

825 * PARAMETERS: WalkList - The list that owns the walk stack
826 * Op - The control Op
827 *
828 * RETURN: Status
829 *
830 * DESCRIPTION: Handles all control ops encountered during control method
831 * execution.
832 *
833 ******************************************************************************/
834
835ACPI_STATUS
836AcpiDsExecEndControlOp (
837 ACPI_WALK_STATE *WalkState,
838 ACPI_PARSE_OBJECT *Op)
839{
840 ACPI_STATUS Status = AE_OK;

--- 102 unchanged lines hidden (view full) ---

943 * cease to exist at the end of the method.
944 *
945 * Allow references created by the Index operator to return unchanged.
946 */
947 if (VALID_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc [0], ACPI_DESC_TYPE_INTERNAL) &&
948 ((WalkState->Results->Results.ObjDesc [0])->Common.Type == INTERNAL_TYPE_REFERENCE) &&
949 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP))
950 {
951 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState);
952 if (ACPI_FAILURE (Status))
953 {
954 return (Status);
955 }
956 }
957
958 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
959 }
960
961 else
962 {
963 /* No return operand */

--- 68 unchanged lines hidden (view full) ---

1032
1033 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
1034 Op->Opcode, Op));
1035
1036 Status = AE_AML_BAD_OPCODE;
1037 break;
1038 }
1039
1040 return (Status);
1041}
1042