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/parser/pstree.c
+++ new/usr/src/common/acpica/components/parser/pstree.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: pstree - Parser op tree manipulation/traversal/search
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 __PSTREE_C__
46 46
47 47 #include "acpi.h"
48 48 #include "accommon.h"
49 49 #include "acparser.h"
50 50 #include "amlcode.h"
51 51
52 52 #define _COMPONENT ACPI_PARSER
53 53 ACPI_MODULE_NAME ("pstree")
54 54
55 55 /* Local prototypes */
56 56
57 57 #ifdef ACPI_OBSOLETE_FUNCTIONS
58 58 ACPI_PARSE_OBJECT *
59 59 AcpiPsGetChild (
60 60 ACPI_PARSE_OBJECT *op);
61 61 #endif
62 62
63 63
64 64 /*******************************************************************************
65 65 *
66 66 * FUNCTION: AcpiPsGetArg
67 67 *
68 68 * PARAMETERS: Op - Get an argument for this op
69 69 * Argn - Nth argument to get
70 70 *
71 71 * RETURN: The argument (as an Op object). NULL if argument does not exist
72 72 *
73 73 * DESCRIPTION: Get the specified op's argument.
74 74 *
75 75 ******************************************************************************/
76 76
77 77 ACPI_PARSE_OBJECT *
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
78 78 AcpiPsGetArg (
79 79 ACPI_PARSE_OBJECT *Op,
80 80 UINT32 Argn)
81 81 {
82 82 ACPI_PARSE_OBJECT *Arg = NULL;
83 83 const ACPI_OPCODE_INFO *OpInfo;
84 84
85 85
86 86 ACPI_FUNCTION_ENTRY ();
87 87
88 -
88 +/*
89 + if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
90 + {
91 + return (Op->Common.Value.Arg);
92 + }
93 +*/
89 94 /* Get the info structure for this opcode */
90 95
91 96 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
92 97 if (OpInfo->Class == AML_CLASS_UNKNOWN)
93 98 {
94 99 /* Invalid opcode or ASCII character */
95 100
96 101 return (NULL);
97 102 }
98 103
99 104 /* Check if this opcode requires argument sub-objects */
100 105
101 106 if (!(OpInfo->Flags & AML_HAS_ARGS))
102 107 {
103 108 /* Has no linked argument objects */
104 109
105 110 return (NULL);
106 111 }
107 112
108 113 /* Get the requested argument object */
109 114
110 115 Arg = Op->Common.Value.Arg;
111 116 while (Arg && Argn)
112 117 {
113 118 Argn--;
114 119 Arg = Arg->Common.Next;
115 120 }
116 121
117 122 return (Arg);
118 123 }
119 124
120 125
121 126 /*******************************************************************************
122 127 *
123 128 * FUNCTION: AcpiPsAppendArg
124 129 *
125 130 * PARAMETERS: Op - Append an argument to this Op.
126 131 * Arg - Argument Op to append
127 132 *
128 133 * RETURN: None.
129 134 *
130 135 * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
131 136 *
132 137 ******************************************************************************/
133 138
134 139 void
135 140 AcpiPsAppendArg (
136 141 ACPI_PARSE_OBJECT *Op,
137 142 ACPI_PARSE_OBJECT *Arg)
138 143 {
139 144 ACPI_PARSE_OBJECT *PrevArg;
140 145 const ACPI_OPCODE_INFO *OpInfo;
141 146
142 147
143 148 ACPI_FUNCTION_ENTRY ();
144 149
145 150
146 151 if (!Op)
147 152 {
148 153 return;
149 154 }
150 155
151 156 /* Get the info structure for this opcode */
152 157
153 158 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
154 159 if (OpInfo->Class == AML_CLASS_UNKNOWN)
155 160 {
156 161 /* Invalid opcode */
157 162
158 163 ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
159 164 Op->Common.AmlOpcode));
160 165 return;
161 166 }
162 167
163 168 /* Check if this opcode requires argument sub-objects */
164 169
165 170 if (!(OpInfo->Flags & AML_HAS_ARGS))
166 171 {
167 172 /* Has no linked argument objects */
168 173
169 174 return;
170 175 }
171 176
172 177 /* Append the argument to the linked argument list */
173 178
174 179 if (Op->Common.Value.Arg)
175 180 {
176 181 /* Append to existing argument list */
177 182
178 183 PrevArg = Op->Common.Value.Arg;
179 184 while (PrevArg->Common.Next)
180 185 {
181 186 PrevArg = PrevArg->Common.Next;
182 187 }
183 188 PrevArg->Common.Next = Arg;
184 189 }
185 190 else
186 191 {
187 192 /* No argument list, this will be the first argument */
188 193
189 194 Op->Common.Value.Arg = Arg;
190 195 }
191 196
192 197 /* Set the parent in this arg and any args linked after it */
193 198
194 199 while (Arg)
195 200 {
196 201 Arg->Common.Parent = Op;
197 202 Arg = Arg->Common.Next;
198 203
199 204 Op->Common.ArgListLength++;
200 205 }
201 206 }
202 207
203 208
204 209 /*******************************************************************************
205 210 *
206 211 * FUNCTION: AcpiPsGetDepthNext
207 212 *
208 213 * PARAMETERS: Origin - Root of subtree to search
209 214 * Op - Last (previous) Op that was found
210 215 *
211 216 * RETURN: Next Op found in the search.
212 217 *
213 218 * DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
214 219 * Return NULL when reaching "origin" or when walking up from root
215 220 *
216 221 ******************************************************************************/
217 222
218 223 ACPI_PARSE_OBJECT *
219 224 AcpiPsGetDepthNext (
220 225 ACPI_PARSE_OBJECT *Origin,
221 226 ACPI_PARSE_OBJECT *Op)
222 227 {
223 228 ACPI_PARSE_OBJECT *Next = NULL;
224 229 ACPI_PARSE_OBJECT *Parent;
225 230 ACPI_PARSE_OBJECT *Arg;
226 231
227 232
228 233 ACPI_FUNCTION_ENTRY ();
229 234
230 235
231 236 if (!Op)
232 237 {
233 238 return (NULL);
234 239 }
235 240
236 241 /* Look for an argument or child */
237 242
238 243 Next = AcpiPsGetArg (Op, 0);
239 244 if (Next)
240 245 {
241 246 return (Next);
242 247 }
243 248
244 249 /* Look for a sibling */
245 250
246 251 Next = Op->Common.Next;
247 252 if (Next)
248 253 {
249 254 return (Next);
250 255 }
251 256
252 257 /* Look for a sibling of parent */
253 258
254 259 Parent = Op->Common.Parent;
255 260
256 261 while (Parent)
257 262 {
258 263 Arg = AcpiPsGetArg (Parent, 0);
259 264 while (Arg && (Arg != Origin) && (Arg != Op))
260 265 {
261 266 Arg = Arg->Common.Next;
262 267 }
263 268
264 269 if (Arg == Origin)
265 270 {
266 271 /* Reached parent of origin, end search */
267 272
268 273 return (NULL);
269 274 }
270 275
271 276 if (Parent->Common.Next)
272 277 {
273 278 /* Found sibling of parent */
274 279
275 280 return (Parent->Common.Next);
276 281 }
277 282
278 283 Op = Parent;
279 284 Parent = Parent->Common.Parent;
280 285 }
281 286
282 287 return (Next);
283 288 }
284 289
285 290
286 291 #ifdef ACPI_OBSOLETE_FUNCTIONS
287 292 /*******************************************************************************
288 293 *
289 294 * FUNCTION: AcpiPsGetChild
290 295 *
291 296 * PARAMETERS: Op - Get the child of this Op
292 297 *
293 298 * RETURN: Child Op, Null if none is found.
294 299 *
295 300 * DESCRIPTION: Get op's children or NULL if none
296 301 *
297 302 ******************************************************************************/
298 303
299 304 ACPI_PARSE_OBJECT *
300 305 AcpiPsGetChild (
301 306 ACPI_PARSE_OBJECT *Op)
302 307 {
303 308 ACPI_PARSE_OBJECT *Child = NULL;
304 309
305 310
306 311 ACPI_FUNCTION_ENTRY ();
307 312
308 313
309 314 switch (Op->Common.AmlOpcode)
↓ open down ↓ |
211 lines elided |
↑ open up ↑ |
310 315 {
311 316 case AML_SCOPE_OP:
312 317 case AML_ELSE_OP:
313 318 case AML_DEVICE_OP:
314 319 case AML_THERMAL_ZONE_OP:
315 320 case AML_INT_METHODCALL_OP:
316 321
317 322 Child = AcpiPsGetArg (Op, 0);
318 323 break;
319 324
320 -
321 325 case AML_BUFFER_OP:
322 326 case AML_PACKAGE_OP:
323 327 case AML_METHOD_OP:
324 328 case AML_IF_OP:
325 329 case AML_WHILE_OP:
326 330 case AML_FIELD_OP:
327 331
328 332 Child = AcpiPsGetArg (Op, 1);
329 333 break;
330 334
331 -
332 335 case AML_POWER_RES_OP:
333 336 case AML_INDEX_FIELD_OP:
334 337
335 338 Child = AcpiPsGetArg (Op, 2);
336 339 break;
337 340
338 -
339 341 case AML_PROCESSOR_OP:
340 342 case AML_BANK_FIELD_OP:
341 343
342 344 Child = AcpiPsGetArg (Op, 3);
343 345 break;
344 346
345 -
346 347 default:
348 +
347 349 /* All others have no children */
350 +
348 351 break;
349 352 }
350 353
351 354 return (Child);
352 355 }
353 356 #endif
354 -
355 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX