Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/namespace/nsparse.c
+++ new/usr/src/common/acpica/components/namespace/nsparse.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: nsparse - namespace interface to AML parser
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 __NSPARSE_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acnamesp.h"
49 49 #include "acparser.h"
50 50 #include "acdispat.h"
51 51 #include "actables.h"
52 52
53 53
54 54 #define _COMPONENT ACPI_NAMESPACE
55 55 ACPI_MODULE_NAME ("nsparse")
56 56
57 57
58 58 /*******************************************************************************
59 59 *
60 60 * FUNCTION: NsOneCompleteParse
61 61 *
62 62 * PARAMETERS: PassNumber - 1 or 2
63 63 * TableDesc - The table to be parsed.
64 64 *
65 65 * RETURN: Status
66 66 *
67 67 * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
68 68 *
69 69 ******************************************************************************/
70 70
71 71 ACPI_STATUS
72 72 AcpiNsOneCompleteParse (
73 73 UINT32 PassNumber,
74 74 UINT32 TableIndex,
75 75 ACPI_NAMESPACE_NODE *StartNode)
76 76 {
77 77 ACPI_PARSE_OBJECT *ParseRoot;
78 78 ACPI_STATUS Status;
79 79 UINT32 AmlLength;
80 80 UINT8 *AmlStart;
81 81 ACPI_WALK_STATE *WalkState;
82 82 ACPI_TABLE_HEADER *Table;
83 83 ACPI_OWNER_ID OwnerId;
84 84
85 85
86 86 ACPI_FUNCTION_TRACE (NsOneCompleteParse);
87 87
88 88
89 89 Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
90 90 if (ACPI_FAILURE (Status))
91 91 {
92 92 return_ACPI_STATUS (Status);
93 93 }
94 94
95 95 /* Create and init a Root Node */
96 96
97 97 ParseRoot = AcpiPsCreateScopeOp ();
98 98 if (!ParseRoot)
99 99 {
100 100 return_ACPI_STATUS (AE_NO_MEMORY);
101 101 }
102 102
103 103 /* Create and initialize a new walk state */
104 104
105 105 WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL);
106 106 if (!WalkState)
107 107 {
108 108 AcpiPsFreeOp (ParseRoot);
109 109 return_ACPI_STATUS (AE_NO_MEMORY);
110 110 }
111 111
112 112 Status = AcpiGetTableByIndex (TableIndex, &Table);
113 113 if (ACPI_FAILURE (Status))
114 114 {
115 115 AcpiDsDeleteWalkState (WalkState);
116 116 AcpiPsFreeOp (ParseRoot);
117 117 return_ACPI_STATUS (Status);
118 118 }
119 119
120 120 /* Table must consist of at least a complete header */
121 121
122 122 if (Table->Length < sizeof (ACPI_TABLE_HEADER))
123 123 {
124 124 Status = AE_BAD_HEADER;
125 125 }
126 126 else
127 127 {
128 128 AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
129 129 AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
130 130 Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL,
131 131 AmlStart, AmlLength, NULL, (UINT8) PassNumber);
132 132 }
133 133
134 134 if (ACPI_FAILURE (Status))
135 135 {
136 136 AcpiDsDeleteWalkState (WalkState);
137 137 goto Cleanup;
138 138 }
139 139
140 140 /* StartNode is the default location to load the table */
141 141
142 142 if (StartNode && StartNode != AcpiGbl_RootNode)
143 143 {
144 144 Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState);
145 145 if (ACPI_FAILURE (Status))
146 146 {
147 147 AcpiDsDeleteWalkState (WalkState);
148 148 goto Cleanup;
149 149 }
150 150 }
151 151
152 152 /* Parse the AML */
153 153
154 154 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber));
155 155 Status = AcpiPsParseAml (WalkState);
156 156
157 157 Cleanup:
158 158 AcpiPsDeleteParseTree (ParseRoot);
159 159 return_ACPI_STATUS (Status);
160 160 }
161 161
162 162
163 163 /*******************************************************************************
164 164 *
165 165 * FUNCTION: AcpiNsParseTable
166 166 *
167 167 * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse
168 168 * StartNode - Where to enter the table into the namespace
169 169 *
170 170 * RETURN: Status
171 171 *
172 172 * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
173 173 *
174 174 ******************************************************************************/
175 175
176 176 ACPI_STATUS
177 177 AcpiNsParseTable (
178 178 UINT32 TableIndex,
179 179 ACPI_NAMESPACE_NODE *StartNode)
↓ open down ↓ |
161 lines elided |
↑ open up ↑ |
180 180 {
181 181 ACPI_STATUS Status;
182 182
183 183
184 184 ACPI_FUNCTION_TRACE (NsParseTable);
185 185
186 186
187 187 /*
188 188 * AML Parse, pass 1
189 189 *
190 - * In this pass, we load most of the namespace. Control methods
191 - * are not parsed until later. A parse tree is not created. Instead,
192 - * each Parser Op subtree is deleted when it is finished. This saves
190 + * In this pass, we load most of the namespace. Control methods
191 + * are not parsed until later. A parse tree is not created. Instead,
192 + * each Parser Op subtree is deleted when it is finished. This saves
193 193 * a great deal of memory, and allows a small cache of parse objects
194 - * to service the entire parse. The second pass of the parse then
194 + * to service the entire parse. The second pass of the parse then
195 195 * performs another complete parse of the AML.
196 196 */
197 197 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n"));
198 198 Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1,
199 199 TableIndex, StartNode);
200 200 if (ACPI_FAILURE (Status))
201 201 {
202 202 return_ACPI_STATUS (Status);
203 203 }
204 204
205 205 /*
206 206 * AML Parse, pass 2
207 207 *
208 208 * In this pass, we resolve forward references and other things
209 209 * that could not be completed during the first pass.
210 210 * Another complete parse of the AML is performed, but the
211 211 * overhead of this is compensated for by the fact that the
212 212 * parse objects are all cached.
213 213 */
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
214 214 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n"));
215 215 Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2,
216 216 TableIndex, StartNode);
217 217 if (ACPI_FAILURE (Status))
218 218 {
219 219 return_ACPI_STATUS (Status);
220 220 }
221 221
222 222 return_ACPI_STATUS (Status);
223 223 }
224 -
225 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX