Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/dispatcher/dswstate.c
+++ new/usr/src/common/acpica/components/dispatcher/dswstate.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: dswstate - Dispatcher parse tree walk management routines
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, 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
45 45 #define __DSWSTATE_C__
46 46
47 47 #include "acpi.h"
48 48 #include "accommon.h"
49 49 #include "acparser.h"
50 50 #include "acdispat.h"
51 51 #include "acnamesp.h"
52 52
53 53 #define _COMPONENT ACPI_DISPATCHER
54 54 ACPI_MODULE_NAME ("dswstate")
55 55
56 56 /* Local prototypes */
57 57
58 58 static ACPI_STATUS
59 59 AcpiDsResultStackPush (
60 60 ACPI_WALK_STATE *WalkState);
61 61
62 62 static ACPI_STATUS
63 63 AcpiDsResultStackPop (
64 64 ACPI_WALK_STATE *WalkState);
65 65
66 66
67 67 /*******************************************************************************
68 68 *
69 69 * FUNCTION: AcpiDsResultPop
70 70 *
71 71 * PARAMETERS: Object - Where to return the popped object
72 72 * WalkState - Current Walk state
73 73 *
74 74 * RETURN: Status
75 75 *
76 76 * DESCRIPTION: Pop an object off the top of this walk's result stack
77 77 *
78 78 ******************************************************************************/
79 79
80 80 ACPI_STATUS
81 81 AcpiDsResultPop (
82 82 ACPI_OPERAND_OBJECT **Object,
83 83 ACPI_WALK_STATE *WalkState)
84 84 {
85 85 UINT32 Index;
86 86 ACPI_GENERIC_STATE *State;
87 87 ACPI_STATUS Status;
88 88
89 89
90 90 ACPI_FUNCTION_NAME (DsResultPop);
91 91
92 92
93 93 State = WalkState->Results;
94 94
95 95 /* Incorrect state of result stack */
96 96
97 97 if (State && !WalkState->ResultCount)
98 98 {
99 99 ACPI_ERROR ((AE_INFO, "No results on result stack"));
100 100 return (AE_AML_INTERNAL);
101 101 }
102 102
103 103 if (!State && WalkState->ResultCount)
104 104 {
105 105 ACPI_ERROR ((AE_INFO, "No result state for result stack"));
106 106 return (AE_AML_INTERNAL);
107 107 }
108 108
109 109 /* Empty result stack */
110 110
111 111 if (!State)
112 112 {
113 113 ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState));
114 114 return (AE_AML_NO_RETURN_VALUE);
115 115 }
116 116
117 117 /* Return object of the top element and clean that top element result stack */
118 118
119 119 WalkState->ResultCount--;
120 120 Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM;
121 121
122 122 *Object = State->Results.ObjDesc [Index];
123 123 if (!*Object)
124 124 {
125 125 ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p",
126 126 WalkState));
127 127 return (AE_AML_NO_RETURN_VALUE);
128 128 }
129 129
130 130 State->Results.ObjDesc [Index] = NULL;
131 131 if (Index == 0)
132 132 {
133 133 Status = AcpiDsResultStackPop (WalkState);
134 134 if (ACPI_FAILURE (Status))
135 135 {
136 136 return (Status);
137 137 }
138 138 }
139 139
140 140 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
141 141 "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object,
142 142 AcpiUtGetObjectTypeName (*Object),
143 143 Index, WalkState, WalkState->ResultCount));
144 144
145 145 return (AE_OK);
146 146 }
147 147
148 148
149 149 /*******************************************************************************
150 150 *
151 151 * FUNCTION: AcpiDsResultPush
152 152 *
153 153 * PARAMETERS: Object - Where to return the popped object
154 154 * WalkState - Current Walk state
155 155 *
156 156 * RETURN: Status
157 157 *
158 158 * DESCRIPTION: Push an object onto the current result stack
159 159 *
160 160 ******************************************************************************/
161 161
162 162 ACPI_STATUS
163 163 AcpiDsResultPush (
164 164 ACPI_OPERAND_OBJECT *Object,
165 165 ACPI_WALK_STATE *WalkState)
166 166 {
167 167 ACPI_GENERIC_STATE *State;
168 168 ACPI_STATUS Status;
169 169 UINT32 Index;
170 170
171 171
172 172 ACPI_FUNCTION_NAME (DsResultPush);
173 173
174 174
175 175 if (WalkState->ResultCount > WalkState->ResultSize)
176 176 {
177 177 ACPI_ERROR ((AE_INFO, "Result stack is full"));
178 178 return (AE_AML_INTERNAL);
179 179 }
180 180 else if (WalkState->ResultCount == WalkState->ResultSize)
181 181 {
182 182 /* Extend the result stack */
183 183
184 184 Status = AcpiDsResultStackPush (WalkState);
185 185 if (ACPI_FAILURE (Status))
186 186 {
187 187 ACPI_ERROR ((AE_INFO, "Failed to extend the result stack"));
188 188 return (Status);
189 189 }
190 190 }
191 191
192 192 if (!(WalkState->ResultCount < WalkState->ResultSize))
193 193 {
194 194 ACPI_ERROR ((AE_INFO, "No free elements in result stack"));
195 195 return (AE_AML_INTERNAL);
196 196 }
197 197
198 198 State = WalkState->Results;
199 199 if (!State)
200 200 {
201 201 ACPI_ERROR ((AE_INFO, "No result stack frame during push"));
202 202 return (AE_AML_INTERNAL);
203 203 }
204 204
205 205 if (!Object)
206 206 {
207 207 ACPI_ERROR ((AE_INFO,
208 208 "Null Object! Obj=%p State=%p Num=%u",
209 209 Object, WalkState, WalkState->ResultCount));
210 210 return (AE_BAD_PARAMETER);
211 211 }
212 212
213 213 /* Assign the address of object to the top free element of result stack */
214 214
215 215 Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM;
216 216 State->Results.ObjDesc [Index] = Object;
217 217 WalkState->ResultCount++;
218 218
219 219 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
220 220 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object),
221 221 WalkState, WalkState->ResultCount, WalkState->CurrentResult));
222 222
223 223 return (AE_OK);
224 224 }
225 225
226 226
227 227 /*******************************************************************************
228 228 *
229 229 * FUNCTION: AcpiDsResultStackPush
230 230 *
231 231 * PARAMETERS: WalkState - Current Walk state
232 232 *
233 233 * RETURN: Status
234 234 *
235 235 * DESCRIPTION: Push an object onto the WalkState result stack
236 236 *
237 237 ******************************************************************************/
238 238
239 239 static ACPI_STATUS
240 240 AcpiDsResultStackPush (
241 241 ACPI_WALK_STATE *WalkState)
242 242 {
243 243 ACPI_GENERIC_STATE *State;
244 244
245 245
246 246 ACPI_FUNCTION_NAME (DsResultStackPush);
247 247
248 248
249 249 /* Check for stack overflow */
250 250
251 251 if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) >
252 252 ACPI_RESULTS_OBJ_NUM_MAX)
253 253 {
254 254 ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%u",
255 255 WalkState, WalkState->ResultSize));
256 256 return (AE_STACK_OVERFLOW);
257 257 }
258 258
259 259 State = AcpiUtCreateGenericState ();
260 260 if (!State)
261 261 {
262 262 return (AE_NO_MEMORY);
263 263 }
264 264
265 265 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT;
266 266 AcpiUtPushGenericState (&WalkState->Results, State);
267 267
268 268 /* Increase the length of the result stack by the length of frame */
269 269
270 270 WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM;
271 271
272 272 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n",
273 273 State, WalkState));
274 274
275 275 return (AE_OK);
276 276 }
277 277
278 278
279 279 /*******************************************************************************
280 280 *
281 281 * FUNCTION: AcpiDsResultStackPop
282 282 *
283 283 * PARAMETERS: WalkState - Current Walk state
284 284 *
285 285 * RETURN: Status
286 286 *
287 287 * DESCRIPTION: Pop an object off of the WalkState result stack
288 288 *
289 289 ******************************************************************************/
290 290
291 291 static ACPI_STATUS
292 292 AcpiDsResultStackPop (
293 293 ACPI_WALK_STATE *WalkState)
294 294 {
295 295 ACPI_GENERIC_STATE *State;
296 296
297 297
298 298 ACPI_FUNCTION_NAME (DsResultStackPop);
299 299
300 300
301 301 /* Check for stack underflow */
302 302
303 303 if (WalkState->Results == NULL)
304 304 {
305 305 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n",
306 306 WalkState));
307 307 return (AE_AML_NO_OPERAND);
308 308 }
309 309
310 310 if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM)
311 311 {
312 312 ACPI_ERROR ((AE_INFO, "Insufficient result stack size"));
313 313 return (AE_AML_INTERNAL);
314 314 }
315 315
316 316 State = AcpiUtPopGenericState (&WalkState->Results);
317 317 AcpiUtDeleteGenericState (State);
318 318
319 319 /* Decrease the length of result stack by the length of frame */
320 320
321 321 WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM;
322 322
323 323 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
324 324 "Result=%p RemainingResults=%X State=%p\n",
325 325 State, WalkState->ResultCount, WalkState));
326 326
327 327 return (AE_OK);
328 328 }
329 329
330 330
331 331 /*******************************************************************************
332 332 *
333 333 * FUNCTION: AcpiDsObjStackPush
334 334 *
335 335 * PARAMETERS: Object - Object to push
336 336 * WalkState - Current Walk state
337 337 *
338 338 * RETURN: Status
339 339 *
340 340 * DESCRIPTION: Push an object onto this walk's object/operand stack
341 341 *
342 342 ******************************************************************************/
343 343
344 344 ACPI_STATUS
345 345 AcpiDsObjStackPush (
346 346 void *Object,
347 347 ACPI_WALK_STATE *WalkState)
348 348 {
349 349 ACPI_FUNCTION_NAME (DsObjStackPush);
350 350
351 351
352 352 /* Check for stack overflow */
353 353
354 354 if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS)
355 355 {
356 356 ACPI_ERROR ((AE_INFO,
357 357 "Object stack overflow! Obj=%p State=%p #Ops=%u",
358 358 Object, WalkState, WalkState->NumOperands));
359 359 return (AE_STACK_OVERFLOW);
360 360 }
361 361
362 362 /* Put the object onto the stack */
363 363
364 364 WalkState->Operands [WalkState->OperandIndex] = Object;
365 365 WalkState->NumOperands++;
366 366
367 367 /* For the usual order of filling the operand stack */
368 368
369 369 WalkState->OperandIndex++;
370 370
371 371 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
372 372 Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object),
373 373 WalkState, WalkState->NumOperands));
374 374
375 375 return (AE_OK);
376 376 }
377 377
↓ open down ↓ |
359 lines elided |
↑ open up ↑ |
378 378
379 379 /*******************************************************************************
380 380 *
381 381 * FUNCTION: AcpiDsObjStackPop
382 382 *
383 383 * PARAMETERS: PopCount - Number of objects/entries to pop
384 384 * WalkState - Current Walk state
385 385 *
386 386 * RETURN: Status
387 387 *
388 - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
388 + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
389 389 * deleted by this routine.
390 390 *
391 391 ******************************************************************************/
392 392
393 393 ACPI_STATUS
394 394 AcpiDsObjStackPop (
395 395 UINT32 PopCount,
396 396 ACPI_WALK_STATE *WalkState)
397 397 {
398 398 UINT32 i;
399 399
400 400
401 401 ACPI_FUNCTION_NAME (DsObjStackPop);
402 402
403 403
404 404 for (i = 0; i < PopCount; i++)
405 405 {
406 406 /* Check for stack underflow */
407 407
408 408 if (WalkState->NumOperands == 0)
409 409 {
410 410 ACPI_ERROR ((AE_INFO,
411 411 "Object stack underflow! Count=%X State=%p #Ops=%u",
412 412 PopCount, WalkState, WalkState->NumOperands));
413 413 return (AE_STACK_UNDERFLOW);
414 414 }
415 415
416 416 /* Just set the stack entry to null */
417 417
418 418 WalkState->NumOperands--;
419 419 WalkState->Operands [WalkState->NumOperands] = NULL;
420 420 }
421 421
422 422 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%u\n",
423 423 PopCount, WalkState, WalkState->NumOperands));
424 424
425 425 return (AE_OK);
426 426 }
427 427
428 428
429 429 /*******************************************************************************
430 430 *
431 431 * FUNCTION: AcpiDsObjStackPopAndDelete
432 432 *
433 433 * PARAMETERS: PopCount - Number of objects/entries to pop
434 434 * WalkState - Current Walk state
435 435 *
436 436 * RETURN: Status
437 437 *
438 438 * DESCRIPTION: Pop this walk's object stack and delete each object that is
439 439 * popped off.
440 440 *
441 441 ******************************************************************************/
442 442
443 443 void
444 444 AcpiDsObjStackPopAndDelete (
445 445 UINT32 PopCount,
446 446 ACPI_WALK_STATE *WalkState)
447 447 {
448 448 INT32 i;
449 449 ACPI_OPERAND_OBJECT *ObjDesc;
450 450
451 451
452 452 ACPI_FUNCTION_NAME (DsObjStackPopAndDelete);
453 453
454 454
455 455 if (PopCount == 0)
456 456 {
457 457 return;
458 458 }
459 459
460 460 for (i = (INT32) PopCount - 1; i >= 0; i--)
461 461 {
462 462 if (WalkState->NumOperands == 0)
463 463 {
464 464 return;
465 465 }
466 466
467 467 /* Pop the stack and delete an object if present in this stack entry */
468 468
469 469 WalkState->NumOperands--;
470 470 ObjDesc = WalkState->Operands [i];
471 471 if (ObjDesc)
472 472 {
473 473 AcpiUtRemoveReference (WalkState->Operands [i]);
474 474 WalkState->Operands [i] = NULL;
475 475 }
476 476 }
477 477
478 478 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
479 479 PopCount, WalkState, WalkState->NumOperands));
480 480 }
481 481
482 482
483 483 /*******************************************************************************
484 484 *
485 485 * FUNCTION: AcpiDsGetCurrentWalkState
486 486 *
487 487 * PARAMETERS: Thread - Get current active state for this Thread
488 488 *
489 489 * RETURN: Pointer to the current walk state
490 490 *
491 491 * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
492 492 * walk state.)
493 493 *
494 494 ******************************************************************************/
495 495
496 496 ACPI_WALK_STATE *
497 497 AcpiDsGetCurrentWalkState (
498 498 ACPI_THREAD_STATE *Thread)
499 499 {
500 500 ACPI_FUNCTION_NAME (DsGetCurrentWalkState);
501 501
502 502
503 503 if (!Thread)
504 504 {
505 505 return (NULL);
506 506 }
507 507
508 508 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n",
509 509 Thread->WalkStateList));
510 510
511 511 return (Thread->WalkStateList);
512 512 }
513 513
514 514
515 515 /*******************************************************************************
516 516 *
517 517 * FUNCTION: AcpiDsPushWalkState
518 518 *
519 519 * PARAMETERS: WalkState - State to push
520 520 * Thread - Thread state object
521 521 *
522 522 * RETURN: None
523 523 *
524 524 * DESCRIPTION: Place the Thread state at the head of the state list
525 525 *
526 526 ******************************************************************************/
527 527
528 528 void
529 529 AcpiDsPushWalkState (
530 530 ACPI_WALK_STATE *WalkState,
531 531 ACPI_THREAD_STATE *Thread)
532 532 {
533 533 ACPI_FUNCTION_TRACE (DsPushWalkState);
534 534
535 535
536 536 WalkState->Next = Thread->WalkStateList;
537 537 Thread->WalkStateList = WalkState;
538 538
539 539 return_VOID;
540 540 }
541 541
↓ open down ↓ |
143 lines elided |
↑ open up ↑ |
542 542
543 543 /*******************************************************************************
544 544 *
545 545 * FUNCTION: AcpiDsPopWalkState
546 546 *
547 547 * PARAMETERS: Thread - Current thread state
548 548 *
549 549 * RETURN: A WalkState object popped from the thread's stack
550 550 *
551 551 * DESCRIPTION: Remove and return the walkstate object that is at the head of
552 - * the walk stack for the given walk list. NULL indicates that
552 + * the walk stack for the given walk list. NULL indicates that
553 553 * the list is empty.
554 554 *
555 555 ******************************************************************************/
556 556
557 557 ACPI_WALK_STATE *
558 558 AcpiDsPopWalkState (
559 559 ACPI_THREAD_STATE *Thread)
560 560 {
561 561 ACPI_WALK_STATE *WalkState;
562 562
563 563
564 564 ACPI_FUNCTION_TRACE (DsPopWalkState);
565 565
566 566
567 567 WalkState = Thread->WalkStateList;
568 568
569 569 if (WalkState)
570 570 {
571 571 /* Next walk state becomes the current walk state */
572 572
573 573 Thread->WalkStateList = WalkState->Next;
574 574
575 575 /*
576 576 * Don't clear the NEXT field, this serves as an indicator
577 577 * that there is a parent WALK STATE
578 578 * Do Not: WalkState->Next = NULL;
579 579 */
580 580 }
581 581
582 582 return_PTR (WalkState);
583 583 }
584 584
585 585
586 586 /*******************************************************************************
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
587 587 *
588 588 * FUNCTION: AcpiDsCreateWalkState
589 589 *
590 590 * PARAMETERS: OwnerId - ID for object creation
591 591 * Origin - Starting point for this walk
592 592 * MethodDesc - Method object
593 593 * Thread - Current thread state
594 594 *
595 595 * RETURN: Pointer to the new walk state.
596 596 *
597 - * DESCRIPTION: Allocate and initialize a new walk state. The current walk
597 + * DESCRIPTION: Allocate and initialize a new walk state. The current walk
598 598 * state is set to this new state.
599 599 *
600 600 ******************************************************************************/
601 601
602 602 ACPI_WALK_STATE *
603 603 AcpiDsCreateWalkState (
604 604 ACPI_OWNER_ID OwnerId,
605 605 ACPI_PARSE_OBJECT *Origin,
606 606 ACPI_OPERAND_OBJECT *MethodDesc,
607 607 ACPI_THREAD_STATE *Thread)
608 608 {
609 609 ACPI_WALK_STATE *WalkState;
610 610
611 611
612 612 ACPI_FUNCTION_TRACE (DsCreateWalkState);
613 613
614 614
615 615 WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE));
616 616 if (!WalkState)
617 617 {
618 618 return_PTR (NULL);
619 619 }
620 620
621 621 WalkState->DescriptorType = ACPI_DESC_TYPE_WALK;
622 622 WalkState->MethodDesc = MethodDesc;
623 623 WalkState->OwnerId = OwnerId;
624 624 WalkState->Origin = Origin;
625 625 WalkState->Thread = Thread;
626 626
627 627 WalkState->ParserState.StartOp = Origin;
628 628
629 629 /* Init the method args/local */
630 630
631 631 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
632 632 AcpiDsMethodDataInit (WalkState);
633 633 #endif
634 634
635 635 /* Put the new state at the head of the walk list */
636 636
637 637 if (Thread)
638 638 {
639 639 AcpiDsPushWalkState (WalkState, Thread);
640 640 }
641 641
642 642 return_PTR (WalkState);
643 643 }
644 644
645 645
646 646 /*******************************************************************************
647 647 *
648 648 * FUNCTION: AcpiDsInitAmlWalk
649 649 *
650 650 * PARAMETERS: WalkState - New state to be initialized
651 651 * Op - Current parse op
652 652 * MethodNode - Control method NS node, if any
653 653 * AmlStart - Start of AML
654 654 * AmlLength - Length of AML
655 655 * Info - Method info block (params, etc.)
656 656 * PassNumber - 1, 2, or 3
657 657 *
658 658 * RETURN: Status
659 659 *
660 660 * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
661 661 *
662 662 ******************************************************************************/
663 663
664 664 ACPI_STATUS
665 665 AcpiDsInitAmlWalk (
666 666 ACPI_WALK_STATE *WalkState,
667 667 ACPI_PARSE_OBJECT *Op,
668 668 ACPI_NAMESPACE_NODE *MethodNode,
669 669 UINT8 *AmlStart,
670 670 UINT32 AmlLength,
671 671 ACPI_EVALUATE_INFO *Info,
672 672 UINT8 PassNumber)
673 673 {
674 674 ACPI_STATUS Status;
675 675 ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
676 676 ACPI_PARSE_OBJECT *ExtraOp;
677 677
678 678
679 679 ACPI_FUNCTION_TRACE (DsInitAmlWalk);
680 680
681 681
682 682 WalkState->ParserState.Aml =
683 683 WalkState->ParserState.AmlStart = AmlStart;
684 684 WalkState->ParserState.AmlEnd =
685 685 WalkState->ParserState.PkgEnd = AmlStart + AmlLength;
686 686
687 687 /* The NextOp of the NextWalk will be the beginning of the method */
688 688
689 689 WalkState->NextOp = NULL;
690 690 WalkState->PassNumber = PassNumber;
691 691
692 692 if (Info)
693 693 {
694 694 WalkState->Params = Info->Parameters;
695 695 WalkState->CallerReturnDesc = &Info->ReturnObject;
696 696 }
697 697
698 698 Status = AcpiPsInitScope (&WalkState->ParserState, Op);
699 699 if (ACPI_FAILURE (Status))
700 700 {
701 701 return_ACPI_STATUS (Status);
702 702 }
703 703
704 704 if (MethodNode)
705 705 {
706 706 WalkState->ParserState.StartNode = MethodNode;
707 707 WalkState->WalkType = ACPI_WALK_METHOD;
708 708 WalkState->MethodNode = MethodNode;
709 709 WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode);
710 710
711 711 /* Push start scope on scope stack and make it current */
712 712
713 713 Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState);
714 714 if (ACPI_FAILURE (Status))
715 715 {
716 716 return_ACPI_STATUS (Status);
717 717 }
718 718
719 719 /* Init the method arguments */
720 720
721 721 Status = AcpiDsMethodDataInitArgs (WalkState->Params,
722 722 ACPI_METHOD_NUM_ARGS, WalkState);
↓ open down ↓ |
115 lines elided |
↑ open up ↑ |
723 723 if (ACPI_FAILURE (Status))
724 724 {
725 725 return_ACPI_STATUS (Status);
726 726 }
727 727 }
728 728 else
729 729 {
730 730 /*
731 731 * Setup the current scope.
732 732 * Find a Named Op that has a namespace node associated with it.
733 - * search upwards from this Op. Current scope is the first
733 + * search upwards from this Op. Current scope is the first
734 734 * Op with a namespace node.
735 735 */
736 736 ExtraOp = ParserState->StartOp;
737 737 while (ExtraOp && !ExtraOp->Common.Node)
738 738 {
739 739 ExtraOp = ExtraOp->Common.Parent;
740 740 }
741 741
742 742 if (!ExtraOp)
743 743 {
744 744 ParserState->StartNode = NULL;
745 745 }
746 746 else
747 747 {
748 748 ParserState->StartNode = ExtraOp->Common.Node;
749 749 }
750 750
751 751 if (ParserState->StartNode)
752 752 {
753 753 /* Push start scope on scope stack and make it current */
754 754
755 755 Status = AcpiDsScopeStackPush (ParserState->StartNode,
756 756 ParserState->StartNode->Type, WalkState);
757 757 if (ACPI_FAILURE (Status))
758 758 {
759 759 return_ACPI_STATUS (Status);
760 760 }
761 761 }
762 762 }
763 763
764 764 Status = AcpiDsInitCallbacks (WalkState, PassNumber);
765 765 return_ACPI_STATUS (Status);
766 766 }
767 767
768 768
769 769 /*******************************************************************************
770 770 *
771 771 * FUNCTION: AcpiDsDeleteWalkState
772 772 *
773 773 * PARAMETERS: WalkState - State to delete
774 774 *
775 775 * RETURN: Status
776 776 *
777 777 * DESCRIPTION: Delete a walk state including all internal data structures
778 778 *
779 779 ******************************************************************************/
780 780
781 781 void
782 782 AcpiDsDeleteWalkState (
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
783 783 ACPI_WALK_STATE *WalkState)
784 784 {
785 785 ACPI_GENERIC_STATE *State;
786 786
787 787
788 788 ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState);
789 789
790 790
791 791 if (!WalkState)
792 792 {
793 - return;
793 + return_VOID;
794 794 }
795 795
796 796 if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK)
797 797 {
798 798 ACPI_ERROR ((AE_INFO, "%p is not a valid walk state",
799 799 WalkState));
800 - return;
800 + return_VOID;
801 801 }
802 802
803 803 /* There should not be any open scopes */
804 804
805 805 if (WalkState->ParserState.Scope)
806 806 {
807 807 ACPI_ERROR ((AE_INFO, "%p walk still has a scope list",
808 808 WalkState));
809 809 AcpiPsCleanupScope (&WalkState->ParserState);
810 810 }
811 811
812 812 /* Always must free any linked control states */
813 813
814 814 while (WalkState->ControlState)
815 815 {
816 816 State = WalkState->ControlState;
817 817 WalkState->ControlState = State->Common.Next;
818 818
819 819 AcpiUtDeleteGenericState (State);
820 820 }
821 821
822 822 /* Always must free any linked parse states */
823 823
824 824 while (WalkState->ScopeInfo)
825 825 {
826 826 State = WalkState->ScopeInfo;
827 827 WalkState->ScopeInfo = State->Common.Next;
828 828
829 829 AcpiUtDeleteGenericState (State);
830 830 }
831 831
832 832 /* Always must free any stacked result states */
833 833
834 834 while (WalkState->Results)
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
835 835 {
836 836 State = WalkState->Results;
837 837 WalkState->Results = State->Common.Next;
838 838
839 839 AcpiUtDeleteGenericState (State);
840 840 }
841 841
842 842 ACPI_FREE (WalkState);
843 843 return_VOID;
844 844 }
845 -
846 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX