0001
0002
0003
0004
0005
0006
0007
0008 #include <acpi/acpi.h>
0009 #include "accommon.h"
0010 #include "acdebug.h"
0011
0012 #ifdef ACPI_APPLICATION
0013 #include "acapps.h"
0014 #endif
0015
0016 #define _COMPONENT ACPI_CA_DEBUGGER
0017 ACPI_MODULE_NAME("dbinput")
0018
0019
0020 static u32 acpi_db_get_line(char *input_buffer);
0021
0022 static u32 acpi_db_match_command(char *user_command);
0023
0024 static void acpi_db_display_command_info(const char *command, u8 display_all);
0025
0026 static void acpi_db_display_help(char *command);
0027
0028 static u8
0029 acpi_db_match_command_help(const char *command,
0030 const struct acpi_db_command_help *help);
0031
0032
0033
0034
0035
0036
0037 enum acpi_ex_debugger_commands {
0038 CMD_NOT_FOUND = 0,
0039 CMD_NULL,
0040 CMD_ALL,
0041 CMD_ALLOCATIONS,
0042 CMD_ARGS,
0043 CMD_ARGUMENTS,
0044 CMD_BREAKPOINT,
0045 CMD_BUSINFO,
0046 CMD_CALL,
0047 CMD_DEBUG,
0048 CMD_DISASSEMBLE,
0049 CMD_DISASM,
0050 CMD_DUMP,
0051 CMD_EVALUATE,
0052 CMD_EXECUTE,
0053 CMD_EXIT,
0054 CMD_FIELDS,
0055 CMD_FIND,
0056 CMD_GO,
0057 CMD_HANDLERS,
0058 CMD_HELP,
0059 CMD_HELP2,
0060 CMD_HISTORY,
0061 CMD_HISTORY_EXE,
0062 CMD_HISTORY_LAST,
0063 CMD_INFORMATION,
0064 CMD_INTEGRITY,
0065 CMD_INTO,
0066 CMD_LEVEL,
0067 CMD_LIST,
0068 CMD_LOCALS,
0069 CMD_LOCKS,
0070 CMD_METHODS,
0071 CMD_NAMESPACE,
0072 CMD_NOTIFY,
0073 CMD_OBJECTS,
0074 CMD_OSI,
0075 CMD_OWNER,
0076 CMD_PATHS,
0077 CMD_PREDEFINED,
0078 CMD_PREFIX,
0079 CMD_QUIT,
0080 CMD_REFERENCES,
0081 CMD_RESOURCES,
0082 CMD_RESULTS,
0083 CMD_SET,
0084 CMD_STATS,
0085 CMD_STOP,
0086 CMD_TABLES,
0087 CMD_TEMPLATE,
0088 CMD_TRACE,
0089 CMD_TREE,
0090 CMD_TYPE,
0091 #ifdef ACPI_APPLICATION
0092 CMD_ENABLEACPI,
0093 CMD_EVENT,
0094 CMD_GPE,
0095 CMD_GPES,
0096 CMD_SCI,
0097 CMD_SLEEP,
0098
0099 CMD_CLOSE,
0100 CMD_LOAD,
0101 CMD_OPEN,
0102 CMD_UNLOAD,
0103
0104 CMD_TERMINATE,
0105 CMD_BACKGROUND,
0106 CMD_THREADS,
0107
0108 CMD_TEST,
0109 #endif
0110 };
0111
0112 #define CMD_FIRST_VALID 2
0113
0114
0115
0116 static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
0117 {"<NOT FOUND>", 0},
0118 {"<NULL>", 0},
0119 {"ALL", 1},
0120 {"ALLOCATIONS", 0},
0121 {"ARGS", 0},
0122 {"ARGUMENTS", 0},
0123 {"BREAKPOINT", 1},
0124 {"BUSINFO", 0},
0125 {"CALL", 0},
0126 {"DEBUG", 1},
0127 {"DISASSEMBLE", 1},
0128 {"DISASM", 1},
0129 {"DUMP", 1},
0130 {"EVALUATE", 1},
0131 {"EXECUTE", 1},
0132 {"EXIT", 0},
0133 {"FIELDS", 1},
0134 {"FIND", 1},
0135 {"GO", 0},
0136 {"HANDLERS", 0},
0137 {"HELP", 0},
0138 {"?", 0},
0139 {"HISTORY", 0},
0140 {"!", 1},
0141 {"!!", 0},
0142 {"INFORMATION", 0},
0143 {"INTEGRITY", 0},
0144 {"INTO", 0},
0145 {"LEVEL", 0},
0146 {"LIST", 0},
0147 {"LOCALS", 0},
0148 {"LOCKS", 0},
0149 {"METHODS", 0},
0150 {"NAMESPACE", 0},
0151 {"NOTIFY", 2},
0152 {"OBJECTS", 0},
0153 {"OSI", 0},
0154 {"OWNER", 1},
0155 {"PATHS", 0},
0156 {"PREDEFINED", 0},
0157 {"PREFIX", 0},
0158 {"QUIT", 0},
0159 {"REFERENCES", 1},
0160 {"RESOURCES", 0},
0161 {"RESULTS", 0},
0162 {"SET", 3},
0163 {"STATS", 1},
0164 {"STOP", 0},
0165 {"TABLES", 0},
0166 {"TEMPLATE", 1},
0167 {"TRACE", 1},
0168 {"TREE", 0},
0169 {"TYPE", 1},
0170 #ifdef ACPI_APPLICATION
0171 {"ENABLEACPI", 0},
0172 {"EVENT", 1},
0173 {"GPE", 1},
0174 {"GPES", 0},
0175 {"SCI", 0},
0176 {"SLEEP", 0},
0177
0178 {"CLOSE", 0},
0179 {"LOAD", 1},
0180 {"OPEN", 1},
0181 {"UNLOAD", 1},
0182
0183 {"TERMINATE", 0},
0184 {"BACKGROUND", 1},
0185 {"THREADS", 3},
0186
0187 {"TEST", 1},
0188 #endif
0189 {NULL, 0}
0190 };
0191
0192
0193
0194
0195
0196
0197
0198
0199 static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
0200 {0, "\nNamespace Access:", "\n"},
0201 {1, " Businfo", "Display system bus info\n"},
0202 {1, " Disassemble <Method>", "Disassemble a control method\n"},
0203 {1, " Find <AcpiName> (? is wildcard)",
0204 "Find ACPI name(s) with wildcards\n"},
0205 {1, " Integrity", "Validate namespace integrity\n"},
0206 {1, " Methods", "Display list of loaded control methods\n"},
0207 {1, " Fields <AddressSpaceId>",
0208 "Display list of loaded field units by space ID\n"},
0209 {1, " Namespace [Object] [Depth]",
0210 "Display loaded namespace tree/subtree\n"},
0211 {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
0212 {1, " Objects [ObjectType]",
0213 "Display summary of all objects or just given type\n"},
0214 {1, " Owner <OwnerId> [Depth]",
0215 "Display loaded namespace by object owner\n"},
0216 {1, " Paths", "Display full pathnames of namespace objects\n"},
0217 {1, " Predefined", "Check all predefined names\n"},
0218 {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
0219 {1, " References <Addr>", "Find all references to object at addr\n"},
0220 {1, " Resources [DeviceName]",
0221 "Display Device resources (no arg = all devices)\n"},
0222 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
0223 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
0224 {1, " Type <Object>", "Display object type\n"},
0225
0226 {0, "\nControl Method Execution:", "\n"},
0227 {1, " All <NameSeg>", "Evaluate all objects named NameSeg\n"},
0228 {1, " Evaluate <Namepath> [Arguments]",
0229 "Evaluate object or control method\n"},
0230 {1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
0231 #ifdef ACPI_APPLICATION
0232 {1, " Background <Namepath> [Arguments]",
0233 "Evaluate object/method in a separate thread\n"},
0234 {1, " Thread <Threads><Loops><NamePath>",
0235 "Spawn threads to execute method(s)\n"},
0236 #endif
0237 {1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
0238 {7, " [Arguments] formats:", "Control method argument formats\n"},
0239 {1, " Hex Integer", "Integer\n"},
0240 {1, " \"Ascii String\"", "String\n"},
0241 {1, " (Hex Byte List)", "Buffer\n"},
0242 {1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
0243 {1, " [Package Element List]", "Package\n"},
0244 {1, " [0x01 0x1234 \"string\"]",
0245 "Package example (3 elements)\n"},
0246
0247 {0, "\nMiscellaneous:", "\n"},
0248 {1, " Allocations", "Display list of current memory allocations\n"},
0249 {2, " Dump <Address>|<Namepath>", "\n"},
0250 {0, " [Byte|Word|Dword|Qword]",
0251 "Display ACPI objects or memory\n"},
0252 {1, " Handlers", "Info about global handlers\n"},
0253 {1, " Help [Command]", "This help screen or individual command\n"},
0254 {1, " History", "Display command history buffer\n"},
0255 {1, " Level <DebugLevel>] [console]",
0256 "Get/Set debug level for file or console\n"},
0257 {1, " Locks", "Current status of internal mutexes\n"},
0258 {1, " Osi [Install|Remove <name>]",
0259 "Display or modify global _OSI list\n"},
0260 {1, " Quit or Exit", "Exit this command\n"},
0261 {8, " Stats <SubCommand>",
0262 "Display namespace and memory statistics\n"},
0263 {1, " Allocations", "Display list of current memory allocations\n"},
0264 {1, " Memory", "Dump internal memory lists\n"},
0265 {1, " Misc", "Namespace search and mutex stats\n"},
0266 {1, " Objects", "Summary of namespace objects\n"},
0267 {1, " Sizes", "Sizes for each of the internal objects\n"},
0268 {1, " Stack", "Display CPU stack usage\n"},
0269 {1, " Tables", "Info about current ACPI table(s)\n"},
0270 {1, " Tables", "Display info about loaded ACPI tables\n"},
0271 #ifdef ACPI_APPLICATION
0272 {1, " Terminate", "Delete namespace and all internal objects\n"},
0273 #endif
0274 {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
0275 {1, " !!", "Execute last command again\n"},
0276
0277 {0, "\nMethod and Namespace Debugging:", "\n"},
0278 {5, " Trace <State> [<Namepath>] [Once]",
0279 "Trace control method execution\n"},
0280 {1, " Enable", "Enable all messages\n"},
0281 {1, " Disable", "Disable tracing\n"},
0282 {1, " Method", "Enable method execution messages\n"},
0283 {1, " Opcode", "Enable opcode execution messages\n"},
0284 {3, " Test <TestName>", "Invoke a debug test\n"},
0285 {1, " Objects", "Read/write/compare all namespace data objects\n"},
0286 {1, " Predefined",
0287 "Validate all ACPI predefined names (_STA, etc.)\n"},
0288 {1, " Execute predefined",
0289 "Execute all predefined (public) methods\n"},
0290
0291 {0, "\nControl Method Single-Step Execution:", "\n"},
0292 {1, " Arguments (or Args)", "Display method arguments\n"},
0293 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
0294 {1, " Call", "Run to next control method invocation\n"},
0295 {1, " Go", "Allow method to run to completion\n"},
0296 {1, " Information", "Display info about the current method\n"},
0297 {1, " Into", "Step into (not over) a method call\n"},
0298 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
0299 {1, " Locals", "Display method local variables\n"},
0300 {1, " Results", "Display method result stack\n"},
0301 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
0302 {1, " Stop", "Terminate control method\n"},
0303 {1, " Tree", "Display control method calling tree\n"},
0304 {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
0305
0306 #ifdef ACPI_APPLICATION
0307 {0, "\nFile Operations:", "\n"},
0308 {1, " Close", "Close debug output file\n"},
0309 {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
0310 {1, " Open <Output Filename>", "Open a file for debug output\n"},
0311 {1, " Unload <Namepath>",
0312 "Unload an ACPI table via namespace object\n"},
0313
0314 {0, "\nHardware Simulation:", "\n"},
0315 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
0316 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
0317 {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
0318 {1, " Gpes", "Display info on all GPE devices\n"},
0319 {1, " Sci", "Generate an SCI\n"},
0320 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
0321 #endif
0322 {0, NULL, NULL}
0323 };
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339 static u8
0340 acpi_db_match_command_help(const char *command,
0341 const struct acpi_db_command_help *help)
0342 {
0343 char *invocation = help->invocation;
0344 u32 line_count;
0345
0346
0347
0348 if (*invocation != ' ') {
0349 return (FALSE);
0350 }
0351
0352 while (*invocation == ' ') {
0353 invocation++;
0354 }
0355
0356
0357
0358 while ((*command) && (*invocation) && (*invocation != ' ')) {
0359 if (tolower((int)*command) != tolower((int)*invocation)) {
0360 return (FALSE);
0361 }
0362
0363 invocation++;
0364 command++;
0365 }
0366
0367
0368
0369 line_count = help->line_count;
0370 while (line_count) {
0371 acpi_os_printf("%-38s : %s", help->invocation,
0372 help->description);
0373 help++;
0374 line_count--;
0375 }
0376
0377 return (TRUE);
0378 }
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394 static void acpi_db_display_command_info(const char *command, u8 display_all)
0395 {
0396 const struct acpi_db_command_help *next;
0397 u8 matched;
0398
0399 next = acpi_gbl_db_command_help;
0400 while (next->invocation) {
0401 matched = acpi_db_match_command_help(command, next);
0402 if (!display_all && matched) {
0403 return;
0404 }
0405
0406 next++;
0407 }
0408 }
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424 static void acpi_db_display_help(char *command)
0425 {
0426 const struct acpi_db_command_help *next = acpi_gbl_db_command_help;
0427
0428 if (!command) {
0429
0430
0431
0432 acpi_os_printf("\nSummary of AML Debugger Commands\n\n");
0433
0434 while (next->invocation) {
0435 acpi_os_printf("%-38s%s", next->invocation,
0436 next->description);
0437 next++;
0438 }
0439 acpi_os_printf("\n");
0440
0441 } else {
0442
0443
0444 acpi_db_display_command_info(command, TRUE);
0445 }
0446 }
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461 char *acpi_db_get_next_token(char *string,
0462 char **next, acpi_object_type *return_type)
0463 {
0464 char *start;
0465 u32 depth;
0466 acpi_object_type type = ACPI_TYPE_INTEGER;
0467
0468
0469
0470 if (!string || !(*string)) {
0471 return (NULL);
0472 }
0473
0474
0475
0476 while (*string && isspace((int)*string)) {
0477 string++;
0478 }
0479
0480 if (!(*string)) {
0481 return (NULL);
0482 }
0483
0484 switch (*string) {
0485 case '"':
0486
0487
0488
0489 string++;
0490 start = string;
0491 type = ACPI_TYPE_STRING;
0492
0493
0494
0495 while (*string && (*string != '"')) {
0496 string++;
0497 }
0498 break;
0499
0500 case '(':
0501
0502
0503
0504 string++;
0505 start = string;
0506 type = ACPI_TYPE_BUFFER;
0507
0508
0509
0510 while (*string && (*string != ')')) {
0511 string++;
0512 }
0513 break;
0514
0515 case '{':
0516
0517
0518
0519 string++;
0520 start = string;
0521 type = ACPI_TYPE_FIELD_UNIT;
0522
0523
0524
0525 while (*string && (*string != '}')) {
0526 string++;
0527 }
0528 break;
0529
0530 case '[':
0531
0532
0533
0534 string++;
0535 depth = 1;
0536 start = string;
0537 type = ACPI_TYPE_PACKAGE;
0538
0539
0540
0541 while (*string) {
0542
0543
0544
0545 if (*string == '"') {
0546
0547
0548 string++;
0549 while (*string && (*string != '"')) {
0550 string++;
0551 }
0552 if (!(*string)) {
0553 break;
0554 }
0555 } else if (*string == '[') {
0556 depth++;
0557 } else if (*string == ']') {
0558 depth--;
0559 if (depth == 0) {
0560 break;
0561 }
0562 }
0563
0564 string++;
0565 }
0566 break;
0567
0568 default:
0569
0570 start = string;
0571
0572
0573
0574 while (*string && !isspace((int)*string)) {
0575 string++;
0576 }
0577 break;
0578 }
0579
0580 if (!(*string)) {
0581 *next = NULL;
0582 } else {
0583 *string = 0;
0584 *next = string + 1;
0585 }
0586
0587 *return_type = type;
0588 return (start);
0589 }
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604 static u32 acpi_db_get_line(char *input_buffer)
0605 {
0606 u32 i;
0607 u32 count;
0608 char *next;
0609 char *this;
0610
0611 if (acpi_ut_safe_strcpy
0612 (acpi_gbl_db_parsed_buf, sizeof(acpi_gbl_db_parsed_buf),
0613 input_buffer)) {
0614 acpi_os_printf
0615 ("Buffer overflow while parsing input line (max %u characters)\n",
0616 (u32)sizeof(acpi_gbl_db_parsed_buf));
0617 return (0);
0618 }
0619
0620 this = acpi_gbl_db_parsed_buf;
0621 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) {
0622 acpi_gbl_db_args[i] = acpi_db_get_next_token(this, &next,
0623 &acpi_gbl_db_arg_types
0624 [i]);
0625 if (!acpi_gbl_db_args[i]) {
0626 break;
0627 }
0628
0629 this = next;
0630 }
0631
0632
0633
0634 acpi_ut_strupr(acpi_gbl_db_args[0]);
0635
0636 count = i;
0637 if (count) {
0638 count--;
0639 }
0640
0641 return (count);
0642 }
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656 static u32 acpi_db_match_command(char *user_command)
0657 {
0658 u32 i;
0659
0660 if (!user_command || user_command[0] == 0) {
0661 return (CMD_NULL);
0662 }
0663
0664 for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++) {
0665 if (strstr
0666 (ACPI_CAST_PTR(char, acpi_gbl_db_commands[i].name),
0667 user_command) == acpi_gbl_db_commands[i].name) {
0668 return (i);
0669 }
0670 }
0671
0672
0673
0674 return (CMD_NOT_FOUND);
0675 }
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691 acpi_status
0692 acpi_db_command_dispatch(char *input_buffer,
0693 struct acpi_walk_state *walk_state,
0694 union acpi_parse_object *op)
0695 {
0696 u32 temp;
0697 u64 temp64;
0698 u32 command_index;
0699 u32 param_count;
0700 char *command_line;
0701 acpi_status status = AE_CTRL_TRUE;
0702
0703
0704
0705 if (acpi_gbl_db_terminate_loop) {
0706 return (AE_CTRL_TERMINATE);
0707 }
0708
0709
0710
0711 param_count = acpi_db_get_line(input_buffer);
0712 command_index = acpi_db_match_command(acpi_gbl_db_args[0]);
0713
0714
0715
0716
0717
0718
0719 if (command_index != CMD_HISTORY_LAST) {
0720 acpi_db_add_to_history(input_buffer);
0721 }
0722
0723
0724
0725 if (param_count < acpi_gbl_db_commands[command_index].min_args) {
0726 acpi_os_printf
0727 ("%u parameters entered, [%s] requires %u parameters\n",
0728 param_count, acpi_gbl_db_commands[command_index].name,
0729 acpi_gbl_db_commands[command_index].min_args);
0730
0731 acpi_db_display_command_info(acpi_gbl_db_commands
0732 [command_index].name, FALSE);
0733 return (AE_CTRL_TRUE);
0734 }
0735
0736
0737
0738 switch (command_index) {
0739 case CMD_NULL:
0740
0741 if (op) {
0742 return (AE_OK);
0743 }
0744 break;
0745
0746 case CMD_ALL:
0747
0748 acpi_os_printf("Executing all objects with NameSeg: %s\n",
0749 acpi_gbl_db_args[1]);
0750 acpi_db_execute(acpi_gbl_db_args[1], &acpi_gbl_db_args[2],
0751 &acpi_gbl_db_arg_types[2],
0752 EX_NO_SINGLE_STEP | EX_ALL);
0753 break;
0754
0755 case CMD_ALLOCATIONS:
0756
0757 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
0758 acpi_ut_dump_allocations((u32)-1, NULL);
0759 #endif
0760 break;
0761
0762 case CMD_ARGS:
0763 case CMD_ARGUMENTS:
0764
0765 acpi_db_display_arguments();
0766 break;
0767
0768 case CMD_BREAKPOINT:
0769
0770 acpi_db_set_method_breakpoint(acpi_gbl_db_args[1], walk_state,
0771 op);
0772 break;
0773
0774 case CMD_BUSINFO:
0775
0776 acpi_db_get_bus_info();
0777 break;
0778
0779 case CMD_CALL:
0780
0781 acpi_db_set_method_call_breakpoint(op);
0782 status = AE_OK;
0783 break;
0784
0785 case CMD_DEBUG:
0786
0787 acpi_db_execute(acpi_gbl_db_args[1],
0788 &acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
0789 EX_SINGLE_STEP);
0790 break;
0791
0792 case CMD_DISASSEMBLE:
0793 case CMD_DISASM:
0794
0795 #ifdef ACPI_DISASSEMBLER
0796 (void)acpi_db_disassemble_method(acpi_gbl_db_args[1]);
0797 #else
0798 acpi_os_printf
0799 ("The AML Disassembler is not configured/present\n");
0800 #endif
0801 break;
0802
0803 case CMD_DUMP:
0804
0805 acpi_db_decode_and_display_object(acpi_gbl_db_args[1],
0806 acpi_gbl_db_args[2]);
0807 break;
0808
0809 case CMD_EVALUATE:
0810 case CMD_EXECUTE:
0811
0812 acpi_db_execute(acpi_gbl_db_args[1],
0813 &acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
0814 EX_NO_SINGLE_STEP);
0815 break;
0816
0817 case CMD_FIND:
0818
0819 status = acpi_db_find_name_in_namespace(acpi_gbl_db_args[1]);
0820 break;
0821
0822 case CMD_FIELDS:
0823
0824 status = acpi_ut_strtoul64(acpi_gbl_db_args[1], &temp64);
0825
0826 if (ACPI_FAILURE(status)
0827 || temp64 >= ACPI_NUM_PREDEFINED_REGIONS) {
0828 acpi_os_printf
0829 ("Invalid address space ID: must be between 0 and %u inclusive\n",
0830 ACPI_NUM_PREDEFINED_REGIONS - 1);
0831 return (AE_OK);
0832 }
0833
0834 status = acpi_db_display_fields((u32)temp64);
0835 break;
0836
0837 case CMD_GO:
0838
0839 acpi_gbl_cm_single_step = FALSE;
0840 return (AE_OK);
0841
0842 case CMD_HANDLERS:
0843
0844 acpi_db_display_handlers();
0845 break;
0846
0847 case CMD_HELP:
0848 case CMD_HELP2:
0849
0850 acpi_db_display_help(acpi_gbl_db_args[1]);
0851 break;
0852
0853 case CMD_HISTORY:
0854
0855 acpi_db_display_history();
0856 break;
0857
0858 case CMD_HISTORY_EXE:
0859
0860 command_line = acpi_db_get_from_history(acpi_gbl_db_args[1]);
0861 if (!command_line) {
0862 return (AE_CTRL_TRUE);
0863 }
0864
0865 status = acpi_db_command_dispatch(command_line, walk_state, op);
0866 return (status);
0867
0868 case CMD_HISTORY_LAST:
0869
0870 command_line = acpi_db_get_from_history(NULL);
0871 if (!command_line) {
0872 return (AE_CTRL_TRUE);
0873 }
0874
0875 status = acpi_db_command_dispatch(command_line, walk_state, op);
0876 return (status);
0877
0878 case CMD_INFORMATION:
0879
0880 acpi_db_display_method_info(op);
0881 break;
0882
0883 case CMD_INTEGRITY:
0884
0885 acpi_db_check_integrity();
0886 break;
0887
0888 case CMD_INTO:
0889
0890 if (op) {
0891 acpi_gbl_cm_single_step = TRUE;
0892 return (AE_OK);
0893 }
0894 break;
0895
0896 case CMD_LEVEL:
0897
0898 if (param_count == 0) {
0899 acpi_os_printf
0900 ("Current debug level for file output is: %8.8X\n",
0901 acpi_gbl_db_debug_level);
0902 acpi_os_printf
0903 ("Current debug level for console output is: %8.8X\n",
0904 acpi_gbl_db_console_debug_level);
0905 } else if (param_count == 2) {
0906 temp = acpi_gbl_db_console_debug_level;
0907 acpi_gbl_db_console_debug_level =
0908 strtoul(acpi_gbl_db_args[1], NULL, 16);
0909 acpi_os_printf
0910 ("Debug Level for console output was %8.8X, now %8.8X\n",
0911 temp, acpi_gbl_db_console_debug_level);
0912 } else {
0913 temp = acpi_gbl_db_debug_level;
0914 acpi_gbl_db_debug_level =
0915 strtoul(acpi_gbl_db_args[1], NULL, 16);
0916 acpi_os_printf
0917 ("Debug Level for file output was %8.8X, now %8.8X\n",
0918 temp, acpi_gbl_db_debug_level);
0919 }
0920 break;
0921
0922 case CMD_LIST:
0923
0924 #ifdef ACPI_DISASSEMBLER
0925 acpi_db_disassemble_aml(acpi_gbl_db_args[1], op);
0926 #else
0927 acpi_os_printf
0928 ("The AML Disassembler is not configured/present\n");
0929 #endif
0930 break;
0931
0932 case CMD_LOCKS:
0933
0934 acpi_db_display_locks();
0935 break;
0936
0937 case CMD_LOCALS:
0938
0939 acpi_db_display_locals();
0940 break;
0941
0942 case CMD_METHODS:
0943
0944 status = acpi_db_display_objects("METHOD", acpi_gbl_db_args[1]);
0945 break;
0946
0947 case CMD_NAMESPACE:
0948
0949 acpi_db_dump_namespace(acpi_gbl_db_args[1],
0950 acpi_gbl_db_args[2]);
0951 break;
0952
0953 case CMD_NOTIFY:
0954
0955 temp = strtoul(acpi_gbl_db_args[2], NULL, 0);
0956 acpi_db_send_notify(acpi_gbl_db_args[1], temp);
0957 break;
0958
0959 case CMD_OBJECTS:
0960
0961 acpi_ut_strupr(acpi_gbl_db_args[1]);
0962 status =
0963 acpi_db_display_objects(acpi_gbl_db_args[1],
0964 acpi_gbl_db_args[2]);
0965 break;
0966
0967 case CMD_OSI:
0968
0969 acpi_db_display_interfaces(acpi_gbl_db_args[1],
0970 acpi_gbl_db_args[2]);
0971 break;
0972
0973 case CMD_OWNER:
0974
0975 acpi_db_dump_namespace_by_owner(acpi_gbl_db_args[1],
0976 acpi_gbl_db_args[2]);
0977 break;
0978
0979 case CMD_PATHS:
0980
0981 acpi_db_dump_namespace_paths();
0982 break;
0983
0984 case CMD_PREFIX:
0985
0986 acpi_db_set_scope(acpi_gbl_db_args[1]);
0987 break;
0988
0989 case CMD_REFERENCES:
0990
0991 acpi_db_find_references(acpi_gbl_db_args[1]);
0992 break;
0993
0994 case CMD_RESOURCES:
0995
0996 acpi_db_display_resources(acpi_gbl_db_args[1]);
0997 break;
0998
0999 case CMD_RESULTS:
1000
1001 acpi_db_display_results();
1002 break;
1003
1004 case CMD_SET:
1005
1006 acpi_db_set_method_data(acpi_gbl_db_args[1],
1007 acpi_gbl_db_args[2],
1008 acpi_gbl_db_args[3]);
1009 break;
1010
1011 case CMD_STATS:
1012
1013 status = acpi_db_display_statistics(acpi_gbl_db_args[1]);
1014 break;
1015
1016 case CMD_STOP:
1017
1018 return (AE_NOT_IMPLEMENTED);
1019
1020 case CMD_TABLES:
1021
1022 acpi_db_display_table_info(acpi_gbl_db_args[1]);
1023 break;
1024
1025 case CMD_TEMPLATE:
1026
1027 acpi_db_display_template(acpi_gbl_db_args[1]);
1028 break;
1029
1030 case CMD_TRACE:
1031
1032 acpi_db_trace(acpi_gbl_db_args[1], acpi_gbl_db_args[2],
1033 acpi_gbl_db_args[3]);
1034 break;
1035
1036 case CMD_TREE:
1037
1038 acpi_db_display_calling_tree();
1039 break;
1040
1041 case CMD_TYPE:
1042
1043 acpi_db_display_object_type(acpi_gbl_db_args[1]);
1044 break;
1045
1046 #ifdef ACPI_APPLICATION
1047
1048
1049
1050 case CMD_ENABLEACPI:
1051 #if (!ACPI_REDUCED_HARDWARE)
1052
1053 status = acpi_enable();
1054 if (ACPI_FAILURE(status)) {
1055 acpi_os_printf("AcpiEnable failed (Status=%X)\n",
1056 status);
1057 return (status);
1058 }
1059 #endif
1060 break;
1061
1062 case CMD_EVENT:
1063
1064 acpi_os_printf("Event command not implemented\n");
1065 break;
1066
1067 case CMD_GPE:
1068
1069 acpi_db_generate_gpe(acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
1070 break;
1071
1072 case CMD_GPES:
1073
1074 acpi_db_display_gpes();
1075 break;
1076
1077 case CMD_SCI:
1078
1079 acpi_db_generate_sci();
1080 break;
1081
1082 case CMD_SLEEP:
1083
1084 status = acpi_db_sleep(acpi_gbl_db_args[1]);
1085 break;
1086
1087
1088
1089 case CMD_CLOSE:
1090
1091 acpi_db_close_debug_file();
1092 break;
1093
1094 case CMD_LOAD:{
1095 struct acpi_new_table_desc *list_head = NULL;
1096
1097 status =
1098 ac_get_all_tables_from_file(acpi_gbl_db_args[1],
1099 ACPI_GET_ALL_TABLES,
1100 &list_head);
1101 if (ACPI_SUCCESS(status)) {
1102 acpi_db_load_tables(list_head);
1103 }
1104 }
1105 break;
1106
1107 case CMD_OPEN:
1108
1109 acpi_db_open_debug_file(acpi_gbl_db_args[1]);
1110 break;
1111
1112
1113
1114 case CMD_TERMINATE:
1115
1116 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
1117 acpi_ut_subsystem_shutdown();
1118
1119
1120
1121
1122
1123
1124 acpi_gbl_db_terminate_loop = TRUE;
1125
1126 break;
1127
1128 case CMD_BACKGROUND:
1129
1130 acpi_db_create_execution_thread(acpi_gbl_db_args[1],
1131 &acpi_gbl_db_args[2],
1132 &acpi_gbl_db_arg_types[2]);
1133 break;
1134
1135 case CMD_THREADS:
1136
1137 acpi_db_create_execution_threads(acpi_gbl_db_args[1],
1138 acpi_gbl_db_args[2],
1139 acpi_gbl_db_args[3]);
1140 break;
1141
1142
1143
1144 case CMD_PREDEFINED:
1145
1146 acpi_db_check_predefined_names();
1147 break;
1148
1149 case CMD_TEST:
1150
1151 acpi_db_execute_test(acpi_gbl_db_args[1]);
1152 break;
1153
1154 case CMD_UNLOAD:
1155
1156 acpi_db_unload_acpi_table(acpi_gbl_db_args[1]);
1157 break;
1158 #endif
1159
1160 case CMD_EXIT:
1161 case CMD_QUIT:
1162
1163 if (op) {
1164 acpi_os_printf("Method execution terminated\n");
1165 return (AE_CTRL_TERMINATE);
1166 }
1167
1168 if (!acpi_gbl_db_output_to_file) {
1169 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
1170 }
1171 #ifdef ACPI_APPLICATION
1172 acpi_db_close_debug_file();
1173 #endif
1174 acpi_gbl_db_terminate_loop = TRUE;
1175 return (AE_CTRL_TERMINATE);
1176
1177 case CMD_NOT_FOUND:
1178 default:
1179
1180 acpi_os_printf("%s: unknown command\n", acpi_gbl_db_args[0]);
1181 return (AE_CTRL_TRUE);
1182 }
1183
1184 if (ACPI_SUCCESS(status)) {
1185 status = AE_CTRL_TRUE;
1186 }
1187
1188 return (status);
1189 }
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204 void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context)
1205 {
1206
1207 (void)acpi_db_user_commands();
1208 acpi_gbl_db_threads_terminated = TRUE;
1209 }
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224 acpi_status acpi_db_user_commands(void)
1225 {
1226 acpi_status status = AE_OK;
1227
1228 acpi_os_printf("\n");
1229
1230
1231
1232 while (!acpi_gbl_db_terminate_loop) {
1233
1234
1235
1236 status = acpi_os_wait_command_ready();
1237 if (ACPI_FAILURE(status)) {
1238 break;
1239 }
1240
1241
1242
1243 acpi_gbl_method_executing = FALSE;
1244 acpi_gbl_step_to_next_call = FALSE;
1245
1246 (void)acpi_db_command_dispatch(acpi_gbl_db_line_buf, NULL,
1247 NULL);
1248
1249
1250
1251 status = acpi_os_notify_command_complete();
1252 if (ACPI_FAILURE(status)) {
1253 break;
1254 }
1255 }
1256
1257 if (ACPI_FAILURE(status) && status != AE_CTRL_TERMINATE) {
1258 ACPI_EXCEPTION((AE_INFO, status, "While parsing command line"));
1259 }
1260 return (status);
1261 }