This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_db_match_command_help
- acpi_db_display_command_info
- acpi_db_display_help
- acpi_db_get_next_token
- acpi_db_get_line
- acpi_db_match_command
- acpi_db_command_dispatch
- acpi_db_execute_thread
- acpi_db_user_commands
1
2
3
4
5
6
7
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acdebug.h"
11
12 #ifdef ACPI_APPLICATION
13 #include "acapps.h"
14 #endif
15
16 #define _COMPONENT ACPI_CA_DEBUGGER
17 ACPI_MODULE_NAME("dbinput")
18
19
20 static u32 acpi_db_get_line(char *input_buffer);
21
22 static u32 acpi_db_match_command(char *user_command);
23
24 static void acpi_db_display_command_info(const char *command, u8 display_all);
25
26 static void acpi_db_display_help(char *command);
27
28 static u8
29 acpi_db_match_command_help(const char *command,
30 const struct acpi_db_command_help *help);
31
32
33
34
35
36
37 enum acpi_ex_debugger_commands {
38 CMD_NOT_FOUND = 0,
39 CMD_NULL,
40 CMD_ALLOCATIONS,
41 CMD_ARGS,
42 CMD_ARGUMENTS,
43 CMD_BREAKPOINT,
44 CMD_BUSINFO,
45 CMD_CALL,
46 CMD_DEBUG,
47 CMD_DISASSEMBLE,
48 CMD_DISASM,
49 CMD_DUMP,
50 CMD_EVALUATE,
51 CMD_EXECUTE,
52 CMD_EXIT,
53 CMD_FIND,
54 CMD_GO,
55 CMD_HANDLERS,
56 CMD_HELP,
57 CMD_HELP2,
58 CMD_HISTORY,
59 CMD_HISTORY_EXE,
60 CMD_HISTORY_LAST,
61 CMD_INFORMATION,
62 CMD_INTEGRITY,
63 CMD_INTO,
64 CMD_LEVEL,
65 CMD_LIST,
66 CMD_LOCALS,
67 CMD_LOCKS,
68 CMD_METHODS,
69 CMD_NAMESPACE,
70 CMD_NOTIFY,
71 CMD_OBJECTS,
72 CMD_OSI,
73 CMD_OWNER,
74 CMD_PATHS,
75 CMD_PREDEFINED,
76 CMD_PREFIX,
77 CMD_QUIT,
78 CMD_REFERENCES,
79 CMD_RESOURCES,
80 CMD_RESULTS,
81 CMD_SET,
82 CMD_STATS,
83 CMD_STOP,
84 CMD_TABLES,
85 CMD_TEMPLATE,
86 CMD_TRACE,
87 CMD_TREE,
88 CMD_TYPE,
89 #ifdef ACPI_APPLICATION
90 CMD_ENABLEACPI,
91 CMD_EVENT,
92 CMD_GPE,
93 CMD_GPES,
94 CMD_SCI,
95 CMD_SLEEP,
96
97 CMD_CLOSE,
98 CMD_LOAD,
99 CMD_OPEN,
100 CMD_UNLOAD,
101
102 CMD_TERMINATE,
103 CMD_BACKGROUND,
104 CMD_THREADS,
105
106 CMD_TEST,
107 #endif
108 };
109
110 #define CMD_FIRST_VALID 2
111
112
113
114 static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
115 {"<NOT FOUND>", 0},
116 {"<NULL>", 0},
117 {"ALLOCATIONS", 0},
118 {"ARGS", 0},
119 {"ARGUMENTS", 0},
120 {"BREAKPOINT", 1},
121 {"BUSINFO", 0},
122 {"CALL", 0},
123 {"DEBUG", 1},
124 {"DISASSEMBLE", 1},
125 {"DISASM", 1},
126 {"DUMP", 1},
127 {"EVALUATE", 1},
128 {"EXECUTE", 1},
129 {"EXIT", 0},
130 {"FIND", 1},
131 {"GO", 0},
132 {"HANDLERS", 0},
133 {"HELP", 0},
134 {"?", 0},
135 {"HISTORY", 0},
136 {"!", 1},
137 {"!!", 0},
138 {"INFORMATION", 0},
139 {"INTEGRITY", 0},
140 {"INTO", 0},
141 {"LEVEL", 0},
142 {"LIST", 0},
143 {"LOCALS", 0},
144 {"LOCKS", 0},
145 {"METHODS", 0},
146 {"NAMESPACE", 0},
147 {"NOTIFY", 2},
148 {"OBJECTS", 0},
149 {"OSI", 0},
150 {"OWNER", 1},
151 {"PATHS", 0},
152 {"PREDEFINED", 0},
153 {"PREFIX", 0},
154 {"QUIT", 0},
155 {"REFERENCES", 1},
156 {"RESOURCES", 0},
157 {"RESULTS", 0},
158 {"SET", 3},
159 {"STATS", 1},
160 {"STOP", 0},
161 {"TABLES", 0},
162 {"TEMPLATE", 1},
163 {"TRACE", 1},
164 {"TREE", 0},
165 {"TYPE", 1},
166 #ifdef ACPI_APPLICATION
167 {"ENABLEACPI", 0},
168 {"EVENT", 1},
169 {"GPE", 1},
170 {"GPES", 0},
171 {"SCI", 0},
172 {"SLEEP", 0},
173
174 {"CLOSE", 0},
175 {"LOAD", 1},
176 {"OPEN", 1},
177 {"UNLOAD", 1},
178
179 {"TERMINATE", 0},
180 {"BACKGROUND", 1},
181 {"THREADS", 3},
182
183 {"TEST", 1},
184 #endif
185 {NULL, 0}
186 };
187
188
189
190
191
192
193
194
195 static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
196 {0, "\nNamespace Access:", "\n"},
197 {1, " Businfo", "Display system bus info\n"},
198 {1, " Disassemble <Method>", "Disassemble a control method\n"},
199 {1, " Find <AcpiName> (? is wildcard)",
200 "Find ACPI name(s) with wildcards\n"},
201 {1, " Integrity", "Validate namespace integrity\n"},
202 {1, " Methods", "Display list of loaded control methods\n"},
203 {1, " Namespace [Object] [Depth]",
204 "Display loaded namespace tree/subtree\n"},
205 {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
206 {1, " Objects [ObjectType]",
207 "Display summary of all objects or just given type\n"},
208 {1, " Owner <OwnerId> [Depth]",
209 "Display loaded namespace by object owner\n"},
210 {1, " Paths", "Display full pathnames of namespace objects\n"},
211 {1, " Predefined", "Check all predefined names\n"},
212 {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
213 {1, " References <Addr>", "Find all references to object at addr\n"},
214 {1, " Resources [DeviceName]",
215 "Display Device resources (no arg = all devices)\n"},
216 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
217 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
218 {1, " Type <Object>", "Display object type\n"},
219
220 {0, "\nControl Method Execution:", "\n"},
221 {1, " Evaluate <Namepath> [Arguments]",
222 "Evaluate object or control method\n"},
223 {1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
224 #ifdef ACPI_APPLICATION
225 {1, " Background <Namepath> [Arguments]",
226 "Evaluate object/method in a separate thread\n"},
227 {1, " Thread <Threads><Loops><NamePath>",
228 "Spawn threads to execute method(s)\n"},
229 #endif
230 {1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
231 {7, " [Arguments] formats:", "Control method argument formats\n"},
232 {1, " Hex Integer", "Integer\n"},
233 {1, " \"Ascii String\"", "String\n"},
234 {1, " (Hex Byte List)", "Buffer\n"},
235 {1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
236 {1, " [Package Element List]", "Package\n"},
237 {1, " [0x01 0x1234 \"string\"]",
238 "Package example (3 elements)\n"},
239
240 {0, "\nMiscellaneous:", "\n"},
241 {1, " Allocations", "Display list of current memory allocations\n"},
242 {2, " Dump <Address>|<Namepath>", "\n"},
243 {0, " [Byte|Word|Dword|Qword]",
244 "Display ACPI objects or memory\n"},
245 {1, " Handlers", "Info about global handlers\n"},
246 {1, " Help [Command]", "This help screen or individual command\n"},
247 {1, " History", "Display command history buffer\n"},
248 {1, " Level <DebugLevel>] [console]",
249 "Get/Set debug level for file or console\n"},
250 {1, " Locks", "Current status of internal mutexes\n"},
251 {1, " Osi [Install|Remove <name>]",
252 "Display or modify global _OSI list\n"},
253 {1, " Quit or Exit", "Exit this command\n"},
254 {8, " Stats <SubCommand>",
255 "Display namespace and memory statistics\n"},
256 {1, " Allocations", "Display list of current memory allocations\n"},
257 {1, " Memory", "Dump internal memory lists\n"},
258 {1, " Misc", "Namespace search and mutex stats\n"},
259 {1, " Objects", "Summary of namespace objects\n"},
260 {1, " Sizes", "Sizes for each of the internal objects\n"},
261 {1, " Stack", "Display CPU stack usage\n"},
262 {1, " Tables", "Info about current ACPI table(s)\n"},
263 {1, " Tables", "Display info about loaded ACPI tables\n"},
264 #ifdef ACPI_APPLICATION
265 {1, " Terminate", "Delete namespace and all internal objects\n"},
266 #endif
267 {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
268 {1, " !!", "Execute last command again\n"},
269
270 {0, "\nMethod and Namespace Debugging:", "\n"},
271 {5, " Trace <State> [<Namepath>] [Once]",
272 "Trace control method execution\n"},
273 {1, " Enable", "Enable all messages\n"},
274 {1, " Disable", "Disable tracing\n"},
275 {1, " Method", "Enable method execution messages\n"},
276 {1, " Opcode", "Enable opcode execution messages\n"},
277 {3, " Test <TestName>", "Invoke a debug test\n"},
278 {1, " Objects", "Read/write/compare all namespace data objects\n"},
279 {1, " Predefined",
280 "Validate all ACPI predefined names (_STA, etc.)\n"},
281 {1, " Execute predefined",
282 "Execute all predefined (public) methods\n"},
283
284 {0, "\nControl Method Single-Step Execution:", "\n"},
285 {1, " Arguments (or Args)", "Display method arguments\n"},
286 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
287 {1, " Call", "Run to next control method invocation\n"},
288 {1, " Go", "Allow method to run to completion\n"},
289 {1, " Information", "Display info about the current method\n"},
290 {1, " Into", "Step into (not over) a method call\n"},
291 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
292 {1, " Locals", "Display method local variables\n"},
293 {1, " Results", "Display method result stack\n"},
294 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
295 {1, " Stop", "Terminate control method\n"},
296 {1, " Tree", "Display control method calling tree\n"},
297 {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
298
299 #ifdef ACPI_APPLICATION
300 {0, "\nFile Operations:", "\n"},
301 {1, " Close", "Close debug output file\n"},
302 {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
303 {1, " Open <Output Filename>", "Open a file for debug output\n"},
304 {1, " Unload <Namepath>",
305 "Unload an ACPI table via namespace object\n"},
306
307 {0, "\nHardware Simulation:", "\n"},
308 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
309 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
310 {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
311 {1, " Gpes", "Display info on all GPE devices\n"},
312 {1, " Sci", "Generate an SCI\n"},
313 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
314 #endif
315 {0, NULL, NULL}
316 };
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332 static u8
333 acpi_db_match_command_help(const char *command,
334 const struct acpi_db_command_help *help)
335 {
336 char *invocation = help->invocation;
337 u32 line_count;
338
339
340
341 if (*invocation != ' ') {
342 return (FALSE);
343 }
344
345 while (*invocation == ' ') {
346 invocation++;
347 }
348
349
350
351 while ((*command) && (*invocation) && (*invocation != ' ')) {
352 if (tolower((int)*command) != tolower((int)*invocation)) {
353 return (FALSE);
354 }
355
356 invocation++;
357 command++;
358 }
359
360
361
362 line_count = help->line_count;
363 while (line_count) {
364 acpi_os_printf("%-38s : %s", help->invocation,
365 help->description);
366 help++;
367 line_count--;
368 }
369
370 return (TRUE);
371 }
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387 static void acpi_db_display_command_info(const char *command, u8 display_all)
388 {
389 const struct acpi_db_command_help *next;
390 u8 matched;
391
392 next = acpi_gbl_db_command_help;
393 while (next->invocation) {
394 matched = acpi_db_match_command_help(command, next);
395 if (!display_all && matched) {
396 return;
397 }
398
399 next++;
400 }
401 }
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417 static void acpi_db_display_help(char *command)
418 {
419 const struct acpi_db_command_help *next = acpi_gbl_db_command_help;
420
421 if (!command) {
422
423
424
425 acpi_os_printf("\nSummary of AML Debugger Commands\n\n");
426
427 while (next->invocation) {
428 acpi_os_printf("%-38s%s", next->invocation,
429 next->description);
430 next++;
431 }
432 acpi_os_printf("\n");
433
434 } else {
435
436
437 acpi_db_display_command_info(command, TRUE);
438 }
439 }
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454 char *acpi_db_get_next_token(char *string,
455 char **next, acpi_object_type *return_type)
456 {
457 char *start;
458 u32 depth;
459 acpi_object_type type = ACPI_TYPE_INTEGER;
460
461
462
463 if (!string || !(*string)) {
464 return (NULL);
465 }
466
467
468
469 while (*string && isspace(*string)) {
470 string++;
471 }
472
473 if (!(*string)) {
474 return (NULL);
475 }
476
477 switch (*string) {
478 case '"':
479
480
481
482 string++;
483 start = string;
484 type = ACPI_TYPE_STRING;
485
486
487
488 while (*string && (*string != '"')) {
489 string++;
490 }
491 break;
492
493 case '(':
494
495
496
497 string++;
498 start = string;
499 type = ACPI_TYPE_BUFFER;
500
501
502
503 while (*string && (*string != ')')) {
504 string++;
505 }
506 break;
507
508 case '[':
509
510
511
512 string++;
513 depth = 1;
514 start = string;
515 type = ACPI_TYPE_PACKAGE;
516
517
518
519 while (*string) {
520
521
522
523 if (*string == '"') {
524
525
526 string++;
527 while (*string && (*string != '"')) {
528 string++;
529 }
530 if (!(*string)) {
531 break;
532 }
533 } else if (*string == '[') {
534 depth++;
535 } else if (*string == ']') {
536 depth--;
537 if (depth == 0) {
538 break;
539 }
540 }
541
542 string++;
543 }
544 break;
545
546 default:
547
548 start = string;
549
550
551
552 while (*string && !isspace(*string)) {
553 string++;
554 }
555 break;
556 }
557
558 if (!(*string)) {
559 *next = NULL;
560 } else {
561 *string = 0;
562 *next = string + 1;
563 }
564
565 *return_type = type;
566 return (start);
567 }
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582 static u32 acpi_db_get_line(char *input_buffer)
583 {
584 u32 i;
585 u32 count;
586 char *next;
587 char *this;
588
589 if (acpi_ut_safe_strcpy
590 (acpi_gbl_db_parsed_buf, sizeof(acpi_gbl_db_parsed_buf),
591 input_buffer)) {
592 acpi_os_printf
593 ("Buffer overflow while parsing input line (max %u characters)\n",
594 (u32)sizeof(acpi_gbl_db_parsed_buf));
595 return (0);
596 }
597
598 this = acpi_gbl_db_parsed_buf;
599 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) {
600 acpi_gbl_db_args[i] = acpi_db_get_next_token(this, &next,
601 &acpi_gbl_db_arg_types
602 [i]);
603 if (!acpi_gbl_db_args[i]) {
604 break;
605 }
606
607 this = next;
608 }
609
610
611
612 acpi_ut_strupr(acpi_gbl_db_args[0]);
613
614 count = i;
615 if (count) {
616 count--;
617 }
618
619 return (count);
620 }
621
622
623
624
625
626
627
628
629
630
631
632
633
634 static u32 acpi_db_match_command(char *user_command)
635 {
636 u32 i;
637
638 if (!user_command || user_command[0] == 0) {
639 return (CMD_NULL);
640 }
641
642 for (i = CMD_FIRST_VALID; acpi_gbl_db_commands[i].name; i++) {
643 if (strstr
644 (ACPI_CAST_PTR(char, acpi_gbl_db_commands[i].name),
645 user_command) == acpi_gbl_db_commands[i].name) {
646 return (i);
647 }
648 }
649
650
651
652 return (CMD_NOT_FOUND);
653 }
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669 acpi_status
670 acpi_db_command_dispatch(char *input_buffer,
671 struct acpi_walk_state *walk_state,
672 union acpi_parse_object *op)
673 {
674 u32 temp;
675 u32 command_index;
676 u32 param_count;
677 char *command_line;
678 acpi_status status = AE_CTRL_TRUE;
679
680
681
682 if (acpi_gbl_db_terminate_loop) {
683 return (AE_CTRL_TERMINATE);
684 }
685
686
687
688 param_count = acpi_db_get_line(input_buffer);
689 command_index = acpi_db_match_command(acpi_gbl_db_args[0]);
690 temp = 0;
691
692
693
694
695
696
697 if (command_index != CMD_HISTORY_LAST) {
698 acpi_db_add_to_history(input_buffer);
699 }
700
701
702
703 if (param_count < acpi_gbl_db_commands[command_index].min_args) {
704 acpi_os_printf
705 ("%u parameters entered, [%s] requires %u parameters\n",
706 param_count, acpi_gbl_db_commands[command_index].name,
707 acpi_gbl_db_commands[command_index].min_args);
708
709 acpi_db_display_command_info(acpi_gbl_db_commands
710 [command_index].name, FALSE);
711 return (AE_CTRL_TRUE);
712 }
713
714
715
716 switch (command_index) {
717 case CMD_NULL:
718
719 if (op) {
720 return (AE_OK);
721 }
722 break;
723
724 case CMD_ALLOCATIONS:
725
726 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
727 acpi_ut_dump_allocations((u32)-1, NULL);
728 #endif
729 break;
730
731 case CMD_ARGS:
732 case CMD_ARGUMENTS:
733
734 acpi_db_display_arguments();
735 break;
736
737 case CMD_BREAKPOINT:
738
739 acpi_db_set_method_breakpoint(acpi_gbl_db_args[1], walk_state,
740 op);
741 break;
742
743 case CMD_BUSINFO:
744
745 acpi_db_get_bus_info();
746 break;
747
748 case CMD_CALL:
749
750 acpi_db_set_method_call_breakpoint(op);
751 status = AE_OK;
752 break;
753
754 case CMD_DEBUG:
755
756 acpi_db_execute(acpi_gbl_db_args[1],
757 &acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
758 EX_SINGLE_STEP);
759 break;
760
761 case CMD_DISASSEMBLE:
762 case CMD_DISASM:
763
764 #ifdef ACPI_DISASSEMBLER
765 (void)acpi_db_disassemble_method(acpi_gbl_db_args[1]);
766 #else
767 acpi_os_printf
768 ("The AML Disassembler is not configured/present\n");
769 #endif
770 break;
771
772 case CMD_DUMP:
773
774 acpi_db_decode_and_display_object(acpi_gbl_db_args[1],
775 acpi_gbl_db_args[2]);
776 break;
777
778 case CMD_EVALUATE:
779 case CMD_EXECUTE:
780
781 acpi_db_execute(acpi_gbl_db_args[1],
782 &acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
783 EX_NO_SINGLE_STEP);
784 break;
785
786 case CMD_FIND:
787
788 status = acpi_db_find_name_in_namespace(acpi_gbl_db_args[1]);
789 break;
790
791 case CMD_GO:
792
793 acpi_gbl_cm_single_step = FALSE;
794 return (AE_OK);
795
796 case CMD_HANDLERS:
797
798 acpi_db_display_handlers();
799 break;
800
801 case CMD_HELP:
802 case CMD_HELP2:
803
804 acpi_db_display_help(acpi_gbl_db_args[1]);
805 break;
806
807 case CMD_HISTORY:
808
809 acpi_db_display_history();
810 break;
811
812 case CMD_HISTORY_EXE:
813
814 command_line = acpi_db_get_from_history(acpi_gbl_db_args[1]);
815 if (!command_line) {
816 return (AE_CTRL_TRUE);
817 }
818
819 status = acpi_db_command_dispatch(command_line, walk_state, op);
820 return (status);
821
822 case CMD_HISTORY_LAST:
823
824 command_line = acpi_db_get_from_history(NULL);
825 if (!command_line) {
826 return (AE_CTRL_TRUE);
827 }
828
829 status = acpi_db_command_dispatch(command_line, walk_state, op);
830 return (status);
831
832 case CMD_INFORMATION:
833
834 acpi_db_display_method_info(op);
835 break;
836
837 case CMD_INTEGRITY:
838
839 acpi_db_check_integrity();
840 break;
841
842 case CMD_INTO:
843
844 if (op) {
845 acpi_gbl_cm_single_step = TRUE;
846 return (AE_OK);
847 }
848 break;
849
850 case CMD_LEVEL:
851
852 if (param_count == 0) {
853 acpi_os_printf
854 ("Current debug level for file output is: %8.8X\n",
855 acpi_gbl_db_debug_level);
856 acpi_os_printf
857 ("Current debug level for console output is: %8.8X\n",
858 acpi_gbl_db_console_debug_level);
859 } else if (param_count == 2) {
860 temp = acpi_gbl_db_console_debug_level;
861 acpi_gbl_db_console_debug_level =
862 strtoul(acpi_gbl_db_args[1], NULL, 16);
863 acpi_os_printf
864 ("Debug Level for console output was %8.8X, now %8.8X\n",
865 temp, acpi_gbl_db_console_debug_level);
866 } else {
867 temp = acpi_gbl_db_debug_level;
868 acpi_gbl_db_debug_level =
869 strtoul(acpi_gbl_db_args[1], NULL, 16);
870 acpi_os_printf
871 ("Debug Level for file output was %8.8X, now %8.8X\n",
872 temp, acpi_gbl_db_debug_level);
873 }
874 break;
875
876 case CMD_LIST:
877
878 #ifdef ACPI_DISASSEMBLER
879 acpi_db_disassemble_aml(acpi_gbl_db_args[1], op);
880 #else
881 acpi_os_printf
882 ("The AML Disassembler is not configured/present\n");
883 #endif
884 break;
885
886 case CMD_LOCKS:
887
888 acpi_db_display_locks();
889 break;
890
891 case CMD_LOCALS:
892
893 acpi_db_display_locals();
894 break;
895
896 case CMD_METHODS:
897
898 status = acpi_db_display_objects("METHOD", acpi_gbl_db_args[1]);
899 break;
900
901 case CMD_NAMESPACE:
902
903 acpi_db_dump_namespace(acpi_gbl_db_args[1],
904 acpi_gbl_db_args[2]);
905 break;
906
907 case CMD_NOTIFY:
908
909 temp = strtoul(acpi_gbl_db_args[2], NULL, 0);
910 acpi_db_send_notify(acpi_gbl_db_args[1], temp);
911 break;
912
913 case CMD_OBJECTS:
914
915 acpi_ut_strupr(acpi_gbl_db_args[1]);
916 status =
917 acpi_db_display_objects(acpi_gbl_db_args[1],
918 acpi_gbl_db_args[2]);
919 break;
920
921 case CMD_OSI:
922
923 acpi_db_display_interfaces(acpi_gbl_db_args[1],
924 acpi_gbl_db_args[2]);
925 break;
926
927 case CMD_OWNER:
928
929 acpi_db_dump_namespace_by_owner(acpi_gbl_db_args[1],
930 acpi_gbl_db_args[2]);
931 break;
932
933 case CMD_PATHS:
934
935 acpi_db_dump_namespace_paths();
936 break;
937
938 case CMD_PREFIX:
939
940 acpi_db_set_scope(acpi_gbl_db_args[1]);
941 break;
942
943 case CMD_REFERENCES:
944
945 acpi_db_find_references(acpi_gbl_db_args[1]);
946 break;
947
948 case CMD_RESOURCES:
949
950 acpi_db_display_resources(acpi_gbl_db_args[1]);
951 break;
952
953 case CMD_RESULTS:
954
955 acpi_db_display_results();
956 break;
957
958 case CMD_SET:
959
960 acpi_db_set_method_data(acpi_gbl_db_args[1],
961 acpi_gbl_db_args[2],
962 acpi_gbl_db_args[3]);
963 break;
964
965 case CMD_STATS:
966
967 status = acpi_db_display_statistics(acpi_gbl_db_args[1]);
968 break;
969
970 case CMD_STOP:
971
972 return (AE_NOT_IMPLEMENTED);
973
974 case CMD_TABLES:
975
976 acpi_db_display_table_info(acpi_gbl_db_args[1]);
977 break;
978
979 case CMD_TEMPLATE:
980
981 acpi_db_display_template(acpi_gbl_db_args[1]);
982 break;
983
984 case CMD_TRACE:
985
986 acpi_db_trace(acpi_gbl_db_args[1], acpi_gbl_db_args[2],
987 acpi_gbl_db_args[3]);
988 break;
989
990 case CMD_TREE:
991
992 acpi_db_display_calling_tree();
993 break;
994
995 case CMD_TYPE:
996
997 acpi_db_display_object_type(acpi_gbl_db_args[1]);
998 break;
999
1000 #ifdef ACPI_APPLICATION
1001
1002
1003
1004 case CMD_ENABLEACPI:
1005 #if (!ACPI_REDUCED_HARDWARE)
1006
1007 status = acpi_enable();
1008 if (ACPI_FAILURE(status)) {
1009 acpi_os_printf("AcpiEnable failed (Status=%X)\n",
1010 status);
1011 return (status);
1012 }
1013 #endif
1014 break;
1015
1016 case CMD_EVENT:
1017
1018 acpi_os_printf("Event command not implemented\n");
1019 break;
1020
1021 case CMD_GPE:
1022
1023 acpi_db_generate_gpe(acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
1024 break;
1025
1026 case CMD_GPES:
1027
1028 acpi_db_display_gpes();
1029 break;
1030
1031 case CMD_SCI:
1032
1033 acpi_db_generate_sci();
1034 break;
1035
1036 case CMD_SLEEP:
1037
1038 status = acpi_db_sleep(acpi_gbl_db_args[1]);
1039 break;
1040
1041
1042
1043 case CMD_CLOSE:
1044
1045 acpi_db_close_debug_file();
1046 break;
1047
1048 case CMD_LOAD:{
1049 struct acpi_new_table_desc *list_head = NULL;
1050
1051 status =
1052 ac_get_all_tables_from_file(acpi_gbl_db_args[1],
1053 ACPI_GET_ALL_TABLES,
1054 &list_head);
1055 if (ACPI_SUCCESS(status)) {
1056 acpi_db_load_tables(list_head);
1057 }
1058 }
1059 break;
1060
1061 case CMD_OPEN:
1062
1063 acpi_db_open_debug_file(acpi_gbl_db_args[1]);
1064 break;
1065
1066
1067
1068 case CMD_TERMINATE:
1069
1070 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
1071 acpi_ut_subsystem_shutdown();
1072
1073
1074
1075
1076
1077
1078 acpi_gbl_db_terminate_loop = TRUE;
1079
1080 break;
1081
1082 case CMD_BACKGROUND:
1083
1084 acpi_db_create_execution_thread(acpi_gbl_db_args[1],
1085 &acpi_gbl_db_args[2],
1086 &acpi_gbl_db_arg_types[2]);
1087 break;
1088
1089 case CMD_THREADS:
1090
1091 acpi_db_create_execution_threads(acpi_gbl_db_args[1],
1092 acpi_gbl_db_args[2],
1093 acpi_gbl_db_args[3]);
1094 break;
1095
1096
1097
1098 case CMD_PREDEFINED:
1099
1100 acpi_db_check_predefined_names();
1101 break;
1102
1103 case CMD_TEST:
1104
1105 acpi_db_execute_test(acpi_gbl_db_args[1]);
1106 break;
1107
1108 case CMD_UNLOAD:
1109
1110 acpi_db_unload_acpi_table(acpi_gbl_db_args[1]);
1111 break;
1112 #endif
1113
1114 case CMD_EXIT:
1115 case CMD_QUIT:
1116
1117 if (op) {
1118 acpi_os_printf("Method execution terminated\n");
1119 return (AE_CTRL_TERMINATE);
1120 }
1121
1122 if (!acpi_gbl_db_output_to_file) {
1123 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
1124 }
1125 #ifdef ACPI_APPLICATION
1126 acpi_db_close_debug_file();
1127 #endif
1128 acpi_gbl_db_terminate_loop = TRUE;
1129 return (AE_CTRL_TERMINATE);
1130
1131 case CMD_NOT_FOUND:
1132 default:
1133
1134 acpi_os_printf("%s: unknown command\n", acpi_gbl_db_args[0]);
1135 return (AE_CTRL_TRUE);
1136 }
1137
1138 if (ACPI_SUCCESS(status)) {
1139 status = AE_CTRL_TRUE;
1140 }
1141
1142 return (status);
1143 }
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158 void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context)
1159 {
1160
1161 (void)acpi_db_user_commands();
1162 acpi_gbl_db_threads_terminated = TRUE;
1163 }
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178 acpi_status acpi_db_user_commands(void)
1179 {
1180 acpi_status status = AE_OK;
1181
1182 acpi_os_printf("\n");
1183
1184
1185
1186 while (!acpi_gbl_db_terminate_loop) {
1187
1188
1189
1190 status = acpi_os_wait_command_ready();
1191 if (ACPI_FAILURE(status)) {
1192 break;
1193 }
1194
1195
1196
1197 acpi_gbl_method_executing = FALSE;
1198 acpi_gbl_step_to_next_call = FALSE;
1199
1200 (void)acpi_db_command_dispatch(acpi_gbl_db_line_buf, NULL,
1201 NULL);
1202
1203
1204
1205 status = acpi_os_notify_command_complete();
1206 if (ACPI_FAILURE(status)) {
1207 break;
1208 }
1209 }
1210
1211 if (ACPI_FAILURE(status) && status != AE_CTRL_TERMINATE) {
1212 ACPI_EXCEPTION((AE_INFO, status, "While parsing command line"));
1213 }
1214 return (status);
1215 }