Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/debugger/dbutils.c
+++ new/usr/src/common/acpica/components/debugger/dbutils.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: dbutils - AML debugger utilities
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
45 45 #include "acpi.h"
46 46 #include "accommon.h"
47 47 #include "acnamesp.h"
48 48 #include "acdebug.h"
49 49 #include "acdisasm.h"
50 50
51 51
52 52 #ifdef ACPI_DEBUGGER
53 53
54 54 #define _COMPONENT ACPI_CA_DEBUGGER
55 55 ACPI_MODULE_NAME ("dbutils")
56 56
57 57 /* Local prototypes */
58 58
59 59 #ifdef ACPI_OBSOLETE_FUNCTIONS
60 60 ACPI_STATUS
61 61 AcpiDbSecondPassParse (
62 62 ACPI_PARSE_OBJECT *Root);
63 63
64 64 void
65 65 AcpiDbDumpBuffer (
66 66 UINT32 Address);
67 67 #endif
68 68
69 69 static char *Converter = "0123456789ABCDEF";
70 70
71 71
72 72 /*******************************************************************************
73 73 *
74 74 * FUNCTION: AcpiDbMatchArgument
75 75 *
76 76 * PARAMETERS: UserArgument - User command line
77 77 * Arguments - Array of commands to match against
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
78 78 *
79 79 * RETURN: Index into command array or ACPI_TYPE_NOT_FOUND if not found
80 80 *
81 81 * DESCRIPTION: Search command array for a command match
82 82 *
83 83 ******************************************************************************/
84 84
85 85 ACPI_OBJECT_TYPE
86 86 AcpiDbMatchArgument (
87 87 char *UserArgument,
88 - ARGUMENT_INFO *Arguments)
88 + ACPI_DB_ARGUMENT_INFO *Arguments)
89 89 {
90 90 UINT32 i;
91 91
92 92
93 93 if (!UserArgument || UserArgument[0] == 0)
94 94 {
95 95 return (ACPI_TYPE_NOT_FOUND);
96 96 }
97 97
98 98 for (i = 0; Arguments[i].Name; i++)
99 99 {
100 100 if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
101 101 {
102 102 return (i);
103 103 }
104 104 }
105 105
106 106 /* Argument not recognized */
107 107
108 108 return (ACPI_TYPE_NOT_FOUND);
109 109 }
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
110 110
111 111
112 112 /*******************************************************************************
113 113 *
114 114 * FUNCTION: AcpiDbSetOutputDestination
115 115 *
116 116 * PARAMETERS: OutputFlags - Current flags word
117 117 *
118 118 * RETURN: None
119 119 *
120 - * DESCRIPTION: Set the current destination for debugger output. Also sets
120 + * DESCRIPTION: Set the current destination for debugger output. Also sets
121 121 * the debug output level accordingly.
122 122 *
123 123 ******************************************************************************/
124 124
125 125 void
126 126 AcpiDbSetOutputDestination (
127 127 UINT32 OutputFlags)
128 128 {
129 129
130 130 AcpiGbl_DbOutputFlags = (UINT8) OutputFlags;
131 131
132 132 if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile)
133 133 {
134 134 AcpiDbgLevel = AcpiGbl_DbDebugLevel;
135 135 }
136 136 else
137 137 {
138 138 AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel;
139 139 }
140 140 }
141 141
142 142
143 143 /*******************************************************************************
144 144 *
145 145 * FUNCTION: AcpiDbDumpExternalObject
146 146 *
147 147 * PARAMETERS: ObjDesc - External ACPI object to dump
148 148 * Level - Nesting level.
149 149 *
150 150 * RETURN: None
151 151 *
152 152 * DESCRIPTION: Dump the contents of an ACPI external object
153 153 *
154 154 ******************************************************************************/
155 155
156 156 void
157 157 AcpiDbDumpExternalObject (
158 158 ACPI_OBJECT *ObjDesc,
159 159 UINT32 Level)
160 160 {
161 161 UINT32 i;
162 162
163 163
164 164 if (!ObjDesc)
165 165 {
166 166 AcpiOsPrintf ("[Null Object]\n");
167 167 return;
168 168 }
169 169
170 170 for (i = 0; i < Level; i++)
171 171 {
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
172 172 AcpiOsPrintf (" ");
173 173 }
174 174
175 175 switch (ObjDesc->Type)
176 176 {
177 177 case ACPI_TYPE_ANY:
178 178
179 179 AcpiOsPrintf ("[Null Object] (Type=0)\n");
180 180 break;
181 181
182 -
183 182 case ACPI_TYPE_INTEGER:
184 183
185 184 AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
186 185 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
187 186 break;
188 187
189 -
190 188 case ACPI_TYPE_STRING:
191 189
192 190 AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length);
193 - for (i = 0; i < ObjDesc->String.Length; i++)
194 - {
195 - AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
196 - }
191 + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
197 192 AcpiOsPrintf ("\n");
198 193 break;
199 194
200 -
201 195 case ACPI_TYPE_BUFFER:
202 196
203 197 AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
204 198 if (ObjDesc->Buffer.Length)
205 199 {
206 200 if (ObjDesc->Buffer.Length > 16)
207 201 {
208 202 AcpiOsPrintf ("\n");
209 203 }
210 - AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
211 - ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
204 + AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
205 + ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT);
212 206 }
213 207 else
214 208 {
215 209 AcpiOsPrintf ("\n");
216 210 }
217 211 break;
218 212
219 -
220 213 case ACPI_TYPE_PACKAGE:
221 214
222 215 AcpiOsPrintf ("[Package] Contains %u Elements:\n",
223 216 ObjDesc->Package.Count);
224 217
225 218 for (i = 0; i < ObjDesc->Package.Count; i++)
226 219 {
227 220 AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1);
228 221 }
229 222 break;
230 223
231 -
232 224 case ACPI_TYPE_LOCAL_REFERENCE:
233 225
234 226 AcpiOsPrintf ("[Object Reference] = ");
235 227 AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL);
236 228 break;
237 229
238 -
239 230 case ACPI_TYPE_PROCESSOR:
240 231
241 232 AcpiOsPrintf ("[Processor]\n");
242 233 break;
243 234
244 -
245 235 case ACPI_TYPE_POWER:
246 236
247 237 AcpiOsPrintf ("[Power Resource]\n");
248 238 break;
249 239
250 -
251 240 default:
252 241
253 242 AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type);
254 243 break;
255 244 }
256 245 }
257 246
258 247
259 248 /*******************************************************************************
260 249 *
261 250 * FUNCTION: AcpiDbPrepNamestring
262 251 *
263 252 * PARAMETERS: Name - String to prepare
264 253 *
265 254 * RETURN: None
266 255 *
267 256 * DESCRIPTION: Translate all forward slashes and dots to backslashes.
268 257 *
269 258 ******************************************************************************/
270 259
271 260 void
272 261 AcpiDbPrepNamestring (
273 262 char *Name)
274 263 {
275 264
276 265 if (!Name)
277 266 {
278 267 return;
279 268 }
280 269
281 270 AcpiUtStrupr (Name);
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
282 271
283 272 /* Convert a leading forward slash to a backslash */
284 273
285 274 if (*Name == '/')
286 275 {
287 276 *Name = '\\';
288 277 }
289 278
290 279 /* Ignore a leading backslash, this is the root prefix */
291 280
292 - if (*Name == '\\')
281 + if (ACPI_IS_ROOT_PREFIX (*Name))
293 282 {
294 283 Name++;
295 284 }
296 285
297 286 /* Convert all slash path separators to dots */
298 287
299 288 while (*Name)
300 289 {
301 290 if ((*Name == '/') ||
302 291 (*Name == '\\'))
303 292 {
304 293 *Name = '.';
305 294 }
306 295
307 296 Name++;
308 297 }
309 298 }
310 299
311 300
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
312 301 /*******************************************************************************
313 302 *
314 303 * FUNCTION: AcpiDbLocalNsLookup
315 304 *
316 305 * PARAMETERS: Name - Name to lookup
317 306 *
318 307 * RETURN: Pointer to a namespace node, null on failure
319 308 *
320 309 * DESCRIPTION: Lookup a name in the ACPI namespace
321 310 *
322 - * Note: Currently begins search from the root. Could be enhanced to use
311 + * Note: Currently begins search from the root. Could be enhanced to use
323 312 * the current prefix (scope) node as the search beginning point.
324 313 *
325 314 ******************************************************************************/
326 315
327 316 ACPI_NAMESPACE_NODE *
328 317 AcpiDbLocalNsLookup (
329 318 char *Name)
330 319 {
331 320 char *InternalPath;
332 321 ACPI_STATUS Status;
333 322 ACPI_NAMESPACE_NODE *Node = NULL;
334 323
335 324
336 325 AcpiDbPrepNamestring (Name);
337 326
338 327 /* Build an internal namestring */
339 328
340 329 Status = AcpiNsInternalizeName (Name, &InternalPath);
341 330 if (ACPI_FAILURE (Status))
342 331 {
343 332 AcpiOsPrintf ("Invalid namestring: %s\n", Name);
344 333 return (NULL);
345 334 }
346 335
347 336 /*
348 337 * Lookup the name.
349 338 * (Uses root node as the search starting point)
350 339 */
351 340 Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
352 341 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
353 342 if (ACPI_FAILURE (Status))
354 343 {
355 344 AcpiOsPrintf ("Could not locate name: %s, %s\n",
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
356 345 Name, AcpiFormatException (Status));
357 346 }
358 347
359 348 ACPI_FREE (InternalPath);
360 349 return (Node);
361 350 }
362 351
363 352
364 353 /*******************************************************************************
365 354 *
366 - * FUNCTION: AcpiDbUInt32ToHexString
355 + * FUNCTION: AcpiDbUint32ToHexString
367 356 *
368 357 * PARAMETERS: Value - The value to be converted to string
369 358 * Buffer - Buffer for result (not less than 11 bytes)
370 359 *
371 360 * RETURN: None
372 361 *
373 362 * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
374 363 *
375 364 * NOTE: It is the caller's responsibility to ensure that the length of buffer
376 365 * is sufficient.
377 366 *
378 367 ******************************************************************************/
379 368
380 369 void
381 -AcpiDbUInt32ToHexString (
370 +AcpiDbUint32ToHexString (
382 371 UINT32 Value,
383 372 char *Buffer)
384 373 {
385 374 int i;
386 375
387 376
388 377 if (Value == 0)
389 378 {
390 379 ACPI_STRCPY (Buffer, "0");
391 380 return;
392 381 }
393 382
394 383 Buffer[8] = '\0';
395 384
396 385 for (i = 7; i >= 0; i--)
397 386 {
398 387 Buffer[i] = Converter [Value & 0x0F];
399 388 Value = Value >> 4;
400 389 }
401 390 }
402 391
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
403 392
404 393 #ifdef ACPI_OBSOLETE_FUNCTIONS
405 394 /*******************************************************************************
406 395 *
407 396 * FUNCTION: AcpiDbSecondPassParse
408 397 *
409 398 * PARAMETERS: Root - Root of the parse tree
410 399 *
411 400 * RETURN: Status
412 401 *
413 - * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until
402 + * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until
414 403 * second pass to parse the control methods
415 404 *
416 405 ******************************************************************************/
417 406
418 407 ACPI_STATUS
419 408 AcpiDbSecondPassParse (
420 409 ACPI_PARSE_OBJECT *Root)
421 410 {
422 411 ACPI_PARSE_OBJECT *Op = Root;
423 412 ACPI_PARSE_OBJECT *Method;
424 413 ACPI_PARSE_OBJECT *SearchOp;
425 414 ACPI_PARSE_OBJECT *StartOp;
426 415 ACPI_STATUS Status = AE_OK;
427 416 UINT32 BaseAmlOffset;
428 417 ACPI_WALK_STATE *WalkState;
429 418
430 419
431 420 ACPI_FUNCTION_ENTRY ();
432 421
433 422
434 423 AcpiOsPrintf ("Pass two parse ....\n");
435 424
436 425 while (Op)
437 426 {
438 427 if (Op->Common.AmlOpcode == AML_METHOD_OP)
439 428 {
440 429 Method = Op;
441 430
442 431 /* Create a new walk state for the parse */
443 432
444 433 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
445 434 if (!WalkState)
446 435 {
447 436 return (AE_NO_MEMORY);
448 437 }
449 438
450 439 /* Init the Walk State */
451 440
452 441 WalkState->ParserState.Aml =
453 442 WalkState->ParserState.AmlStart = Method->Named.Data;
454 443 WalkState->ParserState.AmlEnd =
455 444 WalkState->ParserState.PkgEnd = Method->Named.Data +
456 445 Method->Named.Length;
457 446 WalkState->ParserState.StartScope = Op;
458 447
459 448 WalkState->DescendingCallback = AcpiDsLoad1BeginOp;
460 449 WalkState->AscendingCallback = AcpiDsLoad1EndOp;
461 450
462 451 /* Perform the AML parse */
463 452
464 453 Status = AcpiPsParseAml (WalkState);
465 454
466 455 BaseAmlOffset = (Method->Common.Value.Arg)->Common.AmlOffset + 1;
467 456 StartOp = (Method->Common.Value.Arg)->Common.Next;
468 457 SearchOp = StartOp;
469 458
470 459 while (SearchOp)
471 460 {
472 461 SearchOp->Common.AmlOffset += BaseAmlOffset;
473 462 SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
474 463 }
475 464 }
476 465
477 466 if (Op->Common.AmlOpcode == AML_REGION_OP)
478 467 {
479 468 /* TBD: [Investigate] this isn't quite the right thing to do! */
480 469 /*
481 470 *
482 471 * Method = (ACPI_DEFERRED_OP *) Op;
483 472 * Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength);
484 473 */
485 474 }
486 475
487 476 if (ACPI_FAILURE (Status))
488 477 {
489 478 break;
490 479 }
491 480
492 481 Op = AcpiPsGetDepthNext (Root, Op);
493 482 }
494 483
495 484 return (Status);
496 485 }
497 486
498 487
499 488 /*******************************************************************************
500 489 *
501 490 * FUNCTION: AcpiDbDumpBuffer
502 491 *
503 492 * PARAMETERS: Address - Pointer to the buffer
504 493 *
505 494 * RETURN: None
506 495 *
507 496 * DESCRIPTION: Print a portion of a buffer
508 497 *
↓ open down ↓ |
85 lines elided |
↑ open up ↑ |
509 498 ******************************************************************************/
510 499
511 500 void
512 501 AcpiDbDumpBuffer (
513 502 UINT32 Address)
514 503 {
515 504
516 505 AcpiOsPrintf ("\nLocation %X:\n", Address);
517 506
518 507 AcpiDbgLevel |= ACPI_LV_TABLES;
519 - AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY,
508 + AcpiUtDebugDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY,
520 509 ACPI_UINT32_MAX);
521 510 }
522 511 #endif
523 512
524 513 #endif /* ACPI_DEBUGGER */
525 -
526 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX