Deleted Added
sdiff udiff text old ( 151937 ) new ( 167802 )
full compact
1
2/******************************************************************************
3 *
4 * Module Name: asltransform - Parse tree transforms
5 * $Revision: 1.35 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
22 *
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118
119#include <contrib/dev/acpica/compiler/aslcompiler.h>
120#include "aslcompiler.y.h"
121
122#define _COMPONENT ACPI_COMPILER
123 ACPI_MODULE_NAME ("asltransform")
124
125/* Local prototypes */
126
127static void
128TrTransformSubtree (
129 ACPI_PARSE_OBJECT *Op);
130
131static char *
132TrAmlGetNextTempName (
133 ACPI_PARSE_OBJECT *Op,
134 UINT8 *TempCount);
135
136static void
137TrAmlInitLineNumbers (
138 ACPI_PARSE_OBJECT *Op,
139 ACPI_PARSE_OBJECT *Neighbor);
140
141static void
142TrAmlInitNode (
143 ACPI_PARSE_OBJECT *Op,
144 UINT16 ParseOpcode);
145
146static void
147TrAmlSetSubtreeParent (
148 ACPI_PARSE_OBJECT *Op,
149 ACPI_PARSE_OBJECT *Parent);
150
151static void
152TrAmlInsertPeer (
153 ACPI_PARSE_OBJECT *Op,
154 ACPI_PARSE_OBJECT *NewPeer);
155
156static void
157TrDoDefinitionBlock (
158 ACPI_PARSE_OBJECT *Op);
159
160static void
161TrDoSwitch (
162 ACPI_PARSE_OBJECT *StartNode);
163
164
165/*******************************************************************************
166 *
167 * FUNCTION: TrAmlGetNextTempName
168 *
169 * PARAMETERS: Op - Current parse op
170 * TempCount - Current temporary counter. Was originally
171 * per-module; Currently per method, could be
172 * expanded to per-scope.
173 *
174 * RETURN: A pointer to name (allocated here).
175 *
176 * DESCRIPTION: Generate an ACPI name of the form _T_x. These names are
177 * reserved for use by the ASL compiler. (_T_0 through _T_Z)
178 *
179 ******************************************************************************/
180
181static char *
182TrAmlGetNextTempName (
183 ACPI_PARSE_OBJECT *Op,
184 UINT8 *TempCount)
185{
186 char *TempName;
187
188
189 if (*TempCount >= (10+26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */
190 {
191 /* Too many temps */
192
193 AslError (ASL_ERROR, ASL_MSG_TOO_MANY_TEMPS, Op, NULL);
194 return (NULL);
195 }
196
197 TempName = UtLocalCalloc (5);
198
199 if (*TempCount < 10) /* 0-9 */
200 {
201 TempName[3] = (char) (*TempCount + '0');
202 }
203 else /* 10-35: A-Z */
204 {
205 TempName[3] = (char) (*TempCount + ('A' - 10));
206 }
207 (*TempCount)++;
208
209 /* First three characters are always "_T_" */
210
211 TempName[0] = '_';
212 TempName[1] = 'T';
213 TempName[2] = '_';
214
215 return (TempName);
216}
217
218
219/*******************************************************************************
220 *
221 * FUNCTION: TrAmlInitLineNumbers
222 *
223 * PARAMETERS: Op - Op to be initialized
224 * Neighbor - Op used for initialization values
225 *
226 * RETURN: None
227 *
228 * DESCRIPTION: Initialized the various line numbers for a parse node.
229 *
230 ******************************************************************************/
231
232static void
233TrAmlInitLineNumbers (
234 ACPI_PARSE_OBJECT *Op,
235 ACPI_PARSE_OBJECT *Neighbor)
236{
237
238 Op->Asl.EndLine = Neighbor->Asl.EndLine;
239 Op->Asl.EndLogicalLine = Neighbor->Asl.EndLogicalLine;
240 Op->Asl.LineNumber = Neighbor->Asl.LineNumber;
241 Op->Asl.LogicalByteOffset = Neighbor->Asl.LogicalByteOffset;
242 Op->Asl.LogicalLineNumber = Neighbor->Asl.LogicalLineNumber;
243}
244
245
246/*******************************************************************************
247 *
248 * FUNCTION: TrAmlInitNode
249 *
250 * PARAMETERS: Op - Op to be initialized
251 * ParseOpcode - Opcode for this node
252 *
253 * RETURN: None
254 *
255 * DESCRIPTION: Initialize a node with the parse opcode and opcode name.
256 *
257 ******************************************************************************/
258
259static void
260TrAmlInitNode (
261 ACPI_PARSE_OBJECT *Op,
262 UINT16 ParseOpcode)
263{
264
265 Op->Asl.ParseOpcode = ParseOpcode;
266 UtSetParseOpName (Op);
267}
268
269
270/*******************************************************************************
271 *
272 * FUNCTION: TrAmlSetSubtreeParent
273 *
274 * PARAMETERS: Op - First node in a list of peer nodes
275 * Parent - Parent of the subtree
276 *
277 * RETURN: None
278 *
279 * DESCRIPTION: Set the parent for all peer nodes in a subtree
280 *
281 ******************************************************************************/
282
283static void
284TrAmlSetSubtreeParent (
285 ACPI_PARSE_OBJECT *Op,
286 ACPI_PARSE_OBJECT *Parent)
287{
288 ACPI_PARSE_OBJECT *Next;
289
290
291 Next = Op;
292 while (Next)
293 {
294 Next->Asl.Parent = Parent;
295 Next = Next->Asl.Next;
296 }
297}
298
299
300/*******************************************************************************
301 *
302 * FUNCTION: TrAmlInsertPeer
303 *
304 * PARAMETERS: Op - First node in a list of peer nodes
305 * NewPeer - Peer node to insert
306 *
307 * RETURN: None
308 *
309 * DESCRIPTION: Insert a new peer node into a list of peers.
310 *
311 ******************************************************************************/
312
313static void
314TrAmlInsertPeer (
315 ACPI_PARSE_OBJECT *Op,
316 ACPI_PARSE_OBJECT *NewPeer)
317{
318
319 NewPeer->Asl.Next = Op->Asl.Next;
320 Op->Asl.Next = NewPeer;
321}
322
323
324/*******************************************************************************
325 *
326 * FUNCTION: TrAmlTransformWalk
327 *
328 * PARAMETERS: ASL_WALK_CALLBACK
329 *
330 * RETURN: None
331 *
332 * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
333 * operands.
334 *
335 ******************************************************************************/
336
337ACPI_STATUS
338TrAmlTransformWalk (
339 ACPI_PARSE_OBJECT *Op,
340 UINT32 Level,
341 void *Context)
342{
343
344 TrTransformSubtree (Op);
345 return (AE_OK);
346}
347
348
349/*******************************************************************************
350 *
351 * FUNCTION: TrTransformSubtree
352 *
353 * PARAMETERS: Op - The parent parse node
354 *
355 * RETURN: None
356 *
357 * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
358 * complex AML opcodes require processing of the child nodes
359 * (arguments/operands).
360 *
361 ******************************************************************************/
362
363static void
364TrTransformSubtree (
365 ACPI_PARSE_OBJECT *Op)
366{
367
368 if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
369 {
370 return;
371 }
372
373 switch (Op->Asl.ParseOpcode)
374 {
375 case PARSEOP_DEFINITIONBLOCK:
376 TrDoDefinitionBlock (Op);
377 break;
378
379 case PARSEOP_SWITCH:
380 TrDoSwitch (Op);
381 break;
382
383 case PARSEOP_METHOD:
384
385 /*
386 * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global,
387 * however
388 */
389 Gbl_TempCount = 0;
390 break;
391
392 default:
393 /* Nothing to do here for other opcodes */
394 break;
395 }
396}
397
398
399/*******************************************************************************
400 *
401 * FUNCTION: TrDoDefinitionBlock
402 *
403 * PARAMETERS: Op - Parse node
404 *
405 * RETURN: None
406 *
407 * DESCRIPTION: Find the end of the definition block and set a global to this
408 * node. It is used by the compiler to insert compiler-generated
409 * names at the root level of the namespace.
410 *
411 ******************************************************************************/
412
413static void
414TrDoDefinitionBlock (
415 ACPI_PARSE_OBJECT *Op)
416{
417 ACPI_PARSE_OBJECT *Next;
418 UINT32 i;
419
420
421 Next = Op->Asl.Child;
422 for (i = 0; i < 5; i++)
423 {
424 Next = Next->Asl.Next;
425 if (i == 0)
426 {
427 /*
428 * This is the table signature. Only the DSDT can be assumed
429 * to be at the root of the namespace; Therefore, namepath
430 * optimization can only be performed on the DSDT.
431 */
432 if (ACPI_STRNCMP (Next->Asl.Value.String, "DSDT", 4))
433 {
434 Gbl_ReferenceOptimizationFlag = FALSE;
435 }
436 }
437 }
438
439 Gbl_FirstLevelInsertionNode = Next;
440}
441
442
443/*******************************************************************************
444 *
445 * FUNCTION: TrDoSwitch
446 *
447 * PARAMETERS: StartNode - Parse node for SWITCH
448 *
449 * RETURN: None
450 *
451 *
452 * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is
453 * no actual AML opcode for SWITCH -- it must be simulated.
454 *
455 ******************************************************************************/
456
457static void
458TrDoSwitch (
459 ACPI_PARSE_OBJECT *StartNode)
460{
461 ACPI_PARSE_OBJECT *Next;
462 ACPI_PARSE_OBJECT *CaseOp = NULL;
463 ACPI_PARSE_OBJECT *CaseBlock = NULL;
464 ACPI_PARSE_OBJECT *DefaultOp = NULL;
465 ACPI_PARSE_OBJECT *CurrentParentNode;
466 ACPI_PARSE_OBJECT *Conditional = NULL;
467 ACPI_PARSE_OBJECT *Predicate;
468 ACPI_PARSE_OBJECT *Peer;
469 ACPI_PARSE_OBJECT *NewOp;
470 ACPI_PARSE_OBJECT *NewOp2;
471 char *PredicateValueName;
472 UINT16 Index;
473 UINT32 Btype;
474
475
476 /* Start node is the Switch() node */
477
478 CurrentParentNode = StartNode;
479
480 /* Create a new temp name of the form _T_x */
481
482 PredicateValueName = TrAmlGetNextTempName (StartNode, &Gbl_TempCount);
483 if (!PredicateValueName)
484 {
485 return;
486 }
487
488 /* First child is the Switch() predicate */
489
490 Next = StartNode->Asl.Child;
491
492 /*
493 * Examine the return type of the Switch Value -
494 * must be Integer/Buffer/String
495 */
496 Index = (UINT16) (Next->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
497 Btype = AslKeywordMapping[Index].AcpiBtype;
498 if ((Btype != ACPI_BTYPE_INTEGER) &&
499 (Btype != ACPI_BTYPE_STRING) &&
500 (Btype != ACPI_BTYPE_BUFFER))
501 {
502 AslError (ASL_WARNING, ASL_MSG_SWITCH_TYPE, Next, NULL);
503 Btype = ACPI_BTYPE_INTEGER;
504 }
505
506 /* CASE statements start at next child */
507
508 Peer = Next->Asl.Next;
509 while (Peer)
510 {
511 Next = Peer;
512 Peer = Next->Asl.Next;
513
514 if (Next->Asl.ParseOpcode == PARSEOP_CASE)
515 {
516 if (CaseOp)
517 {
518 /* Add an ELSE to complete the previous CASE */
519
520 if (!Conditional)
521 {
522 return;
523 }
524 NewOp = TrCreateLeafNode (PARSEOP_ELSE);
525 NewOp->Asl.Parent = Conditional->Asl.Parent;
526 TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent);
527
528 /* Link ELSE node as a peer to the previous IF */
529
530 TrAmlInsertPeer (Conditional, NewOp);
531 CurrentParentNode = NewOp;
532 }
533
534 CaseOp = Next;
535 Conditional = CaseOp;
536 CaseBlock = CaseOp->Asl.Child->Asl.Next;
537 Conditional->Asl.Child->Asl.Next = NULL;
538 Predicate = CaseOp->Asl.Child;
539
540 if ((Predicate->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
541 (Predicate->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
542 {
543 /*
544 * Convert the package declaration to this form:
545 *
546 * If (LNotEqual (Match (Package(<size>){<data>},
547 * MEQ, _T_x, MTR, Zero, Zero), Ones))
548 */
549 NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);
550 Predicate->Asl.Next = NewOp2;
551 TrAmlInitLineNumbers (NewOp2, Conditional);
552
553 NewOp = NewOp2;
554 NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
555 (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
556 NewOp->Asl.Next = NewOp2;
557 TrAmlInitLineNumbers (NewOp2, Predicate);
558
559 NewOp = NewOp2;
560 NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);
561 NewOp->Asl.Next = NewOp2;
562 TrAmlInitLineNumbers (NewOp2, Predicate);
563
564 NewOp = NewOp2;
565 NewOp2 = TrCreateLeafNode (PARSEOP_ZERO);
566 NewOp->Asl.Next = NewOp2;
567 TrAmlInitLineNumbers (NewOp2, Predicate);
568
569 NewOp = NewOp2;
570 NewOp2 = TrCreateLeafNode (PARSEOP_ZERO);
571 NewOp->Asl.Next = NewOp2;
572 TrAmlInitLineNumbers (NewOp2, Predicate);
573
574 NewOp2 = TrCreateLeafNode (PARSEOP_MATCH);
575 NewOp2->Asl.Child = Predicate; /* PARSEOP_PACKAGE */
576 TrAmlInitLineNumbers (NewOp2, Conditional);
577 TrAmlSetSubtreeParent (Predicate, NewOp2);
578
579 NewOp = NewOp2;
580 NewOp2 = TrCreateLeafNode (PARSEOP_ONES);
581 NewOp->Asl.Next = NewOp2;
582 TrAmlInitLineNumbers (NewOp2, Conditional);
583
584 NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
585 NewOp2->Asl.Child = NewOp;
586 NewOp->Asl.Parent = NewOp2;
587 TrAmlInitLineNumbers (NewOp2, Conditional);
588 TrAmlSetSubtreeParent (NewOp, NewOp2);
589
590 NewOp = NewOp2;
591 NewOp2 = TrCreateLeafNode (PARSEOP_LNOT);
592 NewOp2->Asl.Child = NewOp;
593 NewOp2->Asl.Parent = Conditional;
594 NewOp->Asl.Parent = NewOp2;
595 TrAmlInitLineNumbers (NewOp2, Conditional);
596
597 Conditional->Asl.Child = NewOp2;
598 NewOp2->Asl.Next = CaseBlock;
599 }
600 else
601 {
602 /*
603 * Integer and Buffer case.
604 *
605 * Change CaseOp() to: If (LEqual (SwitchValue, CaseValue)) {...}
606 * Note: SwitchValue is first to allow the CaseValue to be implicitly
607 * converted to the type of SwitchValue if necessary.
608 *
609 * CaseOp->Child is the case value
610 * CaseOp->Child->Peer is the beginning of the case block
611 */
612 NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
613 (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
614 NewOp->Asl.Next = Predicate;
615 TrAmlInitLineNumbers (NewOp, Predicate);
616
617 NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL);
618 NewOp2->Asl.Parent = Conditional;
619 NewOp2->Asl.Child = NewOp;
620 TrAmlInitLineNumbers (NewOp2, Conditional);
621
622 TrAmlSetSubtreeParent (NewOp, NewOp2);
623
624 Predicate = NewOp2;
625 Predicate->Asl.Next = CaseBlock;
626
627 TrAmlSetSubtreeParent (Predicate, Conditional);
628 Conditional->Asl.Child = Predicate;
629 }
630
631 /* Reinitialize the CASE node to an IF node */
632
633 TrAmlInitNode (Conditional, PARSEOP_IF);
634
635 /*
636 * The first CASE(IF) is not nested under an ELSE.
637 * All other CASEs are children of a parent ELSE.
638 */
639 if (CurrentParentNode == StartNode)
640 {
641 Conditional->Asl.Parent = CurrentParentNode->Asl.Parent;
642
643 /* Link IF into the peer list */
644
645 TrAmlInsertPeer (CurrentParentNode, Conditional);
646 }
647 else
648 {
649 /*
650 * The IF is a child of previous IF/ELSE. It
651 * is therefore without peer.
652 */
653 CurrentParentNode->Asl.Child = Conditional;
654 Conditional->Asl.Parent = CurrentParentNode;
655 Conditional->Asl.Next = NULL;
656 }
657 }
658 else if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT)
659 {
660 if (DefaultOp)
661 {
662 /*
663 * More than one Default
664 * (Parser should catch this, should not get here)
665 */
666 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Next,
667 "Found more than one Default()");
668 }
669
670 /* Save the DEFAULT node for later, after CASEs */
671
672 DefaultOp = Next;
673 }
674 else
675 {
676 /* Unknown peer opcode */
677
678 AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%d)\n",
679 Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
680 }
681 }
682
683 /* Add the default case at the end of the if/else construct */
684
685 if (DefaultOp)
686 {
687 /* If no CASE statements, this is an error - see below */
688
689 if (CaseOp)
690 {
691 /* Convert the DEFAULT node to an ELSE */
692
693 if (!Conditional)
694 {
695 return;
696 }
697 TrAmlInitNode (DefaultOp, PARSEOP_ELSE);
698 DefaultOp->Asl.Parent = Conditional->Asl.Parent;
699
700 /* Link ELSE node as a peer to the previous IF */
701
702 TrAmlInsertPeer (Conditional, DefaultOp);
703 }
704 }
705
706 if (!CaseOp)
707 {
708 AslError (ASL_ERROR, ASL_MSG_NO_CASES, StartNode, NULL);
709 }
710
711 /*
712 * Add a NAME node for the temp integer:
713 * Change the SWITCH node to a Name (_T_x, Type)
714 */
715 Predicate = StartNode->Asl.Child;
716 TrAmlInitNode (StartNode, PARSEOP_NAME);
717
718 NewOp = StartNode;
719
720 NewOp->Asl.CompileFlags |= NODE_COMPILER_EMITTED;
721
722 NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
723 (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
724 NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION;
725 NewOp->Asl.Child = NewOp2;
726
727 /* Btype was already validated above */
728
729 switch (Btype)
730 {
731 case ACPI_BTYPE_INTEGER:
732 NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO,
733 (ACPI_INTEGER) 0);
734 break;
735
736 case ACPI_BTYPE_STRING:
737 NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL,
738 (ACPI_INTEGER) "");
739 break;
740
741 case ACPI_BTYPE_BUFFER:
742 (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER,
743 (ACPI_INTEGER) 0));
744 Next = NewOp2->Asl.Next;
745 (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO,
746 (ACPI_INTEGER) 1));
747 (void) TrLinkPeerNode (Next->Asl.Child,
748 TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (ACPI_INTEGER) 0));
749
750 TrAmlSetSubtreeParent (Next->Asl.Child, Next);
751 break;
752
753 default:
754 break;
755 }
756
757 TrAmlSetSubtreeParent (NewOp2, NewOp);
758
759 /*
760 * Create and insert a new Store() node which will be used to save the
761 * Switch() value. The store is of the form: Store (Value, _T_x)
762 * where _T_x is the temp variable.
763 */
764 Next = TrCreateLeafNode (PARSEOP_STORE);
765 TrAmlInsertPeer (StartNode, Next);
766 TrAmlSetSubtreeParent (Next, StartNode->Asl.Parent);
767
768 TrAmlInitLineNumbers (Next, StartNode);
769 TrAmlInitLineNumbers (NewOp2, StartNode);
770 TrAmlInitLineNumbers (NewOp2->Asl.Next, StartNode);
771
772 /* Complete the Store subtree */
773
774 Next->Asl.Child = Predicate;
775 Predicate->Asl.Parent = Next;
776
777 NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG,
778 (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName));
779 NewOp->Asl.Parent = Next;
780 Predicate->Asl.Next = NewOp;
781}
782
783