pswalk.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: pswalk - Parser routines to walk parsed op tree(s)
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer #include "acpi.h"
46 1.1.1.2.2.2 bouyer #include "accommon.h"
47 1.1.1.2.2.2 bouyer #include "acparser.h"
48 1.1.1.2.2.2 bouyer
49 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_PARSER
50 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("pswalk")
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer /*******************************************************************************
54 1.1.1.2.2.2 bouyer *
55 1.1.1.2.2.2 bouyer * FUNCTION: AcpiPsDeleteParseTree
56 1.1.1.2.2.2 bouyer *
57 1.1.1.2.2.2 bouyer * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete
58 1.1.1.2.2.2 bouyer *
59 1.1.1.2.2.2 bouyer * RETURN: None
60 1.1.1.2.2.2 bouyer *
61 1.1.1.2.2.2 bouyer * DESCRIPTION: Delete a portion of or an entire parse tree.
62 1.1.1.2.2.2 bouyer *
63 1.1.1.2.2.2 bouyer ******************************************************************************/
64 1.1.1.2.2.2 bouyer
65 1.1.1.2.2.2 bouyer void
66 1.1.1.2.2.2 bouyer AcpiPsDeleteParseTree (
67 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *SubtreeRoot)
68 1.1.1.2.2.2 bouyer {
69 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op = SubtreeRoot;
70 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Next = NULL;
71 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Parent = NULL;
72 1.1.1.2.2.2 bouyer
73 1.1.1.2.2.2 bouyer
74 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot);
75 1.1.1.2.2.2 bouyer
76 1.1.1.2.2.2 bouyer
77 1.1.1.2.2.2 bouyer /* Visit all nodes in the subtree */
78 1.1.1.2.2.2 bouyer
79 1.1.1.2.2.2 bouyer while (Op)
80 1.1.1.2.2.2 bouyer {
81 1.1.1.2.2.2 bouyer /* Check if we are not ascending */
82 1.1.1.2.2.2 bouyer
83 1.1.1.2.2.2 bouyer if (Op != Parent)
84 1.1.1.2.2.2 bouyer {
85 1.1.1.2.2.2 bouyer /* Look for an argument or child of the current op */
86 1.1.1.2.2.2 bouyer
87 1.1.1.2.2.2 bouyer Next = AcpiPsGetArg (Op, 0);
88 1.1.1.2.2.2 bouyer if (Next)
89 1.1.1.2.2.2 bouyer {
90 1.1.1.2.2.2 bouyer /* Still going downward in tree (Op is not completed yet) */
91 1.1.1.2.2.2 bouyer
92 1.1.1.2.2.2 bouyer Op = Next;
93 1.1.1.2.2.2 bouyer continue;
94 1.1.1.2.2.2 bouyer }
95 1.1.1.2.2.2 bouyer }
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer /* No more children, this Op is complete. */
98 1.1.1.2.2.2 bouyer
99 1.1.1.2.2.2 bouyer Next = Op->Common.Next;
100 1.1.1.2.2.2 bouyer Parent = Op->Common.Parent;
101 1.1.1.2.2.2 bouyer
102 1.1.1.2.2.2 bouyer AcpiPsFreeOp (Op);
103 1.1.1.2.2.2 bouyer
104 1.1.1.2.2.2 bouyer /* If we are back to the starting point, the walk is complete. */
105 1.1.1.2.2.2 bouyer
106 1.1.1.2.2.2 bouyer if (Op == SubtreeRoot)
107 1.1.1.2.2.2 bouyer {
108 1.1.1.2.2.2 bouyer return_VOID;
109 1.1.1.2.2.2 bouyer }
110 1.1.1.2.2.2 bouyer if (Next)
111 1.1.1.2.2.2 bouyer {
112 1.1.1.2.2.2 bouyer Op = Next;
113 1.1.1.2.2.2 bouyer }
114 1.1.1.2.2.2 bouyer else
115 1.1.1.2.2.2 bouyer {
116 1.1.1.2.2.2 bouyer Op = Parent;
117 1.1.1.2.2.2 bouyer }
118 1.1.1.2.2.2 bouyer }
119 1.1.1.2.2.2 bouyer
120 1.1.1.2.2.2 bouyer return_VOID;
121 1.1.1.2.2.2 bouyer }
122