Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/disassembler/dmnames.c
+++ new/usr/src/common/acpica/components/disassembler/dmnames.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: dmnames - AML disassembler, names, namestrings, pathnames
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
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
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 #include "acpi.h"
46 46 #include "accommon.h"
47 -#include "acparser.h"
48 47 #include "amlcode.h"
49 48 #include "acnamesp.h"
50 49 #include "acdisasm.h"
51 50
52 51
53 52 #ifdef ACPI_DISASSEMBLER
54 53
55 54 #define _COMPONENT ACPI_CA_DEBUGGER
56 55 ACPI_MODULE_NAME ("dmnames")
57 56
58 57 /* Local prototypes */
59 58
60 59 #ifdef ACPI_OBSOLETE_FUNCTIONS
61 60 void
62 61 AcpiDmDisplayPath (
63 62 ACPI_PARSE_OBJECT *Op);
64 63 #endif
65 64
66 65
67 66 /*******************************************************************************
68 67 *
69 68 * FUNCTION: AcpiDmDumpName
70 69 *
71 70 * PARAMETERS: Name - 4 character ACPI name
72 71 *
73 72 * RETURN: Final length of name
74 73 *
75 74 * DESCRIPTION: Dump an ACPI name, minus any trailing underscores.
76 75 *
77 76 ******************************************************************************/
78 77
79 78 UINT32
80 79 AcpiDmDumpName (
81 80 UINT32 Name)
82 81 {
83 82 UINT32 i;
84 83 UINT32 Length;
85 84 char NewName[4];
86 85
87 86
88 87 /* Copy name locally in case the original name is not writeable */
89 88
90 89 *ACPI_CAST_PTR (UINT32, &NewName[0]) = Name;
91 90
92 91 /* Ensure that the name is printable, even if we have to fix it */
93 92
94 93 AcpiUtRepairName (NewName);
95 94
96 95 /* Remove all trailing underscores from the name */
97 96
98 97 Length = ACPI_NAME_SIZE;
99 98 for (i = (ACPI_NAME_SIZE - 1); i != 0; i--)
100 99 {
101 100 if (NewName[i] == '_')
102 101 {
103 102 Length--;
104 103 }
105 104 else
106 105 {
107 106 break;
108 107 }
109 108 }
110 109
111 110 /* Dump the name, up to the start of the trailing underscores */
112 111
113 112 for (i = 0; i < Length; i++)
114 113 {
115 114 AcpiOsPrintf ("%c", NewName[i]);
116 115 }
117 116
118 117 return (Length);
119 118 }
120 119
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
121 120
122 121 /*******************************************************************************
123 122 *
124 123 * FUNCTION: AcpiPsDisplayObjectPathname
125 124 *
126 125 * PARAMETERS: WalkState - Current walk state
127 126 * Op - Object whose pathname is to be obtained
128 127 *
129 128 * RETURN: Status
130 129 *
131 - * DESCRIPTION: Diplay the pathname associated with a named object. Two
130 + * DESCRIPTION: Diplay the pathname associated with a named object. Two
132 131 * versions. One searches the parse tree (for parser-only
133 132 * applications suchas AcpiDump), and the other searches the
134 133 * ACPI namespace (the parse tree is probably deleted)
135 134 *
136 135 ******************************************************************************/
137 136
138 137 ACPI_STATUS
139 138 AcpiPsDisplayObjectPathname (
140 139 ACPI_WALK_STATE *WalkState,
141 140 ACPI_PARSE_OBJECT *Op)
142 141 {
143 142 ACPI_STATUS Status;
144 143 ACPI_NAMESPACE_NODE *Node;
145 144 ACPI_BUFFER Buffer;
146 145 UINT32 DebugLevel;
147 146
148 147
149 148 /* Save current debug level so we don't get extraneous debug output */
150 149
151 150 DebugLevel = AcpiDbgLevel;
152 151 AcpiDbgLevel = 0;
153 152
154 153 /* Just get the Node out of the Op object */
155 154
156 155 Node = Op->Common.Node;
157 156 if (!Node)
158 157 {
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
159 158 /* Node not defined in this scope, look it up */
160 159
161 160 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String,
162 161 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
163 162 WalkState, &(Node));
164 163
165 164 if (ACPI_FAILURE (Status))
166 165 {
167 166 /*
168 167 * We can't get the pathname since the object
169 - * is not in the namespace. This can happen during single
168 + * is not in the namespace. This can happen during single
170 169 * stepping where a dynamic named object is *about* to be created.
171 170 */
172 171 AcpiOsPrintf (" [Path not found]");
173 172 goto Exit;
174 173 }
175 174
176 175 /* Save it for next time. */
177 176
178 177 Op->Common.Node = Node;
179 178 }
180 179
181 180 /* Convert NamedDesc/handle to a full pathname */
182 181
183 182 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
184 183 Status = AcpiNsHandleToPathname (Node, &Buffer);
185 184 if (ACPI_FAILURE (Status))
186 185 {
187 186 AcpiOsPrintf ("****Could not get pathname****)");
188 187 goto Exit;
189 188 }
190 189
191 190 AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer);
192 191 ACPI_FREE (Buffer.Pointer);
193 192
194 193
195 194 Exit:
196 195 /* Restore the debug level */
197 196
198 197 AcpiDbgLevel = DebugLevel;
199 198 return (Status);
200 199 }
201 200
202 201
203 202 /*******************************************************************************
204 203 *
205 204 * FUNCTION: AcpiDmNamestring
206 205 *
207 206 * PARAMETERS: Name - ACPI Name string to store
208 207 *
209 208 * RETURN: None
210 209 *
211 210 * DESCRIPTION: Decode and dump an ACPI namestring. Handles prefix characters
212 211 *
213 212 ******************************************************************************/
214 213
215 214 void
216 215 AcpiDmNamestring (
217 216 char *Name)
218 217 {
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
219 218 UINT32 SegCount;
220 219
221 220
222 221 if (!Name)
223 222 {
224 223 return;
225 224 }
226 225
227 226 /* Handle all Scope Prefix operators */
228 227
229 - while (AcpiPsIsPrefixChar (ACPI_GET8 (Name)))
228 + while (ACPI_IS_ROOT_PREFIX (ACPI_GET8 (Name)) ||
229 + ACPI_IS_PARENT_PREFIX (ACPI_GET8 (Name)))
230 230 {
231 231 /* Append prefix character */
232 232
233 233 AcpiOsPrintf ("%1c", ACPI_GET8 (Name));
234 234 Name++;
235 235 }
236 236
237 237 switch (ACPI_GET8 (Name))
238 238 {
239 239 case 0:
240 +
240 241 SegCount = 0;
241 242 break;
242 243
243 244 case AML_DUAL_NAME_PREFIX:
245 +
244 246 SegCount = 2;
245 247 Name++;
246 248 break;
247 249
248 250 case AML_MULTI_NAME_PREFIX_OP:
251 +
249 252 SegCount = (UINT32) ACPI_GET8 (Name + 1);
250 253 Name += 2;
251 254 break;
252 255
253 256 default:
257 +
254 258 SegCount = 1;
255 259 break;
256 260 }
257 261
258 262 while (SegCount)
259 263 {
260 264 /* Append Name segment */
261 265
262 266 AcpiDmDumpName (*ACPI_CAST_PTR (UINT32, Name));
263 267
264 268 SegCount--;
265 269 if (SegCount)
266 270 {
267 271 /* Not last name, append dot separator */
268 272
269 273 AcpiOsPrintf (".");
270 274 }
271 275 Name += ACPI_NAME_SIZE;
272 276 }
273 277 }
274 278
275 279
276 280 #ifdef ACPI_OBSOLETE_FUNCTIONS
277 281 /*******************************************************************************
278 282 *
279 283 * FUNCTION: AcpiDmDisplayPath
280 284 *
281 285 * PARAMETERS: Op - Named Op whose path is to be constructed
282 286 *
283 287 * RETURN: None
284 288 *
285 289 * DESCRIPTION: Walk backwards from current scope and display the name
286 290 * of each previous level of scope up to the root scope
287 291 * (like "pwd" does with file systems)
288 292 *
289 293 ******************************************************************************/
290 294
291 295 void
292 296 AcpiDmDisplayPath (
293 297 ACPI_PARSE_OBJECT *Op)
294 298 {
295 299 ACPI_PARSE_OBJECT *Prev;
296 300 ACPI_PARSE_OBJECT *Search;
297 301 UINT32 Name;
298 302 BOOLEAN DoDot = FALSE;
299 303 ACPI_PARSE_OBJECT *NamePath;
300 304 const ACPI_OPCODE_INFO *OpInfo;
301 305
302 306
303 307 /* We are only interested in named objects */
304 308
305 309 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
306 310 if (!(OpInfo->Flags & AML_NSNODE))
307 311 {
308 312 return;
309 313 }
310 314
311 315 if (OpInfo->Flags & AML_CREATE)
312 316 {
313 317 /* Field creation - check for a fully qualified namepath */
314 318
315 319 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
316 320 {
317 321 NamePath = AcpiPsGetArg (Op, 3);
318 322 }
319 323 else
320 324 {
321 325 NamePath = AcpiPsGetArg (Op, 2);
322 326 }
323 327
324 328 if ((NamePath) &&
325 329 (NamePath->Common.Value.String) &&
326 - (NamePath->Common.Value.String[0] == '\\'))
330 + (ACPI_IS_ROOT_PREFIX (NamePath->Common.Value.String[0])))
327 331 {
328 332 AcpiDmNamestring (NamePath->Common.Value.String);
329 333 return;
330 334 }
331 335 }
332 336
333 337 Prev = NULL; /* Start with Root Node */
334 338
335 339 while (Prev != Op)
336 340 {
337 341 /* Search upwards in the tree to find scope with "prev" as its parent */
338 342
339 343 Search = Op;
340 344 for (; ;)
341 345 {
342 346 if (Search->Common.Parent == Prev)
343 347 {
344 348 break;
345 349 }
346 350
347 351 /* Go up one level */
348 352
349 353 Search = Search->Common.Parent;
350 354 }
351 355
352 356 if (Prev)
353 357 {
354 358 OpInfo = AcpiPsGetOpcodeInfo (Search->Common.AmlOpcode);
355 359 if (!(OpInfo->Flags & AML_FIELD))
356 360 {
357 361 /* Below root scope, append scope name */
358 362
359 363 if (DoDot)
360 364 {
361 365 /* Append dot */
362 366
363 367 AcpiOsPrintf (".");
364 368 }
365 369
366 370 if (OpInfo->Flags & AML_CREATE)
367 371 {
368 372 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
369 373 {
370 374 NamePath = AcpiPsGetArg (Op, 3);
371 375 }
372 376 else
373 377 {
374 378 NamePath = AcpiPsGetArg (Op, 2);
375 379 }
376 380
377 381 if ((NamePath) &&
378 382 (NamePath->Common.Value.String))
379 383 {
380 384 AcpiDmDumpName (NamePath->Common.Value.String);
381 385 }
382 386 }
383 387 else
384 388 {
385 389 Name = AcpiPsGetName (Search);
386 390 AcpiDmDumpName ((char *) &Name);
387 391 }
388 392
389 393 DoDot = TRUE;
390 394 }
391 395 }
392 396 Prev = Search;
393 397 }
394 398 }
395 399
396 400
397 401 /*******************************************************************************
398 402 *
399 403 * FUNCTION: AcpiDmValidateName
400 404 *
401 405 * PARAMETERS: Name - 4 character ACPI name
402 406 *
403 407 * RETURN: None
404 408 *
405 409 * DESCRIPTION: Lookup the name
406 410 *
407 411 ******************************************************************************/
408 412
409 413 void
410 414 AcpiDmValidateName (
411 415 char *Name,
412 416 ACPI_PARSE_OBJECT *Op)
413 417 {
414 418
415 419 if ((!Name) ||
416 420 (!Op->Common.Parent))
417 421 {
418 422 return;
419 423 }
420 424
421 425 if (!Op->Common.Node)
422 426 {
423 427 AcpiOsPrintf (
424 428 " /**** Name not found or not accessible from this scope ****/ ");
425 429 }
426 430
427 431 ACPI_PARSE_OBJECT *TargetOp;
428 432
429 433
↓ open down ↓ |
93 lines elided |
↑ open up ↑ |
430 434 if ((!Name) ||
431 435 (!Op->Common.Parent))
432 436 {
433 437 return;
434 438 }
435 439
436 440 TargetOp = AcpiPsFind (Op, Name, 0, 0);
437 441 if (!TargetOp)
438 442 {
439 443 /*
440 - * Didn't find the name in the parse tree. This may be
444 + * Didn't find the name in the parse tree. This may be
441 445 * a problem, or it may simply be one of the predefined names
442 - * (such as _OS_). Rather than worry about looking up all
446 + * (such as _OS_). Rather than worry about looking up all
443 447 * the predefined names, just display the name as given
444 448 */
445 449 AcpiOsPrintf (
446 450 " /**** Name not found or not accessible from this scope ****/ ");
447 451 }
448 452 }
449 453 #endif
450 454
451 455 #endif
452 -
453 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX