1 /****************************************************************************** 2 * 3 * Name: acdebug.h - ACPI/AML debugger 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2021, 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 MERCHANTABILITY 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 char NameSeg[ACPI_NAMESEG_SIZE + 1]; 83 84 } ACPI_DB_EXECUTE_WALK; 85 86 87 #define PARAM_LIST(pl) pl 88 89 #define EX_NO_SINGLE_STEP 1 90 #define EX_SINGLE_STEP 2 91 #define EX_ALL 4 92 93 94 /* 95 * dbxface - external debugger interfaces 96 */ 97 ACPI_DBR_DEPENDENT_RETURN_OK ( 98 ACPI_STATUS 99 AcpiDbSingleStep ( 100 ACPI_WALK_STATE *WalkState, 101 ACPI_PARSE_OBJECT *Op, 102 UINT32 OpType)) 103 104 ACPI_DBR_DEPENDENT_RETURN_VOID ( 105 void 106 AcpiDbSignalBreakPoint ( 107 ACPI_WALK_STATE *WalkState)) 108 109 110 /* 111 * dbcmds - debug commands and output routines 112 */ 113 ACPI_NAMESPACE_NODE * 114 AcpiDbConvertToNode ( 115 char *InString); 116 117 void 118 AcpiDbDisplayTableInfo ( 119 char *TableArg); 120 121 void 122 AcpiDbDisplayTemplate ( 123 char *BufferArg); 124 125 void 126 AcpiDbUnloadAcpiTable ( 127 char *Name); 128 129 void 130 AcpiDbSendNotify ( 131 char *Name, 132 UINT32 Value); 133 134 void 135 AcpiDbDisplayInterfaces ( 136 char *ActionArg, 137 char *InterfaceNameArg); 138 139 ACPI_STATUS 140 AcpiDbSleep ( 141 char *ObjectArg); 142 143 void 144 AcpiDbTrace ( 145 char *EnableArg, 146 char *MethodArg, 147 char *OnceArg); 148 149 void 150 AcpiDbDisplayLocks ( 151 void); 152 153 void 154 AcpiDbDisplayResources ( 155 char *ObjectArg); 156 157 ACPI_HW_DEPENDENT_RETURN_VOID ( 158 void 159 AcpiDbDisplayGpes ( 160 void)) 161 162 void 163 AcpiDbDisplayHandlers ( 164 void); 165 166 ACPI_HW_DEPENDENT_RETURN_VOID ( 167 void 168 AcpiDbGenerateGpe ( 169 char *GpeArg, 170 char *BlockArg)) 171 172 ACPI_HW_DEPENDENT_RETURN_VOID ( 173 void 174 AcpiDbGenerateSci ( 175 void)) 176 177 void 178 AcpiDbExecuteTest ( 179 char *TypeArg); 180 181 182 /* 183 * dbconvert - miscellaneous conversion routines 184 */ 185 ACPI_STATUS 186 AcpiDbHexCharToValue ( 187 int HexChar, 188 UINT8 *ReturnValue); 189 190 ACPI_STATUS 191 AcpiDbConvertToPackage ( 192 char *String, 193 ACPI_OBJECT *Object); 194 195 ACPI_STATUS 196 AcpiDbConvertToObject ( 197 ACPI_OBJECT_TYPE Type, 198 char *String, 199 ACPI_OBJECT *Object); 200 201 UINT8 * 202 AcpiDbEncodePldBuffer ( 203 ACPI_PLD_INFO *PldInfo); 204 205 void 206 AcpiDbDumpPldBuffer ( 207 ACPI_OBJECT *ObjDesc); 208 209 210 /* 211 * dbmethod - control method commands 212 */ 213 void 214 AcpiDbSetMethodBreakpoint ( 215 char *Location, 216 ACPI_WALK_STATE *WalkState, 217 ACPI_PARSE_OBJECT *Op); 218 219 void 220 AcpiDbSetMethodCallBreakpoint ( 221 ACPI_PARSE_OBJECT *Op); 222 223 void 224 AcpiDbSetMethodData ( 225 char *TypeArg, 226 char *IndexArg, 227 char *ValueArg); 228 229 ACPI_STATUS 230 AcpiDbDisassembleMethod ( 231 char *Name); 232 233 void 234 AcpiDbDisassembleAml ( 235 char *Statements, 236 ACPI_PARSE_OBJECT *Op); 237 238 void 239 AcpiDbEvaluatePredefinedNames ( 240 void); 241 242 void 243 AcpiDbEvaluateAll ( 244 char *NameSeg); 245 246 247 /* 248 * dbnames - namespace commands 249 */ 250 void 251 AcpiDbSetScope ( 252 char *Name); 253 254 void 255 AcpiDbDumpNamespace ( 256 char *StartArg, 257 char *DepthArg); 258 259 void 260 AcpiDbDumpNamespacePaths ( 261 void); 262 263 void 264 AcpiDbDumpNamespaceByOwner ( 265 char *OwnerArg, 266 char *DepthArg); 267 268 ACPI_STATUS 269 AcpiDbFindNameInNamespace ( 270 char *NameArg); 271 272 void 273 AcpiDbCheckPredefinedNames ( 274 void); 275 276 ACPI_STATUS 277 AcpiDbDisplayObjects ( 278 char *ObjTypeArg, 279 char *DisplayCountArg); 280 281 void 282 AcpiDbCheckIntegrity ( 283 void); 284 285 void 286 AcpiDbFindReferences ( 287 char *ObjectArg); 288 289 void 290 AcpiDbGetBusInfo ( 291 void); 292 293 ACPI_STATUS 294 AcpiDbDisplayFields ( 295 UINT32 AddressSpaceId); 296 297 298 /* 299 * dbdisply - debug display commands 300 */ 301 void 302 AcpiDbDisplayMethodInfo ( 303 ACPI_PARSE_OBJECT *Op); 304 305 void 306 AcpiDbDecodeAndDisplayObject ( 307 char *Target, 308 char *OutputType); 309 310 ACPI_DBR_DEPENDENT_RETURN_VOID ( 311 void 312 AcpiDbDisplayResultObject ( 313 ACPI_OPERAND_OBJECT *ObjDesc, 314 ACPI_WALK_STATE *WalkState)) 315 316 ACPI_STATUS 317 AcpiDbDisplayAllMethods ( 318 char *DisplayCountArg); 319 320 void 321 AcpiDbDisplayArguments ( 322 void); 323 324 void 325 AcpiDbDisplayLocals ( 326 void); 327 328 void 329 AcpiDbDisplayResults ( 330 void); 331 332 void 333 AcpiDbDisplayCallingTree ( 334 void); 335 336 void 337 AcpiDbDisplayObjectType ( 338 char *ObjectArg); 339 340 ACPI_DBR_DEPENDENT_RETURN_VOID ( 341 void 342 AcpiDbDisplayArgumentObject ( 343 ACPI_OPERAND_OBJECT *ObjDesc, 344 ACPI_WALK_STATE *WalkState)) 345 346 347 /* 348 * dbexec - debugger control method execution 349 */ 350 void 351 AcpiDbExecute ( 352 char *Name, 353 char **Args, 354 ACPI_OBJECT_TYPE *Types, 355 UINT32 Flags); 356 357 void 358 AcpiDbCreateExecutionThread ( 359 char *MethodNameArg, 360 char **Arguments, 361 ACPI_OBJECT_TYPE *Types); 362 363 void 364 AcpiDbCreateExecutionThreads ( 365 char *NumThreadsArg, 366 char *NumLoopsArg, 367 char *MethodNameArg); 368 369 void 370 AcpiDbDeleteObjects ( 371 UINT32 Count, 372 ACPI_OBJECT *Objects); 373 374 #ifdef ACPI_DBG_TRACK_ALLOCATIONS 375 UINT32 376 AcpiDbGetCacheInfo ( 377 ACPI_MEMORY_LIST *Cache); 378 #endif 379 380 381 /* 382 * dbfileio - Debugger file I/O commands 383 */ 384 ACPI_OBJECT_TYPE 385 AcpiDbMatchArgument ( 386 char *UserArgument, 387 ACPI_DB_ARGUMENT_INFO *Arguments); 388 389 void 390 AcpiDbCloseDebugFile ( 391 void); 392 393 void 394 AcpiDbOpenDebugFile ( 395 char *Name); 396 397 ACPI_STATUS 398 AcpiDbLoadAcpiTable ( 399 char *Filename); 400 401 ACPI_STATUS 402 AcpiDbLoadTables ( 403 ACPI_NEW_TABLE_DESC *ListHead); 404 405 406 /* 407 * dbhistry - debugger HISTORY command 408 */ 409 void 410 AcpiDbAddToHistory ( 411 char *CommandLine); 412 413 void 414 AcpiDbDisplayHistory ( 415 void); 416 417 char * 418 AcpiDbGetFromHistory ( 419 char *CommandNumArg); 420 421 char * 422 AcpiDbGetHistoryByIndex ( 423 UINT32 CommanddNum); 424 425 426 /* 427 * dbinput - user front-end to the AML debugger 428 */ 429 ACPI_STATUS 430 AcpiDbCommandDispatch ( 431 char *InputBuffer, 432 ACPI_WALK_STATE *WalkState, 433 ACPI_PARSE_OBJECT *Op); 434 435 void ACPI_SYSTEM_XFACE 436 AcpiDbExecuteThread ( 437 void *Context); 438 439 ACPI_STATUS 440 AcpiDbUserCommands ( 441 void); 442 443 char * 444 AcpiDbGetNextToken ( 445 char *String, 446 char **Next, 447 ACPI_OBJECT_TYPE *ReturnType); 448 449 450 /* 451 * dbobject 452 */ 453 void 454 AcpiDbDecodeInternalObject ( 455 ACPI_OPERAND_OBJECT *ObjDesc); 456 457 void 458 AcpiDbDisplayInternalObject ( 459 ACPI_OPERAND_OBJECT *ObjDesc, 460 ACPI_WALK_STATE *WalkState); 461 462 void 463 AcpiDbDecodeArguments ( 464 ACPI_WALK_STATE *WalkState); 465 466 void 467 AcpiDbDecodeLocals ( 468 ACPI_WALK_STATE *WalkState); 469 470 void 471 AcpiDbDumpMethodInfo ( 472 ACPI_STATUS Status, 473 ACPI_WALK_STATE *WalkState); 474 475 476 /* 477 * dbstats - Generation and display of ACPI table statistics 478 */ 479 void 480 AcpiDbGenerateStatistics ( 481 ACPI_PARSE_OBJECT *Root, 482 BOOLEAN IsMethod); 483 484 ACPI_STATUS 485 AcpiDbDisplayStatistics ( 486 char *TypeArg); 487 488 489 /* 490 * dbutils - AML debugger utilities 491 */ 492 void 493 AcpiDbSetOutputDestination ( 494 UINT32 Where); 495 496 void 497 AcpiDbDumpExternalObject ( 498 ACPI_OBJECT *ObjDesc, 499 UINT32 Level); 500 501 void 502 AcpiDbPrepNamestring ( 503 char *Name); 504 505 ACPI_NAMESPACE_NODE * 506 AcpiDbLocalNsLookup ( 507 char *Name); 508 509 void 510 AcpiDbUint32ToHexString ( 511 UINT32 Value, 512 char *Buffer); 513 514 #endif /* __ACDEBUG_H__ */ 515