1 /****************************************************************************** 2 * 3 * Name: acdebug.h - ACPI/AML debugger 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2019, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #ifndef __ACDEBUG_H__ 45 #define __ACDEBUG_H__ 46 47 /* The debugger is used in conjunction with the disassembler most of time */ 48 49 #ifdef ACPI_DISASSEMBLER 50 #include "acdisasm.h" 51 #endif 52 53 54 #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ 55 #define ACPI_DEBUG_LENGTH_FORMAT " (%.4X bits, %.3X bytes)" 56 57 typedef struct acpi_db_command_info 58 { 59 const char *Name; /* Command Name */ 60 UINT8 MinArgs; /* Minimum arguments required */ 61 62 } ACPI_DB_COMMAND_INFO; 63 64 typedef struct acpi_db_command_help 65 { 66 UINT8 LineCount; /* Number of help lines */ 67 char *Invocation; /* Command Invocation */ 68 char *Description; /* Command Description */ 69 70 } ACPI_DB_COMMAND_HELP; 71 72 typedef struct acpi_db_argument_info 73 { 74 const char *Name; /* Argument Name */ 75 76 } ACPI_DB_ARGUMENT_INFO; 77 78 typedef struct acpi_db_execute_walk 79 { 80 UINT32 Count; 81 UINT32 MaxCount; 82 83 } ACPI_DB_EXECUTE_WALK; 84 85 86 #define PARAM_LIST(pl) pl 87 88 #define EX_NO_SINGLE_STEP 1 89 #define EX_SINGLE_STEP 2 90 91 92 /* 93 * dbxface - external debugger interfaces 94 */ 95 ACPI_DBR_DEPENDENT_RETURN_OK ( 96 ACPI_STATUS 97 AcpiDbSingleStep ( 98 ACPI_WALK_STATE *WalkState, 99 ACPI_PARSE_OBJECT *Op, 100 UINT32 OpType)) 101 102 ACPI_DBR_DEPENDENT_RETURN_VOID ( 103 void 104 AcpiDbSignalBreakPoint ( 105 ACPI_WALK_STATE *WalkState)) 106 107 108 /* 109 * dbcmds - debug commands and output routines 110 */ 111 ACPI_NAMESPACE_NODE * 112 AcpiDbConvertToNode ( 113 char *InString); 114 115 void 116 AcpiDbDisplayTableInfo ( 117 char *TableArg); 118 119 void 120 AcpiDbDisplayTemplate ( 121 char *BufferArg); 122 123 void 124 AcpiDbUnloadAcpiTable ( 125 char *Name); 126 127 void 128 AcpiDbSendNotify ( 129 char *Name, 130 UINT32 Value); 131 132 void 133 AcpiDbDisplayInterfaces ( 134 char *ActionArg, 135 char *InterfaceNameArg); 136 137 ACPI_STATUS 138 AcpiDbSleep ( 139 char *ObjectArg); 140 141 void 142 AcpiDbTrace ( 143 char *EnableArg, 144 char *MethodArg, 145 char *OnceArg); 146 147 void 148 AcpiDbDisplayLocks ( 149 void); 150 151 void 152 AcpiDbDisplayResources ( 153 char *ObjectArg); 154 155 ACPI_HW_DEPENDENT_RETURN_VOID ( 156 void 157 AcpiDbDisplayGpes ( 158 void)) 159 160 void 161 AcpiDbDisplayHandlers ( 162 void); 163 164 ACPI_HW_DEPENDENT_RETURN_VOID ( 165 void 166 AcpiDbGenerateGpe ( 167 char *GpeArg, 168 char *BlockArg)) 169 170 ACPI_HW_DEPENDENT_RETURN_VOID ( 171 void 172 AcpiDbGenerateSci ( 173 void)) 174 175 void 176 AcpiDbExecuteTest ( 177 char *TypeArg); 178 179 180 /* 181 * dbconvert - miscellaneous conversion routines 182 */ 183 ACPI_STATUS 184 AcpiDbHexCharToValue ( 185 int HexChar, 186 UINT8 *ReturnValue); 187 188 ACPI_STATUS 189 AcpiDbConvertToPackage ( 190 char *String, 191 ACPI_OBJECT *Object); 192 193 ACPI_STATUS 194 AcpiDbConvertToObject ( 195 ACPI_OBJECT_TYPE Type, 196 char *String, 197 ACPI_OBJECT *Object); 198 199 UINT8 * 200 AcpiDbEncodePldBuffer ( 201 ACPI_PLD_INFO *PldInfo); 202 203 void 204 AcpiDbDumpPldBuffer ( 205 ACPI_OBJECT *ObjDesc); 206 207 208 /* 209 * dbmethod - control method commands 210 */ 211 void 212 AcpiDbSetMethodBreakpoint ( 213 char *Location, 214 ACPI_WALK_STATE *WalkState, 215 ACPI_PARSE_OBJECT *Op); 216 217 void 218 AcpiDbSetMethodCallBreakpoint ( 219 ACPI_PARSE_OBJECT *Op); 220 221 void 222 AcpiDbSetMethodData ( 223 char *TypeArg, 224 char *IndexArg, 225 char *ValueArg); 226 227 ACPI_STATUS 228 AcpiDbDisassembleMethod ( 229 char *Name); 230 231 void 232 AcpiDbDisassembleAml ( 233 char *Statements, 234 ACPI_PARSE_OBJECT *Op); 235 236 void 237 AcpiDbEvaluatePredefinedNames ( 238 void); 239 240 241 /* 242 * dbnames - namespace commands 243 */ 244 void 245 AcpiDbSetScope ( 246 char *Name); 247 248 void 249 AcpiDbDumpNamespace ( 250 char *StartArg, 251 char *DepthArg); 252 253 void 254 AcpiDbDumpNamespacePaths ( 255 void); 256 257 void 258 AcpiDbDumpNamespaceByOwner ( 259 char *OwnerArg, 260 char *DepthArg); 261 262 ACPI_STATUS 263 AcpiDbFindNameInNamespace ( 264 char *NameArg); 265 266 void 267 AcpiDbCheckPredefinedNames ( 268 void); 269 270 ACPI_STATUS 271 AcpiDbDisplayObjects ( 272 char *ObjTypeArg, 273 char *DisplayCountArg); 274 275 void 276 AcpiDbCheckIntegrity ( 277 void); 278 279 void 280 AcpiDbFindReferences ( 281 char *ObjectArg); 282 283 void 284 AcpiDbGetBusInfo ( 285 void); 286 287 ACPI_STATUS 288 AcpiDbDisplayFields ( 289 UINT32 AddressSpaceId); 290 291 292 /* 293 * dbdisply - debug display commands 294 */ 295 void 296 AcpiDbDisplayMethodInfo ( 297 ACPI_PARSE_OBJECT *Op); 298 299 void 300 AcpiDbDecodeAndDisplayObject ( 301 char *Target, 302 char *OutputType); 303 304 ACPI_DBR_DEPENDENT_RETURN_VOID ( 305 void 306 AcpiDbDisplayResultObject ( 307 ACPI_OPERAND_OBJECT *ObjDesc, 308 ACPI_WALK_STATE *WalkState)) 309 310 ACPI_STATUS 311 AcpiDbDisplayAllMethods ( 312 char *DisplayCountArg); 313 314 void 315 AcpiDbDisplayArguments ( 316 void); 317 318 void 319 AcpiDbDisplayLocals ( 320 void); 321 322 void 323 AcpiDbDisplayResults ( 324 void); 325 326 void 327 AcpiDbDisplayCallingTree ( 328 void); 329 330 void 331 AcpiDbDisplayObjectType ( 332 char *ObjectArg); 333 334 ACPI_DBR_DEPENDENT_RETURN_VOID ( 335 void 336 AcpiDbDisplayArgumentObject ( 337 ACPI_OPERAND_OBJECT *ObjDesc, 338 ACPI_WALK_STATE *WalkState)) 339 340 341 /* 342 * dbexec - debugger control method execution 343 */ 344 void 345 AcpiDbExecute ( 346 char *Name, 347 char **Args, 348 ACPI_OBJECT_TYPE *Types, 349 UINT32 Flags); 350 351 void 352 AcpiDbCreateExecutionThread ( 353 char *MethodNameArg, 354 char **Arguments, 355 ACPI_OBJECT_TYPE *Types); 356 357 void 358 AcpiDbCreateExecutionThreads ( 359 char *NumThreadsArg, 360 char *NumLoopsArg, 361 char *MethodNameArg); 362 363 void 364 AcpiDbDeleteObjects ( 365 UINT32 Count, 366 ACPI_OBJECT *Objects); 367 368 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 369 UINT32 370 AcpiDbGetCacheInfo ( 371 ACPI_MEMORY_LIST *Cache); 372 #endif 373 374 375 /* 376 * dbfileio - Debugger file I/O commands 377 */ 378 ACPI_OBJECT_TYPE 379 AcpiDbMatchArgument ( 380 char *UserArgument, 381 ACPI_DB_ARGUMENT_INFO *Arguments); 382 383 void 384 AcpiDbCloseDebugFile ( 385 void); 386 387 void 388 AcpiDbOpenDebugFile ( 389 char *Name); 390 391 ACPI_STATUS 392 AcpiDbLoadAcpiTable ( 393 char *Filename); 394 395 ACPI_STATUS 396 AcpiDbLoadTables ( 397 ACPI_NEW_TABLE_DESC *ListHead); 398 399 400 /* 401 * dbhistry - debugger HISTORY command 402 */ 403 void 404 AcpiDbAddToHistory ( 405 char *CommandLine); 406 407 void 408 AcpiDbDisplayHistory ( 409 void); 410 411 char * 412 AcpiDbGetFromHistory ( 413 char *CommandNumArg); 414 415 char * 416 AcpiDbGetHistoryByIndex ( 417 UINT32 CommanddNum); 418 419 420 /* 421 * dbinput - user front-end to the AML debugger 422 */ 423 ACPI_STATUS 424 AcpiDbCommandDispatch ( 425 char *InputBuffer, 426 ACPI_WALK_STATE *WalkState, 427 ACPI_PARSE_OBJECT *Op); 428 429 void ACPI_SYSTEM_XFACE 430 AcpiDbExecuteThread ( 431 void *Context); 432 433 ACPI_STATUS 434 AcpiDbUserCommands ( 435 void); 436 437 char * 438 AcpiDbGetNextToken ( 439 char *String, 440 char **Next, 441 ACPI_OBJECT_TYPE *ReturnType); 442 443 444 /* 445 * dbobject 446 */ 447 void 448 AcpiDbDecodeInternalObject ( 449 ACPI_OPERAND_OBJECT *ObjDesc); 450 451 void 452 AcpiDbDisplayInternalObject ( 453 ACPI_OPERAND_OBJECT *ObjDesc, 454 ACPI_WALK_STATE *WalkState); 455 456 void 457 AcpiDbDecodeArguments ( 458 ACPI_WALK_STATE *WalkState); 459 460 void 461 AcpiDbDecodeLocals ( 462 ACPI_WALK_STATE *WalkState); 463 464 void 465 AcpiDbDumpMethodInfo ( 466 ACPI_STATUS Status, 467 ACPI_WALK_STATE *WalkState); 468 469 470 /* 471 * dbstats - Generation and display of ACPI table statistics 472 */ 473 void 474 AcpiDbGenerateStatistics ( 475 ACPI_PARSE_OBJECT *Root, 476 BOOLEAN IsMethod); 477 478 ACPI_STATUS 479 AcpiDbDisplayStatistics ( 480 char *TypeArg); 481 482 483 /* 484 * dbutils - AML debugger utilities 485 */ 486 void 487 AcpiDbSetOutputDestination ( 488 UINT32 Where); 489 490 void 491 AcpiDbDumpExternalObject ( 492 ACPI_OBJECT *ObjDesc, 493 UINT32 Level); 494 495 void 496 AcpiDbPrepNamestring ( 497 char *Name); 498 499 ACPI_NAMESPACE_NODE * 500 AcpiDbLocalNsLookup ( 501 char *Name); 502 503 void 504 AcpiDbUint32ToHexString ( 505 UINT32 Value, 506 char *Buffer); 507 508 #endif /* __ACDEBUG_H__ */ 509