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