dbinput.c revision 1.3.2.2 1 1.3.2.2 bouyer /*******************************************************************************
2 1.3.2.2 bouyer *
3 1.3.2.2 bouyer * Module Name: dbinput - user front-end to the AML debugger
4 1.3.2.2 bouyer *
5 1.3.2.2 bouyer ******************************************************************************/
6 1.3.2.2 bouyer
7 1.3.2.2 bouyer /*
8 1.3.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.3.2.2 bouyer * All rights reserved.
10 1.3.2.2 bouyer *
11 1.3.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.3.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.3.2.2 bouyer * are met:
14 1.3.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.3.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.3.2.2 bouyer * without modification.
17 1.3.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.3.2.2 bouyer * binary redistribution.
22 1.3.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.3.2.2 bouyer * from this software without specific prior written permission.
25 1.3.2.2 bouyer *
26 1.3.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.3.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3.2.2 bouyer * Software Foundation.
29 1.3.2.2 bouyer *
30 1.3.2.2 bouyer * NO WARRANTY
31 1.3.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.3.2.2 bouyer */
43 1.3.2.2 bouyer
44 1.3.2.2 bouyer
45 1.3.2.2 bouyer #include "acpi.h"
46 1.3.2.2 bouyer #include "accommon.h"
47 1.3.2.2 bouyer #include "acdebug.h"
48 1.3.2.2 bouyer
49 1.3.2.2 bouyer
50 1.3.2.2 bouyer #ifdef ACPI_DEBUGGER
51 1.3.2.2 bouyer
52 1.3.2.2 bouyer #define _COMPONENT ACPI_CA_DEBUGGER
53 1.3.2.2 bouyer ACPI_MODULE_NAME ("dbinput")
54 1.3.2.2 bouyer
55 1.3.2.2 bouyer /* Local prototypes */
56 1.3.2.2 bouyer
57 1.3.2.2 bouyer static char *
58 1.3.2.2 bouyer AcpiDbGetNextToken (
59 1.3.2.2 bouyer char *String,
60 1.3.2.2 bouyer char **Next);
61 1.3.2.2 bouyer
62 1.3.2.2 bouyer static UINT32
63 1.3.2.2 bouyer AcpiDbGetLine (
64 1.3.2.2 bouyer char *InputBuffer);
65 1.3.2.2 bouyer
66 1.3.2.2 bouyer static UINT32
67 1.3.2.2 bouyer AcpiDbMatchCommand (
68 1.3.2.2 bouyer char *UserCommand);
69 1.3.2.2 bouyer
70 1.3.2.2 bouyer static void
71 1.3.2.2 bouyer AcpiDbSingleThread (
72 1.3.2.2 bouyer void);
73 1.3.2.2 bouyer
74 1.3.2.2 bouyer static void
75 1.3.2.2 bouyer AcpiDbDisplayHelp (
76 1.3.2.2 bouyer void);
77 1.3.2.2 bouyer
78 1.3.2.2 bouyer
79 1.3.2.2 bouyer /*
80 1.3.2.2 bouyer * Top-level debugger commands.
81 1.3.2.2 bouyer *
82 1.3.2.2 bouyer * This list of commands must match the string table below it
83 1.3.2.2 bouyer */
84 1.3.2.2 bouyer enum AcpiExDebuggerCommands
85 1.3.2.2 bouyer {
86 1.3.2.2 bouyer CMD_NOT_FOUND = 0,
87 1.3.2.2 bouyer CMD_NULL,
88 1.3.2.2 bouyer CMD_ALLOCATIONS,
89 1.3.2.2 bouyer CMD_ARGS,
90 1.3.2.2 bouyer CMD_ARGUMENTS,
91 1.3.2.2 bouyer CMD_BATCH,
92 1.3.2.2 bouyer CMD_BREAKPOINT,
93 1.3.2.2 bouyer CMD_BUSINFO,
94 1.3.2.2 bouyer CMD_CALL,
95 1.3.2.2 bouyer CMD_CLOSE,
96 1.3.2.2 bouyer CMD_DEBUG,
97 1.3.2.2 bouyer CMD_DISASSEMBLE,
98 1.3.2.2 bouyer CMD_DUMP,
99 1.3.2.2 bouyer CMD_ENABLEACPI,
100 1.3.2.2 bouyer CMD_EVENT,
101 1.3.2.2 bouyer CMD_EXECUTE,
102 1.3.2.2 bouyer CMD_EXIT,
103 1.3.2.2 bouyer CMD_FIND,
104 1.3.2.2 bouyer CMD_GO,
105 1.3.2.2 bouyer CMD_GPE,
106 1.3.2.2 bouyer CMD_GPES,
107 1.3.2.2 bouyer CMD_HANDLERS,
108 1.3.2.2 bouyer CMD_HELP,
109 1.3.2.2 bouyer CMD_HELP2,
110 1.3.2.2 bouyer CMD_HISTORY,
111 1.3.2.2 bouyer CMD_HISTORY_EXE,
112 1.3.2.2 bouyer CMD_HISTORY_LAST,
113 1.3.2.2 bouyer CMD_INFORMATION,
114 1.3.2.2 bouyer CMD_INTEGRITY,
115 1.3.2.2 bouyer CMD_INTO,
116 1.3.2.2 bouyer CMD_LEVEL,
117 1.3.2.2 bouyer CMD_LIST,
118 1.3.2.2 bouyer CMD_LOAD,
119 1.3.2.2 bouyer CMD_LOCALS,
120 1.3.2.2 bouyer CMD_LOCKS,
121 1.3.2.2 bouyer CMD_METHODS,
122 1.3.2.2 bouyer CMD_NAMESPACE,
123 1.3.2.2 bouyer CMD_NOTIFY,
124 1.3.2.2 bouyer CMD_OBJECT,
125 1.3.2.2 bouyer CMD_OPEN,
126 1.3.2.2 bouyer CMD_OSI,
127 1.3.2.2 bouyer CMD_OWNER,
128 1.3.2.2 bouyer CMD_PREDEFINED,
129 1.3.2.2 bouyer CMD_PREFIX,
130 1.3.2.2 bouyer CMD_QUIT,
131 1.3.2.2 bouyer CMD_REFERENCES,
132 1.3.2.2 bouyer CMD_RESOURCES,
133 1.3.2.2 bouyer CMD_RESULTS,
134 1.3.2.2 bouyer CMD_SET,
135 1.3.2.2 bouyer CMD_SLEEP,
136 1.3.2.2 bouyer CMD_STATS,
137 1.3.2.2 bouyer CMD_STOP,
138 1.3.2.2 bouyer CMD_TABLES,
139 1.3.2.2 bouyer CMD_TERMINATE,
140 1.3.2.2 bouyer CMD_THREADS,
141 1.3.2.2 bouyer CMD_TRACE,
142 1.3.2.2 bouyer CMD_TREE,
143 1.3.2.2 bouyer CMD_TYPE,
144 1.3.2.2 bouyer CMD_UNLOAD
145 1.3.2.2 bouyer };
146 1.3.2.2 bouyer
147 1.3.2.2 bouyer #define CMD_FIRST_VALID 2
148 1.3.2.2 bouyer
149 1.3.2.2 bouyer
150 1.3.2.2 bouyer /* Second parameter is the required argument count */
151 1.3.2.2 bouyer
152 1.3.2.2 bouyer static const COMMAND_INFO AcpiGbl_DbCommands[] =
153 1.3.2.2 bouyer {
154 1.3.2.2 bouyer {"<NOT FOUND>", 0},
155 1.3.2.2 bouyer {"<NULL>", 0},
156 1.3.2.2 bouyer {"ALLOCATIONS", 0},
157 1.3.2.2 bouyer {"ARGS", 0},
158 1.3.2.2 bouyer {"ARGUMENTS", 0},
159 1.3.2.2 bouyer {"BATCH", 0},
160 1.3.2.2 bouyer {"BREAKPOINT", 1},
161 1.3.2.2 bouyer {"BUSINFO", 0},
162 1.3.2.2 bouyer {"CALL", 0},
163 1.3.2.2 bouyer {"CLOSE", 0},
164 1.3.2.2 bouyer {"DEBUG", 1},
165 1.3.2.2 bouyer {"DISASSEMBLE", 1},
166 1.3.2.2 bouyer {"DUMP", 1},
167 1.3.2.2 bouyer {"ENABLEACPI", 0},
168 1.3.2.2 bouyer {"EVENT", 1},
169 1.3.2.2 bouyer {"EXECUTE", 1},
170 1.3.2.2 bouyer {"EXIT", 0},
171 1.3.2.2 bouyer {"FIND", 1},
172 1.3.2.2 bouyer {"GO", 0},
173 1.3.2.2 bouyer {"GPE", 2},
174 1.3.2.2 bouyer {"GPES", 0},
175 1.3.2.2 bouyer {"HANDLERS", 0},
176 1.3.2.2 bouyer {"HELP", 0},
177 1.3.2.2 bouyer {"?", 0},
178 1.3.2.2 bouyer {"HISTORY", 0},
179 1.3.2.2 bouyer {"!", 1},
180 1.3.2.2 bouyer {"!!", 0},
181 1.3.2.2 bouyer {"INFORMATION", 0},
182 1.3.2.2 bouyer {"INTEGRITY", 0},
183 1.3.2.2 bouyer {"INTO", 0},
184 1.3.2.2 bouyer {"LEVEL", 0},
185 1.3.2.2 bouyer {"LIST", 0},
186 1.3.2.2 bouyer {"LOAD", 1},
187 1.3.2.2 bouyer {"LOCALS", 0},
188 1.3.2.2 bouyer {"LOCKS", 0},
189 1.3.2.2 bouyer {"METHODS", 0},
190 1.3.2.2 bouyer {"NAMESPACE", 0},
191 1.3.2.2 bouyer {"NOTIFY", 2},
192 1.3.2.2 bouyer {"OBJECT", 1},
193 1.3.2.2 bouyer {"OPEN", 1},
194 1.3.2.2 bouyer {"OSI", 0},
195 1.3.2.2 bouyer {"OWNER", 1},
196 1.3.2.2 bouyer {"PREDEFINED", 0},
197 1.3.2.2 bouyer {"PREFIX", 0},
198 1.3.2.2 bouyer {"QUIT", 0},
199 1.3.2.2 bouyer {"REFERENCES", 1},
200 1.3.2.2 bouyer {"RESOURCES", 1},
201 1.3.2.2 bouyer {"RESULTS", 0},
202 1.3.2.2 bouyer {"SET", 3},
203 1.3.2.2 bouyer {"SLEEP", 1},
204 1.3.2.2 bouyer {"STATS", 0},
205 1.3.2.2 bouyer {"STOP", 0},
206 1.3.2.2 bouyer {"TABLES", 0},
207 1.3.2.2 bouyer {"TERMINATE", 0},
208 1.3.2.2 bouyer {"THREADS", 3},
209 1.3.2.2 bouyer {"TRACE", 1},
210 1.3.2.2 bouyer {"TREE", 0},
211 1.3.2.2 bouyer {"TYPE", 1},
212 1.3.2.2 bouyer {"UNLOAD", 1},
213 1.3.2.2 bouyer {NULL, 0}
214 1.3.2.2 bouyer };
215 1.3.2.2 bouyer
216 1.3.2.2 bouyer
217 1.3.2.2 bouyer /*******************************************************************************
218 1.3.2.2 bouyer *
219 1.3.2.2 bouyer * FUNCTION: AcpiDbDisplayHelp
220 1.3.2.2 bouyer *
221 1.3.2.2 bouyer * PARAMETERS: None
222 1.3.2.2 bouyer *
223 1.3.2.2 bouyer * RETURN: None
224 1.3.2.2 bouyer *
225 1.3.2.2 bouyer * DESCRIPTION: Print a usage message.
226 1.3.2.2 bouyer *
227 1.3.2.2 bouyer ******************************************************************************/
228 1.3.2.2 bouyer
229 1.3.2.2 bouyer static void
230 1.3.2.2 bouyer AcpiDbDisplayHelp (
231 1.3.2.2 bouyer void)
232 1.3.2.2 bouyer {
233 1.3.2.2 bouyer
234 1.3.2.2 bouyer AcpiOsPrintf ("\nGeneral-Purpose Commands:\n");
235 1.3.2.2 bouyer AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
236 1.3.2.2 bouyer AcpiOsPrintf (" Dump <Address>|<Namepath>\n");
237 1.3.2.2 bouyer AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
238 1.3.2.2 bouyer AcpiOsPrintf (" EnableAcpi Enable ACPI (hardware) mode\n");
239 1.3.2.2 bouyer AcpiOsPrintf (" Handlers Info about global handlers\n");
240 1.3.2.2 bouyer AcpiOsPrintf (" Help This help screen\n");
241 1.3.2.2 bouyer AcpiOsPrintf (" History Display command history buffer\n");
242 1.3.2.2 bouyer AcpiOsPrintf (" Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
243 1.3.2.2 bouyer AcpiOsPrintf (" Locks Current status of internal mutexes\n");
244 1.3.2.2 bouyer AcpiOsPrintf (" Osi [Install|Remove <name>] Display or modify global _OSI list\n");
245 1.3.2.2 bouyer AcpiOsPrintf (" Quit or Exit Exit this command\n");
246 1.3.2.2 bouyer AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n");
247 1.3.2.2 bouyer AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
248 1.3.2.2 bouyer AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
249 1.3.2.2 bouyer AcpiOsPrintf (" Memory Dump internal memory lists\n");
250 1.3.2.2 bouyer AcpiOsPrintf (" Misc Namespace search and mutex stats\n");
251 1.3.2.2 bouyer AcpiOsPrintf (" Objects Summary of namespace objects\n");
252 1.3.2.2 bouyer AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n");
253 1.3.2.2 bouyer AcpiOsPrintf (" Stack Display CPU stack usage\n");
254 1.3.2.2 bouyer AcpiOsPrintf (" Tables Info about current ACPI table(s)\n");
255 1.3.2.2 bouyer AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n");
256 1.3.2.2 bouyer AcpiOsPrintf (" Unload <TableSig> [Instance] Unload an ACPI table\n");
257 1.3.2.2 bouyer AcpiOsPrintf (" ! <CommandNumber> Execute command from history buffer\n");
258 1.3.2.2 bouyer AcpiOsPrintf (" !! Execute last command again\n");
259 1.3.2.2 bouyer
260 1.3.2.2 bouyer AcpiOsPrintf ("\nNamespace Access Commands:\n");
261 1.3.2.2 bouyer AcpiOsPrintf (" Businfo Display system bus info\n");
262 1.3.2.2 bouyer AcpiOsPrintf (" Disassemble <Method> Disassemble a control method\n");
263 1.3.2.2 bouyer AcpiOsPrintf (" Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
264 1.3.2.2 bouyer AcpiOsPrintf (" Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
265 1.3.2.2 bouyer AcpiOsPrintf (" Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
266 1.3.2.2 bouyer AcpiOsPrintf (" Gpes Display info on all GPEs\n");
267 1.3.2.2 bouyer AcpiOsPrintf (" Integrity Validate namespace integrity\n");
268 1.3.2.2 bouyer AcpiOsPrintf (" Methods Display list of loaded control methods\n");
269 1.3.2.2 bouyer AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
270 1.3.2.2 bouyer AcpiOsPrintf (" Notify <Object> <Value> Send a notification on Object\n");
271 1.3.2.2 bouyer AcpiOsPrintf (" Objects <ObjectType> Display all objects of the given type\n");
272 1.3.2.2 bouyer AcpiOsPrintf (" Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
273 1.3.2.2 bouyer AcpiOsPrintf (" Predefined Check all predefined names\n");
274 1.3.2.2 bouyer AcpiOsPrintf (" Prefix [<NamePath>] Set or Get current execution prefix\n");
275 1.3.2.2 bouyer AcpiOsPrintf (" References <Addr> Find all references to object at addr\n");
276 1.3.2.2 bouyer AcpiOsPrintf (" Resources <Device> Get and display Device resources\n");
277 1.3.2.2 bouyer AcpiOsPrintf (" Set N <NamedObject> <Value> Set value for named integer\n");
278 1.3.2.2 bouyer AcpiOsPrintf (" Sleep <SleepState> Simulate sleep/wake sequence\n");
279 1.3.2.2 bouyer AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n");
280 1.3.2.2 bouyer AcpiOsPrintf (" Type <Object> Display object type\n");
281 1.3.2.2 bouyer
282 1.3.2.2 bouyer AcpiOsPrintf ("\nControl Method Execution Commands:\n");
283 1.3.2.2 bouyer AcpiOsPrintf (" Arguments (or Args) Display method arguments\n");
284 1.3.2.2 bouyer AcpiOsPrintf (" Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
285 1.3.2.2 bouyer AcpiOsPrintf (" Call Run to next control method invocation\n");
286 1.3.2.2 bouyer AcpiOsPrintf (" Debug <Namepath> [Arguments] Single Step a control method\n");
287 1.3.2.2 bouyer AcpiOsPrintf (" Execute <Namepath> [Arguments] Execute control method\n");
288 1.3.2.2 bouyer AcpiOsPrintf (" Go Allow method to run to completion\n");
289 1.3.2.2 bouyer AcpiOsPrintf (" Information Display info about the current method\n");
290 1.3.2.2 bouyer AcpiOsPrintf (" Into Step into (not over) a method call\n");
291 1.3.2.2 bouyer AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n");
292 1.3.2.2 bouyer AcpiOsPrintf (" Locals Display method local variables\n");
293 1.3.2.2 bouyer AcpiOsPrintf (" Results Display method result stack\n");
294 1.3.2.2 bouyer AcpiOsPrintf (" Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
295 1.3.2.2 bouyer AcpiOsPrintf (" Stop Terminate control method\n");
296 1.3.2.2 bouyer AcpiOsPrintf (" Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
297 1.3.2.2 bouyer AcpiOsPrintf (" Trace <method name> Trace method execution\n");
298 1.3.2.2 bouyer AcpiOsPrintf (" Tree Display control method calling tree\n");
299 1.3.2.2 bouyer AcpiOsPrintf (" <Enter> Single step next AML opcode (over calls)\n");
300 1.3.2.2 bouyer
301 1.3.2.2 bouyer AcpiOsPrintf ("\nFile I/O Commands:\n");
302 1.3.2.2 bouyer AcpiOsPrintf (" Close Close debug output file\n");
303 1.3.2.2 bouyer AcpiOsPrintf (" Load <Input Filename> Load ACPI table from a file\n");
304 1.3.2.2 bouyer AcpiOsPrintf (" Open <Output Filename> Open a file for debug output\n");
305 1.3.2.2 bouyer }
306 1.3.2.2 bouyer
307 1.3.2.2 bouyer
308 1.3.2.2 bouyer /*******************************************************************************
309 1.3.2.2 bouyer *
310 1.3.2.2 bouyer * FUNCTION: AcpiDbGetNextToken
311 1.3.2.2 bouyer *
312 1.3.2.2 bouyer * PARAMETERS: String - Command buffer
313 1.3.2.2 bouyer * Next - Return value, end of next token
314 1.3.2.2 bouyer *
315 1.3.2.2 bouyer * RETURN: Pointer to the start of the next token.
316 1.3.2.2 bouyer *
317 1.3.2.2 bouyer * DESCRIPTION: Command line parsing. Get the next token on the command line
318 1.3.2.2 bouyer *
319 1.3.2.2 bouyer ******************************************************************************/
320 1.3.2.2 bouyer
321 1.3.2.2 bouyer static char *
322 1.3.2.2 bouyer AcpiDbGetNextToken (
323 1.3.2.2 bouyer char *String,
324 1.3.2.2 bouyer char **Next)
325 1.3.2.2 bouyer {
326 1.3.2.2 bouyer char *Start;
327 1.3.2.2 bouyer
328 1.3.2.2 bouyer
329 1.3.2.2 bouyer /* At end of buffer? */
330 1.3.2.2 bouyer
331 1.3.2.2 bouyer if (!String || !(*String))
332 1.3.2.2 bouyer {
333 1.3.2.2 bouyer return (NULL);
334 1.3.2.2 bouyer }
335 1.3.2.2 bouyer
336 1.3.2.2 bouyer /* Get rid of any spaces at the beginning */
337 1.3.2.2 bouyer
338 1.3.2.2 bouyer if (*String == ' ')
339 1.3.2.2 bouyer {
340 1.3.2.2 bouyer while (*String && (*String == ' '))
341 1.3.2.2 bouyer {
342 1.3.2.2 bouyer String++;
343 1.3.2.2 bouyer }
344 1.3.2.2 bouyer
345 1.3.2.2 bouyer if (!(*String))
346 1.3.2.2 bouyer {
347 1.3.2.2 bouyer return (NULL);
348 1.3.2.2 bouyer }
349 1.3.2.2 bouyer }
350 1.3.2.2 bouyer
351 1.3.2.2 bouyer if (*String == '"')
352 1.3.2.2 bouyer {
353 1.3.2.2 bouyer /* This is a quoted string, scan until closing quote */
354 1.3.2.2 bouyer
355 1.3.2.2 bouyer String++;
356 1.3.2.2 bouyer Start = String;
357 1.3.2.2 bouyer
358 1.3.2.2 bouyer /* Find end of token */
359 1.3.2.2 bouyer
360 1.3.2.2 bouyer while (*String && (*String != '"'))
361 1.3.2.2 bouyer {
362 1.3.2.2 bouyer String++;
363 1.3.2.2 bouyer }
364 1.3.2.2 bouyer }
365 1.3.2.2 bouyer else
366 1.3.2.2 bouyer {
367 1.3.2.2 bouyer Start = String;
368 1.3.2.2 bouyer
369 1.3.2.2 bouyer /* Find end of token */
370 1.3.2.2 bouyer
371 1.3.2.2 bouyer while (*String && (*String != ' '))
372 1.3.2.2 bouyer {
373 1.3.2.2 bouyer String++;
374 1.3.2.2 bouyer }
375 1.3.2.2 bouyer }
376 1.3.2.2 bouyer
377 1.3.2.2 bouyer if (!(*String))
378 1.3.2.2 bouyer {
379 1.3.2.2 bouyer *Next = NULL;
380 1.3.2.2 bouyer }
381 1.3.2.2 bouyer else
382 1.3.2.2 bouyer {
383 1.3.2.2 bouyer *String = 0;
384 1.3.2.2 bouyer *Next = String + 1;
385 1.3.2.2 bouyer }
386 1.3.2.2 bouyer
387 1.3.2.2 bouyer return (Start);
388 1.3.2.2 bouyer }
389 1.3.2.2 bouyer
390 1.3.2.2 bouyer
391 1.3.2.2 bouyer /*******************************************************************************
392 1.3.2.2 bouyer *
393 1.3.2.2 bouyer * FUNCTION: AcpiDbGetLine
394 1.3.2.2 bouyer *
395 1.3.2.2 bouyer * PARAMETERS: InputBuffer - Command line buffer
396 1.3.2.2 bouyer *
397 1.3.2.2 bouyer * RETURN: Count of arguments to the command
398 1.3.2.2 bouyer *
399 1.3.2.2 bouyer * DESCRIPTION: Get the next command line from the user. Gets entire line
400 1.3.2.2 bouyer * up to the next newline
401 1.3.2.2 bouyer *
402 1.3.2.2 bouyer ******************************************************************************/
403 1.3.2.2 bouyer
404 1.3.2.2 bouyer static UINT32
405 1.3.2.2 bouyer AcpiDbGetLine (
406 1.3.2.2 bouyer char *InputBuffer)
407 1.3.2.2 bouyer {
408 1.3.2.2 bouyer UINT32 i;
409 1.3.2.2 bouyer UINT32 Count;
410 1.3.2.2 bouyer char *Next;
411 1.3.2.2 bouyer char *This;
412 1.3.2.2 bouyer
413 1.3.2.2 bouyer
414 1.3.2.2 bouyer ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
415 1.3.2.2 bouyer
416 1.3.2.2 bouyer This = AcpiGbl_DbParsedBuf;
417 1.3.2.2 bouyer for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
418 1.3.2.2 bouyer {
419 1.3.2.2 bouyer AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next);
420 1.3.2.2 bouyer if (!AcpiGbl_DbArgs[i])
421 1.3.2.2 bouyer {
422 1.3.2.2 bouyer break;
423 1.3.2.2 bouyer }
424 1.3.2.2 bouyer
425 1.3.2.2 bouyer This = Next;
426 1.3.2.2 bouyer }
427 1.3.2.2 bouyer
428 1.3.2.2 bouyer /* Uppercase the actual command */
429 1.3.2.2 bouyer
430 1.3.2.2 bouyer if (AcpiGbl_DbArgs[0])
431 1.3.2.2 bouyer {
432 1.3.2.2 bouyer AcpiUtStrupr (AcpiGbl_DbArgs[0]);
433 1.3.2.2 bouyer }
434 1.3.2.2 bouyer
435 1.3.2.2 bouyer Count = i;
436 1.3.2.2 bouyer if (Count)
437 1.3.2.2 bouyer {
438 1.3.2.2 bouyer Count--; /* Number of args only */
439 1.3.2.2 bouyer }
440 1.3.2.2 bouyer
441 1.3.2.2 bouyer return (Count);
442 1.3.2.2 bouyer }
443 1.3.2.2 bouyer
444 1.3.2.2 bouyer
445 1.3.2.2 bouyer /*******************************************************************************
446 1.3.2.2 bouyer *
447 1.3.2.2 bouyer * FUNCTION: AcpiDbMatchCommand
448 1.3.2.2 bouyer *
449 1.3.2.2 bouyer * PARAMETERS: UserCommand - User command line
450 1.3.2.2 bouyer *
451 1.3.2.2 bouyer * RETURN: Index into command array, -1 if not found
452 1.3.2.2 bouyer *
453 1.3.2.2 bouyer * DESCRIPTION: Search command array for a command match
454 1.3.2.2 bouyer *
455 1.3.2.2 bouyer ******************************************************************************/
456 1.3.2.2 bouyer
457 1.3.2.2 bouyer static UINT32
458 1.3.2.2 bouyer AcpiDbMatchCommand (
459 1.3.2.2 bouyer char *UserCommand)
460 1.3.2.2 bouyer {
461 1.3.2.2 bouyer UINT32 i;
462 1.3.2.2 bouyer
463 1.3.2.2 bouyer
464 1.3.2.2 bouyer if (!UserCommand || UserCommand[0] == 0)
465 1.3.2.2 bouyer {
466 1.3.2.2 bouyer return (CMD_NULL);
467 1.3.2.2 bouyer }
468 1.3.2.2 bouyer
469 1.3.2.2 bouyer for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
470 1.3.2.2 bouyer {
471 1.3.2.2 bouyer if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
472 1.3.2.2 bouyer AcpiGbl_DbCommands[i].Name)
473 1.3.2.2 bouyer {
474 1.3.2.2 bouyer return (i);
475 1.3.2.2 bouyer }
476 1.3.2.2 bouyer }
477 1.3.2.2 bouyer
478 1.3.2.2 bouyer /* Command not recognized */
479 1.3.2.2 bouyer
480 1.3.2.2 bouyer return (CMD_NOT_FOUND);
481 1.3.2.2 bouyer }
482 1.3.2.2 bouyer
483 1.3.2.2 bouyer
484 1.3.2.2 bouyer /*******************************************************************************
485 1.3.2.2 bouyer *
486 1.3.2.2 bouyer * FUNCTION: AcpiDbCommandDispatch
487 1.3.2.2 bouyer *
488 1.3.2.2 bouyer * PARAMETERS: InputBuffer - Command line buffer
489 1.3.2.2 bouyer * WalkState - Current walk
490 1.3.2.2 bouyer * Op - Current (executing) parse op
491 1.3.2.2 bouyer *
492 1.3.2.2 bouyer * RETURN: Status
493 1.3.2.2 bouyer *
494 1.3.2.2 bouyer * DESCRIPTION: Command dispatcher.
495 1.3.2.2 bouyer *
496 1.3.2.2 bouyer ******************************************************************************/
497 1.3.2.2 bouyer
498 1.3.2.2 bouyer ACPI_STATUS
499 1.3.2.2 bouyer AcpiDbCommandDispatch (
500 1.3.2.2 bouyer char *InputBuffer,
501 1.3.2.2 bouyer ACPI_WALK_STATE *WalkState,
502 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Op)
503 1.3.2.2 bouyer {
504 1.3.2.2 bouyer UINT32 Temp;
505 1.3.2.2 bouyer UINT32 CommandIndex;
506 1.3.2.2 bouyer UINT32 ParamCount;
507 1.3.2.2 bouyer char *CommandLine;
508 1.3.2.2 bouyer ACPI_STATUS Status = AE_CTRL_TRUE;
509 1.3.2.2 bouyer
510 1.3.2.2 bouyer
511 1.3.2.2 bouyer /* If AcpiTerminate has been called, terminate this thread */
512 1.3.2.2 bouyer
513 1.3.2.2 bouyer if (AcpiGbl_DbTerminateThreads)
514 1.3.2.2 bouyer {
515 1.3.2.2 bouyer return (AE_CTRL_TERMINATE);
516 1.3.2.2 bouyer }
517 1.3.2.2 bouyer
518 1.3.2.2 bouyer ParamCount = AcpiDbGetLine (InputBuffer);
519 1.3.2.2 bouyer CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
520 1.3.2.2 bouyer Temp = 0;
521 1.3.2.2 bouyer
522 1.3.2.2 bouyer /* Verify that we have the minimum number of params */
523 1.3.2.2 bouyer
524 1.3.2.2 bouyer if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
525 1.3.2.2 bouyer {
526 1.3.2.2 bouyer AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
527 1.3.2.2 bouyer ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
528 1.3.2.2 bouyer AcpiGbl_DbCommands[CommandIndex].MinArgs);
529 1.3.2.2 bouyer
530 1.3.2.2 bouyer return (AE_CTRL_TRUE);
531 1.3.2.2 bouyer }
532 1.3.2.2 bouyer
533 1.3.2.2 bouyer /* Decode and dispatch the command */
534 1.3.2.2 bouyer
535 1.3.2.2 bouyer switch (CommandIndex)
536 1.3.2.2 bouyer {
537 1.3.2.2 bouyer case CMD_NULL:
538 1.3.2.2 bouyer if (Op)
539 1.3.2.2 bouyer {
540 1.3.2.2 bouyer return (AE_OK);
541 1.3.2.2 bouyer }
542 1.3.2.2 bouyer break;
543 1.3.2.2 bouyer
544 1.3.2.2 bouyer case CMD_ALLOCATIONS:
545 1.3.2.2 bouyer
546 1.3.2.2 bouyer #ifdef ACPI_DBG_TRACK_ALLOCATIONS
547 1.3.2.2 bouyer AcpiUtDumpAllocations ((UINT32) -1, NULL);
548 1.3.2.2 bouyer #endif
549 1.3.2.2 bouyer break;
550 1.3.2.2 bouyer
551 1.3.2.2 bouyer case CMD_ARGS:
552 1.3.2.2 bouyer case CMD_ARGUMENTS:
553 1.3.2.2 bouyer AcpiDbDisplayArguments ();
554 1.3.2.2 bouyer break;
555 1.3.2.2 bouyer
556 1.3.2.2 bouyer case CMD_BATCH:
557 1.3.2.2 bouyer AcpiDbBatchExecute (AcpiGbl_DbArgs[1]);
558 1.3.2.2 bouyer break;
559 1.3.2.2 bouyer
560 1.3.2.2 bouyer case CMD_BREAKPOINT:
561 1.3.2.2 bouyer AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
562 1.3.2.2 bouyer break;
563 1.3.2.2 bouyer
564 1.3.2.2 bouyer case CMD_BUSINFO:
565 1.3.2.2 bouyer AcpiDbGetBusInfo ();
566 1.3.2.2 bouyer break;
567 1.3.2.2 bouyer
568 1.3.2.2 bouyer case CMD_CALL:
569 1.3.2.2 bouyer AcpiDbSetMethodCallBreakpoint (Op);
570 1.3.2.2 bouyer Status = AE_OK;
571 1.3.2.2 bouyer break;
572 1.3.2.2 bouyer
573 1.3.2.2 bouyer case CMD_CLOSE:
574 1.3.2.2 bouyer AcpiDbCloseDebugFile ();
575 1.3.2.2 bouyer break;
576 1.3.2.2 bouyer
577 1.3.2.2 bouyer case CMD_DEBUG:
578 1.3.2.2 bouyer AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP);
579 1.3.2.2 bouyer break;
580 1.3.2.2 bouyer
581 1.3.2.2 bouyer case CMD_DISASSEMBLE:
582 1.3.2.2 bouyer (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
583 1.3.2.2 bouyer break;
584 1.3.2.2 bouyer
585 1.3.2.2 bouyer case CMD_DUMP:
586 1.3.2.2 bouyer AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
587 1.3.2.2 bouyer break;
588 1.3.2.2 bouyer
589 1.3.2.2 bouyer case CMD_ENABLEACPI:
590 1.3.2.2 bouyer Status = AcpiEnable();
591 1.3.2.2 bouyer if (ACPI_FAILURE(Status))
592 1.3.2.2 bouyer {
593 1.3.2.2 bouyer AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
594 1.3.2.2 bouyer return (Status);
595 1.3.2.2 bouyer }
596 1.3.2.2 bouyer break;
597 1.3.2.2 bouyer
598 1.3.2.2 bouyer case CMD_EVENT:
599 1.3.2.2 bouyer AcpiOsPrintf ("Event command not implemented\n");
600 1.3.2.2 bouyer break;
601 1.3.2.2 bouyer
602 1.3.2.2 bouyer case CMD_EXECUTE:
603 1.3.2.2 bouyer AcpiDbExecute (AcpiGbl_DbArgs[1],
604 1.3.2.2 bouyer &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP);
605 1.3.2.2 bouyer break;
606 1.3.2.2 bouyer
607 1.3.2.2 bouyer case CMD_FIND:
608 1.3.2.2 bouyer Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
609 1.3.2.2 bouyer break;
610 1.3.2.2 bouyer
611 1.3.2.2 bouyer case CMD_GO:
612 1.3.2.2 bouyer AcpiGbl_CmSingleStep = FALSE;
613 1.3.2.2 bouyer return (AE_OK);
614 1.3.2.2 bouyer
615 1.3.2.2 bouyer case CMD_GPE:
616 1.3.2.2 bouyer AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
617 1.3.2.2 bouyer break;
618 1.3.2.2 bouyer
619 1.3.2.2 bouyer case CMD_GPES:
620 1.3.2.2 bouyer AcpiDbDisplayGpes ();
621 1.3.2.2 bouyer break;
622 1.3.2.2 bouyer
623 1.3.2.2 bouyer case CMD_HANDLERS:
624 1.3.2.2 bouyer AcpiDbDisplayHandlers ();
625 1.3.2.2 bouyer break;
626 1.3.2.2 bouyer
627 1.3.2.2 bouyer case CMD_HELP:
628 1.3.2.2 bouyer case CMD_HELP2:
629 1.3.2.2 bouyer AcpiDbDisplayHelp ();
630 1.3.2.2 bouyer break;
631 1.3.2.2 bouyer
632 1.3.2.2 bouyer case CMD_HISTORY:
633 1.3.2.2 bouyer AcpiDbDisplayHistory ();
634 1.3.2.2 bouyer break;
635 1.3.2.2 bouyer
636 1.3.2.2 bouyer case CMD_HISTORY_EXE:
637 1.3.2.2 bouyer CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
638 1.3.2.2 bouyer if (!CommandLine)
639 1.3.2.2 bouyer {
640 1.3.2.2 bouyer return (AE_CTRL_TRUE);
641 1.3.2.2 bouyer }
642 1.3.2.2 bouyer
643 1.3.2.2 bouyer Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
644 1.3.2.2 bouyer return (Status);
645 1.3.2.2 bouyer
646 1.3.2.2 bouyer case CMD_HISTORY_LAST:
647 1.3.2.2 bouyer CommandLine = AcpiDbGetFromHistory (NULL);
648 1.3.2.2 bouyer if (!CommandLine)
649 1.3.2.2 bouyer {
650 1.3.2.2 bouyer return (AE_CTRL_TRUE);
651 1.3.2.2 bouyer }
652 1.3.2.2 bouyer
653 1.3.2.2 bouyer Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
654 1.3.2.2 bouyer return (Status);
655 1.3.2.2 bouyer
656 1.3.2.2 bouyer case CMD_INFORMATION:
657 1.3.2.2 bouyer AcpiDbDisplayMethodInfo (Op);
658 1.3.2.2 bouyer break;
659 1.3.2.2 bouyer
660 1.3.2.2 bouyer case CMD_INTEGRITY:
661 1.3.2.2 bouyer AcpiDbCheckIntegrity ();
662 1.3.2.2 bouyer break;
663 1.3.2.2 bouyer
664 1.3.2.2 bouyer case CMD_INTO:
665 1.3.2.2 bouyer if (Op)
666 1.3.2.2 bouyer {
667 1.3.2.2 bouyer AcpiGbl_CmSingleStep = TRUE;
668 1.3.2.2 bouyer return (AE_OK);
669 1.3.2.2 bouyer }
670 1.3.2.2 bouyer break;
671 1.3.2.2 bouyer
672 1.3.2.2 bouyer case CMD_LEVEL:
673 1.3.2.2 bouyer if (ParamCount == 0)
674 1.3.2.2 bouyer {
675 1.3.2.2 bouyer AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n",
676 1.3.2.2 bouyer AcpiGbl_DbDebugLevel);
677 1.3.2.2 bouyer AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n",
678 1.3.2.2 bouyer AcpiGbl_DbConsoleDebugLevel);
679 1.3.2.2 bouyer }
680 1.3.2.2 bouyer else if (ParamCount == 2)
681 1.3.2.2 bouyer {
682 1.3.2.2 bouyer Temp = AcpiGbl_DbConsoleDebugLevel;
683 1.3.2.2 bouyer AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1],
684 1.3.2.2 bouyer NULL, 16);
685 1.3.2.2 bouyer AcpiOsPrintf (
686 1.3.2.2 bouyer "Debug Level for console output was %8.8lX, now %8.8lX\n",
687 1.3.2.2 bouyer Temp, AcpiGbl_DbConsoleDebugLevel);
688 1.3.2.2 bouyer }
689 1.3.2.2 bouyer else
690 1.3.2.2 bouyer {
691 1.3.2.2 bouyer Temp = AcpiGbl_DbDebugLevel;
692 1.3.2.2 bouyer AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
693 1.3.2.2 bouyer AcpiOsPrintf (
694 1.3.2.2 bouyer "Debug Level for file output was %8.8lX, now %8.8lX\n",
695 1.3.2.2 bouyer Temp, AcpiGbl_DbDebugLevel);
696 1.3.2.2 bouyer }
697 1.3.2.2 bouyer break;
698 1.3.2.2 bouyer
699 1.3.2.2 bouyer case CMD_LIST:
700 1.3.2.2 bouyer AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
701 1.3.2.2 bouyer break;
702 1.3.2.2 bouyer
703 1.3.2.2 bouyer case CMD_LOAD:
704 1.3.2.2 bouyer Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
705 1.3.2.2 bouyer break;
706 1.3.2.2 bouyer
707 1.3.2.2 bouyer case CMD_LOCKS:
708 1.3.2.2 bouyer AcpiDbDisplayLocks ();
709 1.3.2.2 bouyer break;
710 1.3.2.2 bouyer
711 1.3.2.2 bouyer case CMD_LOCALS:
712 1.3.2.2 bouyer AcpiDbDisplayLocals ();
713 1.3.2.2 bouyer break;
714 1.3.2.2 bouyer
715 1.3.2.2 bouyer case CMD_METHODS:
716 1.3.2.2 bouyer Status = AcpiDbDisplayObjects (__UNCONST("METHOD"), AcpiGbl_DbArgs[1]);
717 1.3.2.2 bouyer break;
718 1.3.2.2 bouyer
719 1.3.2.2 bouyer case CMD_NAMESPACE:
720 1.3.2.2 bouyer AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
721 1.3.2.2 bouyer break;
722 1.3.2.2 bouyer
723 1.3.2.2 bouyer case CMD_NOTIFY:
724 1.3.2.2 bouyer Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
725 1.3.2.2 bouyer AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
726 1.3.2.2 bouyer break;
727 1.3.2.2 bouyer
728 1.3.2.2 bouyer case CMD_OBJECT:
729 1.3.2.2 bouyer AcpiUtStrupr (AcpiGbl_DbArgs[1]);
730 1.3.2.2 bouyer Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
731 1.3.2.2 bouyer break;
732 1.3.2.2 bouyer
733 1.3.2.2 bouyer case CMD_OPEN:
734 1.3.2.2 bouyer AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
735 1.3.2.2 bouyer break;
736 1.3.2.2 bouyer
737 1.3.2.2 bouyer case CMD_OSI:
738 1.3.2.2 bouyer AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
739 1.3.2.2 bouyer break;
740 1.3.2.2 bouyer
741 1.3.2.2 bouyer case CMD_OWNER:
742 1.3.2.2 bouyer AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
743 1.3.2.2 bouyer break;
744 1.3.2.2 bouyer
745 1.3.2.2 bouyer case CMD_PREDEFINED:
746 1.3.2.2 bouyer AcpiDbCheckPredefinedNames ();
747 1.3.2.2 bouyer break;
748 1.3.2.2 bouyer
749 1.3.2.2 bouyer case CMD_PREFIX:
750 1.3.2.2 bouyer AcpiDbSetScope (AcpiGbl_DbArgs[1]);
751 1.3.2.2 bouyer break;
752 1.3.2.2 bouyer
753 1.3.2.2 bouyer case CMD_REFERENCES:
754 1.3.2.2 bouyer AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
755 1.3.2.2 bouyer break;
756 1.3.2.2 bouyer
757 1.3.2.2 bouyer case CMD_RESOURCES:
758 1.3.2.2 bouyer AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
759 1.3.2.2 bouyer break;
760 1.3.2.2 bouyer
761 1.3.2.2 bouyer case CMD_RESULTS:
762 1.3.2.2 bouyer AcpiDbDisplayResults ();
763 1.3.2.2 bouyer break;
764 1.3.2.2 bouyer
765 1.3.2.2 bouyer case CMD_SET:
766 1.3.2.2 bouyer AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
767 1.3.2.2 bouyer AcpiGbl_DbArgs[3]);
768 1.3.2.2 bouyer break;
769 1.3.2.2 bouyer
770 1.3.2.2 bouyer case CMD_SLEEP:
771 1.3.2.2 bouyer Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
772 1.3.2.2 bouyer break;
773 1.3.2.2 bouyer
774 1.3.2.2 bouyer case CMD_STATS:
775 1.3.2.2 bouyer Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
776 1.3.2.2 bouyer break;
777 1.3.2.2 bouyer
778 1.3.2.2 bouyer case CMD_STOP:
779 1.3.2.2 bouyer return (AE_NOT_IMPLEMENTED);
780 1.3.2.2 bouyer
781 1.3.2.2 bouyer case CMD_TABLES:
782 1.3.2.2 bouyer AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
783 1.3.2.2 bouyer break;
784 1.3.2.2 bouyer
785 1.3.2.2 bouyer case CMD_TERMINATE:
786 1.3.2.2 bouyer AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
787 1.3.2.2 bouyer AcpiUtSubsystemShutdown ();
788 1.3.2.2 bouyer
789 1.3.2.2 bouyer /*
790 1.3.2.2 bouyer * TBD: [Restructure] Need some way to re-initialize without
791 1.3.2.2 bouyer * re-creating the semaphores!
792 1.3.2.2 bouyer */
793 1.3.2.2 bouyer
794 1.3.2.2 bouyer /* AcpiInitialize (NULL); */
795 1.3.2.2 bouyer break;
796 1.3.2.2 bouyer
797 1.3.2.2 bouyer case CMD_THREADS:
798 1.3.2.2 bouyer AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
799 1.3.2.2 bouyer AcpiGbl_DbArgs[3]);
800 1.3.2.2 bouyer break;
801 1.3.2.2 bouyer
802 1.3.2.2 bouyer case CMD_TRACE:
803 1.3.2.2 bouyer (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
804 1.3.2.2 bouyer break;
805 1.3.2.2 bouyer
806 1.3.2.2 bouyer case CMD_TREE:
807 1.3.2.2 bouyer AcpiDbDisplayCallingTree ();
808 1.3.2.2 bouyer break;
809 1.3.2.2 bouyer
810 1.3.2.2 bouyer case CMD_TYPE:
811 1.3.2.2 bouyer AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
812 1.3.2.2 bouyer break;
813 1.3.2.2 bouyer
814 1.3.2.2 bouyer case CMD_UNLOAD:
815 1.3.2.2 bouyer AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
816 1.3.2.2 bouyer break;
817 1.3.2.2 bouyer
818 1.3.2.2 bouyer case CMD_EXIT:
819 1.3.2.2 bouyer case CMD_QUIT:
820 1.3.2.2 bouyer if (Op)
821 1.3.2.2 bouyer {
822 1.3.2.2 bouyer AcpiOsPrintf ("Method execution terminated\n");
823 1.3.2.2 bouyer return (AE_CTRL_TERMINATE);
824 1.3.2.2 bouyer }
825 1.3.2.2 bouyer
826 1.3.2.2 bouyer if (!AcpiGbl_DbOutputToFile)
827 1.3.2.2 bouyer {
828 1.3.2.2 bouyer AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
829 1.3.2.2 bouyer }
830 1.3.2.2 bouyer
831 1.3.2.2 bouyer AcpiDbCloseDebugFile ();
832 1.3.2.2 bouyer AcpiGbl_DbTerminateThreads = TRUE;
833 1.3.2.2 bouyer return (AE_CTRL_TERMINATE);
834 1.3.2.2 bouyer
835 1.3.2.2 bouyer case CMD_NOT_FOUND:
836 1.3.2.2 bouyer default:
837 1.3.2.2 bouyer AcpiOsPrintf ("Unknown Command\n");
838 1.3.2.2 bouyer return (AE_CTRL_TRUE);
839 1.3.2.2 bouyer }
840 1.3.2.2 bouyer
841 1.3.2.2 bouyer if (ACPI_SUCCESS (Status))
842 1.3.2.2 bouyer {
843 1.3.2.2 bouyer Status = AE_CTRL_TRUE;
844 1.3.2.2 bouyer }
845 1.3.2.2 bouyer
846 1.3.2.2 bouyer /* Add all commands that come here to the history buffer */
847 1.3.2.2 bouyer
848 1.3.2.2 bouyer AcpiDbAddToHistory (InputBuffer);
849 1.3.2.2 bouyer return (Status);
850 1.3.2.2 bouyer }
851 1.3.2.2 bouyer
852 1.3.2.2 bouyer
853 1.3.2.2 bouyer /*******************************************************************************
854 1.3.2.2 bouyer *
855 1.3.2.2 bouyer * FUNCTION: AcpiDbExecuteThread
856 1.3.2.2 bouyer *
857 1.3.2.2 bouyer * PARAMETERS: Context - Not used
858 1.3.2.2 bouyer *
859 1.3.2.2 bouyer * RETURN: None
860 1.3.2.2 bouyer *
861 1.3.2.2 bouyer * DESCRIPTION: Debugger execute thread. Waits for a command line, then
862 1.3.2.2 bouyer * simply dispatches it.
863 1.3.2.2 bouyer *
864 1.3.2.2 bouyer ******************************************************************************/
865 1.3.2.2 bouyer
866 1.3.2.2 bouyer void ACPI_SYSTEM_XFACE
867 1.3.2.2 bouyer AcpiDbExecuteThread (
868 1.3.2.2 bouyer void *Context)
869 1.3.2.2 bouyer {
870 1.3.2.2 bouyer ACPI_STATUS Status = AE_OK;
871 1.3.2.2 bouyer ACPI_STATUS MStatus;
872 1.3.2.2 bouyer
873 1.3.2.2 bouyer
874 1.3.2.2 bouyer while (Status != AE_CTRL_TERMINATE)
875 1.3.2.2 bouyer {
876 1.3.2.2 bouyer AcpiGbl_MethodExecuting = FALSE;
877 1.3.2.2 bouyer AcpiGbl_StepToNextCall = FALSE;
878 1.3.2.2 bouyer
879 1.3.2.2 bouyer MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
880 1.3.2.2 bouyer if (ACPI_FAILURE (MStatus))
881 1.3.2.2 bouyer {
882 1.3.2.2 bouyer return;
883 1.3.2.2 bouyer }
884 1.3.2.2 bouyer
885 1.3.2.2 bouyer Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
886 1.3.2.2 bouyer
887 1.3.2.2 bouyer MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
888 1.3.2.2 bouyer if (ACPI_FAILURE (MStatus))
889 1.3.2.2 bouyer {
890 1.3.2.2 bouyer return;
891 1.3.2.2 bouyer }
892 1.3.2.2 bouyer }
893 1.3.2.2 bouyer }
894 1.3.2.2 bouyer
895 1.3.2.2 bouyer
896 1.3.2.2 bouyer /*******************************************************************************
897 1.3.2.2 bouyer *
898 1.3.2.2 bouyer * FUNCTION: AcpiDbSingleThread
899 1.3.2.2 bouyer *
900 1.3.2.2 bouyer * PARAMETERS: None
901 1.3.2.2 bouyer *
902 1.3.2.2 bouyer * RETURN: None
903 1.3.2.2 bouyer *
904 1.3.2.2 bouyer * DESCRIPTION: Debugger execute thread. Waits for a command line, then
905 1.3.2.2 bouyer * simply dispatches it.
906 1.3.2.2 bouyer *
907 1.3.2.2 bouyer ******************************************************************************/
908 1.3.2.2 bouyer
909 1.3.2.2 bouyer static void
910 1.3.2.2 bouyer AcpiDbSingleThread (
911 1.3.2.2 bouyer void)
912 1.3.2.2 bouyer {
913 1.3.2.2 bouyer
914 1.3.2.2 bouyer AcpiGbl_MethodExecuting = FALSE;
915 1.3.2.2 bouyer AcpiGbl_StepToNextCall = FALSE;
916 1.3.2.2 bouyer
917 1.3.2.2 bouyer (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
918 1.3.2.2 bouyer }
919 1.3.2.2 bouyer
920 1.3.2.2 bouyer
921 1.3.2.2 bouyer /*******************************************************************************
922 1.3.2.2 bouyer *
923 1.3.2.2 bouyer * FUNCTION: AcpiDbUserCommands
924 1.3.2.2 bouyer *
925 1.3.2.2 bouyer * PARAMETERS: Prompt - User prompt (depends on mode)
926 1.3.2.2 bouyer * Op - Current executing parse op
927 1.3.2.2 bouyer *
928 1.3.2.2 bouyer * RETURN: None
929 1.3.2.2 bouyer *
930 1.3.2.2 bouyer * DESCRIPTION: Command line execution for the AML debugger. Commands are
931 1.3.2.2 bouyer * matched and dispatched here.
932 1.3.2.2 bouyer *
933 1.3.2.2 bouyer ******************************************************************************/
934 1.3.2.2 bouyer
935 1.3.2.2 bouyer ACPI_STATUS
936 1.3.2.2 bouyer AcpiDbUserCommands (
937 1.3.2.2 bouyer char Prompt,
938 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Op)
939 1.3.2.2 bouyer {
940 1.3.2.2 bouyer ACPI_STATUS Status = AE_OK;
941 1.3.2.2 bouyer
942 1.3.2.2 bouyer
943 1.3.2.2 bouyer /* TBD: [Restructure] Need a separate command line buffer for step mode */
944 1.3.2.2 bouyer
945 1.3.2.2 bouyer while (!AcpiGbl_DbTerminateThreads)
946 1.3.2.2 bouyer {
947 1.3.2.2 bouyer /* Force output to console until a command is entered */
948 1.3.2.2 bouyer
949 1.3.2.2 bouyer AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
950 1.3.2.2 bouyer
951 1.3.2.2 bouyer /* Different prompt if method is executing */
952 1.3.2.2 bouyer
953 1.3.2.2 bouyer if (!AcpiGbl_MethodExecuting)
954 1.3.2.2 bouyer {
955 1.3.2.2 bouyer AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
956 1.3.2.2 bouyer }
957 1.3.2.2 bouyer else
958 1.3.2.2 bouyer {
959 1.3.2.2 bouyer AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
960 1.3.2.2 bouyer }
961 1.3.2.2 bouyer
962 1.3.2.2 bouyer /* Get the user input line */
963 1.3.2.2 bouyer
964 1.3.2.2 bouyer (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
965 1.3.2.2 bouyer
966 1.3.2.2 bouyer /* Check for single or multithreaded debug */
967 1.3.2.2 bouyer
968 1.3.2.2 bouyer if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
969 1.3.2.2 bouyer {
970 1.3.2.2 bouyer /*
971 1.3.2.2 bouyer * Signal the debug thread that we have a command to execute,
972 1.3.2.2 bouyer * and wait for the command to complete.
973 1.3.2.2 bouyer */
974 1.3.2.2 bouyer Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY);
975 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
976 1.3.2.2 bouyer {
977 1.3.2.2 bouyer return (Status);
978 1.3.2.2 bouyer }
979 1.3.2.2 bouyer
980 1.3.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
981 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
982 1.3.2.2 bouyer {
983 1.3.2.2 bouyer return (Status);
984 1.3.2.2 bouyer }
985 1.3.2.2 bouyer }
986 1.3.2.2 bouyer else
987 1.3.2.2 bouyer {
988 1.3.2.2 bouyer /* Just call to the command line interpreter */
989 1.3.2.2 bouyer
990 1.3.2.2 bouyer AcpiDbSingleThread ();
991 1.3.2.2 bouyer }
992 1.3.2.2 bouyer }
993 1.3.2.2 bouyer
994 1.3.2.2 bouyer /*
995 1.3.2.2 bouyer * Only this thread (the original thread) should actually terminate the
996 1.3.2.2 bouyer * subsystem, because all the semaphores are deleted during termination
997 1.3.2.2 bouyer */
998 1.3.2.2 bouyer Status = AcpiTerminate ();
999 1.3.2.2 bouyer return (Status);
1000 1.3.2.2 bouyer }
1001 1.3.2.2 bouyer
1002 1.3.2.2 bouyer #endif /* ACPI_DEBUGGER */
1003 1.3.2.2 bouyer
1004