dbinput.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. /*******************************************************************************
  2. *
  3. * Module Name: dbinput - user front-end to the AML debugger
  4. *
  5. ******************************************************************************/
  6. /******************************************************************************
  7. *
  8. * 1. Copyright Notice
  9. *
  10. * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
  11. * All rights reserved.
  12. *
  13. * 2. License
  14. *
  15. * 2.1. This is your license from Intel Corp. under its intellectual property
  16. * rights. You may have additional license terms from the party that provided
  17. * you this software, covering your right to use that party's intellectual
  18. * property rights.
  19. *
  20. * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
  21. * copy of the source code appearing in this file ("Covered Code") an
  22. * irrevocable, perpetual, worldwide license under Intel's copyrights in the
  23. * base code distributed originally by Intel ("Original Intel Code") to copy,
  24. * make derivatives, distribute, use and display any portion of the Covered
  25. * Code in any form, with the right to sublicense such rights; and
  26. *
  27. * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
  28. * license (with the right to sublicense), under only those claims of Intel
  29. * patents that are infringed by the Original Intel Code, to make, use, sell,
  30. * offer to sell, and import the Covered Code and derivative works thereof
  31. * solely to the minimum extent necessary to exercise the above copyright
  32. * license, and in no event shall the patent license extend to any additions
  33. * to or modifications of the Original Intel Code. No other license or right
  34. * is granted directly or by implication, estoppel or otherwise;
  35. *
  36. * The above copyright and patent license is granted only if the following
  37. * conditions are met:
  38. *
  39. * 3. Conditions
  40. *
  41. * 3.1. Redistribution of Source with Rights to Further Distribute Source.
  42. * Redistribution of source code of any substantial portion of the Covered
  43. * Code or modification with rights to further distribute source must include
  44. * the above Copyright Notice, the above License, this list of Conditions,
  45. * and the following Disclaimer and Export Compliance provision. In addition,
  46. * Licensee must cause all Covered Code to which Licensee contributes to
  47. * contain a file documenting the changes Licensee made to create that Covered
  48. * Code and the date of any change. Licensee must include in that file the
  49. * documentation of any changes made by any predecessor Licensee. Licensee
  50. * must include a prominent statement that the modification is derived,
  51. * directly or indirectly, from Original Intel Code.
  52. *
  53. * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
  54. * Redistribution of source code of any substantial portion of the Covered
  55. * Code or modification without rights to further distribute source must
  56. * include the following Disclaimer and Export Compliance provision in the
  57. * documentation and/or other materials provided with distribution. In
  58. * addition, Licensee may not authorize further sublicense of source of any
  59. * portion of the Covered Code, and must include terms to the effect that the
  60. * license from Licensee to its licensee is limited to the intellectual
  61. * property embodied in the software Licensee provides to its licensee, and
  62. * not to intellectual property embodied in modifications its licensee may
  63. * make.
  64. *
  65. * 3.3. Redistribution of Executable. Redistribution in executable form of any
  66. * substantial portion of the Covered Code or modification must reproduce the
  67. * above Copyright Notice, and the following Disclaimer and Export Compliance
  68. * provision in the documentation and/or other materials provided with the
  69. * distribution.
  70. *
  71. * 3.4. Intel retains all right, title, and interest in and to the Original
  72. * Intel Code.
  73. *
  74. * 3.5. Neither the name Intel nor any other trademark owned or controlled by
  75. * Intel shall be used in advertising or otherwise to promote the sale, use or
  76. * other dealings in products derived from or relating to the Covered Code
  77. * without prior written authorization from Intel.
  78. *
  79. * 4. Disclaimer and Export Compliance
  80. *
  81. * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
  82. * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
  83. * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
  84. * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
  85. * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
  86. * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
  87. * PARTICULAR PURPOSE.
  88. *
  89. * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
  90. * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
  91. * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
  92. * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
  93. * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
  94. * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
  95. * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
  96. * LIMITED REMEDY.
  97. *
  98. * 4.3. Licensee shall not export, either directly or indirectly, any of this
  99. * software or system incorporating such software without first obtaining any
  100. * required license or other approval from the U. S. Department of Commerce or
  101. * any other agency or department of the United States Government. In the
  102. * event Licensee exports any such software from the United States or
  103. * re-exports any such software from a foreign destination, Licensee shall
  104. * ensure that the distribution and export/re-export of the software is in
  105. * compliance with all laws, regulations, orders, or other restrictions of the
  106. * U.S. Export Administration Regulations. Licensee agrees that neither it nor
  107. * any of its subsidiaries will export/re-export any technical data, process,
  108. * software, or service, directly or indirectly, to any country for which the
  109. * United States government or any agency thereof requires an export license,
  110. * other governmental approval, or letter of assurance, without first obtaining
  111. * such license, approval or letter.
  112. *
  113. *****************************************************************************
  114. *
  115. * Alternatively, you may choose to be licensed under the terms of the
  116. * following license:
  117. *
  118. * Redistribution and use in source and binary forms, with or without
  119. * modification, are permitted provided that the following conditions
  120. * are met:
  121. * 1. Redistributions of source code must retain the above copyright
  122. * notice, this list of conditions, and the following disclaimer,
  123. * without modification.
  124. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  125. * substantially similar to the "NO WARRANTY" disclaimer below
  126. * ("Disclaimer") and any redistribution must be conditioned upon
  127. * including a substantially similar Disclaimer requirement for further
  128. * binary redistribution.
  129. * 3. Neither the names of the above-listed copyright holders nor the names
  130. * of any contributors may be used to endorse or promote products derived
  131. * from this software without specific prior written permission.
  132. *
  133. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  134. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  135. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  136. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  137. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  138. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  139. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  140. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  141. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  142. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  143. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  144. *
  145. * Alternatively, you may choose to be licensed under the terms of the
  146. * GNU General Public License ("GPL") version 2 as published by the Free
  147. * Software Foundation.
  148. *
  149. *****************************************************************************/
  150. #include <acpi.h>
  151. #include "accommon.h"
  152. #include <acdebug.h>
  153. #if 1
  154. #ifdef ACPI_APPLICATION
  155. #include "acapps.h"
  156. #endif
  157. #define _COMPONENT ACPI_CA_DEBUGGER
  158. ACPI_MODULE_NAME ("dbinput")
  159. /* Local prototypes */
  160. static UINT32
  161. AcpiDbGetLine (
  162. char *InputBuffer);
  163. static UINT32
  164. AcpiDbMatchCommand (
  165. char *UserCommand);
  166. static void
  167. AcpiDbDisplayCommandInfo (
  168. const char *Command,
  169. BOOLEAN DisplayAll);
  170. static void
  171. AcpiDbDisplayHelp (
  172. char *Command);
  173. static BOOLEAN
  174. AcpiDbMatchCommandHelp (
  175. const char *Command,
  176. const ACPI_DB_COMMAND_HELP *Help);
  177. /*
  178. * Top-level debugger commands.
  179. *
  180. * This list of commands must match the string table below it
  181. */
  182. enum AcpiExDebuggerCommands
  183. {
  184. CMD_NOT_FOUND = 0,
  185. CMD_NULL,
  186. CMD_ALLOCATIONS,
  187. CMD_ARGS,
  188. CMD_ARGUMENTS,
  189. CMD_BREAKPOINT,
  190. CMD_BUSINFO,
  191. CMD_CALL,
  192. CMD_DEBUG,
  193. CMD_DISASSEMBLE,
  194. CMD_DISASM,
  195. CMD_DUMP,
  196. CMD_EVALUATE,
  197. CMD_EXECUTE,
  198. CMD_EXIT,
  199. CMD_FIND,
  200. CMD_GO,
  201. CMD_HANDLERS,
  202. CMD_HELP,
  203. CMD_HELP2,
  204. CMD_HISTORY,
  205. CMD_HISTORY_EXE,
  206. CMD_HISTORY_LAST,
  207. CMD_INFORMATION,
  208. CMD_INTEGRITY,
  209. CMD_INTO,
  210. CMD_LEVEL,
  211. CMD_LIST,
  212. CMD_LOCALS,
  213. CMD_LOCKS,
  214. CMD_METHODS,
  215. CMD_NAMESPACE,
  216. CMD_NOTIFY,
  217. CMD_OBJECTS,
  218. CMD_OSI,
  219. CMD_OWNER,
  220. CMD_PATHS,
  221. CMD_PREDEFINED,
  222. CMD_PREFIX,
  223. CMD_QUIT,
  224. CMD_REFERENCES,
  225. CMD_RESOURCES,
  226. CMD_RESULTS,
  227. CMD_SET,
  228. CMD_STATS,
  229. CMD_STOP,
  230. CMD_TABLES,
  231. CMD_TEMPLATE,
  232. CMD_TRACE,
  233. CMD_TREE,
  234. CMD_TYPE,
  235. #ifdef ACPI_APPLICATION
  236. CMD_ENABLEACPI,
  237. CMD_EVENT,
  238. CMD_GPE,
  239. CMD_GPES,
  240. CMD_SCI,
  241. CMD_SLEEP,
  242. CMD_CLOSE,
  243. CMD_LOAD,
  244. CMD_OPEN,
  245. CMD_UNLOAD,
  246. CMD_TERMINATE,
  247. CMD_BACKGROUND,
  248. CMD_THREADS,
  249. CMD_TEST,
  250. #endif
  251. };
  252. #define CMD_FIRST_VALID 2
  253. /* Second parameter is the required argument count */
  254. static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
  255. {
  256. {"<NOT FOUND>", 0},
  257. {"<NULL>", 0},
  258. {"ALLOCATIONS", 0},
  259. {"ARGS", 0},
  260. {"ARGUMENTS", 0},
  261. {"BREAKPOINT", 1},
  262. {"BUSINFO", 0},
  263. {"CALL", 0},
  264. {"DEBUG", 1},
  265. {"DISASSEMBLE", 1},
  266. {"DISASM", 1},
  267. {"DUMP", 1},
  268. {"EVALUATE", 1},
  269. {"EXECUTE", 1},
  270. {"EXIT", 0},
  271. {"FIND", 1},
  272. {"GO", 0},
  273. {"HANDLERS", 0},
  274. {"HELP", 0},
  275. {"?", 0},
  276. {"HISTORY", 0},
  277. {"!", 1},
  278. {"!!", 0},
  279. {"INFORMATION", 0},
  280. {"INTEGRITY", 0},
  281. {"INTO", 0},
  282. {"LEVEL", 0},
  283. {"LIST", 0},
  284. {"LOCALS", 0},
  285. {"LOCKS", 0},
  286. {"METHODS", 0},
  287. {"NAMESPACE", 0},
  288. {"NOTIFY", 2},
  289. {"OBJECTS", 0},
  290. {"OSI", 0},
  291. {"OWNER", 1},
  292. {"PATHS", 0},
  293. {"PREDEFINED", 0},
  294. {"PREFIX", 0},
  295. {"QUIT", 0},
  296. {"REFERENCES", 1},
  297. {"RESOURCES", 0},
  298. {"RESULTS", 0},
  299. {"SET", 3},
  300. {"STATS", 1},
  301. {"STOP", 0},
  302. {"TABLES", 0},
  303. {"TEMPLATE", 1},
  304. {"TRACE", 1},
  305. {"TREE", 0},
  306. {"TYPE", 1},
  307. #ifdef ACPI_APPLICATION
  308. {"ENABLEACPI", 0},
  309. {"EVENT", 1},
  310. {"GPE", 1},
  311. {"GPES", 0},
  312. {"SCI", 0},
  313. {"SLEEP", 0},
  314. {"CLOSE", 0},
  315. {"LOAD", 1},
  316. {"OPEN", 1},
  317. {"UNLOAD", 1},
  318. {"TERMINATE", 0},
  319. {"BACKGROUND", 1},
  320. {"THREADS", 3},
  321. {"TEST", 1},
  322. #endif
  323. {NULL, 0}
  324. };
  325. /*
  326. * Help for all debugger commands. First argument is the number of lines
  327. * of help to output for the command.
  328. *
  329. * Note: Some commands are not supported by the kernel-level version of
  330. * the debugger.
  331. */
  332. static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
  333. {
  334. {0, "\nNamespace Access:", "\n"},
  335. {1, " Businfo", "Display system bus info\n"},
  336. {1, " Disassemble <Method>", "Disassemble a control method\n"},
  337. {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"},
  338. {1, " Integrity", "Validate namespace integrity\n"},
  339. {1, " Methods", "Display list of loaded control methods\n"},
  340. {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
  341. {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
  342. {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"},
  343. {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
  344. {1, " Paths", "Display full pathnames of namespace objects\n"},
  345. {1, " Predefined", "Check all predefined names\n"},
  346. {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
  347. {1, " References <Addr>", "Find all references to object at addr\n"},
  348. {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"},
  349. {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
  350. {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
  351. {1, " Type <Object>", "Display object type\n"},
  352. {0, "\nControl Method Execution:", "\n"},
  353. {1, " Evaluate <Namepath> [Arguments]", "Evaluate object or control method\n"},
  354. {1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
  355. #ifdef ACPI_APPLICATION
  356. {1, " Background <Namepath> [Arguments]", "Evaluate object/method in a separate thread\n"},
  357. {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
  358. #endif
  359. {1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
  360. {7, " [Arguments] formats:", "Control method argument formats\n"},
  361. {1, " Hex Integer", "Integer\n"},
  362. {1, " \"Ascii String\"", "String\n"},
  363. {1, " (Hex Byte List)", "Buffer\n"},
  364. {1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
  365. {1, " [Package Element List]", "Package\n"},
  366. {1, " [0x01 0x1234 \"string\"]", "Package example (3 elements)\n"},
  367. {0, "\nMiscellaneous:", "\n"},
  368. {1, " Allocations", "Display list of current memory allocations\n"},
  369. {2, " Dump <Address>|<Namepath>", "\n"},
  370. {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"},
  371. {1, " Handlers", "Info about global handlers\n"},
  372. {1, " Help [Command]", "This help screen or individual command\n"},
  373. {1, " History", "Display command history buffer\n"},
  374. {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"},
  375. {1, " Locks", "Current status of internal mutexes\n"},
  376. {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"},
  377. {1, " Quit or Exit", "Exit this command\n"},
  378. {8, " Stats <SubCommand>", "Display namespace and memory statistics\n"},
  379. {1, " Allocations", "Display list of current memory allocations\n"},
  380. {1, " Memory", "Dump internal memory lists\n"},
  381. {1, " Misc", "Namespace search and mutex stats\n"},
  382. {1, " Objects", "Summary of namespace objects\n"},
  383. {1, " Sizes", "Sizes for each of the internal objects\n"},
  384. {1, " Stack", "Display CPU stack usage\n"},
  385. {1, " Tables", "Info about current ACPI table(s)\n"},
  386. {1, " Tables", "Display info about loaded ACPI tables\n"},
  387. #ifdef ACPI_APPLICATION
  388. {1, " Terminate", "Delete namespace and all internal objects\n"},
  389. #endif
  390. {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
  391. {1, " !!", "Execute last command again\n"},
  392. {0, "\nMethod and Namespace Debugging:", "\n"},
  393. {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"},
  394. {1, " Enable", "Enable all messages\n"},
  395. {1, " Disable", "Disable tracing\n"},
  396. {1, " Method", "Enable method execution messages\n"},
  397. {1, " Opcode", "Enable opcode execution messages\n"},
  398. {3, " Test <TestName>", "Invoke a debug test\n"},
  399. {1, " Objects", "Read/write/compare all namespace data objects\n"},
  400. {1, " Predefined", "Validate all ACPI predefined names (_STA, etc.)\n"},
  401. {1, " Execute predefined", "Execute all predefined (public) methods\n"},
  402. {0, "\nControl Method Single-Step Execution:","\n"},
  403. {1, " Arguments (or Args)", "Display method arguments\n"},
  404. {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
  405. {1, " Call", "Run to next control method invocation\n"},
  406. {1, " Go", "Allow method to run to completion\n"},
  407. {1, " Information", "Display info about the current method\n"},
  408. {1, " Into", "Step into (not over) a method call\n"},
  409. {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
  410. {1, " Locals", "Display method local variables\n"},
  411. {1, " Results", "Display method result stack\n"},
  412. {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
  413. {1, " Stop", "Terminate control method\n"},
  414. {1, " Tree", "Display control method calling tree\n"},
  415. {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
  416. #ifdef ACPI_APPLICATION
  417. {0, "\nFile Operations:", "\n"},
  418. {1, " Close", "Close debug output file\n"},
  419. {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
  420. {1, " Open <Output Filename>", "Open a file for debug output\n"},
  421. {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"},
  422. {0, "\nHardware Simulation:", "\n"},
  423. {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
  424. {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
  425. {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
  426. {1, " Gpes", "Display info on all GPE devices\n"},
  427. {1, " Sci", "Generate an SCI\n"},
  428. {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
  429. #endif
  430. {0, NULL, NULL}
  431. };
  432. /*******************************************************************************
  433. *
  434. * FUNCTION: AcpiDbMatchCommandHelp
  435. *
  436. * PARAMETERS: Command - Command string to match
  437. * Help - Help table entry to attempt match
  438. *
  439. * RETURN: TRUE if command matched, FALSE otherwise
  440. *
  441. * DESCRIPTION: Attempt to match a command in the help table in order to
  442. * print help information for a single command.
  443. *
  444. ******************************************************************************/
  445. static BOOLEAN
  446. AcpiDbMatchCommandHelp (
  447. const char *Command,
  448. const ACPI_DB_COMMAND_HELP *Help)
  449. {
  450. char *Invocation = Help->Invocation;
  451. UINT32 LineCount;
  452. /* Valid commands in the help table begin with a couple of spaces */
  453. if (*Invocation != ' ')
  454. {
  455. return (FALSE);
  456. }
  457. while (*Invocation == ' ')
  458. {
  459. Invocation++;
  460. }
  461. /* Match command name (full command or substring) */
  462. while ((*Command) && (*Invocation) && (*Invocation != ' '))
  463. {
  464. if (tolower ((int) *Command) != tolower ((int) *Invocation))
  465. {
  466. return (FALSE);
  467. }
  468. Invocation++;
  469. Command++;
  470. }
  471. /* Print the appropriate number of help lines */
  472. LineCount = Help->LineCount;
  473. while (LineCount)
  474. {
  475. AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
  476. Help++;
  477. LineCount--;
  478. }
  479. return (TRUE);
  480. }
  481. /*******************************************************************************
  482. *
  483. * FUNCTION: AcpiDbDisplayCommandInfo
  484. *
  485. * PARAMETERS: Command - Command string to match
  486. * DisplayAll - Display all matching commands, or just
  487. * the first one (substring match)
  488. *
  489. * RETURN: None
  490. *
  491. * DESCRIPTION: Display help information for a Debugger command.
  492. *
  493. ******************************************************************************/
  494. static void
  495. AcpiDbDisplayCommandInfo (
  496. const char *Command,
  497. BOOLEAN DisplayAll)
  498. {
  499. const ACPI_DB_COMMAND_HELP *Next;
  500. BOOLEAN Matched;
  501. Next = AcpiGbl_DbCommandHelp;
  502. while (Next->Invocation)
  503. {
  504. Matched = AcpiDbMatchCommandHelp (Command, Next);
  505. if (!DisplayAll && Matched)
  506. {
  507. return;
  508. }
  509. Next++;
  510. }
  511. }
  512. /*******************************************************************************
  513. *
  514. * FUNCTION: AcpiDbDisplayHelp
  515. *
  516. * PARAMETERS: Command - Optional command string to display help.
  517. * if not specified, all debugger command
  518. * help strings are displayed
  519. *
  520. * RETURN: None
  521. *
  522. * DESCRIPTION: Display help for a single debugger command, or all of them.
  523. *
  524. ******************************************************************************/
  525. static void
  526. AcpiDbDisplayHelp (
  527. char *Command)
  528. {
  529. const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp;
  530. if (!Command)
  531. {
  532. /* No argument to help, display help for all commands */
  533. AcpiOsPrintf ("\nSummary of AML Debugger Commands\n\n");
  534. while (Next->Invocation)
  535. {
  536. AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
  537. Next++;
  538. }
  539. AcpiOsPrintf ("\n");
  540. }
  541. else
  542. {
  543. /* Display help for all commands that match the subtring */
  544. AcpiDbDisplayCommandInfo (Command, TRUE);
  545. }
  546. }
  547. /*******************************************************************************
  548. *
  549. * FUNCTION: AcpiDbGetNextToken
  550. *
  551. * PARAMETERS: String - Command buffer
  552. * Next - Return value, end of next token
  553. *
  554. * RETURN: Pointer to the start of the next token.
  555. *
  556. * DESCRIPTION: Command line parsing. Get the next token on the command line
  557. *
  558. ******************************************************************************/
  559. char *
  560. AcpiDbGetNextToken (
  561. char *String,
  562. char **Next,
  563. ACPI_OBJECT_TYPE *ReturnType)
  564. {
  565. char *Start;
  566. UINT32 Depth;
  567. ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER;
  568. /* At end of buffer? */
  569. if (!String || !(*String))
  570. {
  571. return (NULL);
  572. }
  573. /* Remove any spaces at the beginning */
  574. if (*String == ' ')
  575. {
  576. while (*String && (*String == ' '))
  577. {
  578. String++;
  579. }
  580. if (!(*String))
  581. {
  582. return (NULL);
  583. }
  584. }
  585. switch (*String)
  586. {
  587. case '"':
  588. /* This is a quoted string, scan until closing quote */
  589. String++;
  590. Start = String;
  591. Type = ACPI_TYPE_STRING;
  592. /* Find end of string */
  593. while (*String && (*String != '"'))
  594. {
  595. String++;
  596. }
  597. break;
  598. case '(':
  599. /* This is the start of a buffer, scan until closing paren */
  600. String++;
  601. Start = String;
  602. Type = ACPI_TYPE_BUFFER;
  603. /* Find end of buffer */
  604. while (*String && (*String != ')'))
  605. {
  606. String++;
  607. }
  608. break;
  609. case '[':
  610. /* This is the start of a package, scan until closing bracket */
  611. String++;
  612. Depth = 1;
  613. Start = String;
  614. Type = ACPI_TYPE_PACKAGE;
  615. /* Find end of package (closing bracket) */
  616. while (*String)
  617. {
  618. /* Handle String package elements */
  619. if (*String == '"')
  620. {
  621. /* Find end of string */
  622. String++;
  623. while (*String && (*String != '"'))
  624. {
  625. String++;
  626. }
  627. if (!(*String))
  628. {
  629. break;
  630. }
  631. }
  632. else if (*String == '[')
  633. {
  634. Depth++; /* A nested package declaration */
  635. }
  636. else if (*String == ']')
  637. {
  638. Depth--;
  639. if (Depth == 0) /* Found final package closing bracket */
  640. {
  641. break;
  642. }
  643. }
  644. String++;
  645. }
  646. break;
  647. default:
  648. Start = String;
  649. /* Find end of token */
  650. while (*String && (*String != ' '))
  651. {
  652. String++;
  653. }
  654. break;
  655. }
  656. if (!(*String))
  657. {
  658. *Next = NULL;
  659. }
  660. else
  661. {
  662. *String = 0;
  663. *Next = String + 1;
  664. }
  665. *ReturnType = Type;
  666. return (Start);
  667. }
  668. /*******************************************************************************
  669. *
  670. * FUNCTION: AcpiDbGetLine
  671. *
  672. * PARAMETERS: InputBuffer - Command line buffer
  673. *
  674. * RETURN: Count of arguments to the command
  675. *
  676. * DESCRIPTION: Get the next command line from the user. Gets entire line
  677. * up to the next newline
  678. *
  679. ******************************************************************************/
  680. static UINT32
  681. AcpiDbGetLine (
  682. char *InputBuffer)
  683. {
  684. UINT32 i;
  685. UINT32 Count;
  686. char *Next;
  687. char *This;
  688. if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
  689. InputBuffer))
  690. {
  691. AcpiOsPrintf (
  692. "Buffer overflow while parsing input line (max %u characters)\n",
  693. sizeof (AcpiGbl_DbParsedBuf));
  694. return (0);
  695. }
  696. This = AcpiGbl_DbParsedBuf;
  697. for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
  698. {
  699. AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
  700. &AcpiGbl_DbArgTypes[i]);
  701. if (!AcpiGbl_DbArgs[i])
  702. {
  703. break;
  704. }
  705. This = Next;
  706. }
  707. /* Uppercase the actual command */
  708. AcpiUtStrupr (AcpiGbl_DbArgs[0]);
  709. Count = i;
  710. if (Count)
  711. {
  712. Count--; /* Number of args only */
  713. }
  714. return (Count);
  715. }
  716. /*******************************************************************************
  717. *
  718. * FUNCTION: AcpiDbMatchCommand
  719. *
  720. * PARAMETERS: UserCommand - User command line
  721. *
  722. * RETURN: Index into command array, -1 if not found
  723. *
  724. * DESCRIPTION: Search command array for a command match
  725. *
  726. ******************************************************************************/
  727. static UINT32
  728. AcpiDbMatchCommand (
  729. char *UserCommand)
  730. {
  731. UINT32 i;
  732. if (!UserCommand || UserCommand[0] == 0)
  733. {
  734. return (CMD_NULL);
  735. }
  736. for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
  737. {
  738. if (strstr (
  739. ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
  740. AcpiGbl_DbCommands[i].Name)
  741. {
  742. return (i);
  743. }
  744. }
  745. /* Command not recognized */
  746. return (CMD_NOT_FOUND);
  747. }
  748. /*******************************************************************************
  749. *
  750. * FUNCTION: AcpiDbCommandDispatch
  751. *
  752. * PARAMETERS: InputBuffer - Command line buffer
  753. * WalkState - Current walk
  754. * Op - Current (executing) parse op
  755. *
  756. * RETURN: Status
  757. *
  758. * DESCRIPTION: Command dispatcher.
  759. *
  760. ******************************************************************************/
  761. ACPI_STATUS
  762. AcpiDbCommandDispatch (
  763. char *InputBuffer,
  764. ACPI_WALK_STATE *WalkState,
  765. ACPI_PARSE_OBJECT *Op)
  766. {
  767. UINT32 Temp;
  768. UINT32 CommandIndex;
  769. UINT32 ParamCount;
  770. char *CommandLine;
  771. ACPI_STATUS Status = AE_CTRL_TRUE;
  772. /* If AcpiTerminate has been called, terminate this thread */
  773. if (AcpiGbl_DbTerminateLoop)
  774. {
  775. return (AE_CTRL_TERMINATE);
  776. }
  777. /* Find command and add to the history buffer */
  778. ParamCount = AcpiDbGetLine (InputBuffer);
  779. CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
  780. Temp = 0;
  781. /*
  782. * We don't want to add the !! command to the history buffer. It
  783. * would cause an infinite loop because it would always be the
  784. * previous command.
  785. */
  786. if (CommandIndex != CMD_HISTORY_LAST)
  787. {
  788. AcpiDbAddToHistory (InputBuffer);
  789. }
  790. /* Verify that we have the minimum number of params */
  791. if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
  792. {
  793. AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
  794. ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
  795. AcpiGbl_DbCommands[CommandIndex].MinArgs);
  796. AcpiDbDisplayCommandInfo (
  797. AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
  798. return (AE_CTRL_TRUE);
  799. }
  800. /* Decode and dispatch the command */
  801. switch (CommandIndex)
  802. {
  803. case CMD_NULL:
  804. if (Op)
  805. {
  806. return (AE_OK);
  807. }
  808. break;
  809. case CMD_ALLOCATIONS:
  810. #ifdef ACPI_DBG_TRACK_ALLOCATIONS
  811. AcpiUtDumpAllocations ((UINT32) -1, NULL);
  812. #endif
  813. break;
  814. case CMD_ARGS:
  815. case CMD_ARGUMENTS:
  816. AcpiDbDisplayArguments ();
  817. break;
  818. case CMD_BREAKPOINT:
  819. AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
  820. break;
  821. case CMD_BUSINFO:
  822. AcpiDbGetBusInfo ();
  823. break;
  824. case CMD_CALL:
  825. AcpiDbSetMethodCallBreakpoint (Op);
  826. Status = AE_OK;
  827. break;
  828. case CMD_DEBUG:
  829. AcpiDbExecute (AcpiGbl_DbArgs[1],
  830. &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
  831. break;
  832. case CMD_DISASSEMBLE:
  833. case CMD_DISASM:
  834. #ifdef ACPI_DISASSEMBLER
  835. (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
  836. #else
  837. AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
  838. #endif
  839. break;
  840. case CMD_DUMP:
  841. AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  842. break;
  843. case CMD_EVALUATE:
  844. case CMD_EXECUTE:
  845. AcpiDbExecute (AcpiGbl_DbArgs[1],
  846. &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
  847. break;
  848. case CMD_FIND:
  849. Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
  850. break;
  851. case CMD_GO:
  852. AcpiGbl_CmSingleStep = FALSE;
  853. return (AE_OK);
  854. case CMD_HANDLERS:
  855. AcpiDbDisplayHandlers ();
  856. break;
  857. case CMD_HELP:
  858. case CMD_HELP2:
  859. AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
  860. break;
  861. case CMD_HISTORY:
  862. AcpiDbDisplayHistory ();
  863. break;
  864. case CMD_HISTORY_EXE: /* ! command */
  865. CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
  866. if (!CommandLine)
  867. {
  868. return (AE_CTRL_TRUE);
  869. }
  870. Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
  871. return (Status);
  872. case CMD_HISTORY_LAST: /* !! command */
  873. CommandLine = AcpiDbGetFromHistory (NULL);
  874. if (!CommandLine)
  875. {
  876. return (AE_CTRL_TRUE);
  877. }
  878. Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
  879. return (Status);
  880. case CMD_INFORMATION:
  881. AcpiDbDisplayMethodInfo (Op);
  882. break;
  883. case CMD_INTEGRITY:
  884. AcpiDbCheckIntegrity ();
  885. break;
  886. case CMD_INTO:
  887. if (Op)
  888. {
  889. AcpiGbl_CmSingleStep = TRUE;
  890. return (AE_OK);
  891. }
  892. break;
  893. case CMD_LEVEL:
  894. if (ParamCount == 0)
  895. {
  896. AcpiOsPrintf (
  897. "Current debug level for file output is: %8.8lX\n",
  898. AcpiGbl_DbDebugLevel);
  899. AcpiOsPrintf (
  900. "Current debug level for console output is: %8.8lX\n",
  901. AcpiGbl_DbConsoleDebugLevel);
  902. }
  903. else if (ParamCount == 2)
  904. {
  905. Temp = AcpiGbl_DbConsoleDebugLevel;
  906. AcpiGbl_DbConsoleDebugLevel =
  907. strtoul (AcpiGbl_DbArgs[1], NULL, 16);
  908. AcpiOsPrintf (
  909. "Debug Level for console output was %8.8lX, now %8.8lX\n",
  910. Temp, AcpiGbl_DbConsoleDebugLevel);
  911. }
  912. else
  913. {
  914. Temp = AcpiGbl_DbDebugLevel;
  915. AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
  916. AcpiOsPrintf (
  917. "Debug Level for file output was %8.8lX, now %8.8lX\n",
  918. Temp, AcpiGbl_DbDebugLevel);
  919. }
  920. break;
  921. case CMD_LIST:
  922. #ifdef ACPI_DISASSEMBLER
  923. AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
  924. #else
  925. AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
  926. #endif
  927. break;
  928. case CMD_LOCKS:
  929. AcpiDbDisplayLocks ();
  930. break;
  931. case CMD_LOCALS:
  932. AcpiDbDisplayLocals ();
  933. break;
  934. case CMD_METHODS:
  935. Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
  936. break;
  937. case CMD_NAMESPACE:
  938. AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  939. break;
  940. case CMD_NOTIFY:
  941. Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
  942. AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
  943. break;
  944. case CMD_OBJECTS:
  945. AcpiUtStrupr (AcpiGbl_DbArgs[1]);
  946. Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  947. break;
  948. case CMD_OSI:
  949. AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  950. break;
  951. case CMD_OWNER:
  952. AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  953. break;
  954. case CMD_PATHS:
  955. AcpiDbDumpNamespacePaths ();
  956. break;
  957. case CMD_PREFIX:
  958. AcpiDbSetScope (AcpiGbl_DbArgs[1]);
  959. break;
  960. case CMD_REFERENCES:
  961. AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
  962. break;
  963. case CMD_RESOURCES:
  964. AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
  965. break;
  966. case CMD_RESULTS:
  967. AcpiDbDisplayResults ();
  968. break;
  969. case CMD_SET:
  970. AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
  971. AcpiGbl_DbArgs[3]);
  972. break;
  973. case CMD_STATS:
  974. Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
  975. break;
  976. case CMD_STOP:
  977. return (AE_NOT_IMPLEMENTED);
  978. case CMD_TABLES:
  979. AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
  980. break;
  981. case CMD_TEMPLATE:
  982. AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
  983. break;
  984. case CMD_TRACE:
  985. AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
  986. break;
  987. case CMD_TREE:
  988. AcpiDbDisplayCallingTree ();
  989. break;
  990. case CMD_TYPE:
  991. AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
  992. break;
  993. #ifdef ACPI_APPLICATION
  994. /* Hardware simulation commands. */
  995. case CMD_ENABLEACPI:
  996. #if (!ACPI_REDUCED_HARDWARE)
  997. Status = AcpiEnable();
  998. if (ACPI_FAILURE(Status))
  999. {
  1000. AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
  1001. return (Status);
  1002. }
  1003. #endif /* !ACPI_REDUCED_HARDWARE */
  1004. break;
  1005. case CMD_EVENT:
  1006. AcpiOsPrintf ("Event command not implemented\n");
  1007. break;
  1008. case CMD_GPE:
  1009. AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
  1010. break;
  1011. case CMD_GPES:
  1012. AcpiDbDisplayGpes ();
  1013. break;
  1014. case CMD_SCI:
  1015. AcpiDbGenerateSci ();
  1016. break;
  1017. case CMD_SLEEP:
  1018. Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
  1019. break;
  1020. /* File I/O commands. */
  1021. case CMD_CLOSE:
  1022. AcpiDbCloseDebugFile ();
  1023. break;
  1024. case CMD_LOAD:
  1025. {
  1026. ACPI_NEW_TABLE_DESC *ListHead = NULL;
  1027. Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
  1028. ACPI_GET_ALL_TABLES, &ListHead);
  1029. if (ACPI_SUCCESS (Status))
  1030. {
  1031. AcpiDbLoadTables (ListHead);
  1032. }
  1033. }
  1034. break;
  1035. case CMD_OPEN:
  1036. AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
  1037. break;
  1038. /* User space commands. */
  1039. case CMD_TERMINATE:
  1040. AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
  1041. AcpiUtSubsystemShutdown ();
  1042. /*
  1043. * TBD: [Restructure] Need some way to re-initialize without
  1044. * re-creating the semaphores!
  1045. */
  1046. AcpiGbl_DbTerminateLoop = TRUE;
  1047. /* AcpiInitialize (NULL); */
  1048. break;
  1049. case CMD_BACKGROUND:
  1050. AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
  1051. &AcpiGbl_DbArgTypes[2]);
  1052. break;
  1053. case CMD_THREADS:
  1054. AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
  1055. AcpiGbl_DbArgs[3]);
  1056. break;
  1057. /* Debug test commands. */
  1058. case CMD_PREDEFINED:
  1059. AcpiDbCheckPredefinedNames ();
  1060. break;
  1061. case CMD_TEST:
  1062. AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
  1063. break;
  1064. case CMD_UNLOAD:
  1065. AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
  1066. break;
  1067. #endif
  1068. case CMD_EXIT:
  1069. case CMD_QUIT:
  1070. if (Op)
  1071. {
  1072. AcpiOsPrintf ("Method execution terminated\n");
  1073. return (AE_CTRL_TERMINATE);
  1074. }
  1075. if (!AcpiGbl_DbOutputToFile)
  1076. {
  1077. AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
  1078. }
  1079. #ifdef ACPI_APPLICATION
  1080. AcpiDbCloseDebugFile ();
  1081. #endif
  1082. AcpiGbl_DbTerminateLoop = TRUE;
  1083. return (AE_CTRL_TERMINATE);
  1084. case CMD_NOT_FOUND:
  1085. default:
  1086. AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
  1087. return (AE_CTRL_TRUE);
  1088. }
  1089. if (ACPI_SUCCESS (Status))
  1090. {
  1091. Status = AE_CTRL_TRUE;
  1092. }
  1093. return (Status);
  1094. }
  1095. /*******************************************************************************
  1096. *
  1097. * FUNCTION: AcpiDbExecuteThread
  1098. *
  1099. * PARAMETERS: Context - Not used
  1100. *
  1101. * RETURN: None
  1102. *
  1103. * DESCRIPTION: Debugger execute thread. Waits for a command line, then
  1104. * simply dispatches it.
  1105. *
  1106. ******************************************************************************/
  1107. void ACPI_SYSTEM_XFACE
  1108. AcpiDbExecuteThread (
  1109. void *Context)
  1110. {
  1111. (void) AcpiDbUserCommands ();
  1112. AcpiGbl_DbThreadsTerminated = TRUE;
  1113. }
  1114. /*******************************************************************************
  1115. *
  1116. * FUNCTION: AcpiDbUserCommands
  1117. *
  1118. * PARAMETERS: None
  1119. *
  1120. * RETURN: None
  1121. *
  1122. * DESCRIPTION: Command line execution for the AML debugger. Commands are
  1123. * matched and dispatched here.
  1124. *
  1125. ******************************************************************************/
  1126. ACPI_STATUS
  1127. AcpiDbUserCommands (
  1128. void)
  1129. {
  1130. ACPI_STATUS Status = AE_OK;
  1131. AcpiOsPrintf ("\n");
  1132. /* TBD: [Restructure] Need a separate command line buffer for step mode */
  1133. while (!AcpiGbl_DbTerminateLoop)
  1134. {
  1135. /* Wait the readiness of the command */
  1136. Status = AcpiOsWaitCommandReady ();
  1137. if (ACPI_FAILURE (Status))
  1138. {
  1139. break;
  1140. }
  1141. /* Just call to the command line interpreter */
  1142. AcpiGbl_MethodExecuting = FALSE;
  1143. AcpiGbl_StepToNextCall = FALSE;
  1144. (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
  1145. /* Notify the completion of the command */
  1146. Status = AcpiOsNotifyCommandComplete ();
  1147. if (ACPI_FAILURE (Status))
  1148. {
  1149. break;
  1150. }
  1151. }
  1152. if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
  1153. {
  1154. ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
  1155. }
  1156. return (Status);
  1157. }
  1158. #else
  1159. ACPI_STATUS
  1160. AcpiDbCommandDispatch (
  1161. char *InputBuffer,
  1162. ACPI_WALK_STATE *WalkState,
  1163. ACPI_PARSE_OBJECT *Op)
  1164. {
  1165. sysfatal("%s", __func__);
  1166. return AE_OK;
  1167. }
  1168. void ACPI_SYSTEM_XFACE
  1169. AcpiDbExecuteThread (
  1170. void *Context)
  1171. {
  1172. sysfatal("%s", __func__);
  1173. }
  1174. char *
  1175. AcpiDbGetNextToken (
  1176. char *String,
  1177. char **Next,
  1178. ACPI_OBJECT_TYPE *ReturnType)
  1179. {
  1180. sysfatal("%s", __func__);
  1181. return NULL;
  1182. }
  1183. #endif