Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/dispatcher/dsmthdat.c
+++ new/usr/src/common/acpica/components/dispatcher/dsmthdat.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: dsmthdat - control method arguments and local variables
4 4 *
5 5 ******************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __DSMTHDAT_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acdispat.h"
49 49 #include "acnamesp.h"
50 50 #include "acinterp.h"
51 51
52 52
53 53 #define _COMPONENT ACPI_DISPATCHER
54 54 ACPI_MODULE_NAME ("dsmthdat")
55 55
56 56 /* Local prototypes */
57 57
58 58 static void
59 59 AcpiDsMethodDataDeleteValue (
60 60 UINT8 Type,
61 61 UINT32 Index,
62 62 ACPI_WALK_STATE *WalkState);
63 63
64 64 static ACPI_STATUS
65 65 AcpiDsMethodDataSetValue (
66 66 UINT8 Type,
67 67 UINT32 Index,
68 68 ACPI_OPERAND_OBJECT *Object,
69 69 ACPI_WALK_STATE *WalkState);
70 70
71 71 #ifdef ACPI_OBSOLETE_FUNCTIONS
72 72 ACPI_OBJECT_TYPE
73 73 AcpiDsMethodDataGetType (
74 74 UINT16 Opcode,
75 75 UINT32 Index,
76 76 ACPI_WALK_STATE *WalkState);
77 77 #endif
78 78
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
79 79
80 80 /*******************************************************************************
81 81 *
82 82 * FUNCTION: AcpiDsMethodDataInit
83 83 *
84 84 * PARAMETERS: WalkState - Current walk state object
85 85 *
86 86 * RETURN: Status
87 87 *
88 88 * DESCRIPTION: Initialize the data structures that hold the method's arguments
89 - * and locals. The data struct is an array of namespace nodes for
89 + * and locals. The data struct is an array of namespace nodes for
90 90 * each - this allows RefOf and DeRefOf to work properly for these
91 91 * special data types.
92 92 *
93 93 * NOTES: WalkState fields are initialized to zero by the
94 94 * ACPI_ALLOCATE_ZEROED().
95 95 *
96 96 * A pseudo-Namespace Node is assigned to each argument and local
97 97 * so that RefOf() can return a pointer to the Node.
98 98 *
99 99 ******************************************************************************/
100 100
101 101 void
102 102 AcpiDsMethodDataInit (
103 103 ACPI_WALK_STATE *WalkState)
104 104 {
105 105 UINT32 i;
106 106
107 107
108 108 ACPI_FUNCTION_TRACE (DsMethodDataInit);
109 109
110 110
111 111 /* Init the method arguments */
112 112
113 113 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
114 114 {
115 115 ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
116 116 WalkState->Arguments[i].Name.Integer |= (i << 24);
117 117 WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
118 118 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
119 119 WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
120 120 }
121 121
122 122 /* Init the method locals */
123 123
124 124 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
125 125 {
126 126 ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
127 127
128 128 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
129 129 WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
130 130 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
131 131 WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
132 132 }
133 133
134 134 return_VOID;
135 135 }
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
136 136
137 137
138 138 /*******************************************************************************
139 139 *
140 140 * FUNCTION: AcpiDsMethodDataDeleteAll
141 141 *
142 142 * PARAMETERS: WalkState - Current walk state object
143 143 *
144 144 * RETURN: None
145 145 *
146 - * DESCRIPTION: Delete method locals and arguments. Arguments are only
146 + * DESCRIPTION: Delete method locals and arguments. Arguments are only
147 147 * deleted if this method was called from another method.
148 148 *
149 149 ******************************************************************************/
150 150
151 151 void
152 152 AcpiDsMethodDataDeleteAll (
153 153 ACPI_WALK_STATE *WalkState)
154 154 {
155 155 UINT32 Index;
156 156
157 157
158 158 ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
159 159
160 160
161 161 /* Detach the locals */
162 162
163 163 for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
164 164 {
165 165 if (WalkState->LocalVariables[Index].Object)
166 166 {
167 167 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
168 168 Index, WalkState->LocalVariables[Index].Object));
169 169
170 170 /* Detach object (if present) and remove a reference */
171 171
172 172 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
173 173 }
174 174 }
175 175
176 176 /* Detach the arguments */
177 177
178 178 for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
179 179 {
180 180 if (WalkState->Arguments[Index].Object)
181 181 {
182 182 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
183 183 Index, WalkState->Arguments[Index].Object));
184 184
185 185 /* Detach object (if present) and remove a reference */
186 186
187 187 AcpiNsDetachObject (&WalkState->Arguments[Index]);
188 188 }
189 189 }
190 190
191 191 return_VOID;
192 192 }
193 193
194 194
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
195 195 /*******************************************************************************
196 196 *
197 197 * FUNCTION: AcpiDsMethodDataInitArgs
198 198 *
199 199 * PARAMETERS: *Params - Pointer to a parameter list for the method
200 200 * MaxParamCount - The arg count for this method
201 201 * WalkState - Current walk state object
202 202 *
203 203 * RETURN: Status
204 204 *
205 - * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
205 + * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
206 206 * of ACPI operand objects, either null terminated or whose length
207 207 * is defined by MaxParamCount.
208 208 *
209 209 ******************************************************************************/
210 210
211 211 ACPI_STATUS
212 212 AcpiDsMethodDataInitArgs (
213 213 ACPI_OPERAND_OBJECT **Params,
214 214 UINT32 MaxParamCount,
215 215 ACPI_WALK_STATE *WalkState)
216 216 {
217 217 ACPI_STATUS Status;
218 218 UINT32 Index = 0;
219 219
220 220
221 221 ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
222 222
223 223
224 224 if (!Params)
225 225 {
226 226 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
227 227 return_ACPI_STATUS (AE_OK);
228 228 }
229 229
230 230 /* Copy passed parameters into the new method stack frame */
231 231
232 232 while ((Index < ACPI_METHOD_NUM_ARGS) &&
233 233 (Index < MaxParamCount) &&
234 234 Params[Index])
235 235 {
236 236 /*
237 237 * A valid parameter.
238 238 * Store the argument in the method/walk descriptor.
239 239 * Do not copy the arg in order to implement call by reference
240 240 */
241 241 Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
242 242 Params[Index], WalkState);
243 243 if (ACPI_FAILURE (Status))
244 244 {
245 245 return_ACPI_STATUS (Status);
246 246 }
247 247
248 248 Index++;
249 249 }
250 250
251 251 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
252 252 return_ACPI_STATUS (AE_OK);
253 253 }
254 254
255 255
256 256 /*******************************************************************************
257 257 *
258 258 * FUNCTION: AcpiDsMethodDataGetNode
259 259 *
260 260 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
261 261 * ACPI_REFCLASS_ARG
262 262 * Index - Which Local or Arg whose type to get
263 263 * WalkState - Current walk state object
264 264 * Node - Where the node is returned.
265 265 *
266 266 * RETURN: Status and node
267 267 *
268 268 * DESCRIPTION: Get the Node associated with a local or arg.
269 269 *
270 270 ******************************************************************************/
271 271
272 272 ACPI_STATUS
273 273 AcpiDsMethodDataGetNode (
274 274 UINT8 Type,
275 275 UINT32 Index,
276 276 ACPI_WALK_STATE *WalkState,
277 277 ACPI_NAMESPACE_NODE **Node)
278 278 {
279 279 ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
280 280
281 281
282 282 /*
283 283 * Method Locals and Arguments are supported
284 284 */
285 285 switch (Type)
286 286 {
287 287 case ACPI_REFCLASS_LOCAL:
288 288
289 289 if (Index > ACPI_METHOD_MAX_LOCAL)
290 290 {
291 291 ACPI_ERROR ((AE_INFO,
292 292 "Local index %u is invalid (max %u)",
293 293 Index, ACPI_METHOD_MAX_LOCAL));
294 294 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
295 295 }
296 296
297 297 /* Return a pointer to the pseudo-node */
298 298
299 299 *Node = &WalkState->LocalVariables[Index];
300 300 break;
301 301
302 302 case ACPI_REFCLASS_ARG:
303 303
304 304 if (Index > ACPI_METHOD_MAX_ARG)
305 305 {
306 306 ACPI_ERROR ((AE_INFO,
307 307 "Arg index %u is invalid (max %u)",
↓ open down ↓ |
92 lines elided |
↑ open up ↑ |
308 308 Index, ACPI_METHOD_MAX_ARG));
309 309 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
310 310 }
311 311
312 312 /* Return a pointer to the pseudo-node */
313 313
314 314 *Node = &WalkState->Arguments[Index];
315 315 break;
316 316
317 317 default:
318 +
318 319 ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
319 320 return_ACPI_STATUS (AE_TYPE);
320 321 }
321 322
322 323 return_ACPI_STATUS (AE_OK);
323 324 }
324 325
325 326
326 327 /*******************************************************************************
327 328 *
328 329 * FUNCTION: AcpiDsMethodDataSetValue
329 330 *
330 331 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
331 332 * ACPI_REFCLASS_ARG
332 333 * Index - Which Local or Arg to get
333 334 * Object - Object to be inserted into the stack entry
334 335 * WalkState - Current walk state object
335 336 *
336 337 * RETURN: Status
337 338 *
338 339 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
339 340 * Note: There is no "implicit conversion" for locals.
340 341 *
341 342 ******************************************************************************/
342 343
343 344 static ACPI_STATUS
344 345 AcpiDsMethodDataSetValue (
345 346 UINT8 Type,
346 347 UINT32 Index,
347 348 ACPI_OPERAND_OBJECT *Object,
348 349 ACPI_WALK_STATE *WalkState)
349 350 {
350 351 ACPI_STATUS Status;
351 352 ACPI_NAMESPACE_NODE *Node;
352 353
353 354
354 355 ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
355 356
356 357
357 358 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
358 359 "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
359 360 Type, Object->Common.ReferenceCount,
360 361 AcpiUtGetTypeName (Object->Common.Type)));
361 362
362 363 /* Get the namespace node for the arg/local */
363 364
364 365 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
365 366 if (ACPI_FAILURE (Status))
366 367 {
367 368 return_ACPI_STATUS (Status);
368 369 }
369 370
370 371 /*
371 372 * Increment ref count so object can't be deleted while installed.
372 373 * NOTE: We do not copy the object in order to preserve the call by
373 374 * reference semantics of ACPI Control Method invocation.
374 375 * (See ACPI Specification 2.0C)
375 376 */
376 377 AcpiUtAddReference (Object);
377 378
378 379 /* Install the object */
379 380
380 381 Node->Object = Object;
381 382 return_ACPI_STATUS (Status);
382 383 }
383 384
384 385
385 386 /*******************************************************************************
386 387 *
387 388 * FUNCTION: AcpiDsMethodDataGetValue
388 389 *
389 390 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
390 391 * ACPI_REFCLASS_ARG
391 392 * Index - Which localVar or argument to get
392 393 * WalkState - Current walk state object
393 394 * DestDesc - Where Arg or Local value is returned
394 395 *
395 396 * RETURN: Status
396 397 *
397 398 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
398 399 * Used only in AcpiExResolveToValue().
399 400 *
400 401 ******************************************************************************/
401 402
402 403 ACPI_STATUS
403 404 AcpiDsMethodDataGetValue (
404 405 UINT8 Type,
405 406 UINT32 Index,
406 407 ACPI_WALK_STATE *WalkState,
407 408 ACPI_OPERAND_OBJECT **DestDesc)
408 409 {
409 410 ACPI_STATUS Status;
410 411 ACPI_NAMESPACE_NODE *Node;
411 412 ACPI_OPERAND_OBJECT *Object;
412 413
413 414
414 415 ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
415 416
416 417
417 418 /* Validate the object descriptor */
418 419
419 420 if (!DestDesc)
420 421 {
421 422 ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
422 423 return_ACPI_STATUS (AE_BAD_PARAMETER);
423 424 }
424 425
425 426 /* Get the namespace node for the arg/local */
426 427
427 428 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
428 429 if (ACPI_FAILURE (Status))
429 430 {
430 431 return_ACPI_STATUS (Status);
431 432 }
432 433
433 434 /* Get the object from the node */
434 435
435 436 Object = Node->Object;
↓ open down ↓ |
108 lines elided |
↑ open up ↑ |
436 437
437 438 /* Examine the returned object, it must be valid. */
438 439
439 440 if (!Object)
440 441 {
441 442 /*
442 443 * Index points to uninitialized object.
443 444 * This means that either 1) The expected argument was
444 445 * not passed to the method, or 2) A local variable
445 446 * was referenced by the method (via the ASL)
446 - * before it was initialized. Either case is an error.
447 + * before it was initialized. Either case is an error.
447 448 */
448 449
449 450 /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
450 451
451 452 if (AcpiGbl_EnableInterpreterSlack)
452 453 {
453 454 Object = AcpiUtCreateIntegerObject ((UINT64) 0);
454 455 if (!Object)
455 456 {
456 457 return_ACPI_STATUS (AE_NO_MEMORY);
457 458 }
458 459
459 460 Node->Object = Object;
460 461 }
461 462
462 463 /* Otherwise, return the error */
463 464
464 465 else switch (Type)
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
465 466 {
466 467 case ACPI_REFCLASS_ARG:
467 468
468 469 ACPI_ERROR ((AE_INFO,
469 470 "Uninitialized Arg[%u] at node %p",
470 471 Index, Node));
471 472
472 473 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
473 474
474 475 case ACPI_REFCLASS_LOCAL:
475 -
476 476 /*
477 477 * No error message for this case, will be trapped again later to
478 478 * detect and ignore cases of Store(LocalX,LocalX)
479 479 */
480 480 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
481 481
482 482 default:
483 483
484 484 ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
485 485 return_ACPI_STATUS (AE_AML_INTERNAL);
486 486 }
487 487 }
488 488
489 489 /*
490 490 * The Index points to an initialized and valid object.
491 491 * Return an additional reference to the object
492 492 */
493 493 *DestDesc = Object;
494 494 AcpiUtAddReference (Object);
495 495
496 496 return_ACPI_STATUS (AE_OK);
497 497 }
498 498
499 499
500 500 /*******************************************************************************
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
501 501 *
502 502 * FUNCTION: AcpiDsMethodDataDeleteValue
503 503 *
504 504 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
505 505 * ACPI_REFCLASS_ARG
506 506 * Index - Which localVar or argument to delete
507 507 * WalkState - Current walk state object
508 508 *
509 509 * RETURN: None
510 510 *
511 - * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
511 + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
512 512 * a null into the stack slot after the object is deleted.
513 513 *
514 514 ******************************************************************************/
515 515
516 516 static void
517 517 AcpiDsMethodDataDeleteValue (
518 518 UINT8 Type,
519 519 UINT32 Index,
520 520 ACPI_WALK_STATE *WalkState)
521 521 {
522 522 ACPI_STATUS Status;
523 523 ACPI_NAMESPACE_NODE *Node;
524 524 ACPI_OPERAND_OBJECT *Object;
525 525
526 526
527 527 ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
528 528
529 529
530 530 /* Get the namespace node for the arg/local */
531 531
532 532 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
533 533 if (ACPI_FAILURE (Status))
534 534 {
535 535 return_VOID;
536 536 }
537 537
538 538 /* Get the associated object */
539 539
540 540 Object = AcpiNsGetAttachedObject (Node);
541 541
542 542 /*
543 543 * Undefine the Arg or Local by setting its descriptor
544 544 * pointer to NULL. Locals/Args can contain both
545 545 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
546 546 */
547 547 Node->Object = NULL;
548 548
549 549 if ((Object) &&
550 550 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
551 551 {
552 552 /*
553 553 * There is a valid object.
554 554 * Decrement the reference count by one to balance the
555 555 * increment when the object was stored.
556 556 */
557 557 AcpiUtRemoveReference (Object);
558 558 }
559 559
560 560 return_VOID;
561 561 }
562 562
563 563
564 564 /*******************************************************************************
565 565 *
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
566 566 * FUNCTION: AcpiDsStoreObjectToLocal
567 567 *
568 568 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
569 569 * ACPI_REFCLASS_ARG
570 570 * Index - Which Local or Arg to set
571 571 * ObjDesc - Value to be stored
572 572 * WalkState - Current walk state
573 573 *
574 574 * RETURN: Status
575 575 *
576 - * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
576 + * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
577 577 * as the new value for the Arg or Local and the reference count
578 578 * for ObjDesc is incremented.
579 579 *
580 580 ******************************************************************************/
581 581
582 582 ACPI_STATUS
583 583 AcpiDsStoreObjectToLocal (
584 584 UINT8 Type,
585 585 UINT32 Index,
586 586 ACPI_OPERAND_OBJECT *ObjDesc,
587 587 ACPI_WALK_STATE *WalkState)
588 588 {
589 589 ACPI_STATUS Status;
590 590 ACPI_NAMESPACE_NODE *Node;
591 591 ACPI_OPERAND_OBJECT *CurrentObjDesc;
592 592 ACPI_OPERAND_OBJECT *NewObjDesc;
593 593
594 594
595 595 ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
596 596 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
597 597 Type, Index, ObjDesc));
598 598
599 599 /* Parameter validation */
600 600
601 601 if (!ObjDesc)
602 602 {
603 603 return_ACPI_STATUS (AE_BAD_PARAMETER);
604 604 }
605 605
606 606 /* Get the namespace node for the arg/local */
607 607
608 608 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
609 609 if (ACPI_FAILURE (Status))
610 610 {
611 611 return_ACPI_STATUS (Status);
612 612 }
613 613
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
614 614 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
615 615 if (CurrentObjDesc == ObjDesc)
616 616 {
617 617 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
618 618 ObjDesc));
619 619 return_ACPI_STATUS (Status);
620 620 }
621 621
622 622 /*
623 623 * If the reference count on the object is more than one, we must
624 - * take a copy of the object before we store. A reference count
624 + * take a copy of the object before we store. A reference count
625 625 * of exactly 1 means that the object was just created during the
626 626 * evaluation of an expression, and we can safely use it since it
627 627 * is not used anywhere else.
628 628 */
629 629 NewObjDesc = ObjDesc;
630 630 if (ObjDesc->Common.ReferenceCount > 1)
631 631 {
632 632 Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
633 633 if (ACPI_FAILURE (Status))
634 634 {
635 635 return_ACPI_STATUS (Status);
636 636 }
637 637 }
638 638
639 639 /*
640 640 * If there is an object already in this slot, we either
641 641 * have to delete it, or if this is an argument and there
642 642 * is an object reference stored there, we have to do
643 643 * an indirect store!
644 644 */
645 645 if (CurrentObjDesc)
646 646 {
647 647 /*
648 648 * Check for an indirect store if an argument
649 649 * contains an object reference (stored as an Node).
650 650 * We don't allow this automatic dereferencing for
651 651 * locals, since a store to a local should overwrite
652 652 * anything there, including an object reference.
653 653 *
654 654 * If both Arg0 and Local0 contain RefOf (Local4):
655 655 *
656 656 * Store (1, Arg0) - Causes indirect store to local4
657 657 * Store (1, Local0) - Stores 1 in local0, overwriting
658 658 * the reference to local4
659 659 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
660 660 *
661 661 * Weird, but true.
662 662 */
663 663 if (Type == ACPI_REFCLASS_ARG)
664 664 {
665 665 /*
666 666 * If we have a valid reference object that came from RefOf(),
667 667 * do the indirect store
668 668 */
669 669 if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
670 670 (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
671 671 (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
672 672 {
673 673 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
674 674 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
675 675 NewObjDesc, CurrentObjDesc));
676 676
677 677 /*
678 678 * Store this object to the Node (perform the indirect store)
679 679 * NOTE: No implicit conversion is performed, as per the ACPI
680 680 * specification rules on storing to Locals/Args.
681 681 */
682 682 Status = AcpiExStoreObjectToNode (NewObjDesc,
683 683 CurrentObjDesc->Reference.Object, WalkState,
684 684 ACPI_NO_IMPLICIT_CONVERSION);
685 685
686 686 /* Remove local reference if we copied the object above */
687 687
688 688 if (NewObjDesc != ObjDesc)
689 689 {
690 690 AcpiUtRemoveReference (NewObjDesc);
691 691 }
692 692 return_ACPI_STATUS (Status);
693 693 }
694 694 }
695 695
696 696 /* Delete the existing object before storing the new one */
697 697
698 698 AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
699 699 }
700 700
701 701 /*
702 702 * Install the Obj descriptor (*NewObjDesc) into
703 703 * the descriptor for the Arg or Local.
704 704 * (increments the object reference count by one)
705 705 */
706 706 Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
707 707
708 708 /* Remove local reference if we copied the object above */
709 709
710 710 if (NewObjDesc != ObjDesc)
711 711 {
712 712 AcpiUtRemoveReference (NewObjDesc);
713 713 }
714 714
715 715 return_ACPI_STATUS (Status);
716 716 }
717 717
718 718
719 719 #ifdef ACPI_OBSOLETE_FUNCTIONS
720 720 /*******************************************************************************
721 721 *
722 722 * FUNCTION: AcpiDsMethodDataGetType
723 723 *
724 724 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
725 725 * Index - Which Local or Arg whose type to get
726 726 * WalkState - Current walk state object
727 727 *
728 728 * RETURN: Data type of current value of the selected Arg or Local
729 729 *
730 730 * DESCRIPTION: Get the type of the object stored in the Local or Arg
731 731 *
732 732 ******************************************************************************/
733 733
734 734 ACPI_OBJECT_TYPE
735 735 AcpiDsMethodDataGetType (
736 736 UINT16 Opcode,
737 737 UINT32 Index,
738 738 ACPI_WALK_STATE *WalkState)
739 739 {
740 740 ACPI_STATUS Status;
741 741 ACPI_NAMESPACE_NODE *Node;
742 742 ACPI_OPERAND_OBJECT *Object;
743 743
744 744
745 745 ACPI_FUNCTION_TRACE (DsMethodDataGetType);
746 746
747 747
748 748 /* Get the namespace node for the arg/local */
749 749
750 750 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
751 751 if (ACPI_FAILURE (Status))
752 752 {
753 753 return_VALUE ((ACPI_TYPE_NOT_FOUND));
754 754 }
755 755
756 756 /* Get the object */
757 757
758 758 Object = AcpiNsGetAttachedObject (Node);
759 759 if (!Object)
760 760 {
↓ open down ↓ |
126 lines elided |
↑ open up ↑ |
761 761 /* Uninitialized local/arg, return TYPE_ANY */
762 762
763 763 return_VALUE (ACPI_TYPE_ANY);
764 764 }
765 765
766 766 /* Get the object type */
767 767
768 768 return_VALUE (Object->Type);
769 769 }
770 770 #endif
771 -
772 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX