dsmthdat.c (83174) | dsmthdat.c (87031) |
---|---|
1/******************************************************************************* 2 * 3 * Module Name: dsmthdat - control method arguments and local variables | 1/******************************************************************************* 2 * 3 * Module Name: dsmthdat - control method arguments and local variables |
4 * $Revision: 49 $ | 4 * $Revision: 53 $ |
5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 123 unchanged lines hidden (view full) --- 136 * 137 * RETURN: Status 138 * 139 * DESCRIPTION: Initialize the data structures that hold the method's arguments 140 * and locals. The data struct is an array of NTEs for each. 141 * This allows RefOf and DeRefOf to work properly for these 142 * special data types. 143 * | 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 123 unchanged lines hidden (view full) --- 136 * 137 * RETURN: Status 138 * 139 * DESCRIPTION: Initialize the data structures that hold the method's arguments 140 * and locals. The data struct is an array of NTEs for each. 141 * This allows RefOf and DeRefOf to work properly for these 142 * special data types. 143 * |
144 * NOTES: WalkState fields are initialized to zero by the 145 * ACPI_MEM_CALLOCATE(). 146 * 147 * A pseudo-Namespace Node is assigned to each argument and local 148 * so that RefOf() can return a pointer to the Node. 149 * |
|
144 ******************************************************************************/ 145 146ACPI_STATUS 147AcpiDsMethodDataInit ( 148 ACPI_WALK_STATE *WalkState) 149{ 150 UINT32 i; 151 152 153 FUNCTION_TRACE ("DsMethodDataInit"); 154 | 150 ******************************************************************************/ 151 152ACPI_STATUS 153AcpiDsMethodDataInit ( 154 ACPI_WALK_STATE *WalkState) 155{ 156 UINT32 i; 157 158 159 FUNCTION_TRACE ("DsMethodDataInit"); 160 |
155 /* 156 * WalkState fields are initialized to zero by the 157 * ACPI_MEM_CALLOCATE(). 158 * 159 * An Node is assigned to each argument and local so 160 * that RefOf() can return a pointer to the Node. 161 */ | |
162 163 /* Init the method arguments */ 164 165 for (i = 0; i < MTH_NUM_ARGS; i++) 166 { 167 MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, 168 NAMEOF_ARG_NTE); 169 WalkState->Arguments[i].Name |= (i << 24); --- 32 unchanged lines hidden (view full) --- 202 * 203 ******************************************************************************/ 204 205ACPI_STATUS 206AcpiDsMethodDataDeleteAll ( 207 ACPI_WALK_STATE *WalkState) 208{ 209 UINT32 Index; | 161 162 /* Init the method arguments */ 163 164 for (i = 0; i < MTH_NUM_ARGS; i++) 165 { 166 MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, 167 NAMEOF_ARG_NTE); 168 WalkState->Arguments[i].Name |= (i << 24); --- 32 unchanged lines hidden (view full) --- 201 * 202 ******************************************************************************/ 203 204ACPI_STATUS 205AcpiDsMethodDataDeleteAll ( 206 ACPI_WALK_STATE *WalkState) 207{ 208 UINT32 Index; |
210 ACPI_OPERAND_OBJECT *Object; | |
211 212 213 FUNCTION_TRACE ("DsMethodDataDeleteAll"); 214 215 | 209 210 211 FUNCTION_TRACE ("DsMethodDataDeleteAll"); 212 213 |
216 /* Delete the locals */ | 214 /* Detach the locals */ |
217 | 215 |
218 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting local variables in %p\n", WalkState)); 219 | |
220 for (Index = 0; Index < MTH_NUM_LOCALS; Index++) 221 { | 216 for (Index = 0; Index < MTH_NUM_LOCALS; Index++) 217 { |
222 Object = WalkState->LocalVariables[Index].Object; 223 if (Object) | 218 if (WalkState->LocalVariables[Index].Object) |
224 { | 219 { |
225 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", Index, Object)); | 220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", 221 Index, WalkState->LocalVariables[Index].Object)); |
226 | 222 |
227 /* Remove first */ | 223 /* Detach object (if present) and remove a reference */ |
228 | 224 |
229 WalkState->LocalVariables[Index].Object = NULL; 230 231 /* Was given a ref when stored */ 232 233 AcpiUtRemoveReference (Object); | 225 AcpiNsDetachObject (&WalkState->LocalVariables[Index]); |
234 } 235 } 236 | 226 } 227 } 228 |
229 /* Detach the arguments */ |
|
237 | 230 |
238 /* Delete the arguments */ 239 240 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting arguments in %p\n", WalkState)); 241 | |
242 for (Index = 0; Index < MTH_NUM_ARGS; Index++) 243 { | 231 for (Index = 0; Index < MTH_NUM_ARGS; Index++) 232 { |
244 Object = WalkState->Arguments[Index].Object; 245 if (Object) | 233 if (WalkState->Arguments[Index].Object) |
246 { | 234 { |
247 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", Index, Object)); | 235 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", 236 Index, WalkState->Arguments[Index].Object)); |
248 | 237 |
249 /* Remove first */ | 238 /* Detach object (if present) and remove a reference */ |
250 | 239 |
251 WalkState->Arguments[Index].Object = NULL; 252 253 /* Was given a ref when stored */ 254 255 AcpiUtRemoveReference (Object); | 240 AcpiNsDetachObject (&WalkState->Arguments[Index]); |
256 } 257 } 258 259 return_ACPI_STATUS (AE_OK); 260} 261 262 263/******************************************************************************* 264 * 265 * FUNCTION: AcpiDsMethodDataInitArgs 266 * 267 * PARAMETERS: *Params - Pointer to a parameter list for the method 268 * MaxParamCount - The arg count for this method 269 * WalkState - Current walk state object 270 * 271 * RETURN: Status 272 * | 241 } 242 } 243 244 return_ACPI_STATUS (AE_OK); 245} 246 247 248/******************************************************************************* 249 * 250 * FUNCTION: AcpiDsMethodDataInitArgs 251 * 252 * PARAMETERS: *Params - Pointer to a parameter list for the method 253 * MaxParamCount - The arg count for this method 254 * WalkState - Current walk state object 255 * 256 * RETURN: Status 257 * |
273 * DESCRIPTION: Initialize arguments for a method | 258 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list 259 * of ACPI operand objects, either null terminated or whose length 260 * is defined by MaxParamCount. |
274 * 275 ******************************************************************************/ 276 277ACPI_STATUS 278AcpiDsMethodDataInitArgs ( 279 ACPI_OPERAND_OBJECT **Params, 280 UINT32 MaxParamCount, 281 ACPI_WALK_STATE *WalkState) 282{ 283 ACPI_STATUS Status; | 261 * 262 ******************************************************************************/ 263 264ACPI_STATUS 265AcpiDsMethodDataInitArgs ( 266 ACPI_OPERAND_OBJECT **Params, 267 UINT32 MaxParamCount, 268 ACPI_WALK_STATE *WalkState) 269{ 270 ACPI_STATUS Status; |
284 UINT32 Mindex; 285 UINT32 Pindex; | 271 UINT32 Index = 0; |
286 287 288 FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); 289 290 291 if (!Params) 292 { 293 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); 294 return_ACPI_STATUS (AE_OK); 295 } 296 297 /* Copy passed parameters into the new method stack frame */ 298 | 272 273 274 FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); 275 276 277 if (!Params) 278 { 279 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); 280 return_ACPI_STATUS (AE_OK); 281 } 282 283 /* Copy passed parameters into the new method stack frame */ 284 |
299 for (Pindex = Mindex = 0; 300 (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); 301 Mindex++) | 285 while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) |
302 { | 286 { |
303 if (Params[Pindex]) | 287 /* 288 * A valid parameter. 289 * Store the argument in the method/walk descriptor 290 */ 291 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index], 292 WalkState); 293 if (ACPI_FAILURE (Status)) |
304 { | 294 { |
305 /* 306 * A valid parameter. 307 * Set the current method argument to the 308 * Params[Pindex++] argument object descriptor 309 */ 310 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Mindex, 311 Params[Pindex], WalkState); 312 if (ACPI_FAILURE (Status)) 313 { 314 break; 315 } 316 317 Pindex++; | 295 return_ACPI_STATUS (Status); |
318 } 319 | 296 } 297 |
320 else 321 { 322 break; 323 } | 298 Index++; |
324 } 325 | 299 } 300 |
326 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Pindex)); | 301 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); |
327 return_ACPI_STATUS (AE_OK); 328} 329 330 331/******************************************************************************* 332 * | 302 return_ACPI_STATUS (AE_OK); 303} 304 305 306/******************************************************************************* 307 * |
333 * FUNCTION: AcpiDsMethodDataGetEntry | 308 * FUNCTION: AcpiDsMethodDataGetNode |
334 * 335 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 309 * 310 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
336 * Index - Which localVar or argument to get 337 * Entry - Pointer to where a pointer to the stack 338 * entry is returned. | 311 * Index - Which localVar or argument whose type 312 * to get |
339 * WalkState - Current walk state object 340 * | 313 * WalkState - Current walk state object 314 * |
341 * RETURN: Status | 315 * RETURN: Get the Node associated with a local or arg. |
342 * | 316 * |
343 * DESCRIPTION: Get the address of the object entry given by Opcode:Index 344 * | |
345 ******************************************************************************/ 346 347ACPI_STATUS | 317 ******************************************************************************/ 318 319ACPI_STATUS |
348AcpiDsMethodDataGetEntry ( | 320AcpiDsMethodDataGetNode ( |
349 UINT16 Opcode, 350 UINT32 Index, 351 ACPI_WALK_STATE *WalkState, | 321 UINT16 Opcode, 322 UINT32 Index, 323 ACPI_WALK_STATE *WalkState, |
352 ACPI_OPERAND_OBJECT ***Entry) | 324 ACPI_NAMESPACE_NODE **Node) |
353{ | 325{ |
326 FUNCTION_TRACE ("DsMethodDataGetNode"); |
|
354 | 327 |
355 FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); | |
356 | 328 |
357 | |
358 /* | 329 /* |
359 * Get the requested object. 360 * The stack "Opcode" is either a LocalVariable or an Argument | 330 * Method Locals and Arguments are supported |
361 */ 362 switch (Opcode) 363 { | 331 */ 332 switch (Opcode) 333 { |
364 | |
365 case AML_LOCAL_OP: 366 367 if (Index > MTH_MAX_LOCAL) 368 { | 334 case AML_LOCAL_OP: 335 336 if (Index > MTH_MAX_LOCAL) 337 { |
369 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "LocalVar index %d is invalid (max %d)\n", | 338 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", |
370 Index, MTH_MAX_LOCAL)); | 339 Index, MTH_MAX_LOCAL)); |
371 return_ACPI_STATUS (AE_BAD_PARAMETER); | 340 return_ACPI_STATUS (AE_AML_INVALID_INDEX); |
372 } 373 | 341 } 342 |
374 *Entry = (ACPI_OPERAND_OBJECT **) 375 &WalkState->LocalVariables[Index].Object; | 343 /* Return a pointer to the pseudo-node */ 344 345 *Node = &WalkState->LocalVariables[Index]; |
376 break; 377 | 346 break; 347 |
378 | |
379 case AML_ARG_OP: 380 381 if (Index > MTH_MAX_ARG) 382 { 383 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 384 Index, MTH_MAX_ARG)); | 348 case AML_ARG_OP: 349 350 if (Index > MTH_MAX_ARG) 351 { 352 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 353 Index, MTH_MAX_ARG)); |
385 return_ACPI_STATUS (AE_BAD_PARAMETER); | 354 return_ACPI_STATUS (AE_AML_INVALID_INDEX); |
386 } 387 | 355 } 356 |
388 *Entry = (ACPI_OPERAND_OBJECT **) 389 &WalkState->Arguments[Index].Object; | 357 /* Return a pointer to the pseudo-node */ 358 359 *Node = &WalkState->Arguments[Index]; |
390 break; 391 | 360 break; 361 |
392 | |
393 default: 394 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); | 362 default: 363 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); |
395 return_ACPI_STATUS (AE_BAD_PARAMETER); | 364 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 365 break; |
396 } 397 | 366 } 367 |
398 | |
399 return_ACPI_STATUS (AE_OK); 400} 401 402 403/******************************************************************************* 404 * | 368 return_ACPI_STATUS (AE_OK); 369} 370 371 372/******************************************************************************* 373 * |
405 * FUNCTION: AcpiDsMethodDataSetEntry | 374 * FUNCTION: AcpiDsMethodDataSetValue |
406 * 407 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 408 * Index - Which localVar or argument to get 409 * Object - Object to be inserted into the stack entry 410 * WalkState - Current walk state object 411 * 412 * RETURN: Status 413 * 414 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. 415 * 416 ******************************************************************************/ 417 418ACPI_STATUS | 375 * 376 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 377 * Index - Which localVar or argument to get 378 * Object - Object to be inserted into the stack entry 379 * WalkState - Current walk state object 380 * 381 * RETURN: Status 382 * 383 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. 384 * 385 ******************************************************************************/ 386 387ACPI_STATUS |
419AcpiDsMethodDataSetEntry ( | 388AcpiDsMethodDataSetValue ( |
420 UINT16 Opcode, 421 UINT32 Index, 422 ACPI_OPERAND_OBJECT *Object, 423 ACPI_WALK_STATE *WalkState) 424{ 425 ACPI_STATUS Status; | 389 UINT16 Opcode, 390 UINT32 Index, 391 ACPI_OPERAND_OBJECT *Object, 392 ACPI_WALK_STATE *WalkState) 393{ 394 ACPI_STATUS Status; |
426 ACPI_OPERAND_OBJECT **Entry; | 395 ACPI_NAMESPACE_NODE *Node; |
427 428 | 396 397 |
429 FUNCTION_TRACE ("DsMethodDataSetEntry"); | 398 FUNCTION_TRACE ("DsMethodDataSetValue"); |
430 431 | 399 400 |
432 /* Get a pointer to the stack entry to set */ | 401 /* Get the namespace node for the arg/local */ |
433 | 402 |
434 Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); | 403 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); |
435 if (ACPI_FAILURE (Status)) 436 { 437 return_ACPI_STATUS (Status); 438 } 439 440 /* Increment ref count so object can't be deleted while installed */ 441 442 AcpiUtAddReference (Object); 443 444 /* Install the object into the stack entry */ 445 | 404 if (ACPI_FAILURE (Status)) 405 { 406 return_ACPI_STATUS (Status); 407 } 408 409 /* Increment ref count so object can't be deleted while installed */ 410 411 AcpiUtAddReference (Object); 412 413 /* Install the object into the stack entry */ 414 |
446 *Entry = Object; 447 | 415 Node->Object = Object; |
448 return_ACPI_STATUS (AE_OK); 449} 450 451 452/******************************************************************************* 453 * 454 * FUNCTION: AcpiDsMethodDataGetType 455 * 456 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 457 * Index - Which localVar or argument whose type 458 * to get 459 * WalkState - Current walk state object 460 * | 416 return_ACPI_STATUS (AE_OK); 417} 418 419 420/******************************************************************************* 421 * 422 * FUNCTION: AcpiDsMethodDataGetType 423 * 424 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 425 * Index - Which localVar or argument whose type 426 * to get 427 * WalkState - Current walk state object 428 * |
461 * RETURN: Data type of selected Arg or Local 462 * Used only in ExecMonadic2()/TypeOp. | 429 * RETURN: Data type of current value of the selected Arg or Local |
463 * 464 ******************************************************************************/ 465 466ACPI_OBJECT_TYPE8 467AcpiDsMethodDataGetType ( 468 UINT16 Opcode, 469 UINT32 Index, 470 ACPI_WALK_STATE *WalkState) 471{ 472 ACPI_STATUS Status; | 430 * 431 ******************************************************************************/ 432 433ACPI_OBJECT_TYPE8 434AcpiDsMethodDataGetType ( 435 UINT16 Opcode, 436 UINT32 Index, 437 ACPI_WALK_STATE *WalkState) 438{ 439 ACPI_STATUS Status; |
473 ACPI_OPERAND_OBJECT **Entry; | 440 ACPI_NAMESPACE_NODE *Node; |
474 ACPI_OPERAND_OBJECT *Object; 475 476 477 FUNCTION_TRACE ("DsMethodDataGetType"); 478 479 | 441 ACPI_OPERAND_OBJECT *Object; 442 443 444 FUNCTION_TRACE ("DsMethodDataGetType"); 445 446 |
480 /* Get a pointer to the requested stack entry */ | 447 /* Get the namespace node for the arg/local */ |
481 | 448 |
482 Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); | 449 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); |
483 if (ACPI_FAILURE (Status)) 484 { 485 return_VALUE ((ACPI_TYPE_NOT_FOUND)); 486 } 487 | 450 if (ACPI_FAILURE (Status)) 451 { 452 return_VALUE ((ACPI_TYPE_NOT_FOUND)); 453 } 454 |
488 /* Get the object from the method stack */ | 455 /* Get the object */ |
489 | 456 |
490 Object = *Entry; 491 492 /* Get the object type */ 493 | 457 Object = AcpiNsGetAttachedObject (Node); |
494 if (!Object) 495 { | 458 if (!Object) 459 { |
496 /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ | 460 /* Uninitialized local/arg, return TYPE_ANY */ 461 |
497 return_VALUE (ACPI_TYPE_ANY); 498 } 499 | 462 return_VALUE (ACPI_TYPE_ANY); 463 } 464 |
465 /* Get the object type */ 466 |
|
500 return_VALUE (Object->Common.Type); 501} 502 503 504/******************************************************************************* 505 * | 467 return_VALUE (Object->Common.Type); 468} 469 470 471/******************************************************************************* 472 * |
506 * FUNCTION: AcpiDsMethodDataGetNode 507 * 508 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 509 * Index - Which localVar or argument whose type 510 * to get 511 * WalkState - Current walk state object 512 * 513 * RETURN: Get the Node associated with a local or arg. 514 * 515 ******************************************************************************/ 516 517ACPI_NAMESPACE_NODE * 518AcpiDsMethodDataGetNode ( 519 UINT16 Opcode, 520 UINT32 Index, 521 ACPI_WALK_STATE *WalkState) 522{ 523 ACPI_NAMESPACE_NODE *Node = NULL; 524 525 526 FUNCTION_TRACE ("DsMethodDataGetNode"); 527 528 529 switch (Opcode) 530 { 531 532 case AML_LOCAL_OP: 533 534 if (Index > MTH_MAX_LOCAL) 535 { 536 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", 537 Index, MTH_MAX_LOCAL)); 538 return_PTR (Node); 539 } 540 541 Node = &WalkState->LocalVariables[Index]; 542 break; 543 544 545 case AML_ARG_OP: 546 547 if (Index > MTH_MAX_ARG) 548 { 549 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 550 Index, MTH_MAX_ARG)); 551 return_PTR (Node); 552 } 553 554 Node = &WalkState->Arguments[Index]; 555 break; 556 557 558 default: 559 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); 560 break; 561 } 562 563 564 return_PTR (Node); 565} 566 567 568/******************************************************************************* 569 * | |
570 * FUNCTION: AcpiDsMethodDataGetValue 571 * 572 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 573 * Index - Which localVar or argument to get 574 * WalkState - Current walk state object 575 * *DestDesc - Ptr to Descriptor into which selected Arg 576 * or Local value should be copied 577 * --- 8 unchanged lines hidden (view full) --- 586ACPI_STATUS 587AcpiDsMethodDataGetValue ( 588 UINT16 Opcode, 589 UINT32 Index, 590 ACPI_WALK_STATE *WalkState, 591 ACPI_OPERAND_OBJECT **DestDesc) 592{ 593 ACPI_STATUS Status; | 473 * FUNCTION: AcpiDsMethodDataGetValue 474 * 475 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 476 * Index - Which localVar or argument to get 477 * WalkState - Current walk state object 478 * *DestDesc - Ptr to Descriptor into which selected Arg 479 * or Local value should be copied 480 * --- 8 unchanged lines hidden (view full) --- 489ACPI_STATUS 490AcpiDsMethodDataGetValue ( 491 UINT16 Opcode, 492 UINT32 Index, 493 ACPI_WALK_STATE *WalkState, 494 ACPI_OPERAND_OBJECT **DestDesc) 495{ 496 ACPI_STATUS Status; |
594 ACPI_OPERAND_OBJECT **Entry; | 497 ACPI_NAMESPACE_NODE *Node; |
595 ACPI_OPERAND_OBJECT *Object; 596 597 598 FUNCTION_TRACE ("DsMethodDataGetValue"); 599 600 601 /* Validate the object descriptor */ 602 603 if (!DestDesc) 604 { 605 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); 606 return_ACPI_STATUS (AE_BAD_PARAMETER); 607 } 608 | 498 ACPI_OPERAND_OBJECT *Object; 499 500 501 FUNCTION_TRACE ("DsMethodDataGetValue"); 502 503 504 /* Validate the object descriptor */ 505 506 if (!DestDesc) 507 { 508 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); 509 return_ACPI_STATUS (AE_BAD_PARAMETER); 510 } 511 |
512 /* Get the namespace node for the arg/local */ |
|
609 | 513 |
610 /* Get a pointer to the requested method stack entry */ 611 612 Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); | 514 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); |
613 if (ACPI_FAILURE (Status)) 614 { 615 return_ACPI_STATUS (Status); 616 } 617 | 515 if (ACPI_FAILURE (Status)) 516 { 517 return_ACPI_STATUS (Status); 518 } 519 |
618 /* Get the object from the method stack */ | 520 /* Get the object from the node */ |
619 | 521 |
620 Object = *Entry; | 522 Object = Node->Object; |
621 | 523 |
622 | |
623 /* Examine the returned object, it must be valid. */ 624 625 if (!Object) 626 { 627 /* | 524 /* Examine the returned object, it must be valid. */ 525 526 if (!Object) 527 { 528 /* |
628 * Index points to uninitialized object stack value. | 529 * Index points to uninitialized object. |
629 * This means that either 1) The expected argument was 630 * not passed to the method, or 2) A local variable 631 * was referenced by the method (via the ASL) 632 * before it was initialized. Either case is an error. 633 */ 634 switch (Opcode) 635 { 636 case AML_ARG_OP: 637 | 530 * This means that either 1) The expected argument was 531 * not passed to the method, or 2) A local variable 532 * was referenced by the method (via the ASL) 533 * before it was initialized. Either case is an error. 534 */ 535 switch (Opcode) 536 { 537 case AML_ARG_OP: 538 |
638 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n", 639 Index, Entry)); | 539 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", 540 Index, Node)); |
640 641 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 642 break; 643 644 case AML_LOCAL_OP: 645 | 541 542 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 543 break; 544 545 case AML_LOCAL_OP: 546 |
646 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n", 647 Index, Entry)); | 547 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", 548 Index, Node)); |
648 649 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 650 break; 651 } 652 } 653 | 549 550 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 551 break; 552 } 553 } 554 |
654 | |
655 /* | 555 /* |
656 * Index points to initialized and valid object stack value. | 556 * The Index points to an initialized and valid object. |
657 * Return an additional reference to the object 658 */ 659 *DestDesc = Object; 660 AcpiUtAddReference (Object); 661 662 return_ACPI_STATUS (AE_OK); 663} 664 --- 15 unchanged lines hidden (view full) --- 680 681ACPI_STATUS 682AcpiDsMethodDataDeleteValue ( 683 UINT16 Opcode, 684 UINT32 Index, 685 ACPI_WALK_STATE *WalkState) 686{ 687 ACPI_STATUS Status; | 557 * Return an additional reference to the object 558 */ 559 *DestDesc = Object; 560 AcpiUtAddReference (Object); 561 562 return_ACPI_STATUS (AE_OK); 563} 564 --- 15 unchanged lines hidden (view full) --- 580 581ACPI_STATUS 582AcpiDsMethodDataDeleteValue ( 583 UINT16 Opcode, 584 UINT32 Index, 585 ACPI_WALK_STATE *WalkState) 586{ 587 ACPI_STATUS Status; |
688 ACPI_OPERAND_OBJECT **Entry; | 588 ACPI_NAMESPACE_NODE *Node; |
689 ACPI_OPERAND_OBJECT *Object; 690 691 692 FUNCTION_TRACE ("DsMethodDataDeleteValue"); 693 694 | 589 ACPI_OPERAND_OBJECT *Object; 590 591 592 FUNCTION_TRACE ("DsMethodDataDeleteValue"); 593 594 |
695 /* Get a pointer to the requested entry */ | 595 /* Get the namespace node for the arg/local */ |
696 | 596 |
697 Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); | 597 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); |
698 if (ACPI_FAILURE (Status)) 699 { 700 return_ACPI_STATUS (Status); 701 } 702 | 598 if (ACPI_FAILURE (Status)) 599 { 600 return_ACPI_STATUS (Status); 601 } 602 |
703 /* Get the current entry in this slot k */ | 603 /* Get the associated object */ |
704 | 604 |
705 Object = *Entry; | 605 Object = AcpiNsGetAttachedObject (Node); |
706 707 /* 708 * Undefine the Arg or Local by setting its descriptor 709 * pointer to NULL. Locals/Args can contain both 710 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs 711 */ | 606 607 /* 608 * Undefine the Arg or Local by setting its descriptor 609 * pointer to NULL. Locals/Args can contain both 610 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs 611 */ |
712 *Entry = NULL; | 612 Node->Object = NULL; |
713 714 if ((Object) && 715 (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) 716 { 717 /* | 613 614 if ((Object) && 615 (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) 616 { 617 /* |
718 * There is a valid object in this slot | 618 * There is a valid object. |
719 * Decrement the reference count by one to balance the | 619 * Decrement the reference count by one to balance the |
720 * increment when the object was stored in the slot. | 620 * increment when the object was stored. |
721 */ 722 AcpiUtRemoveReference (Object); 723 } 724 725 return_ACPI_STATUS (AE_OK); 726} 727 728 729/******************************************************************************* 730 * 731 * FUNCTION: AcpiDsStoreObjectToLocal 732 * 733 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 734 * Index - Which localVar or argument to set | 621 */ 622 AcpiUtRemoveReference (Object); 623 } 624 625 return_ACPI_STATUS (AE_OK); 626} 627 628 629/******************************************************************************* 630 * 631 * FUNCTION: AcpiDsStoreObjectToLocal 632 * 633 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 634 * Index - Which localVar or argument to set |
735 * SrcDesc - Value to be stored | 635 * ObjDesc - Value to be stored |
736 * WalkState - Current walk state 737 * 738 * RETURN: Status 739 * | 636 * WalkState - Current walk state 637 * 638 * RETURN: Status 639 * |
740 * DESCRIPTION: Store a value in an Arg or Local. The SrcDesc is installed | 640 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed |
741 * as the new value for the Arg or Local and the reference count | 641 * as the new value for the Arg or Local and the reference count |
742 * for SrcDesc is incremented. | 642 * for ObjDesc is incremented. |
743 * 744 ******************************************************************************/ 745 746ACPI_STATUS 747AcpiDsStoreObjectToLocal ( 748 UINT16 Opcode, 749 UINT32 Index, | 643 * 644 ******************************************************************************/ 645 646ACPI_STATUS 647AcpiDsStoreObjectToLocal ( 648 UINT16 Opcode, 649 UINT32 Index, |
750 ACPI_OPERAND_OBJECT *SrcDesc, | 650 ACPI_OPERAND_OBJECT *ObjDesc, |
751 ACPI_WALK_STATE *WalkState) 752{ 753 ACPI_STATUS Status; | 651 ACPI_WALK_STATE *WalkState) 652{ 653 ACPI_STATUS Status; |
754 ACPI_OPERAND_OBJECT **Entry; | 654 ACPI_NAMESPACE_NODE *Node; 655 ACPI_OPERAND_OBJECT *CurrentObjDesc; |
755 756 | 656 657 |
757 FUNCTION_TRACE ("DsMethodDataSetValue"); | 658 FUNCTION_TRACE ("DsStoreObjectToLocal"); |
758 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", | 659 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", |
759 Opcode, Index, SrcDesc)); | 660 Opcode, Index, ObjDesc)); |
760 761 762 /* Parameter validation */ 763 | 661 662 663 /* Parameter validation */ 664 |
764 if (!SrcDesc) | 665 if (!ObjDesc) |
765 { 766 return_ACPI_STATUS (AE_BAD_PARAMETER); 767 } 768 | 666 { 667 return_ACPI_STATUS (AE_BAD_PARAMETER); 668 } 669 |
670 /* Get the namespace node for the arg/local */ |
|
769 | 671 |
770 /* Get a pointer to the requested method stack entry */ 771 772 Status = AcpiDsMethodDataGetEntry (Opcode, Index, WalkState, &Entry); | 672 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); |
773 if (ACPI_FAILURE (Status)) 774 { | 673 if (ACPI_FAILURE (Status)) 674 { |
775 goto Cleanup; | 675 return_ACPI_STATUS (Status); |
776 } 777 | 676 } 677 |
778 if (*Entry == SrcDesc) | 678 CurrentObjDesc = AcpiNsGetAttachedObject (Node); 679 if (CurrentObjDesc == ObjDesc) |
779 { | 680 { |
780 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", SrcDesc)); 781 goto Cleanup; | 681 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc)); 682 return_ACPI_STATUS (Status); |
782 } 783 | 683 } 684 |
784 | |
785 /* 786 * If there is an object already in this slot, we either 787 * have to delete it, or if this is an argument and there 788 * is an object reference stored there, we have to do 789 * an indirect store! 790 */ | 685 /* 686 * If there is an object already in this slot, we either 687 * have to delete it, or if this is an argument and there 688 * is an object reference stored there, we have to do 689 * an indirect store! 690 */ |
791 if (*Entry) | 691 if (CurrentObjDesc) |
792 { 793 /* 794 * Check for an indirect store if an argument 795 * contains an object reference (stored as an Node). 796 * We don't allow this automatic dereferencing for 797 * locals, since a store to a local should overwrite 798 * anything there, including an object reference. 799 * 800 * If both Arg0 and Local0 contain RefOf (Local4): 801 * 802 * Store (1, Arg0) - Causes indirect store to local4 803 * Store (1, Local0) - Stores 1 in local0, overwriting 804 * the reference to local4 805 * Store (1, DeRefof (Local0)) - Causes indirect store to local4 806 * 807 * Weird, but true. 808 */ 809 if ((Opcode == AML_ARG_OP) && | 692 { 693 /* 694 * Check for an indirect store if an argument 695 * contains an object reference (stored as an Node). 696 * We don't allow this automatic dereferencing for 697 * locals, since a store to a local should overwrite 698 * anything there, including an object reference. 699 * 700 * If both Arg0 and Local0 contain RefOf (Local4): 701 * 702 * Store (1, Arg0) - Causes indirect store to local4 703 * Store (1, Local0) - Stores 1 in local0, overwriting 704 * the reference to local4 705 * Store (1, DeRefof (Local0)) - Causes indirect store to local4 706 * 707 * Weird, but true. 708 */ 709 if ((Opcode == AML_ARG_OP) && |
810 (VALID_DESCRIPTOR_TYPE (*Entry, ACPI_DESC_TYPE_NAMED))) | 710 (VALID_DESCRIPTOR_TYPE (CurrentObjDesc, ACPI_DESC_TYPE_NAMED))) |
811 { 812 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, | 711 { 712 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
813 "Arg (%p) is an ObjRef(Node), storing in %p\n", 814 SrcDesc, *Entry)); | 713 "Arg (%p) is an ObjRef(Node), storing in node %p\n", 714 ObjDesc, CurrentObjDesc)); |
815 816 /* Detach an existing object from the Node */ 817 | 715 716 /* Detach an existing object from the Node */ 717 |
818 AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) *Entry); | 718 AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc); |
819 820 /* 821 * Store this object into the Node | 719 720 /* 721 * Store this object into the Node |
822 * (do the indirect store) | 722 * (perform the indirect store) |
823 */ | 723 */ |
824 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) *Entry, SrcDesc, 825 SrcDesc->Common.Type); | 724 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) CurrentObjDesc, 725 ObjDesc, ObjDesc->Common.Type); |
826 return_ACPI_STATUS (Status); 827 } 828 | 726 return_ACPI_STATUS (Status); 727 } 728 |
829 830#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION | |
831 /* | 729 /* |
832 * Perform "Implicit conversion" of the new object to the type of the 833 * existing object 834 */ 835 Status = AcpiExConvertToTargetType ((*Entry)->Common.Type, &SrcDesc, WalkState); 836 if (ACPI_FAILURE (Status)) 837 { 838 goto Cleanup; 839 } 840#endif 841 842 /* | |
843 * Delete the existing object 844 * before storing the new one 845 */ 846 AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); 847 } 848 | 730 * Delete the existing object 731 * before storing the new one 732 */ 733 AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); 734 } 735 |
849 | |
850 /* | 736 /* |
851 * Install the ObjStack descriptor (*SrcDesc) into | 737 * Install the ObjStack descriptor (*ObjDesc) into |
852 * the descriptor for the Arg or Local. 853 * Install the new object in the stack entry 854 * (increments the object reference count by one) 855 */ | 738 * the descriptor for the Arg or Local. 739 * Install the new object in the stack entry 740 * (increments the object reference count by one) 741 */ |
856 Status = AcpiDsMethodDataSetEntry (Opcode, Index, SrcDesc, WalkState); 857 if (ACPI_FAILURE (Status)) 858 { 859 goto Cleanup; 860 } 861 862 /* Normal exit */ 863 864 return_ACPI_STATUS (AE_OK); 865 866 867 /* Error exit */ 868 869Cleanup: 870 | 742 Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState); |
871 return_ACPI_STATUS (Status); 872} 873 | 743 return_ACPI_STATUS (Status); 744} 745 |
746 |
|