Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5888 lines
173 KiB

  1. /*** amli.c - AML Debugger functions
  2. *
  3. * This module contains all the debug functions.
  4. *
  5. * Copyright (c) 1996,2001 Microsoft Corporation
  6. * Author: Michael Tsang (MikeTs)
  7. * Created 08/14/96
  8. *
  9. * MODIFICATION HISTORY
  10. * hanumany 5/10/01 Ported to handle 64bit debugging.
  11. *
  12. */
  13. #include "precomp.h"
  14. #include "amlikd.h"
  15. /*** Macros
  16. */
  17. #define ReadAtAddress(A,V,S) { ULONG _r; \
  18. if (!ReadMemory((A), &(V), (S), &_r ) || (_r < (S))) { \
  19. dprintf("Can't Read Memory at %08p\n", (A)); \
  20. rc = DBGERR_CMD_FAILED; \
  21. } \
  22. }
  23. #define WriteAtAddress(A,V,S) { ULONG _r; \
  24. if (!WriteMemory( (A), &(V), (S), &_r ) || (_r < (S))) {\
  25. dprintf("Can't Write Memory at %p\n", (A)); \
  26. rc = DBGERR_CMD_FAILED; \
  27. } \
  28. }
  29. /*** Local data
  30. */
  31. int giLevel = 0;
  32. ULONG64 guipbOpXlate = 0;
  33. ULONG64 gpnsCurUnAsmScope = 0;
  34. char gcszTokenSeps[] = " \t\n";
  35. ULONG dwfDebuggerON = 0, dwfDebuggerOFF = 0;
  36. ULONG dwfAMLIInitON = 0, dwfAMLIInitOFF = 0;
  37. ULONG dwCmdArg = 0;
  38. CMDARG ArgsBC[] =
  39. {
  40. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgBC,
  41. NULL, AT_END, 0, NULL, 0, NULL
  42. };
  43. CMDARG ArgsBD[] =
  44. {
  45. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgBD,
  46. NULL, AT_END, 0, NULL, 0, NULL
  47. };
  48. CMDARG ArgsBE[] =
  49. {
  50. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgBE,
  51. NULL, AT_END, 0, NULL, 0, NULL
  52. };
  53. CMDARG ArgsBP[] =
  54. {
  55. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgBP,
  56. NULL, AT_END, 0, NULL, 0, NULL
  57. };
  58. CMDARG ArgsHelp[] =
  59. {
  60. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgHelp,
  61. NULL, AT_END, 0, NULL, 0, NULL
  62. };
  63. CMDARG ArgsDH[] =
  64. {
  65. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgDH,
  66. NULL, AT_END, 0, NULL, 0, NULL
  67. };
  68. CMDARG ArgsDNS[] =
  69. {
  70. "s", AT_ENABLE, 0, &dwCmdArg, DNSF_RECURSE, NULL,
  71. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgDNS,
  72. NULL, AT_END, 0, NULL, 0, NULL
  73. };
  74. CMDARG ArgsDO[] =
  75. {
  76. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgDO,
  77. NULL, AT_END, 0, NULL, 0, NULL
  78. };
  79. CMDARG ArgsDS[] =
  80. {
  81. "v", AT_ENABLE, 0, &dwCmdArg, DSF_VERBOSE, NULL,
  82. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgDS,
  83. NULL, AT_END, 0, NULL, 0, NULL
  84. };
  85. CMDARG ArgsFind[] =
  86. {
  87. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgFind,
  88. NULL, AT_END, 0, NULL, 0, NULL
  89. };
  90. CMDARG ArgsLN[] =
  91. {
  92. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgLN,
  93. NULL, AT_END, 0, NULL, 0, NULL
  94. };
  95. CMDARG ArgsR[] =
  96. {
  97. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgR,
  98. NULL, AT_END, 0, NULL, 0, NULL
  99. };
  100. CMDARG ArgsSet[] =
  101. {
  102. "traceon", AT_ENABLE, 0, &dwfDebuggerON, DBGF_AMLTRACE_ON, NULL,
  103. "traceoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_AMLTRACE_ON, NULL,
  104. "spewon", AT_ENABLE, 0, &dwfDebuggerON, DBGF_DEBUG_SPEW_ON, NULL,
  105. "spewoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_DEBUG_SPEW_ON, NULL,
  106. "nesttraceon", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_TRACE_NONEST, NULL,
  107. "nesttraceoff", AT_ENABLE, 0, &dwfDebuggerON, DBGF_TRACE_NONEST, NULL,
  108. "lbrkon", AT_ENABLE, 0, &dwfAMLIInitON, AMLIIF_LOADDDB_BREAK, NULL,
  109. "lbrkoff", AT_ENABLE, 0, &dwfAMLIInitOFF, AMLIIF_LOADDDB_BREAK, NULL,
  110. "errbrkon", AT_ENABLE, 0, &dwfDebuggerON, DBGF_ERRBREAK_ON, NULL,
  111. "errbrkoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_ERRBREAK_ON, NULL,
  112. "verboseon", AT_ENABLE, 0, &dwfDebuggerON, DBGF_VERBOSE_ON, NULL,
  113. "verboseoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_VERBOSE_ON, NULL,
  114. "logon", AT_ENABLE, 0, &dwfDebuggerON, DBGF_LOGEVENT_ON, NULL,
  115. "logoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_LOGEVENT_ON, NULL,
  116. "logmuton", AT_ENABLE, 0, &dwfDebuggerON, DBGF_LOGEVENT_MUTEX, NULL,
  117. "logmutoff", AT_ENABLE, 0, &dwfDebuggerOFF, DBGF_LOGEVENT_MUTEX, NULL,
  118. NULL, AT_END, 0, NULL, 0, NULL
  119. };
  120. CMDARG ArgsU[] =
  121. {
  122. NULL, AT_ACTION, 0, NULL, 0, AMLIDbgU,
  123. NULL, AT_END, 0, NULL, 0, NULL
  124. };
  125. DBGCMD DbgCmds[] =
  126. {
  127. "?", 0, ArgsHelp, AMLIDbgHelp,
  128. "bc", 0, ArgsBC, AMLIDbgBC,
  129. "bd", 0, ArgsBD, AMLIDbgBD,
  130. "be", 0, ArgsBE, AMLIDbgBE,
  131. "bl", 0, NULL, AMLIDbgBL,
  132. "bp", 0, ArgsBP, AMLIDbgBP,
  133. "cl", 0, NULL, AMLIDbgCL,
  134. "debugger", 0, NULL, AMLIDbgDebugger,
  135. "dh", 0, ArgsDH, AMLIDbgDH,
  136. "dl", 0, NULL, AMLIDbgDL,
  137. "dns", 0, ArgsDNS, AMLIDbgDNS,
  138. "do", 0, ArgsDO, AMLIDbgDO,
  139. "ds", 0, ArgsDS, AMLIDbgDS,
  140. "find", 0, ArgsFind, AMLIDbgFind,
  141. "lc", 0, NULL, AMLIDbgLC,
  142. "ln", 0, ArgsLN, AMLIDbgLN,
  143. "p", 0, NULL, AMLIDbgP,
  144. "r", 0, ArgsR, AMLIDbgR,
  145. "set", 0, ArgsSet, AMLIDbgSet,
  146. "u", 0, ArgsU, AMLIDbgU,
  147. NULL, 0, NULL, NULL
  148. };
  149. PSZ pszSwitchChars = "-/";
  150. PSZ pszOptionSeps = "=:";
  151. ASLTERM TermTable[] =
  152. {
  153. "DefinitionBlock", CD, 0, OP_NONE, NULL, NULL, OL|CL|LL|AF|AV,
  154. "Include", CD, 0, OP_NONE, NULL, NULL, AF,
  155. "External", CD, 0, OP_NONE, NULL, "uX", AF,
  156. // Short Objects
  157. "Zero", CN, 0, OP_ZERO, NULL, NULL, 0,
  158. "One", CN, 0, OP_ONE, NULL, NULL, 0,
  159. "Ones", CN, 0, OP_ONES, NULL, NULL, 0,
  160. "Revision", CN, 0, OP_REVISION, NULL, NULL, 0,
  161. "Arg0", SN, 0, OP_ARG0, NULL, NULL, 0,
  162. "Arg1", SN, 0, OP_ARG1, NULL, NULL, 0,
  163. "Arg2", SN, 0, OP_ARG2, NULL, NULL, 0,
  164. "Arg3", SN, 0, OP_ARG3, NULL, NULL, 0,
  165. "Arg4", SN, 0, OP_ARG4, NULL, NULL, 0,
  166. "Arg5", SN, 0, OP_ARG5, NULL, NULL, 0,
  167. "Arg6", SN, 0, OP_ARG6, NULL, NULL, 0,
  168. "Local0", SN, 0, OP_LOCAL0, NULL, NULL, 0,
  169. "Local1", SN, 0, OP_LOCAL1, NULL, NULL, 0,
  170. "Local2", SN, 0, OP_LOCAL2, NULL, NULL, 0,
  171. "Local3", SN, 0, OP_LOCAL3, NULL, NULL, 0,
  172. "Local4", SN, 0, OP_LOCAL4, NULL, NULL, 0,
  173. "Local5", SN, 0, OP_LOCAL5, NULL, NULL, 0,
  174. "Local6", SN, 0, OP_LOCAL6, NULL, NULL, 0,
  175. "Local7", SN, 0, OP_LOCAL7, NULL, NULL, 0,
  176. "Debug", SN, 0, OP_DEBUG, NULL, NULL, 0,
  177. // Named Terms
  178. "Alias", NS, 0, OP_ALIAS, "NN", "Ua", 0,
  179. "Name", NS, 0, OP_NAME, "NO", "u", 0,
  180. "Scope", NS, 0, OP_SCOPE, "N", "S", OL|LN|CC,
  181. // Data Objects
  182. "Buffer", DO, 0, OP_BUFFER, "C", "U", DL|LN,
  183. "Package", DO, 0, OP_PACKAGE, "B", NULL, PL|LN,
  184. "EISAID", DO, 0, OP_DWORD, NULL,NULL, AF,
  185. // Argument Keywords
  186. "AnyAcc", KW, AANY, OP_NONE, NULL, "A", 0,
  187. "ByteAcc", KW, AB, OP_NONE, NULL, "A", 0,
  188. "WordAcc", KW, AW, OP_NONE, NULL, "A", 0,
  189. "DWordAcc", KW, ADW, OP_NONE, NULL, "A", 0,
  190. "BlockAcc", KW, ABLK, OP_NONE, NULL, "A", 0,
  191. "SMBSendRecvAcc", KW, ASSR, OP_NONE, NULL, "A", 0,
  192. "SMBQuickAcc", KW, ASQ, OP_NONE, NULL, "A", 0,
  193. "Lock", KW, LK, OP_NONE, NULL, "B", 0,
  194. "NoLock", KW, NOLK, OP_NONE, NULL, "B", 0,
  195. "Preserve", KW, PSRV, OP_NONE, NULL, "C", 0,
  196. "WriteAsOnes", KW, WA1S, OP_NONE, NULL, "C", 0,
  197. "WriteAsZeros", KW, WA0S, OP_NONE, NULL, "C", 0,
  198. "SystemMemory", KW, MEM, OP_NONE, NULL, "D", 0,
  199. "SystemIO", KW, IO, OP_NONE, NULL, "D", 0,
  200. "PCI_Config", KW, CFG, OP_NONE, NULL, "D", 0,
  201. "EmbeddedControl", KW, EC, OP_NONE, NULL, "D", 0,
  202. "SMBus", KW, SMB, OP_NONE, NULL, "D", 0,
  203. "Serialized", KW, SER, OP_NONE, NULL, "E", 0,
  204. "NotSerialized", KW, NOSER,OP_NONE, NULL, "E", 0,
  205. "MTR", KW, OMTR, OP_NONE, NULL, "F", 0,
  206. "MEQ", KW, OMEQ, OP_NONE, NULL, "F", 0,
  207. "MLE", KW, OMLE, OP_NONE, NULL, "F", 0,
  208. "MLT", KW, OMLT, OP_NONE, NULL, "F", 0,
  209. "MGE", KW, OMGE, OP_NONE, NULL, "F", 0,
  210. "MGT", KW, OMGT, OP_NONE, NULL, "F", 0,
  211. "Edge", KW, _HE, OP_NONE, NULL, "G", 0,
  212. "Level", KW, _LL, OP_NONE, NULL, "G", 0,
  213. "ActiveHigh", KW, _HE, OP_NONE, NULL, "H", 0,
  214. "ActiveLow", KW, _LL, OP_NONE, NULL, "H", 0,
  215. "Shared", KW, _SHR, OP_NONE, NULL, "I", 0,
  216. "Exclusive", KW, _EXC, OP_NONE, NULL, "I", 0,
  217. "Compatibility", KW, COMP, OP_NONE, NULL, "J", 0,
  218. "TypeA", KW, TYPA, OP_NONE, NULL, "J", 0,
  219. "TypeB", KW, TYPB, OP_NONE, NULL, "J", 0,
  220. "TypeF", KW, TYPF, OP_NONE, NULL, "J", 0,
  221. "BusMaster", KW, BM, OP_NONE, NULL, "K", 0,
  222. "NotBusMaster", KW, NOBM, OP_NONE, NULL, "K", 0,
  223. "Transfer8", KW, X8, OP_NONE, NULL, "L", 0,
  224. "Transfer8_16", KW, X816, OP_NONE, NULL, "L", 0,
  225. "Transfer16", KW, X16, OP_NONE, NULL, "L", 0,
  226. "Decode16", KW, DC16, OP_NONE, NULL, "M", 0,
  227. "Decode10", KW, DC10, OP_NONE, NULL, "M", 0,
  228. "ReadWrite", KW, _RW, OP_NONE, NULL, "N", 0,
  229. "ReadOnly", KW, _ROM, OP_NONE, NULL, "N", 0,
  230. "ResourceConsumer",KW, RCS, OP_NONE, NULL, "O", 0,
  231. "ResourceProducer",KW, RPD, OP_NONE, NULL, "O", 0,
  232. "SubDecode", KW, BSD, OP_NONE, NULL, "P", 0,
  233. "PosDecode", KW, BPD, OP_NONE, NULL, "P", 0,
  234. "MinFixed", KW, MIF, OP_NONE, NULL, "Q", 0,
  235. "MinNotFixed", KW, NMIF, OP_NONE, NULL, "Q", 0,
  236. "MaxFixed", KW, MAF, OP_NONE, NULL, "R", 0,
  237. "MaxNotFixed", KW, NMAF, OP_NONE, NULL, "R", 0,
  238. "Cacheable", KW, CACH, OP_NONE, NULL, "S", 0,
  239. "WriteCombining", KW, WRCB, OP_NONE, NULL, "S", 0,
  240. "Prefetchable", KW, PREF, OP_NONE, NULL, "S", 0,
  241. "NonCacheable", KW, NCAC, OP_NONE, NULL, "S", 0,
  242. "ISAOnlyRanges", KW, ISA, OP_NONE, NULL, "T", 0,
  243. "NonISAOnlyRanges",KW, NISA, OP_NONE, NULL, "T", 0,
  244. "EntireRange", KW, ERNG, OP_NONE, NULL, "T", 0,
  245. "ExtEdge", KW, ($HGH | $EDG), OP_NONE, NULL, "U", 0,
  246. "ExtLevel", KW, ($LOW | $LVL), OP_NONE, NULL, "U", 0,
  247. "ExtActiveHigh", KW, ($HGH | $EDG), OP_NONE, NULL, "V", 0,
  248. "ExtActiveLow", KW, ($LOW | $LVL), OP_NONE, NULL, "V", 0,
  249. "ExtShared", KW, $SHR, OP_NONE, NULL, "W", 0,
  250. "ExtExclusive", KW, $EXC, OP_NONE, NULL, "W", 0,
  251. "UnknownObj", KW, UNK, OP_NONE, NULL, "X", 0,
  252. "IntObj", KW, INT, OP_NONE, NULL, "X", 0,
  253. "StrObj", KW, STR, OP_NONE, NULL, "X", 0,
  254. "BuffObj", KW, BUF, OP_NONE, NULL, "X", 0,
  255. "PkgObj", KW, PKG, OP_NONE, NULL, "X", 0,
  256. "FieldUnitObj", KW, FDU, OP_NONE, NULL, "X", 0,
  257. "DeviceObj", KW, DEV, OP_NONE, NULL, "X", 0,
  258. "EventObj", KW, EVT, OP_NONE, NULL, "X", 0,
  259. "MethodObj", KW, MET, OP_NONE, NULL, "X", 0,
  260. "MutexObj", KW, MUT, OP_NONE, NULL, "X", 0,
  261. "OpRegionObj", KW, OPR, OP_NONE, NULL, "X", 0,
  262. "PowerResObj", KW, PWR, OP_NONE, NULL, "X", 0,
  263. "ThermalZoneObj", KW, THM, OP_NONE, NULL, "X", 0,
  264. "BuffFieldObj", KW, BFD, OP_NONE, NULL, "X", 0,
  265. "DDBHandleObj", KW, DDB, OP_NONE, NULL, "X", 0,
  266. // Field Macros
  267. "Offset", FM, 0, OP_NONE, NULL, NULL, 0,
  268. "AccessAs", FM, 0, 0x01, NULL, "A" , AF,
  269. // Named Object Creators
  270. "BankField", NO, 0, OP_BANKFIELD, "NNCKkk","OFUABC", FL|FM|LN|AF,
  271. "CreateBitField", NO, 0, OP_BITFIELD, "CCN", "UUb", 0,
  272. "CreateByteField", NO, 0, OP_BYTEFIELD, "CCN", "UUb", 0,
  273. "CreateDWordField",NO, 0, OP_DWORDFIELD, "CCN", "UUb", 0,
  274. "CreateField", NO, 0, OP_CREATEFIELD,"CCCN", "UUUb", 0,
  275. "CreateWordField", NO, 0, OP_WORDFIELD, "CCN", "UUb", 0,
  276. "Device", NO, 0, OP_DEVICE, "N", "d", OL|LN|CC,
  277. "Event", NO, 0, OP_EVENT, "N", "e", 0,
  278. "Field", NO, 0, OP_FIELD, "NKkk", "OABC", FL|FM|LN|AF,
  279. "IndexField", NO, 0, OP_IDXFIELD, "NNKkk", "FFABC", FL|FM|LN|AF,
  280. "Method", NO, 0, OP_METHOD, "NKk", "m!E", CL|OL|LN|AF|CC|SK,
  281. "Mutex", NO, 0, OP_MUTEX, "NB", "x", 0,
  282. "OperationRegion", NO, 0, OP_OPREGION, "NKCC", "oDUU", AF,
  283. "PowerResource", NO, 0, OP_POWERRES, "NBW", "p", OL|LN|CC,
  284. "Processor", NO, 0, OP_PROCESSOR, "NBDB", "c", OL|LN|CC,
  285. "ThermalZone", NO, 0, OP_THERMALZONE,"N", "t", OL|LN|CC,
  286. // Type 1 Opcode Terms
  287. "Break", C1, 0, OP_BREAK, NULL, NULL, 0,
  288. "BreakPoint", C1, 0, OP_BREAKPOINT, NULL, NULL, 0,
  289. "Else", C1, 0, OP_ELSE, NULL, NULL, AF|CL|OL|LN,
  290. "Fatal", C1, 0, OP_FATAL, "BDC", " U",0,
  291. "If", C1, 0, OP_IF, "C", "U", CL|OL|LN,
  292. "Load", C1, 0, OP_LOAD, "NS", "UU", 0,
  293. "Noop", C1, 0, OP_NOP, NULL, NULL, 0,
  294. "Notify", C1, 0, OP_NOTIFY, "SC", "UU", 0,
  295. "Release", C1, 0, OP_RELEASE, "S", "X", 0,
  296. "Reset", C1, 0, OP_RESET, "S", "E", 0,
  297. "Return", C1, 0, OP_RETURN, "C", "U", 0,
  298. "Signal", C1, 0, OP_SIGNAL, "S", "E", 0,
  299. "Sleep", C1, 0, OP_SLEEP, "C", "U", 0,
  300. "Stall", C1, 0, OP_STALL, "C", "U", 0,
  301. "Unload", C1, 0, OP_UNLOAD, "S", "U", 0,
  302. "While", C1, 0, OP_WHILE, "C", "U", CL|OL|LN,
  303. // Type 2 Opcode Terms
  304. "Acquire", C2, 0, OP_ACQUIRE, "SW", "X", 0,
  305. "Add", C2, 0, OP_ADD, "CCS", "UUU",0,
  306. "And", C2, 0, OP_AND, "CCS", "UUU",0,
  307. "Concatenate", C2, 0, OP_CONCAT, "CCS", "UUU",0,
  308. "CondRefOf", C2, 0, OP_CONDREFOF, "SS", "UU", 0,
  309. "Decrement", C2, 0, OP_DECREMENT, "S", "U", 0,
  310. "DerefOf", C2, 0, OP_DEREFOF, "C", "U", 0,
  311. "Divide", C2, 0, OP_DIVIDE, "CCSS", "UUUU",0,
  312. "FindSetLeftBit", C2, 0, OP_FINDSETLBIT, "CS", "UU", 0,
  313. "FindSetRightBit", C2, 0, OP_FINDSETRBIT, "CS", "UU", 0,
  314. "FromBCD", C2, 0, OP_FROMBCD, "CS", "UU", 0,
  315. "Increment", C2, 0, OP_INCREMENT, "S", "U", 0,
  316. "Index", C2, 0, OP_INDEX, "CCS", "UUU",0,
  317. "LAnd", C2, 0, OP_LAND, "CC", "UU", 0,
  318. "LEqual", C2, 0, OP_LEQ, "CC", "UU", 0,
  319. "LGreater", C2, 0, OP_LG, "CC", "UU", 0,
  320. "LGreaterEqual", C2, 0, OP_LGEQ, "CC", "UU", 0,
  321. "LLess", C2, 0, OP_LL, "CC", "UU", 0,
  322. "LLessEqual", C2, 0, OP_LLEQ, "CC", "UU", 0,
  323. "LNot", C2, 0, OP_LNOT, "C", "U", 0,
  324. "LNotEqual", C2, 0, OP_LNOTEQ, "CC", "UU", 0,
  325. "LOr", C2, 0, OP_LOR, "CC", "UU", 0,
  326. "Match", C2, 0, OP_MATCH, "CKCKCC", "UFUFUU",AF,
  327. "Multiply", C2, 0, OP_MULTIPLY, "CCS", "UUU",0,
  328. "NAnd", C2, 0, OP_NAND, "CCS", "UUU",0,
  329. "NOr", C2, 0, OP_NOR, "CCS", "UUU",0,
  330. "Not", C2, 0, OP_NOT, "CS", "UU", 0,
  331. "ObjectType", C2, 0, OP_OBJTYPE, "S", "U", 0,
  332. "Or", C2, 0, OP_OR, "CCS", "UUU",0,
  333. "RefOf", C2, 0, OP_REFOF, "S", "U", 0,
  334. "ShiftLeft", C2, 0, OP_SHIFTL, "CCS", "UUU",0,
  335. "ShiftRight", C2, 0, OP_SHIFTR, "CCS", "UUU",0,
  336. "SizeOf", C2, 0, OP_SIZEOF, "S", "U", 0,
  337. "Store", C2, 0, OP_STORE, "CS", "UU", 0,
  338. "Subtract", C2, 0, OP_SUBTRACT, "CCS", "UUU",0,
  339. "ToBCD", C2, 0, OP_TOBCD, "CS", "UU", 0,
  340. "Wait", C2, 0, OP_WAIT, "SC", "E", 0,
  341. "XOr", C2, 0, OP_XOR, "CCS", "UUU",0,
  342. NULL, 0, 0, OP_NONE, NULL, NULL, 0
  343. };
  344. UCHAR OpClassTable[256] =
  345. { //0x00 0x01 0x02 0x03
  346. CONSTOBJ, CONSTOBJ, INVALID, INVALID,
  347. //0x04 0x05 0x06 0x07
  348. INVALID, INVALID, CODEOBJ, INVALID,
  349. //0x08 0x09 0x0a 0x0b
  350. CODEOBJ, INVALID, DATAOBJ, DATAOBJ,
  351. //0x0c 0x0d 0x0e 0x0f
  352. DATAOBJ, DATAOBJ, INVALID, INVALID,
  353. //0x10 0x11 0x12 0x13
  354. CODEOBJ, CODEOBJ, CODEOBJ, INVALID,
  355. //0x14 0x15 0x16 0x17
  356. CODEOBJ, INVALID, INVALID, INVALID,
  357. //0x18 0x19 0x1a 0x1b
  358. INVALID, INVALID, INVALID, INVALID,
  359. //0x1c 0x1d 0x1e 0x1f
  360. INVALID, INVALID, INVALID, INVALID,
  361. //0x20 0x21 0x22 0x23
  362. INVALID, INVALID, INVALID, INVALID,
  363. //0x24 0x25 0x26 0x27
  364. INVALID, INVALID, INVALID, INVALID,
  365. //0x28 0x29 0x2a 0x2b
  366. INVALID, INVALID, INVALID, INVALID,
  367. //0x2c 0x2d 0x2e 0x2f
  368. INVALID, INVALID, NAMEOBJ, NAMEOBJ,
  369. //0x30 0x31 0x32 0x33
  370. INVALID, INVALID, INVALID, INVALID,
  371. //0x34 0x35 0x36 0x37
  372. INVALID, INVALID, INVALID, INVALID,
  373. //0x38 0x39 0x3a 0x3b
  374. INVALID, INVALID, INVALID, INVALID,
  375. //0x3c 0x3d 0x3e 0x3f
  376. INVALID, INVALID, INVALID, INVALID,
  377. //0x40 0x41 0x42 0x43
  378. INVALID, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  379. //0x44 0x45 0x46 0x47
  380. NAMEOBJ, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  381. //0x48 0x49 0x4a 0x4b
  382. NAMEOBJ, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  383. //0x4c 0x4d 0x4e 0x4f
  384. NAMEOBJ, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  385. //0x50 0x51 0x52 0x53
  386. NAMEOBJ, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  387. //0x54 0x55 0x56 0x57
  388. NAMEOBJ, NAMEOBJ, NAMEOBJ, NAMEOBJ,
  389. //0x58 0x59 0x5a 0x5b
  390. NAMEOBJ, NAMEOBJ, NAMEOBJ, INVALID,
  391. //0x5c 0x5d 0x5e 0x5f
  392. NAMEOBJ, INVALID, NAMEOBJ, NAMEOBJ,
  393. //0x60 0x61 0x62 0x63
  394. LOCALOBJ, LOCALOBJ, LOCALOBJ, LOCALOBJ,
  395. //0x64 0x65 0x66 0x67
  396. LOCALOBJ, LOCALOBJ, LOCALOBJ, LOCALOBJ,
  397. //0x68 0x69 0x6a 0x6b
  398. ARGOBJ, ARGOBJ, ARGOBJ, ARGOBJ,
  399. //0x6c 0x6d 0x6e 0x6f
  400. ARGOBJ, ARGOBJ, ARGOBJ, INVALID,
  401. //0x70 0x71 0x72 0x73
  402. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  403. //0x74 0x75 0x76 0x77
  404. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  405. //0x78 0x79 0x7a 0x7b
  406. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  407. //0x7c 0x7d 0x7e 0x7f
  408. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  409. //0x80 0x81 0x82 0x83
  410. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  411. //0x84 0x85 0x86 0x87
  412. INVALID, INVALID, CODEOBJ, CODEOBJ,
  413. //0x88 0x89 0x8a 0x8b
  414. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  415. //0x8c 0x8d 0x8e 0x8f
  416. CODEOBJ, CODEOBJ, CODEOBJ, INVALID,
  417. //0x90 0x91 0x92 0x93
  418. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  419. //0x94 0x95 0x96 0x97
  420. CODEOBJ, CODEOBJ, INVALID, INVALID,
  421. //0x98 0x99 0x9a 0x9b
  422. INVALID, INVALID, INVALID, INVALID,
  423. //0x9c 0x9d 0x9e 0x9f
  424. INVALID, INVALID, INVALID, INVALID,
  425. //0xa0 0xa1 0xa2 0xa3
  426. CODEOBJ, CODEOBJ, CODEOBJ, CODEOBJ,
  427. //0xa4 0xa5 0xa6 0xa7
  428. CODEOBJ, CODEOBJ, INVALID, INVALID,
  429. //0xa8 0xa9 0xaa 0xab
  430. INVALID, INVALID, INVALID, INVALID,
  431. //0xac 0xad 0xae 0xaf
  432. INVALID, INVALID, INVALID, INVALID,
  433. //0xb0 0xb1 0xb2 0xb3
  434. INVALID, INVALID, INVALID, INVALID,
  435. //0xb4 0xb5 0xb6 0xb7
  436. INVALID, INVALID, INVALID, INVALID,
  437. //0xb8 0xb9 0xba 0xbb
  438. INVALID, INVALID, INVALID, INVALID,
  439. //0xbc 0xbd 0xbe 0xbf
  440. INVALID, INVALID, INVALID, INVALID,
  441. //0xc0 0xc1 0xc2 0xc3
  442. INVALID, INVALID, INVALID, INVALID,
  443. //0xc4 0xc5 0xc6 0xc7
  444. INVALID, INVALID, INVALID, INVALID,
  445. //0xc8 0xc9 0xca 0xcb
  446. INVALID, INVALID, INVALID, INVALID,
  447. //0xcc 0xcd 0xce 0xcf
  448. CODEOBJ, INVALID, INVALID, INVALID,
  449. //0xd0 0xd1 0xd2 0xd3
  450. INVALID, INVALID, INVALID, INVALID,
  451. //0xd4 0xd5 0xd6 0xd7
  452. INVALID, INVALID, INVALID, INVALID,
  453. //0xd8 0xd9 0xda 0xdb
  454. INVALID, INVALID, INVALID, INVALID,
  455. //0xdc 0xdd 0xde 0xdf
  456. INVALID, INVALID, INVALID, INVALID,
  457. //0xe0 0xe1 0xe2 0xe3
  458. INVALID, INVALID, INVALID, INVALID,
  459. //0xe4 0xe5 0xe6 0xe7
  460. INVALID, INVALID, INVALID, INVALID,
  461. //0xe8 0xe9 0xea 0xeb
  462. INVALID, INVALID, INVALID, INVALID,
  463. //0xec 0xed 0xee 0xef
  464. INVALID, INVALID, INVALID, INVALID,
  465. //0xf0 0xf1 0xf2 0xf3
  466. INVALID, INVALID, INVALID, INVALID,
  467. //0xf4 0xf5 0xf6 0xf7
  468. INVALID, INVALID, INVALID, INVALID,
  469. //0xf8 0xf9 0xfa 0xfb
  470. INVALID, INVALID, INVALID, INVALID,
  471. //0xfc 0xfd 0xfe 0xff
  472. INVALID, INVALID, INVALID, CONSTOBJ
  473. };
  474. OPMAP ExOpClassTable[] =
  475. {
  476. EXOP_MUTEX, CODEOBJ,
  477. EXOP_EVENT, CODEOBJ,
  478. EXOP_CONDREFOF, CODEOBJ,
  479. EXOP_CREATEFIELD, CODEOBJ,
  480. EXOP_LOAD, CODEOBJ,
  481. EXOP_STALL, CODEOBJ,
  482. EXOP_SLEEP, CODEOBJ,
  483. EXOP_ACQUIRE, CODEOBJ,
  484. EXOP_SIGNAL, CODEOBJ,
  485. EXOP_WAIT, CODEOBJ,
  486. EXOP_RESET, CODEOBJ,
  487. EXOP_RELEASE, CODEOBJ,
  488. EXOP_FROMBCD, CODEOBJ,
  489. EXOP_TOBCD, CODEOBJ,
  490. EXOP_UNLOAD, CODEOBJ,
  491. EXOP_REVISION, CODEOBJ,
  492. EXOP_DEBUG, CODEOBJ,
  493. EXOP_FATAL, CODEOBJ,
  494. EXOP_OPREGION, CODEOBJ,
  495. EXOP_FIELD, CODEOBJ,
  496. EXOP_DEVICE, CODEOBJ,
  497. EXOP_PROCESSOR, CODEOBJ,
  498. EXOP_POWERRES, CODEOBJ,
  499. EXOP_THERMALZONE, CODEOBJ,
  500. EXOP_IDXFIELD, CODEOBJ,
  501. EXOP_BANKFIELD, CODEOBJ,
  502. 0, 0
  503. };
  504. /*** END Local data
  505. */
  506. DECLARE_API( amli )
  507. /*++
  508. Routine Description:
  509. Invoke AMLI debugger
  510. Arguments:
  511. None
  512. Return Value:
  513. None
  514. --*/
  515. {
  516. if ((args == NULL) || (*args == '\0'))
  517. {
  518. dprintf("Usage: amli <cmd> [arguments ...]\n"
  519. "where <cmd> is one of the following:\n");
  520. AMLIDbgHelp(NULL, NULL, 0, 0);
  521. dprintf("\n");
  522. }
  523. else
  524. {
  525. AMLIDbgExecuteCmd((PSZ)args);
  526. dprintf("\n");
  527. }
  528. return S_OK;
  529. }
  530. /***EP AMLIDbgExecuteCmd - Parse and execute a debugger command
  531. *
  532. * ENTRY
  533. * pszCmd -> command string
  534. *
  535. * EXIT
  536. * None
  537. */
  538. VOID STDCALL AMLIDbgExecuteCmd(PSZ pszCmd)
  539. {
  540. PSZ psz;
  541. int i;
  542. ULONG dwNumArgs = 0, dwNonSWArgs = 0;
  543. if ((psz = strtok(pszCmd, gcszTokenSeps)) != NULL)
  544. {
  545. for (i = 0; DbgCmds[i].pszCmd != NULL; i++)
  546. {
  547. if (strcmp(psz, DbgCmds[i].pszCmd) == 0)
  548. {
  549. if ((DbgCmds[i].pArgTable == NULL) ||
  550. (DbgParseArgs(DbgCmds[i].pArgTable,
  551. &dwNumArgs,
  552. &dwNonSWArgs,
  553. gcszTokenSeps) == ARGERR_NONE))
  554. {
  555. ASSERT(DbgCmds[i].pfnCmd != NULL);
  556. DbgCmds[i].pfnCmd(NULL, NULL, dwNumArgs, dwNonSWArgs);
  557. }
  558. break;
  559. }
  560. }
  561. }
  562. else
  563. {
  564. DBG_ERROR(("invalid command \"%s\"", pszCmd));
  565. }
  566. } //AMLIDbgExecuteCmd
  567. /***LP AMLIDbgHelp - help
  568. *
  569. * ENTRY
  570. * pArg -> argument type entry
  571. * pszArg -> argument string
  572. * dwArgNum - argument number
  573. * dwNonSWArgs - number of non-switch arguments
  574. *
  575. * EXIT-SUCCESS
  576. * returns DBGERR_NONE
  577. * EXIT-FAILURE
  578. * returns negative error code
  579. */
  580. LONG LOCAL AMLIDbgHelp(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  581. ULONG dwNonSWArgs)
  582. {
  583. LONG rc = DBGERR_NONE;
  584. DEREF(pArg);
  585. DEREF(dwNonSWArgs);
  586. //
  587. // User typed ? <cmd>
  588. //
  589. if (pszArg != NULL)
  590. {
  591. if (strcmp(pszArg, "?") == 0)
  592. {
  593. dprintf("\nHelp:\n");
  594. dprintf("Usage: ? [<Cmd>]\n");
  595. dprintf("<Cmd> - command to get help on\n");
  596. }
  597. else if (strcmp(pszArg, "bc") == 0)
  598. {
  599. dprintf("\nClear Breakpoints:\n");
  600. dprintf("Usage: bc <bp list> | *\n");
  601. dprintf("<bp list> - list of breakpoint numbers\n");
  602. dprintf("* - all breakpoints\n");
  603. }
  604. else if (strcmp(pszArg, "bd") == 0)
  605. {
  606. dprintf("\nDisable Breakpoints:\n");
  607. dprintf("Usage: bd <bp list> | *\n");
  608. dprintf("<bp list> - list of breakpoint numbers\n");
  609. dprintf("* - all breakpoints\n");
  610. }
  611. else if (strcmp(pszArg, "be") == 0)
  612. {
  613. dprintf("\nEnable Breakpoints:\n");
  614. dprintf("Usage: be <bp list> | *\n");
  615. dprintf("<bp list> - list of breakpoint numbers\n");
  616. dprintf("* - all breakpoints\n");
  617. }
  618. else if (strcmp(pszArg, "bl") == 0)
  619. {
  620. dprintf("\nList All Breakpoints:\n");
  621. dprintf("Usage: bl\n");
  622. }
  623. else if (strcmp(pszArg, "bp") == 0)
  624. {
  625. dprintf("\nSet BreakPoints:\n");
  626. dprintf("Usage: bp <MethodName> | <CodeAddr> ...\n");
  627. dprintf("<MethodName> - full path of method name to have breakpoint set at\n");
  628. dprintf("<CodeAddr> - address of AML code to have breakpoint set at\n");
  629. }
  630. else if (strcmp(pszArg, "cl") == 0)
  631. {
  632. dprintf("\nClear Event Log:\n");
  633. dprintf("Usage: cl\n");
  634. }
  635. else if (strcmp(pszArg, "debugger") == 0)
  636. {
  637. dprintf("\nRequest entering AMLI debugger:\n");
  638. dprintf("Usage: debugger\n");
  639. }
  640. else if (strcmp(pszArg, "dh") == 0)
  641. {
  642. dprintf("\nDump Heap:\n");
  643. dprintf("Usage: dh [<Addr>]\n");
  644. dprintf("<Addr> - address of the heap block, global heap if missing\n");
  645. }
  646. else if (strcmp(pszArg, "dl") == 0)
  647. {
  648. dprintf("\nDump Event Log:\n");
  649. dprintf("Usage: dl\n");
  650. }
  651. else if (strcmp(pszArg, "dns") == 0)
  652. {
  653. dprintf("\nDump Name Space Object:\n");
  654. dprintf("Usage: dns [[/s] [<NameStr> | <Addr>]]\n");
  655. dprintf("s - recursively dump the name space subtree\n");
  656. dprintf("<NameStr> - name space path (dump whole name space if absent)\n");
  657. dprintf("<Addr> - specify address of the name space object\n");
  658. }
  659. else if (strcmp(pszArg, "do") == 0)
  660. {
  661. dprintf("\nDump Data Object:\n");
  662. dprintf("Usage: do <Addr>\n");
  663. dprintf("<Addr> - address of the data object\n");
  664. }
  665. else if (strcmp(pszArg, "ds") == 0)
  666. {
  667. dprintf("\nDump Stack:\n");
  668. dprintf("Usage: ds [/v] [<Addr>]\n");
  669. dprintf("v - enable versbos mode\n");
  670. dprintf("<Addr> - address of the context block, use current context if missing\n");
  671. }
  672. else if (strcmp(pszArg, "find") == 0)
  673. {
  674. dprintf("\nFind NameSpace Object:\n");
  675. dprintf("Usage: find <NameSeg>\n");
  676. dprintf("<NameSeg> - Name of the NameSpace object without path\n");
  677. }
  678. else if (strcmp(pszArg, "lc") == 0)
  679. {
  680. dprintf("\nList All Contexts:\n");
  681. dprintf("Usage: lc\n");
  682. }
  683. else if (strcmp(pszArg, "ln") == 0)
  684. {
  685. dprintf("\nDisplay Nearest Method Name:\n");
  686. dprintf("Usage: ln [<MethodName> | <CodeAddr>]\n");
  687. dprintf("<MethodName> - full path of method name\n");
  688. dprintf("<CodeAddr> - address of AML code\n");
  689. }
  690. else if (strcmp(pszArg, "p") == 0)
  691. {
  692. dprintf("\nStep over AML Code\n");
  693. dprintf("Usage: p\n");
  694. }
  695. else if (strcmp(pszArg, "r") == 0)
  696. {
  697. dprintf("\nDisplay Context Information:\n");
  698. dprintf("Usage: r\n");
  699. }
  700. else if (strcmp(pszArg, "set") == 0)
  701. {
  702. dprintf("\nSet Debugger Options:\n");
  703. dprintf("Usage: set [traceon | traceoff] [nesttraceon | nesttraceoff] [spewon | spewoff]\n"
  704. " [lbrkon | lbrkoff] [errbrkon | errbrkoff] [verboseon | verboseoff] \n"
  705. " [logon | logoff] [logmuton | logmutoff]\n");
  706. dprintf("traceon - turn on AML tracing\n");
  707. dprintf("traceoff - turn off AML tracing\n");
  708. dprintf("nesttraceon - turn on nest tracing (only valid with traceon)\n");
  709. dprintf("nesttraceoff - turn off nest tracing (only valid with traceon)\n");
  710. dprintf("spewon - turn on debug spew\n");
  711. dprintf("spewoff - turn off debug spew\n");
  712. dprintf("lbrkon - enable load DDB completion break\n");
  713. dprintf("lbrkoff - disable load DDB completion break\n");
  714. dprintf("errbrkon - enable break on error\n");
  715. dprintf("errbrkoff - disable break on error\n");
  716. dprintf("verboseon - enable verbose mode\n");
  717. dprintf("verboseoff - disable verbose mode\n");
  718. dprintf("logon - enable event logging\n");
  719. dprintf("logoff - disable event logging\n");
  720. dprintf("logmuton - enable mutex event logging\n");
  721. dprintf("logmutoff - disable mutex event logging\n");
  722. }
  723. else if (strcmp(pszArg, "u") == 0)
  724. {
  725. dprintf("\nUnassemble AML code:\n");
  726. dprintf("Usage: u [<MethodName> | <CodeAddr>]\n");
  727. dprintf("<MethodName> - full path of method name\n");
  728. dprintf("<CodeAddr> - address of AML code\n");
  729. }
  730. else
  731. {
  732. DBG_ERROR(("invalid help command - %s", pszArg));
  733. rc = DBGERR_INVALID_CMD;
  734. }
  735. }
  736. //
  737. // User typed just a "?" without any arguments
  738. //
  739. else if (dwArgNum == 0)
  740. {
  741. dprintf("\n");
  742. dprintf("Help - ? [<Cmd>]\n");
  743. dprintf("Clear Breakpoints - bc <bp list> | *\n");
  744. dprintf("Disable Breakpoints - bd <bp list> | *\n");
  745. dprintf("Enable Breakpoints - be <bp list> | *\n");
  746. dprintf("List Breakpoints - bl\n");
  747. dprintf("Set Breakpoints - bp <MethodName> | <CodeAddr> ...\n");
  748. dprintf("Clear Event Log - cl\n");
  749. dprintf("Request entering debugger- debugger\n");
  750. dprintf("Dump Heap - dh [<Addr>]\n");
  751. dprintf("Dump Event Log - dl\n");
  752. dprintf("Dump Name Space Object - dns [[/s] [<NameStr> | <Addr>]]\n");
  753. dprintf("Dump Data Object - do <Addr>\n");
  754. if(GetExpression("ACPI!gDebugger"))
  755. dprintf("Dump Stack - ds [/v] [<Addr>]\n");
  756. else
  757. dprintf("Dump Stack - ds [<Addr>]\n");
  758. dprintf("Find NameSpace Object - find <NameSeg>\n");
  759. dprintf("List All Contexts - lc\n");
  760. dprintf("Display Nearest Method - ln [<MethodName> | <CodeAddr>]\n");
  761. dprintf("Step Over AML Code - p\n");
  762. dprintf("Display Context Info. - r\n");
  763. dprintf("Set Debugger Options - set [traceon | traceoff] [nesttraceon | nesttraceoff] [spewon | spewoff]\n"
  764. " [lbrkon | lbrkoff] [errbrkon | errbrkoff] [verboseon | verboseoff] \n"
  765. " [logon | logoff] [logmuton | logmutoff]\n");
  766. dprintf("Unassemble AML code - u [<MethodName> | <CodeAddr>]\n");
  767. }
  768. return rc;
  769. } //AMLIDbgHelp
  770. /***LP AMLIDbgBC - Clear BreakPoint
  771. *
  772. * ENTRY
  773. * pArg -> argument type entry
  774. * pszArg -> argument string
  775. * dwArgNum - argument number
  776. * dwNonSWArgs - number of non-switch arguments
  777. *
  778. * EXIT-SUCCESS
  779. * returns DBGERR_NONE
  780. * EXIT-FAILURE
  781. * returns negative error code
  782. */
  783. LONG LOCAL AMLIDbgBC(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  784. ULONG dwNonSWArgs)
  785. {
  786. LONG rc = DBGERR_NONE;
  787. DEREF(pArg);
  788. DEREF(dwNonSWArgs);
  789. if (pszArg != NULL)
  790. {
  791. ULONG dwBrkPt;
  792. if (STRCMP(pszArg, "*") == 0)
  793. {
  794. for (dwBrkPt = 0; dwBrkPt < MAX_BRK_PTS; ++dwBrkPt)
  795. {
  796. if ((rc = ClearBrkPt((int)dwBrkPt)) != DBGERR_NONE)
  797. {
  798. break;
  799. }
  800. }
  801. }
  802. else if (IsNumber(pszArg, 10, (PULONG64)&dwBrkPt))
  803. {
  804. rc = ClearBrkPt((int)dwBrkPt);
  805. }
  806. else
  807. {
  808. DBG_ERROR(("invalid breakpoint number"));
  809. rc = DBGERR_INVALID_CMD;
  810. }
  811. }
  812. else if (dwArgNum == 0)
  813. {
  814. DBG_ERROR(("invalid breakpoint command"));
  815. rc = DBGERR_INVALID_CMD;
  816. }
  817. return rc;
  818. } //AMLIDbgBC
  819. /***LP AMLIDbgBD - Disable BreakPoint
  820. *
  821. * ENTRY
  822. * pArg -> argument type entry
  823. * pszArg -> argument string
  824. * dwArgNum - argument number
  825. * dwNonSWArgs - number of non-switch arguments
  826. *
  827. * EXIT-SUCCESS
  828. * returns DBGERR_NONE
  829. * EXIT-FAILURE
  830. * returns negative error code
  831. */
  832. LONG LOCAL AMLIDbgBD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  833. ULONG dwNonSWArgs)
  834. {
  835. LONG rc =0;
  836. DEREF(pArg);
  837. DEREF(dwNonSWArgs);
  838. rc = EnableDisableBP(pszArg, FALSE, dwArgNum);
  839. return rc;
  840. } //AMLIDbgBD
  841. /***LP AMLIDbgBE - Enable BreakPoint
  842. *
  843. * ENTRY
  844. * pArg -> argument type entry
  845. * pszArg -> argument string
  846. * dwArgNum - argument number
  847. * dwNonSWArgs - number of non-switch arguments
  848. *
  849. * EXIT-SUCCESS
  850. * returns DBGERR_NONE
  851. * EXIT-FAILURE
  852. * returns negative error code
  853. */
  854. LONG LOCAL AMLIDbgBE(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  855. ULONG dwNonSWArgs)
  856. {
  857. LONG rc=0;
  858. DEREF(pArg);
  859. DEREF(dwNonSWArgs);
  860. rc = EnableDisableBP(pszArg, TRUE, dwArgNum);
  861. return rc;
  862. } //AMLIDbgBE
  863. /***LP AMLIDbgBL - List BreakPoints
  864. *
  865. * ENTRY
  866. * pArg -> argument type entry
  867. * pszArg -> argument string
  868. * dwArgNum - argument number
  869. * dwNonSWArgs - number of non-switch arguments
  870. *
  871. * EXIT-SUCCESS
  872. * returns DBGERR_NONE
  873. * EXIT-FAILURE
  874. * returns negative error code
  875. */
  876. LONG LOCAL AMLIDbgBL(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  877. ULONG dwNonSWArgs)
  878. {
  879. LONG rc = DBGERR_NONE;
  880. DEREF(pArg);
  881. DEREF(dwArgNum);
  882. DEREF(dwNonSWArgs);
  883. if (pszArg == NULL)
  884. {
  885. ULONG64 Address_BrkPts = FIELDADDROF("gDebugger", "DBGR", "BrkPts");
  886. if ( Address_BrkPts != 0)
  887. {
  888. int i;
  889. ULONG dwOffset;
  890. for (i = 0; i < MAX_BRK_PTS; ++i)
  891. {
  892. if(InitTypeRead(Address_BrkPts + GetTypeSize("ACPI!_brkpt") * i, ACPI!_brkpt) ==0)
  893. {
  894. if ((VOID*)ReadField(pbBrkPt) != NULL)
  895. {
  896. ULONG dwfBrkPt = (ULONG)ReadField(dwfBrkPt);
  897. PRINTF("%2d: <%c> ",
  898. i,
  899. (dwfBrkPt & BPF_ENABLED)? 'e': 'd');
  900. PrintSymbol((ULONG64)ReadField(pbBrkPt));
  901. PRINTF("\n");
  902. }
  903. }
  904. else
  905. {
  906. DBG_ERROR(("failed to Initialize break point table for address (%p)", Address_BrkPts + GetTypeSize("ACPI!_brkpt") * i));
  907. }
  908. }
  909. }
  910. else
  911. {
  912. DBG_ERROR(("failed to read break point table"));
  913. rc = DBGERR_CMD_FAILED;
  914. }
  915. }
  916. else
  917. {
  918. DBG_ERROR(("invalid breakpoint command"));
  919. rc = DBGERR_INVALID_CMD;
  920. }
  921. return rc;
  922. } //AMLIDbgBL
  923. /***LP AMLIDbgBP - Set BreakPoint
  924. *
  925. * ENTRY
  926. * pArg -> argument type entry
  927. * pszArg -> argument string
  928. * dwArgNum - argument number
  929. * dwNonSWArgs - number of non-switch arguments
  930. *
  931. * EXIT-SUCCESS
  932. * returns DBGERR_NONE
  933. * EXIT-FAILURE
  934. * returns negative error code
  935. */
  936. LONG LOCAL AMLIDbgBP(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  937. ULONG dwNonSWArgs)
  938. {
  939. LONG rc = DBGERR_NONE;
  940. DEREF(pArg);
  941. DEREF(dwNonSWArgs);
  942. if (pszArg != NULL)
  943. {
  944. ULONG64 uipBP;
  945. if ((rc = EvalExpr(pszArg, &uipBP, NULL, NULL, NULL)) == DBGERR_NONE)
  946. {
  947. rc = AddBrkPt(uipBP);
  948. }
  949. }
  950. else if (dwArgNum == 0)
  951. {
  952. DBG_ERROR(("invalid breakpoint command"));
  953. rc = DBGERR_INVALID_CMD;
  954. }
  955. return rc;
  956. } //AMLIDbgBP
  957. /***LP AddBrkPt - Add breakpoint
  958. *
  959. * ENTRY
  960. * uipBrkPtAddr - breakpoint address
  961. *
  962. * EXIT-SUCCESS
  963. * returns DBGERR_NONE
  964. * EXIT-FAILURE
  965. * returns DBGERR_CMD_FAILED
  966. */
  967. LONG LOCAL AddBrkPt(ULONG64 uipBrkPtAddr)
  968. {
  969. LONG rc = DBGERR_NONE;
  970. ULONG64 uipBrkPts = FIELDADDROF("gDebugger", "DBGR", "BrkPts"), uipBP = 0;
  971. int i, iBrkPt;
  972. //
  973. // Look for a vacant slot.
  974. //
  975. for (i = 0, iBrkPt = -1; i < MAX_BRK_PTS; ++i)
  976. {
  977. if(InitTypeRead(uipBrkPts + (GetTypeSize("ACPI!_brkpt") * i), ACPI!_brkpt) == 0)
  978. {
  979. uipBP = ReadField(pbBrkPt) ;
  980. if ((uipBrkPtAddr == uipBP) || (iBrkPt == -1) && (uipBP == 0))
  981. {
  982. iBrkPt = i;
  983. }
  984. }
  985. else
  986. {
  987. DBG_ERROR(("Failed to initialize breakpoint table %p", uipBrkPts + (GetTypeSize("ACPI!_brkpt") * i)));
  988. }
  989. }
  990. if (iBrkPt == -1)
  991. {
  992. DBG_ERROR(("no free breakpoint"));
  993. rc = DBGERR_CMD_FAILED;
  994. }
  995. else if (uipBP == 0)
  996. {
  997. ULONG64 pbBrkPt = 0;
  998. ULONG dwfBrkPt = 0;
  999. dwfBrkPt = BPF_ENABLED;
  1000. pbBrkPt = uipBrkPtAddr;
  1001. if (!WriteMemory(uipBrkPts + GetTypeSize("ACPI!_brkpt")*iBrkPt,
  1002. &dwfBrkPt,
  1003. sizeof(dwfBrkPt),
  1004. NULL))
  1005. {
  1006. DBG_ERROR(("failed to write to break point %d", iBrkPt));
  1007. rc = DBGERR_CMD_FAILED;
  1008. }
  1009. if (!WriteMemory(uipBrkPts + GetTypeSize("ACPI!_brkpt")*iBrkPt + AMLI_FIELD_OFFSET("_brkpt", "pbBrkPt"),
  1010. &pbBrkPt,
  1011. IsPtr64()? sizeof(ULONG64): sizeof(ULONG),
  1012. NULL))
  1013. {
  1014. DBG_ERROR(("failed to write to break point %d", iBrkPt));
  1015. rc = DBGERR_CMD_FAILED;
  1016. }
  1017. }
  1018. return rc;
  1019. } //AddBrkPt
  1020. /***LP ClearBrkPt - Clear breakpoint
  1021. *
  1022. * ENTRY
  1023. * iBrkPt - breakpoint number
  1024. *
  1025. * EXIT-SUCCESS
  1026. * returns DBGERR_NONE
  1027. * EXIT-FAILURE
  1028. * returns DBGERR_CMD_FAILED
  1029. */
  1030. LONG LOCAL ClearBrkPt(int iBrkPt)
  1031. {
  1032. LONG rc=0;
  1033. if (iBrkPt < MAX_BRK_PTS)
  1034. {
  1035. MZERO(FIELDADDROF("gDebugger", "DBGR", "BrkPts") + (GetTypeSize("ACPI!BRKPT")*iBrkPt),
  1036. GetTypeSize("ACPI!BRKPT"));
  1037. rc = DBGERR_NONE;
  1038. }
  1039. else
  1040. {
  1041. DBG_ERROR(("invalid breakpoint number"));
  1042. rc = DBGERR_CMD_FAILED;
  1043. }
  1044. return rc;
  1045. } //ClearBrkPt
  1046. /***LP SetBrkPtState - Enable/Disable breakpoint
  1047. *
  1048. * ENTRY
  1049. * iBrkPt - breakpoint number
  1050. * fEnable - enable breakpoint
  1051. *
  1052. * EXIT-SUCCESS
  1053. * returns DBGERR_NONE
  1054. * EXIT-FAILURE
  1055. * returns DBGERR_CMD_FAILED
  1056. */
  1057. LONG LOCAL SetBrkPtState(int iBrkPt, BOOLEAN fEnable)
  1058. {
  1059. LONG rc = DBGERR_CMD_FAILED;
  1060. if (iBrkPt < MAX_BRK_PTS)
  1061. {
  1062. ULONG64 Address_BP = FIELDADDROF("gDebugger", "DBGR", "BrkPts") +
  1063. (GetTypeSize("ACPI!_brkpt") * iBrkPt);
  1064. ULONG dwfBrkPt = 0;
  1065. if(InitTypeRead(Address_BP, ACPI!_brkpt) == 0)
  1066. {
  1067. if ((VOID*)ReadField(pbBrkPt) != NULL)
  1068. {
  1069. if (fEnable)
  1070. {
  1071. dwfBrkPt |= BPF_ENABLED;
  1072. }
  1073. else
  1074. {
  1075. dwfBrkPt &= ~BPF_ENABLED;
  1076. }
  1077. //Address_BP = Address_BP + AMLI_FIELD_OFFSET("_brkpt", "dwfBrkPt");
  1078. if (WriteMemory(Address_BP, &dwfBrkPt, sizeof(ULONG), NULL))
  1079. {
  1080. rc = DBGERR_NONE;
  1081. }
  1082. else
  1083. {
  1084. DBG_ERROR(("failed to write break point %d", iBrkPt));
  1085. }
  1086. }
  1087. else
  1088. {
  1089. rc = DBGERR_NONE;
  1090. }
  1091. }
  1092. else
  1093. {
  1094. DBG_ERROR(("failed to initialize break point %d", iBrkPt));
  1095. }
  1096. }
  1097. else
  1098. {
  1099. DBG_ERROR(("invalid breakpoint number"));
  1100. }
  1101. return rc;
  1102. } //SetBrkPtState
  1103. /***LP EnableDisableBP - Enable/Disable BreakPoints
  1104. *
  1105. * ENTRY
  1106. * pszArg -> argument string
  1107. * fEnable - TRUE if enable breakpoints
  1108. * dwArgNum - argument number
  1109. *
  1110. * EXIT-SUCCESS
  1111. * returns DBGERR_NONE
  1112. * EXIT-FAILURE
  1113. * returns negative error code
  1114. */
  1115. LONG LOCAL EnableDisableBP(PSZ pszArg, BOOLEAN fEnable, ULONG dwArgNum)
  1116. {
  1117. LONG rc = DBGERR_NONE;
  1118. if (pszArg != NULL)
  1119. {
  1120. ULONG64 dwBrkPt = 0;
  1121. if (STRCMP(pszArg, "*") == 0)
  1122. {
  1123. for (dwBrkPt = 0; dwBrkPt < MAX_BRK_PTS; ++dwBrkPt)
  1124. {
  1125. if ((rc = SetBrkPtState((int)dwBrkPt, fEnable)) != DBGERR_NONE)
  1126. break;
  1127. }
  1128. }
  1129. else if (IsNumber(pszArg, 10, &dwBrkPt))
  1130. {
  1131. rc = SetBrkPtState((int)dwBrkPt, fEnable);
  1132. }
  1133. else
  1134. {
  1135. DBG_ERROR(("invalid breakpoint number"));
  1136. rc = DBGERR_INVALID_CMD;
  1137. }
  1138. }
  1139. else if (dwArgNum == 0)
  1140. {
  1141. DBG_ERROR(("invalid breakpoint command"));
  1142. rc = DBGERR_INVALID_CMD;
  1143. }
  1144. return rc;
  1145. } //EnableDisableBP
  1146. /***LP AMLIDbgCL - Clear event log
  1147. *
  1148. * ENTRY
  1149. * pArg -> argument type entry
  1150. * pszArg -> argument string
  1151. * dwArgNum - argument number
  1152. * dwNonSWArgs - number of non-switch arguments
  1153. *
  1154. * EXIT-SUCCESS
  1155. * returns DBGERR_NONE
  1156. * EXIT-FAILURE
  1157. * returns negative error code
  1158. */
  1159. LONG LOCAL AMLIDbgCL(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1160. ULONG dwNonSWArgs)
  1161. {
  1162. LONG rc=0;
  1163. DEREF(pArg);
  1164. DEREF(dwArgNum);
  1165. DEREF(dwNonSWArgs);
  1166. if (pszArg == NULL)
  1167. {
  1168. ULONG64 uipEventLog = 0;
  1169. ULONG64 Address_gDebugger = 0;
  1170. Address_gDebugger = GetExpression("ACPI!gDebugger");
  1171. if (Address_gDebugger)
  1172. {
  1173. InitTypeRead(Address_gDebugger, ACPI!_dbgr);
  1174. uipEventLog = ReadField(pEventLog);
  1175. if (uipEventLog != 0)
  1176. {
  1177. ULONG dwLogSize = (ULONG)ReadField(dwLogSize);
  1178. ULONG i = 0;
  1179. if(dwLogSize != 0)
  1180. {
  1181. //
  1182. // For some reason, zeroing the whole eventlog in one shot
  1183. // causes WriteMemory to hang, so I'll do one record at a
  1184. // time.
  1185. //
  1186. for (i = 0; i < dwLogSize; ++i)
  1187. {
  1188. MZERO((ULONG64)(uipEventLog + (ULONG64)(i * GetTypeSize("ACPI!_eventlog"))), (ULONG)GetTypeSize("ACPI!_eventlog"));
  1189. }
  1190. i = 0;
  1191. WRITEMEMDWORD(FIELDADDROF("gDebugger", "DBGR", "dwLogIndex"), i);
  1192. rc = DBGERR_NONE;
  1193. }
  1194. }
  1195. else
  1196. {
  1197. DBG_ERROR(("no event log allocated"));
  1198. rc = DBGERR_CMD_FAILED;
  1199. }
  1200. }
  1201. else
  1202. {
  1203. DBG_ERROR(("failed to to get the address of ACPI!gDegugger %I64x", Address_gDebugger));
  1204. }
  1205. }
  1206. else
  1207. {
  1208. DBG_ERROR(("invalid CL command"));
  1209. rc = DBGERR_INVALID_CMD;
  1210. }
  1211. return rc;
  1212. } //AMLIDbgCL
  1213. /***LP AMLIDbgDebugger - Request entering debugger
  1214. *
  1215. * ENTRY
  1216. * pArg -> argument type entry
  1217. * pszArg -> argument string
  1218. * dwArgNum - argument number
  1219. * dwNonSWArgs - number of non-switch arguments
  1220. *
  1221. * EXIT-SUCCESS
  1222. * returns DBGERR_NONE
  1223. * EXIT-FAILURE
  1224. * returns negative error code
  1225. */
  1226. LONG LOCAL AMLIDbgDebugger(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1227. ULONG dwNonSWArgs)
  1228. {
  1229. LONG rc = DBGERR_NONE;
  1230. ULONG64 Address = 0;
  1231. DWORD dwfDebugger = 0;
  1232. ULONG Offset = 0;
  1233. DEREF(pArg);
  1234. DEREF(dwArgNum);
  1235. DEREF(dwNonSWArgs);
  1236. if (pszArg == NULL)
  1237. {
  1238. Address = GetExpression("ACPI!gDebugger");
  1239. InitTypeRead(Address, ACPI!_dbgr);
  1240. if(Address != 0)
  1241. {
  1242. dwfDebugger = (ULONG)ReadField(dwfDebugger);
  1243. dwfDebugger |= DBGF_DEBUGGER_REQ;
  1244. GetFieldOffset("ACPI!_dbgr", "dwfDebugger", &Offset);
  1245. Address = Address + (ULONG64)Offset;
  1246. WriteAtAddress(Address, dwfDebugger, sizeof(dwfDebugger));
  1247. if(rc != DBGERR_NONE)
  1248. {
  1249. DBG_ERROR(("failed to set dwfDebugger"));
  1250. }
  1251. }
  1252. else
  1253. {
  1254. DBG_ERROR(("failed to get debugger flag address"));
  1255. rc = DBGERR_CMD_FAILED;
  1256. }
  1257. }
  1258. else
  1259. {
  1260. DBG_ERROR(("invalid debugger command"));
  1261. rc = DBGERR_INVALID_CMD;
  1262. }
  1263. return rc;
  1264. } //AMLIDbgDebugger
  1265. /***LP AMLIDbgDH - Dump heap
  1266. *
  1267. * ENTRY
  1268. * pArg -> argument type entry
  1269. * pszArg -> argument string
  1270. * dwArgNum - argument number
  1271. * dwNonSWArgs - number of non-switch arguments
  1272. *
  1273. * EXIT-SUCCESS
  1274. * returns DBGERR_NONE
  1275. * EXIT-FAILURE
  1276. * returns negative error code
  1277. */
  1278. LONG LOCAL AMLIDbgDH(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1279. ULONG dwNonSWArgs)
  1280. {
  1281. LONG rc = DBGERR_NONE;
  1282. ULONG64 uipHeap = 0;
  1283. DEREF(pArg);
  1284. DEREF(dwNonSWArgs);
  1285. if(GetExpression("ACPI!gDebugger"))
  1286. {
  1287. if (pszArg != NULL)
  1288. {
  1289. if (uipHeap == 0)
  1290. {
  1291. if (!IsNumber(pszArg, 16, &uipHeap))
  1292. {
  1293. DBG_ERROR(("invalid heap block address - %s", pszArg));
  1294. rc = DBGERR_INVALID_CMD;
  1295. }
  1296. }
  1297. else
  1298. {
  1299. DBG_ERROR(("invalid dump heap command"));
  1300. rc = DBGERR_INVALID_CMD;
  1301. }
  1302. }
  1303. else
  1304. {
  1305. ULONG64 HeapHdr;
  1306. if (dwArgNum == 0)
  1307. {
  1308. ReadPointer(GetExpression("ACPI!gpheapGlobal"), &uipHeap);
  1309. }
  1310. if (InitTypeRead(uipHeap, ACPI!HEAP) == 0)
  1311. {
  1312. if (ReadField(dwSig) == SIG_HEAP)
  1313. {
  1314. for (uipHeap = ReadField(pheapHead);
  1315. (rc == DBGERR_NONE) &&
  1316. (uipHeap != 0) &&
  1317. (InitTypeRead(uipHeap, ACPI!HEAP) == 0);
  1318. uipHeap = ReadField(pheapNext))
  1319. {
  1320. rc = DumpHeap(uipHeap,
  1321. (ULONG)((ReadField(pbHeapEnd) - uipHeap)));
  1322. }
  1323. }
  1324. else
  1325. {
  1326. DBG_ERROR(("invalid heap block at %I64x", uipHeap));
  1327. rc = DBGERR_CMD_FAILED;
  1328. }
  1329. }
  1330. else
  1331. {
  1332. DBG_ERROR(("failed to Initialize heap header at %I64x", uipHeap));
  1333. rc = DBGERR_CMD_FAILED;
  1334. }
  1335. uipHeap = 0;
  1336. }
  1337. }
  1338. else
  1339. {
  1340. DBG_ERROR(("failed to get gDebugger. This command only works on Checked ACPI.SYS."));
  1341. rc = DBGERR_CMD_FAILED;
  1342. }
  1343. return rc;
  1344. } //AMLIDbgDH
  1345. /***LP DumpHeap - Dump heap block
  1346. *
  1347. * ENTRY
  1348. * uipHeap - Heap block address
  1349. * dwSize - Heap block size
  1350. *
  1351. * EXIT-SUCCESS
  1352. * returns DBGERR_NONE
  1353. * EXIT-FAILURE
  1354. * returns negative error code
  1355. */
  1356. LONG LOCAL DumpHeap(ULONG64 uipHeap, ULONG dwSize)
  1357. {
  1358. LONG rc = DBGERR_NONE;
  1359. if (InitTypeRead(uipHeap, ACPI!HEAP) == 0)
  1360. {
  1361. ULONG64 phobj = 0;
  1362. ULONG Length = 0;
  1363. ULONG64 Heap = 0;
  1364. ULONG64 HeapTop = 0;
  1365. PRINTF("HeapBlock=%I64x, HeapEnd=%I64x, HeapHead=%I64x, HeapNext=%I64x\n",
  1366. uipHeap, ReadField(pbHeapEnd), ReadField(pheapHead), ReadField(pheapNext));
  1367. PRINTF("HeapTop=%I64x, HeapFreeList=%I64x, UsedHeapSize=%I64d bytes\n",
  1368. ReadField(pbHeapTop), ReadField(plistFreeHeap),
  1369. ReadField(pbHeapTop) - uipHeap - AMLI_FIELD_OFFSET("HEAP", "Heap"));
  1370. Heap = ReadField(Heap);
  1371. HeapTop = ReadField(pbHeapTop);
  1372. for (phobj = Heap;
  1373. ((phobj < HeapTop) && (InitTypeRead(phobj, ACPI!HEAPOBJHDR) == 0 ));
  1374. phobj = (phobj + ReadField(dwLen)))
  1375. {
  1376. if (CheckControlC())
  1377. {
  1378. break;
  1379. }
  1380. PRINTF("%I64x: %s, Len=%08d, Prev=%016I64x, Next=%016I64x \n",
  1381. phobj,
  1382. (ReadField(dwSig) == 0)? "free": NameSegString((ULONG)ReadField(dwSig)),
  1383. (ULONG)ReadField(dwLen),
  1384. (ReadField(dwSig) == 0)? ReadField (list.plistPrev): 0,
  1385. (ReadField(dwSig) == 0)? ReadField (list.plistNext): 0);
  1386. }
  1387. }
  1388. else
  1389. {
  1390. DBG_ERROR(("failed to Initialize heap block at %I64x, size=%d",
  1391. uipHeap, dwSize));
  1392. rc = DBGERR_CMD_FAILED;
  1393. }
  1394. return rc;
  1395. } //DumpHeap
  1396. /***LP AMLIDbgDL - Dump event log
  1397. *
  1398. * ENTRY
  1399. * pArg -> argument type entry
  1400. * pszArg -> argument string
  1401. * dwArgNum - argument number
  1402. * dwNonSWArgs - number of non-switch arguments
  1403. *
  1404. * EXIT-SUCCESS
  1405. * returns DBGERR_NONE
  1406. * EXIT-FAILURE
  1407. * returns negative error code
  1408. */
  1409. LONG LOCAL AMLIDbgDL(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1410. ULONG dwNonSWArgs)
  1411. {
  1412. LONG rc = DBGERR_NONE;
  1413. DEREF(pArg);
  1414. DEREF(dwArgNum);
  1415. DEREF(dwNonSWArgs);
  1416. if (pszArg != NULL)
  1417. {
  1418. DBG_ERROR(("invalid DL command"));
  1419. rc = DBGERR_INVALID_CMD;
  1420. }
  1421. else
  1422. {
  1423. ULONG64 uipEventLog = 0;
  1424. ULONG64 Address_gDebugger = 0;
  1425. Address_gDebugger = GetExpression("ACPI!gDebugger");
  1426. if (Address_gDebugger)
  1427. {
  1428. if(InitTypeRead(Address_gDebugger, ACPI!_dbgr) == 0)
  1429. {
  1430. uipEventLog = ReadField(pEventLog);
  1431. if (uipEventLog != 0)
  1432. {
  1433. ULONG dwLogSize, dwLogIndex, i;
  1434. ULONG64 pEventLog;
  1435. TIME_FIELDS eventTime;
  1436. LARGE_INTEGER eventTimeInt;
  1437. dwLogSize = (ULONG)ReadField(dwLogSize);
  1438. dwLogIndex = (ULONG)ReadField(dwLogIndex);
  1439. for (i = dwLogIndex;;)
  1440. {
  1441. if (CheckControlC())
  1442. {
  1443. break;
  1444. }
  1445. pEventLog = uipEventLog + (i * GetTypeSize("ACPI!_eventlog"));
  1446. InitTypeRead(pEventLog, ACPI!_eventlog);
  1447. if ((ULONG)ReadField(dwEvent) != 0)
  1448. {
  1449. ULONG64 d1, d2, d3, d4, d5, d6, d7;
  1450. d1 = ReadField(uipData1);
  1451. d2 = ReadField(uipData2);
  1452. d3 = ReadField(uipData3);
  1453. d4 = ReadField(uipData4);
  1454. d5 = ReadField(uipData5);
  1455. d6 = ReadField(uipData6);
  1456. d7 = ReadField(uipData7);
  1457. eventTimeInt.QuadPart = ReadField(ullTime);
  1458. RtlTimeToTimeFields( &eventTimeInt, &eventTime );
  1459. PRINTF(
  1460. "%d:%02d:%02d.%03d [%I64x] ",
  1461. eventTime.Hour,
  1462. eventTime.Minute,
  1463. eventTime.Second,
  1464. eventTime.Milliseconds,
  1465. d1
  1466. );
  1467. switch ((ULONG)ReadField(dwEvent)) {
  1468. case 'AMUT':
  1469. PRINTF("AcquireMutext ");
  1470. break;
  1471. case 'RMUT':
  1472. PRINTF("ReleaseMutext ");
  1473. break;
  1474. case 'INSQ':
  1475. PRINTF("InsertReadyQueue ");
  1476. break;
  1477. case 'NEST':
  1478. PRINTF("NestContext ");
  1479. break;
  1480. case 'EVAL':
  1481. PRINTF("EvaluateContext ");
  1482. break;
  1483. case 'QCTX':
  1484. PRINTF("QueueContext ");
  1485. break;
  1486. case 'REST':
  1487. PRINTF("RestartContext ");
  1488. break;
  1489. case 'KICK':
  1490. PRINTF("QueueWorkItem ");
  1491. break;
  1492. case 'PAUS':
  1493. PRINTF("PauseInterpreter ");
  1494. break;
  1495. case 'RSCB':
  1496. PRINTF("RestartCtxtCallback ");
  1497. break;
  1498. case 'DONE':
  1499. PRINTF("EvalMethodComplete ");
  1500. break;
  1501. case 'ASCB':
  1502. PRINTF("AsyncCallBack ");
  1503. break;
  1504. case 'NSYN':
  1505. PRINTF("NestedSyncEvalObject ");
  1506. break;
  1507. case 'SYNC':
  1508. PRINTF("SyncEvalObject ");
  1509. break;
  1510. case 'ASYN':
  1511. PRINTF("AsyncEvalObject ");
  1512. break;
  1513. case 'NASY':
  1514. PRINTF("NestedAsyncEvalObject ");
  1515. break;
  1516. case 'RUNC':
  1517. PRINTF("RunContext ");
  1518. break;
  1519. case 'PACB':
  1520. PRINTF("PauseAsyncCallback ");
  1521. break;
  1522. case 'RUN!':
  1523. PRINTF("FinishedContext ");
  1524. break;
  1525. case 'RSUM':
  1526. PRINTF("ResumeInterpreter ");
  1527. break;
  1528. case 'RSTQ':
  1529. PRINTF("ResumeQueueWorkItem ");
  1530. break;
  1531. default:
  1532. break;
  1533. }
  1534. switch ((ULONG)ReadField(dwEvent))
  1535. {
  1536. case 'AMUT':
  1537. case 'RMUT':
  1538. PRINTF("\n Mut=%08x Owner=%08x dwcOwned=%d rc=%x\n",
  1539. (ULONG)d2, (ULONG)d3,
  1540. (ULONG)d4, (ULONG)d5);
  1541. break;
  1542. case 'INSQ':
  1543. case 'NEST':
  1544. case 'EVAL':
  1545. case 'QCTX':
  1546. case 'REST':
  1547. PRINTF("Context=%I64x\n %s\n QTh=%I64x QCt=%I64x QFg=%08x pbOp=",
  1548. d5,
  1549. GetObjAddrPath(d6),
  1550. d2, d3,
  1551. (ULONG)d4
  1552. );
  1553. PrintSymbol(d7);
  1554. PRINTF("\n");
  1555. break;
  1556. case 'KICK':
  1557. case 'PAUS':
  1558. PRINTF("\n QTh=%I64x QCt=%I64x QFg=%08x rc=%x\n",
  1559. d2, d3, d4, (ULONG)d5);
  1560. break;
  1561. case 'RSCB':
  1562. PRINTF("Context=%I64x\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1563. d5, d2, d3, (ULONG)d4);
  1564. break;
  1565. case 'DONE':
  1566. case 'ASCB':
  1567. PRINTF("rc=%x pEvent=%x\n %s\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1568. (ULONG)d6, (ULONG)d7,
  1569. GetObjAddrPath(d5),
  1570. d2, d3,
  1571. d4
  1572. );
  1573. break;
  1574. case 'NSYN':
  1575. case 'SYNC':
  1576. case 'ASYN':
  1577. PRINTF("IRQL=%2x\n %s\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1578. ((ULONG)d5 & 0xff),
  1579. GetObjAddrPath(d6),
  1580. d2, d3,
  1581. (ULONG)d4
  1582. );
  1583. break;
  1584. case 'NASY':
  1585. PRINTF("Context=%I64x CallBack=%I64x\n %s\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1586. d6, d7,
  1587. GetObjAddrPath(d5),
  1588. d2, d3,
  1589. (ULONG)d4
  1590. );
  1591. break;
  1592. case 'RUNC':
  1593. PRINTF("Context=%I64x\n %s\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1594. d5,
  1595. GetObjAddrPath(d6),
  1596. d2, d3,
  1597. (ULONG)d4
  1598. );
  1599. break;
  1600. case 'PACB':
  1601. case 'RUN!':
  1602. PRINTF("Context=%I64x rc=%x\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1603. d5, (ULONG)d6,
  1604. d2, d3,
  1605. (ULONG)d4
  1606. );
  1607. break;
  1608. case 'RSUM':
  1609. case 'RSTQ':
  1610. PRINTF("\n QTh=%I64x QCt=%I64x QFg=%08x\n",
  1611. d2, d3,
  1612. (ULONG)d4);
  1613. break;
  1614. default:
  1615. PRINTF("D1=%I64x,D2=%I64x,D3=%I64x,D4=%08x,D5=%I64x,D6=%I64x,D7=%I64x\n",
  1616. d1, d2,
  1617. d3, (ULONG)d4,
  1618. d5, d6,
  1619. d7);
  1620. }
  1621. PRINTF("\n");
  1622. }
  1623. if (++i >= dwLogSize)
  1624. {
  1625. i = 0;
  1626. }
  1627. if (i == dwLogIndex)
  1628. {
  1629. break;
  1630. }
  1631. }
  1632. }
  1633. else
  1634. {
  1635. DBG_ERROR(("no event log allocated"));
  1636. rc = DBGERR_CMD_FAILED;
  1637. }
  1638. }
  1639. else
  1640. {
  1641. DBG_ERROR(("failed to to Initialize ACPI!gDegugger %I64x", Address_gDebugger));
  1642. rc = DBGERR_CMD_FAILED;
  1643. }
  1644. }
  1645. else
  1646. {
  1647. DBG_ERROR(("failed to to get the address of ACPI!gDegugger"));
  1648. rc = DBGERR_CMD_FAILED;
  1649. }
  1650. }
  1651. return rc;
  1652. } //AMLIDbgDL
  1653. /***LP AMLIDbgDNS - Dump Name Space
  1654. *
  1655. * ENTRY
  1656. * pArg -> argument type entry
  1657. * pszArg -> argument string
  1658. * dwArgNum - argument number
  1659. * dwNonSWArgs - number of non-switch arguments
  1660. *
  1661. * EXIT-SUCCESS
  1662. * returns DBGERR_NONE
  1663. * EXIT-FAILURE
  1664. * returns negative error code
  1665. */
  1666. LONG LOCAL AMLIDbgDNS(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1667. ULONG dwNonSWArgs)
  1668. {
  1669. LONG rc = DBGERR_NONE;
  1670. ULONG64 ObjData;
  1671. ULONG64 uipNSObj;
  1672. DEREF(pArg);
  1673. DEREF(dwNonSWArgs);
  1674. //
  1675. // User specified name space path or name space node address
  1676. //
  1677. if (pszArg != NULL)
  1678. {
  1679. if (!IsNumber(pszArg, 16, &uipNSObj))
  1680. {
  1681. //
  1682. // The argument is not an address, could be a name space path.
  1683. //
  1684. _strupr(pszArg);
  1685. rc = DumpNSObj(pszArg,
  1686. (BOOLEAN)((dwCmdArg & DNSF_RECURSE) != 0));
  1687. }
  1688. else if (InitTypeRead(uipNSObj, ACPI!_NSObj))
  1689. {
  1690. DBG_ERROR(("failed to Initialize NameSpace object at %I64x", uipNSObj));
  1691. rc = DBGERR_INVALID_CMD;
  1692. }
  1693. else
  1694. {
  1695. dprintf("\nACPI Name Space: %s (%I64x)\n",
  1696. GetObjAddrPath(uipNSObj), uipNSObj);
  1697. if (dwCmdArg & DNSF_RECURSE)
  1698. {
  1699. DumpNSTree(&uipNSObj, 0);
  1700. }
  1701. else
  1702. {
  1703. InitTypeRead(uipNSObj, ACPI!_NSObj);
  1704. ObjData = ReadField(ObjData);
  1705. AMLIDumpObject(&ObjData, NameSegString((ULONG)ReadField(dwNameSeg)), 0);
  1706. }
  1707. }
  1708. }
  1709. else
  1710. {
  1711. if (dwArgNum == 0)
  1712. {
  1713. //
  1714. // User typed "dns" but did not specify any name space path
  1715. // or address.
  1716. //
  1717. rc = DumpNSObj(NAMESTR_ROOT, TRUE);
  1718. }
  1719. dwCmdArg = 0;
  1720. }
  1721. return rc;
  1722. } //AMLIDbgDNS
  1723. /***LP DumpNSObj - Dump name space object
  1724. *
  1725. * ENTRY
  1726. * pszPath -> name space path string
  1727. * fRecursive - TRUE if also dump the subtree recursively
  1728. *
  1729. * EXIT-SUCCESS
  1730. * returns DBGERR_NONE
  1731. * EXIT-FAILURE
  1732. * returns DBGERR_ code
  1733. */
  1734. LONG LOCAL DumpNSObj(PSZ pszPath, BOOLEAN fRecursive)
  1735. {
  1736. LONG rc = DBGERR_NONE;
  1737. ULONG64 uipns;
  1738. ULONG64 NSObj = 0;
  1739. ULONG64 ObjData;
  1740. ULONG dwNameSeg = 0;
  1741. if ((rc = GetNSObj(pszPath, NULL, &uipns, &NSObj,
  1742. NSF_LOCAL_SCOPE | NSF_WARN_NOTFOUND)) == DBGERR_NONE)
  1743. {
  1744. dprintf("\nACPI Name Space: %s (%I64x)\n", pszPath, uipns);
  1745. if (!fRecursive)
  1746. {
  1747. char szName[sizeof(NAMESEG) + 1] = {0};
  1748. InitTypeRead(NSObj, ACPI!_NSObj);
  1749. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  1750. STRCPYN(szName, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  1751. ObjData = ReadField(ObjData);
  1752. AMLIDumpObject(&ObjData, szName, 0);
  1753. }
  1754. else
  1755. {
  1756. DumpNSTree(&NSObj, 0);
  1757. }
  1758. }
  1759. return rc;
  1760. } //DumpNSObj
  1761. /***LP DumpNSTree - Dump all the name space objects in the subtree
  1762. *
  1763. * ENTRY
  1764. * pnsObj -> name space subtree root
  1765. * dwLevel - indent level
  1766. *
  1767. * EXIT
  1768. * None
  1769. */
  1770. VOID LOCAL DumpNSTree(PULONG64 pnsObj, ULONG dwLevel)
  1771. {
  1772. char szName[sizeof(NAMESEG) + 1] = {0};
  1773. ULONG64 uipns, uipnsNext;
  1774. ULONG64 NSObj, FirstChild, Obj;
  1775. ULONG dwNameSeg = 0;
  1776. //
  1777. // First, dump myself
  1778. //
  1779. if(InitTypeRead(*pnsObj, ACPI!_NSObj))
  1780. dprintf("DumpNSTree: Failed to initialize pnsObj (%I64x)\n", *pnsObj);
  1781. else
  1782. {
  1783. FirstChild = ReadField(pnsFirstChild);
  1784. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  1785. STRCPYN(szName, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  1786. Obj = (ULONG64)ReadField(ObjData);
  1787. AMLIDumpObject(&Obj, szName, dwLevel);
  1788. //
  1789. // Then, recursively dump each of my children
  1790. //
  1791. for (uipns = FirstChild;
  1792. (uipns != 0) && ((NSObj = uipns) !=0) && (InitTypeRead(NSObj, ACPI!_NSObj) == 0);
  1793. uipns = uipnsNext)
  1794. {
  1795. if (CheckControlC())
  1796. {
  1797. break;
  1798. }
  1799. //
  1800. // If this is the last child, we have no more.
  1801. //
  1802. uipnsNext = ((ReadField(list.plistNext) ==
  1803. FirstChild)?
  1804. 0: ReadField(list.plistNext));
  1805. //
  1806. // Dump a child
  1807. //
  1808. DumpNSTree(&NSObj, dwLevel + 1);
  1809. }
  1810. }
  1811. } //DumpNSTree
  1812. /***LP AMLIDbgDO - Dump data object
  1813. *
  1814. * ENTRY
  1815. * pArg -> argument type entry
  1816. * pszArg -> argument string
  1817. * dwArgNum - argument number
  1818. * dwNonSWArgs - number of non-switch arguments
  1819. *
  1820. * EXIT-SUCCESS
  1821. * returns DBGERR_NONE
  1822. * EXIT-FAILURE
  1823. * returns negative error code
  1824. */
  1825. LONG LOCAL AMLIDbgDO(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1826. ULONG dwNonSWArgs)
  1827. {
  1828. LONG rc = DBGERR_NONE;
  1829. DEREF(pArg);
  1830. DEREF(dwArgNum);
  1831. DEREF(dwNonSWArgs);
  1832. //
  1833. // User specified object address
  1834. //
  1835. if (pszArg != NULL)
  1836. {
  1837. ULONG64 uipObj = 0;
  1838. if (IsNumber(pszArg, 16, &uipObj))
  1839. {
  1840. AMLIDumpObject(&uipObj, NULL, 0);
  1841. }
  1842. else
  1843. {
  1844. DBG_ERROR(("invalid object address %s", pszArg));
  1845. rc = DBGERR_INVALID_CMD;
  1846. }
  1847. }
  1848. return rc;
  1849. } //AMLIDbgDO
  1850. /***LP AMLIDbgDS - Dump stack
  1851. *
  1852. * ENTRY
  1853. * pArg -> argument type entry
  1854. * pszArg -> argument string
  1855. * dwArgNum - argument number
  1856. * dwNonSWArgs - number of non-switch arguments
  1857. *
  1858. * EXIT-SUCCESS
  1859. * returns DBGERR_NONE
  1860. * EXIT-FAILURE
  1861. * returns negative error code
  1862. */
  1863. LONG LOCAL AMLIDbgDS(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1864. ULONG dwNonSWArgs)
  1865. {
  1866. LONG rc = DBGERR_NONE;
  1867. static ULONG64 uipCtxt = 0;
  1868. DEREF(pArg);
  1869. DEREF(dwNonSWArgs);
  1870. if (pszArg != NULL)
  1871. {
  1872. if (uipCtxt == 0)
  1873. {
  1874. if (!IsNumber(pszArg, 16, &uipCtxt))
  1875. {
  1876. DBG_ERROR(("invalid context block address %s", pszArg));
  1877. rc = DBGERR_INVALID_CMD;
  1878. }
  1879. }
  1880. else
  1881. {
  1882. DBG_ERROR(("invalid dump stack command"));
  1883. rc = DBGERR_INVALID_CMD;
  1884. }
  1885. }
  1886. else
  1887. {
  1888. ULONG64 Address_gReadyQueue = 0;
  1889. if (dwArgNum == 0)
  1890. {
  1891. Address_gReadyQueue = GetExpression("ACPI!gReadyQueue");
  1892. if(Address_gReadyQueue != 0)
  1893. {
  1894. if(InitTypeRead(Address_gReadyQueue, ACPI!_ctxtq) == 0)
  1895. {
  1896. uipCtxt = ReadField(pctxtCurrent);
  1897. }
  1898. else
  1899. {
  1900. DBG_ERROR(("Failed to Initialize ACPI!gReadyQueue %I64x", Address_gReadyQueue));
  1901. }
  1902. }
  1903. else
  1904. {
  1905. DBG_ERROR(("Failed to get the address of ACPI!gReadyQueue"));
  1906. }
  1907. }
  1908. if (uipCtxt == 0)
  1909. {
  1910. DBG_ERROR(("no current context"));
  1911. rc = DBGERR_CMD_FAILED;
  1912. }
  1913. else
  1914. {
  1915. if (InitTypeRead(uipCtxt, ACPI!_ctxt) != 0)
  1916. {
  1917. DBG_ERROR(("failed to initialize context block (uipCtxt=%I64x)",
  1918. uipCtxt));
  1919. rc = DBGERR_CMD_FAILED;
  1920. }
  1921. else if (ReadField(dwSig) == SIG_CTXT)
  1922. {
  1923. rc = DumpStack(uipCtxt, (BOOLEAN)((dwCmdArg & DSF_VERBOSE) != 0));
  1924. }
  1925. else
  1926. {
  1927. DBG_ERROR(("invalid context block at %I64x", uipCtxt));
  1928. rc = DBGERR_CMD_FAILED;
  1929. }
  1930. }
  1931. dwCmdArg = 0;
  1932. }
  1933. return rc;
  1934. } //AMLIDbgDS
  1935. /***LP DumpStack - Dump stack of a context block
  1936. *
  1937. * ENTRY
  1938. * uipCtxt - context block address
  1939. * pctxt -> CTXT
  1940. * fVerbose - TRUE if verbose mode on
  1941. *
  1942. * EXIT-SUCCESS
  1943. * returns DBGERR_NONE
  1944. * EXIT-FAILURE
  1945. * returns negative error code
  1946. */
  1947. LONG LOCAL DumpStack(ULONG64 uipCtxt, BOOLEAN fVerbose)
  1948. {
  1949. LONG rc = DBGERR_NONE;
  1950. ULONG64 uipXlate = 0;
  1951. ULONG64 pfh = 0;
  1952. ULONG64 pbOp = 0;
  1953. ULONG64 pbCtxtEnd = ReadField(pbCtxtEnd);
  1954. ASSERT(ReadField(dwSig) == SIG_CTXT);
  1955. if (fVerbose)
  1956. {
  1957. PRINTF("CtxtBlock=%I64x, StackTop=%I64x, StackEnd=%I64x\n\n",
  1958. uipCtxt, ReadField(LocalHeap.pbHeapEnd), ReadField(pbCtxtEnd));
  1959. }
  1960. for (pfh = (ReadField(LocalHeap.pbHeapEnd));
  1961. (InitTypeRead(pfh, ACPI!FRAMEHDR) == 0) && (pfh < pbCtxtEnd);
  1962. (InitTypeRead(pfh, ACPI!FRAMEHDR) == 0) && (pfh = pfh + ReadField(dwLen)))
  1963. {
  1964. if (CheckControlC())
  1965. {
  1966. break;
  1967. }
  1968. InitTypeRead(pfh, ACPI!FRAMEHDR);
  1969. if (fVerbose)
  1970. {
  1971. PRINTF("%I64x: %s, Len=%08d, FrameFlags=%08x, ParseFunc=%I64x\n",
  1972. pfh + uipXlate, NameSegString((ULONG)ReadField(dwSig)),
  1973. (ULONG)ReadField(dwLen), (ULONG)ReadField(dwfFrame), ReadField(pfnParse));
  1974. }
  1975. if (ReadField(dwSig) == SIG_CALL)
  1976. {
  1977. ULONG i;
  1978. ULONG64 pcall = pfh;
  1979. InitTypeRead(pcall, ACPI!CALL);
  1980. //
  1981. // This is a call frame, dump it.
  1982. //
  1983. PRINTF("%I64x: %s(",
  1984. pbOp, GetObjAddrPath(ReadField(pnsMethod)));
  1985. if (ReadField(icArgs) > 0)
  1986. {
  1987. ULONG64 pArgs = ReadField(pdataArgs);
  1988. for (i = 0; i < ReadField(icArgs); ++i)
  1989. {
  1990. AMLIDumpObject((PULONG64)(pArgs + (i * GetTypeSize("ACPI!OBJDATA"))), NULL, -1);
  1991. InitTypeRead(pcall, ACPI!CALL);
  1992. if (i + 1 < ReadField(icArgs))
  1993. {
  1994. PRINTF(",");
  1995. }
  1996. }
  1997. }
  1998. PRINTF(")\n");
  1999. if ((rc == DBGERR_NONE) && fVerbose)
  2000. {
  2001. ULONG64 Locals = 0;
  2002. InitTypeRead(pcall, ACPI!CALL);
  2003. Locals = ReadField(Locals);
  2004. for (i = 0; i < MAX_NUM_LOCALS; ++i)
  2005. {
  2006. InitTypeRead(pcall, ACPI!CALL);
  2007. Locals = (ReadField(Locals) + (i * GetTypeSize("ACPI!OBJDATA")));
  2008. PRINTF("Local%d: ", i);
  2009. AMLIDumpObject( &Locals, NULL, 0);
  2010. }
  2011. }
  2012. }
  2013. else if (ReadField(dwSig) == SIG_SCOPE)
  2014. {
  2015. InitTypeRead(pfh, ACPI!SCOPE);
  2016. pbOp = ReadField(pbOpRet);
  2017. }
  2018. }
  2019. return rc;
  2020. } //DumpStack
  2021. /***LP AMLIDbgFind - Find NameSpace Object
  2022. *
  2023. * ENTRY
  2024. * pArg -> argument type entry
  2025. * pszArg -> argument string
  2026. * dwfDataSize - data size flags
  2027. *
  2028. * EXIT-SUCCESS
  2029. * returns DBGERR_NONE
  2030. * EXIT-FAILURE
  2031. * returns negative error code
  2032. */
  2033. LONG LOCAL AMLIDbgFind(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  2034. ULONG dwNonSWArgs)
  2035. {
  2036. LONG rc = DBGERR_NONE;
  2037. ULONG dwLen;
  2038. ULONG64 NSRoot=0;
  2039. DEREF(pArg);
  2040. DEREF(dwNonSWArgs);
  2041. if (pszArg != NULL)
  2042. {
  2043. dwLen = strlen(pszArg);
  2044. _strupr(pszArg);
  2045. if (dwLen > sizeof(NAMESEG))
  2046. {
  2047. DBG_ERROR(("invalid NameSeg - %s", pszArg));
  2048. rc = DBGERR_INVALID_CMD;
  2049. }
  2050. else if(ReadPointer(GetExpression("acpi!gpnsnamespaceroot"), &NSRoot))
  2051. {
  2052. NAMESEG dwName;
  2053. dwName = NAMESEG_BLANK;
  2054. memcpy(&dwName, pszArg, dwLen);
  2055. if (!FindNSObj(dwName, &NSRoot))
  2056. {
  2057. dprintf("No such NameSpace object - %s\n", pszArg);
  2058. }
  2059. }
  2060. else
  2061. {
  2062. DBG_ERROR(("failed to read NameSpace root object"));
  2063. }
  2064. }
  2065. else if (dwArgNum == 0)
  2066. {
  2067. DBG_ERROR(("invalid Find command"));
  2068. rc = DBGERR_INVALID_CMD;
  2069. }
  2070. return rc;
  2071. } //AMLIDbgFind
  2072. /***LP FindNSObj - Find and print the full path of a name space object
  2073. *
  2074. * ENTRY
  2075. * dwName - NameSeg of the name space object
  2076. * nsRoot - root of subtree to search for object
  2077. *
  2078. * EXIT-SUCCESS
  2079. * returns TRUE - found at least one match
  2080. * EXIT-FAILURE
  2081. * returns FALSE - found no match
  2082. */
  2083. BOOLEAN LOCAL FindNSObj(NAMESEG dwName, PULONG64 pnsRoot)
  2084. {
  2085. BOOLEAN rc = FALSE;
  2086. ULONG64 uip=0, uipNext=0, TempNext=0, FirstChild = 0;
  2087. ULONG dwNameSeg = 0;
  2088. ULONG Offset = 0;
  2089. if (pnsRoot != 0)
  2090. {
  2091. if(InitTypeRead(*pnsRoot, ACPI!_NSObj))
  2092. dprintf("FindNSObj: Failed to initialize pnsRoot \n");
  2093. else
  2094. {
  2095. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2096. }
  2097. if (dwName == dwNameSeg)
  2098. {
  2099. dprintf("%s\n", GetObjectPath(pnsRoot));
  2100. rc = TRUE;
  2101. }
  2102. FirstChild = ReadField(pnsFirstChild);
  2103. if (FirstChild != 0)
  2104. {
  2105. for (uip = FirstChild;
  2106. uip != 0 && InitTypeRead(uip, ACPI!_NSObj) == 0;
  2107. uip = uipNext)
  2108. {
  2109. if (CheckControlC())
  2110. {
  2111. break;
  2112. }
  2113. if(InitTypeRead(uip, ACPI!_NSObj))
  2114. dprintf("FindNSObj: Failed to initialize uip \n");
  2115. TempNext = ReadField(list.plistNext);
  2116. uipNext = ((TempNext == FirstChild) ?
  2117. 0: TempNext);
  2118. rc |= FindNSObj(dwName, &uip);
  2119. }
  2120. }
  2121. }
  2122. return rc;
  2123. } //FindNSObj
  2124. /***LP GetObjectPath - get object namespace path
  2125. *
  2126. * ENTRY
  2127. * pns -> object
  2128. *
  2129. * EXIT
  2130. * returns name space path
  2131. */
  2132. PSZ LOCAL GetObjectPath(PULONG64 pns)
  2133. {
  2134. static char szPath[MAX_NAME_LEN + 1] = {0};
  2135. ULONG64 NSParent, NSGrandParent;
  2136. ULONG NameSeg=0;
  2137. ULONG Length = 0;
  2138. int i;
  2139. if (pns != NULL)
  2140. {
  2141. if(InitTypeRead(*pns, ACPI!_NSObj))
  2142. dprintf("GetObjectPath: Failed to initialize pns \n");
  2143. NSParent = ReadField(pnsParent);
  2144. if (NSParent == 0)
  2145. {
  2146. strcpy(szPath, "\\");
  2147. }
  2148. else
  2149. {
  2150. GetObjectPath(&NSParent);
  2151. if(InitTypeRead(NSParent, ACPI!_NSObj))
  2152. dprintf("GetObjectPath: Failed to initialize NSParent \n");
  2153. NSGrandParent = ReadField(pnsParent);
  2154. if (NSGrandParent != 0)
  2155. {
  2156. if (StringCchCat(szPath, sizeof(szPath), ".") != S_OK)
  2157. {
  2158. return szPath;
  2159. }
  2160. }
  2161. if(InitTypeRead(*pns, ACPI!_NSObj))
  2162. dprintf("GetObjectPath: Failed to initialize pns \n");
  2163. NameSeg = (ULONG)ReadField(dwNameSeg);
  2164. if ((sizeof(szPath) - strlen(szPath)) > sizeof(NAMESEG))
  2165. {
  2166. if (StringCchCatN(szPath, sizeof(szPath), (PSZ)&NameSeg, sizeof(NAMESEG)) != S_OK)
  2167. {
  2168. return szPath;
  2169. }
  2170. }
  2171. }
  2172. for (i = StrLen(szPath, -1) - 1; i >= 0; --i)
  2173. {
  2174. if (szPath[i] == '_')
  2175. szPath[i] = '\0';
  2176. else
  2177. break;
  2178. }
  2179. }
  2180. else
  2181. {
  2182. szPath[0] = '\0';
  2183. }
  2184. return szPath;
  2185. } //GetObjectPath
  2186. /***LP GetObjAddrPath - get object namespace path
  2187. *
  2188. * ENTRY
  2189. * uipns - object address
  2190. *
  2191. * EXIT
  2192. * returns name space path
  2193. */
  2194. PSZ LOCAL GetObjAddrPath(ULONG64 uipns)
  2195. {
  2196. PSZ psz = NULL;
  2197. if (uipns == 0)
  2198. {
  2199. psz = "<null>";
  2200. }
  2201. else
  2202. {
  2203. psz = GetObjectPath(&uipns);
  2204. }
  2205. return psz;
  2206. } //GetObjAddrPath
  2207. /***LP AMLIDumpObject - Dump object info.
  2208. *
  2209. * ENTRY
  2210. * pdata -> data
  2211. * pszName -> object name
  2212. * iLevel - indent level
  2213. *
  2214. * EXIT
  2215. * None
  2216. *
  2217. * NOTE
  2218. * If iLevel is negative, no indentation and newline are printed.
  2219. */
  2220. VOID LOCAL AMLIDumpObject(PULONG64 pdata, PSZ pszName, int iLevel)
  2221. {
  2222. BOOLEAN fPrintNewLine = (BOOLEAN)(iLevel >= 0);
  2223. int i;
  2224. char szName1[sizeof(NAMESEG) + 1],
  2225. szName2[sizeof(NAMESEG) + 1];
  2226. for (i = 0; i < iLevel; ++i)
  2227. {
  2228. dprintf("| ");
  2229. }
  2230. if (pszName == NULL)
  2231. {
  2232. pszName = "";
  2233. }
  2234. if(InitTypeRead(*pdata, ACPI!_ObjData))
  2235. dprintf("AMLIDumpObject: Failed to initialize ObjData (%I64x) \n", *pdata);
  2236. else
  2237. {
  2238. switch ((ULONG)ReadField(dwDataType))
  2239. {
  2240. case OBJTYPE_UNKNOWN:
  2241. dprintf("Unknown(%s)", pszName);
  2242. break;
  2243. case OBJTYPE_INTDATA:
  2244. dprintf("Integer(%s:Value=0x%016I64x[%d])",
  2245. pszName, ReadField(uipDataValue), ReadField(uipDataValue));
  2246. break;
  2247. case OBJTYPE_STRDATA:
  2248. {
  2249. PSZ psz = 0;
  2250. if ((psz = (PSZ)LocalAlloc(LPTR, (ULONG)ReadField(dwDataLen))) == NULL)
  2251. {
  2252. DBG_ERROR(("AMLIDumpObject: failed to allocate object buffer (size=%d)",
  2253. (ULONG)ReadField(dwDataLen)));
  2254. }
  2255. else if (!ReadMemory((ULONG64)ReadField(pbDataBuff),
  2256. psz,
  2257. (ULONG)ReadField(dwDataLen),
  2258. NULL))
  2259. {
  2260. DBG_ERROR(("AMLIDumpObject: failed to read object buffer at %I64x", (ULONG64)ReadField(pbDataBuff)));
  2261. LocalFree(psz);
  2262. psz = NULL;
  2263. }
  2264. dprintf("String(%s:Str=\"%s\")", pszName, psz);
  2265. if(psz)
  2266. LocalFree(psz);
  2267. break;
  2268. }
  2269. case OBJTYPE_BUFFDATA:
  2270. {
  2271. PUCHAR pbData = 0;
  2272. if ((pbData = (PUCHAR)LocalAlloc(LPTR, (ULONG)ReadField(dwDataLen))) == NULL)
  2273. {
  2274. DBG_ERROR(("AMLIDumpObject: failed to allocate object buffer (size=%d)",
  2275. (ULONG)ReadField(dwDataLen)));
  2276. }
  2277. else if (!ReadMemory((ULONG64)ReadField(pbDataBuff),
  2278. pbData,
  2279. (ULONG)ReadField(dwDataLen),
  2280. NULL))
  2281. {
  2282. DBG_ERROR(("AMLIDumpObject: failed to read object buffer at %I64x", (ULONG64)ReadField(pbDataBuff)));
  2283. LocalFree(pbData);
  2284. pbData = NULL;
  2285. }
  2286. dprintf("Buffer(%s:Ptr=%I64x,Len=%d)",
  2287. pszName, ReadField(pbDataBuff), (ULONG)ReadField(dwDataLen));
  2288. PrintBuffData(pbData, (ULONG)ReadField(dwDataLen));
  2289. LocalFree(pbData);
  2290. break;
  2291. }
  2292. case OBJTYPE_PKGDATA:
  2293. {
  2294. ULONG64 Pkg;
  2295. ULONG64 PkgNext = 0;
  2296. ULONG dwcElements = 0;
  2297. ULONG64 offset = 0;
  2298. Pkg = ReadField (pbDataBuff);
  2299. InitTypeRead(Pkg, ACPI!_PackageObj);
  2300. dwcElements = (int)ReadField(dwcElements);
  2301. dprintf("Package(%s:NumElements=%d){", pszName, dwcElements);
  2302. if (fPrintNewLine)
  2303. {
  2304. dprintf("\n");
  2305. }
  2306. for (i = 0; i < (int)dwcElements; ++i)
  2307. {
  2308. GetFieldOffset("acpi!_PackageObj", "adata", (ULONG*) &offset);
  2309. offset += (GetTypeSize ("acpi!_ObjData") * i);
  2310. PkgNext = offset + Pkg;
  2311. AMLIDumpObject(&PkgNext,
  2312. NULL,
  2313. fPrintNewLine? iLevel + 1: -1);
  2314. if (!fPrintNewLine && (i < (int)dwcElements))
  2315. {
  2316. dprintf(",");
  2317. }
  2318. }
  2319. for (i = 0; i < iLevel; ++i)
  2320. {
  2321. dprintf("| ");
  2322. }
  2323. dprintf("}");
  2324. break;
  2325. }
  2326. case OBJTYPE_FIELDUNIT:
  2327. {
  2328. InitTypeRead((ULONG64)ReadField(pbDataBuff), ACPI!_FieldUnitObj);
  2329. dprintf("FieldUnit(%s:FieldParent=%I64x,ByteOffset=0x%x,StartBit=0x%x,NumBits=%d,FieldFlags=0x%x)",
  2330. pszName,
  2331. ReadField(pnsFieldParent),
  2332. (ULONG)ReadField(FieldDesc.dwByteOffset),
  2333. (ULONG)ReadField(FieldDesc.dwStartBitPos),
  2334. (ULONG)ReadField(FieldDesc.dwNumBits),
  2335. (ULONG)ReadField(FieldDesc.dwFieldFlags));
  2336. break;
  2337. }
  2338. case OBJTYPE_DEVICE:
  2339. dprintf("Device(%s)", pszName);
  2340. break;
  2341. case OBJTYPE_EVENT:
  2342. dprintf("Event(%s:pKEvent=%x)", pszName, ReadField(pbDataBuff));
  2343. break;
  2344. case OBJTYPE_METHOD:
  2345. {
  2346. ULONG DataLength = 0;
  2347. ULONG Offset = 0;
  2348. ULONG64 pbDataBuff = 0;
  2349. DataLength = (ULONG)ReadField(dwDataLen);
  2350. pbDataBuff = (ULONG64)ReadField(pbDataBuff);
  2351. InitTypeRead(pbDataBuff, ACPI!_MethodObj);
  2352. GetFieldOffset("ACPI!_MethodObj", "abCodeBuff", &Offset);
  2353. dprintf("Method(%s:Flags=0x%x,CodeBuff=%I64x,Len=%d)",
  2354. pszName, (UCHAR)ReadField(bMethodFlags),
  2355. (ULONG64)Offset + pbDataBuff,
  2356. DataLength - Offset);
  2357. break;
  2358. }
  2359. case OBJTYPE_MUTEX:
  2360. dprintf("Mutex(%s:pKMutex=%p)", pszName, ReadField(pbDataBuff));
  2361. break;
  2362. case OBJTYPE_OPREGION:
  2363. {
  2364. InitTypeRead((ULONG64)ReadField(pbDataBuff), ACPI!_OpRegionObj);
  2365. dprintf("OpRegion(%s:RegionSpace=%s,Offset=0x%I64x,Len=%d)",
  2366. pszName,
  2367. GetRegionSpaceName((UCHAR)ReadField(bRegionSpace)),
  2368. (ULONG64)ReadField(uipOffset),
  2369. (ULONG)ReadField(dwLen));
  2370. break;
  2371. }
  2372. case OBJTYPE_POWERRES:
  2373. {
  2374. InitTypeRead((ULONG64)ReadField(pbDataBuff), ACPI!_PowerResObj);
  2375. dprintf("PowerResource(%s:SystemLevel=0x%x,ResOrder=%d)",
  2376. pszName, (UCHAR)ReadField(bSystemLevel), (UCHAR)ReadField(bResOrder));
  2377. break;
  2378. }
  2379. case OBJTYPE_PROCESSOR:
  2380. {
  2381. InitTypeRead((ULONG64)ReadField(pbDataBuff), ACPI!_ProcessorObj);
  2382. dprintf("Processor(%s:Processor ID=0x%x,PBlk=0x%x,PBlkLen=%d)",
  2383. pszName,
  2384. (UCHAR)ReadField(bApicID),
  2385. (ULONG)ReadField(dwPBlk),
  2386. (ULONG)ReadField(dwPBlkLen));
  2387. break;
  2388. }
  2389. case OBJTYPE_THERMALZONE:
  2390. dprintf("ThermalZone(%s)", pszName);
  2391. break;
  2392. case OBJTYPE_BUFFFIELD:
  2393. {
  2394. InitTypeRead((ULONG64)ReadField(pbDataBuff), ACPI!_BuffFieldObj);
  2395. dprintf("BufferField(%s:Ptr=%I64x,Len=%d,ByteOffset=0x%x,StartBit=0x%x,NumBits=%d,FieldFlags=0x%x)",
  2396. pszName,
  2397. ReadField(pbDataBuff),
  2398. (ULONG)ReadField(dwBuffLen),
  2399. (ULONG)ReadField(FieldDesc.dwByteOffset),
  2400. (ULONG)ReadField(FieldDesc.dwStartBitPos),
  2401. (ULONG)ReadField(FieldDesc.dwNumBits),
  2402. (ULONG)ReadField(FieldDesc.dwFieldFlags));
  2403. break;
  2404. }
  2405. case OBJTYPE_DDBHANDLE:
  2406. dprintf("DDBHandle(%s:Handle=%I64x)", pszName, (ULONG64)ReadField(pbDataBuff));
  2407. break;
  2408. case OBJTYPE_OBJALIAS:
  2409. {
  2410. ULONG64 NSObj = 0;
  2411. ULONG dwDataType;
  2412. NSObj = ReadField(pnsAlias);
  2413. if (NSObj)
  2414. {
  2415. InitTypeRead(NSObj, ACPI!_NSObj);
  2416. dwDataType = (ULONG)ReadField(ObjData.dwDataType);
  2417. }
  2418. else
  2419. {
  2420. dwDataType = OBJTYPE_UNKNOWN;
  2421. }
  2422. dprintf("ObjectAlias(%s:Alias=%s,Type=%s)",
  2423. pszName, GetObjAddrPath(NSObj),
  2424. AMLIGetObjectTypeName(dwDataType));
  2425. break;
  2426. }
  2427. case OBJTYPE_DATAALIAS:
  2428. {
  2429. ULONG64 Obj = 0;
  2430. dprintf("DataAlias(%s:Link=%I64x)", pszName, ReadField(pdataAlias));
  2431. Obj = ReadField(pdataAlias);
  2432. if (fPrintNewLine && Obj)
  2433. {
  2434. AMLIDumpObject(&Obj, NULL, iLevel + 1);
  2435. fPrintNewLine = FALSE;
  2436. }
  2437. break;
  2438. }
  2439. case OBJTYPE_BANKFIELD:
  2440. {
  2441. ULONG64 NSObj = 0;
  2442. ULONG64 DataBuff = 0;
  2443. ULONG dwNameSeg = 0;
  2444. DataBuff = (ULONG64)ReadField(pbDataBuff);
  2445. InitTypeRead(DataBuff, ACPI!_BankFieldObj);
  2446. NSObj = ReadField(pnsBase);
  2447. InitTypeRead(NSObj, ACPI!_NSObj);
  2448. if (NSObj)
  2449. {
  2450. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2451. STRCPYN(szName1, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  2452. }
  2453. else
  2454. {
  2455. szName1[0] = '\0';
  2456. }
  2457. InitTypeRead(DataBuff, ACPI!_BankFieldObj);
  2458. NSObj = ReadField(pnsBank);
  2459. InitTypeRead(NSObj, ACPI!_NSObj);
  2460. if (NSObj)
  2461. {
  2462. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2463. STRCPYN(szName2, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  2464. }
  2465. else
  2466. {
  2467. szName2[0] = '\0';
  2468. }
  2469. InitTypeRead(DataBuff, ACPI!_BankFieldObj);
  2470. dprintf("BankField(%s:Base=%s,BankName=%s,BankValue=0x%x)",
  2471. pszName, szName1, szName2, (ULONG)ReadField(dwBankValue));
  2472. break;
  2473. }
  2474. case OBJTYPE_FIELD:
  2475. {
  2476. ULONG64 NSObj = 0;
  2477. ULONG64 pf = 0;
  2478. ULONG dwNameSeg = 0;
  2479. pf = ReadField(pbDataBuff);
  2480. InitTypeRead(pf, ACPI!_FieldObj);
  2481. NSObj = ReadField(pnsBase);
  2482. InitTypeRead(NSObj, ACPI!_NSObj);
  2483. if (NSObj)
  2484. {
  2485. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2486. STRCPYN(szName1, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  2487. }
  2488. else
  2489. {
  2490. szName1[0] = '\0';
  2491. }
  2492. dprintf("Field(%s:Base=%s)", pszName, szName1);
  2493. break;
  2494. }
  2495. case OBJTYPE_INDEXFIELD:
  2496. {
  2497. ULONG64 pif = 0;
  2498. ULONG64 NSObj = 0;
  2499. ULONG dwNameSeg = 0;
  2500. pif = (ULONG64)ReadField(pbDataBuff);
  2501. InitTypeRead(pif, ACPI!_IndexFieldObj);
  2502. NSObj = ReadField(pnsIndex);
  2503. InitTypeRead(NSObj, ACPI!_NSObj);
  2504. if (NSObj)
  2505. {
  2506. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2507. STRCPYN(szName1, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  2508. }
  2509. else
  2510. {
  2511. szName1[0] = '\0';
  2512. }
  2513. InitTypeRead(pif, ACPI!_IndexFieldObj);
  2514. NSObj = ReadField(pnsData);
  2515. InitTypeRead(NSObj, ACPI!_NSObj);
  2516. if (NSObj)
  2517. {
  2518. dwNameSeg = (ULONG)ReadField(dwNameSeg);
  2519. STRCPYN(szName2, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  2520. }
  2521. else
  2522. {
  2523. szName2[0] = '\0';
  2524. }
  2525. dprintf("IndexField(%s:IndexName=%s,DataName=%s)",
  2526. pszName, szName1, szName2);
  2527. break;
  2528. }
  2529. default:
  2530. DBG_ERROR(("unexpected data object type (type=%x)",
  2531. (ULONG)ReadField(dwDataType)));
  2532. }
  2533. }
  2534. if (fPrintNewLine)
  2535. {
  2536. dprintf("\n");
  2537. }
  2538. } //DumpObject
  2539. /***LP AMLIDbgLC - List all contexts
  2540. *
  2541. * ENTRY
  2542. * pArg -> argument type entry
  2543. * pszArg -> argument string
  2544. * dwArgNum - argument number
  2545. * dwNonSWArgs - number of non-switch arguments
  2546. *
  2547. * EXIT-SUCCESS
  2548. * returns DBGERR_NONE
  2549. * EXIT-FAILURE
  2550. * returns negative error code
  2551. */
  2552. LONG LOCAL AMLIDbgLC(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  2553. {
  2554. LONG rc = DBGERR_NONE;
  2555. DEREF(pArg);
  2556. DEREF(dwArgNum);
  2557. DEREF(dwNonSWArgs);
  2558. if (pszArg == NULL)
  2559. {
  2560. ULONG64 uipHead = 0;
  2561. ReadPointer(GetExpression("ACPI!gplistCtxtHead"), &uipHead);
  2562. if (uipHead != 0)
  2563. {
  2564. ULONG64 Address_gReadyQueue = 0;
  2565. ULONG64 CurrentCtxt = 0, CurrentThread = 0;
  2566. ULONG64 uip = 0, uipNext = 0;
  2567. ULONG CTXT_Flags = 0;
  2568. ULONG64 pOpCode = 0;
  2569. Address_gReadyQueue = GetExpression("ACPI!gReadyQueue");
  2570. if(Address_gReadyQueue != 0)
  2571. {
  2572. if(InitTypeRead(Address_gReadyQueue, ACPI!_ctxtq) == 0)
  2573. {
  2574. CurrentCtxt = ReadField(pctxtCurrent);
  2575. CurrentThread = ReadField(pkthCurrent);
  2576. for (uip = uipHead - AMLI_FIELD_OFFSET("_ctxt", "listCtxt");
  2577. (uip != 0) && (rc == DBGERR_NONE);
  2578. uip = uipNext)
  2579. {
  2580. if (CheckControlC())
  2581. {
  2582. break;
  2583. }
  2584. if (InitTypeRead(uip, ACPI!_ctxt) == 0)
  2585. {
  2586. ULONG Ctxt_sig = (ULONG)ReadField(dwSig);
  2587. if(Ctxt_sig == SIG_CTXT)
  2588. {
  2589. uipNext = ((ULONG64)ReadField(listCtxt.plistNext) == uipHead)?
  2590. 0:
  2591. (ULONG64)ReadField(listCtxt.plistNext) -
  2592. AMLI_FIELD_OFFSET("CTXT", "listCtxt");
  2593. CTXT_Flags = (ULONG)ReadField(dwfCtxt);
  2594. pOpCode = ReadField(pbOp);
  2595. PRINTF("%cCtxt=%016I64x, ThID=%016I64x, Flgs=%c%c%c%c%c%c%c%c%c, pbOp=%016I64x, Obj=%s\n",
  2596. (uip == CurrentCtxt)? '*': ' ',
  2597. uip,
  2598. (uip == CurrentCtxt)? CurrentThread: (ULONG64)0,
  2599. (CTXT_Flags & CTXTF_ASYNC_EVAL)? 'A': '-',
  2600. (CTXT_Flags & CTXTF_NEST_EVAL)? 'N': '-',
  2601. (CTXT_Flags & CTXTF_IN_READYQ)? 'Q': '-',
  2602. (CTXT_Flags & CTXTF_NEED_CALLBACK)? 'C': '-',
  2603. (CTXT_Flags & CTXTF_RUNNING)? 'R': '-',
  2604. (CTXT_Flags & CTXTF_READY)? 'W': '-',
  2605. (CTXT_Flags & CTXTF_TIMEOUT)? 'T': '-',
  2606. (CTXT_Flags & CTXTF_TIMER_DISPATCH)? 'D': '-',
  2607. (CTXT_Flags & CTXTF_TIMER_PENDING)? 'P': '-',
  2608. pOpCode,
  2609. GetObjAddrPath(ReadField(pnsObj)));
  2610. }
  2611. else
  2612. {
  2613. DBG_ERROR(("SIG_CTXT does not match (%08x)", Ctxt_sig));
  2614. rc = DBGERR_CMD_FAILED;
  2615. }
  2616. }
  2617. else
  2618. {
  2619. DBG_ERROR(("failed to initialize ctxt header at %I64x", uip));
  2620. rc = DBGERR_CMD_FAILED;
  2621. }
  2622. }
  2623. }
  2624. else
  2625. {
  2626. DBG_ERROR(("Failed to Initialize ACPI!gReadyQueue (%I64x)", Address_gReadyQueue));
  2627. rc = DBGERR_CMD_FAILED;
  2628. }
  2629. }
  2630. else
  2631. {
  2632. DBG_ERROR(("Failed to get address of ACPI!gReadyQueue"));
  2633. rc = DBGERR_CMD_FAILED;
  2634. }
  2635. }
  2636. }
  2637. else
  2638. {
  2639. DBG_ERROR(("invalid LC command"));
  2640. rc = DBGERR_INVALID_CMD;
  2641. }
  2642. return rc;
  2643. } //AMLIDbgLC
  2644. /***LP AMLIDbgLN - Display nearest symbol
  2645. *
  2646. * ENTRY
  2647. * pArg -> argument type entry
  2648. * pszArg -> argument string
  2649. * dwArgNum - argument number
  2650. * dwNonSWArgs - number of non-switch arguments
  2651. *
  2652. * EXIT-SUCCESS
  2653. * returns DBGERR_NONE
  2654. * EXIT-FAILURE
  2655. * returns negative error code
  2656. */
  2657. LONG LOCAL AMLIDbgLN(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  2658. {
  2659. LONG rc = DBGERR_NONE;
  2660. ULONG64 uip;
  2661. DEREF(pArg);
  2662. DEREF(dwNonSWArgs);
  2663. if (pszArg != NULL)
  2664. {
  2665. if ((rc = EvalExpr(pszArg, &uip, NULL, NULL, NULL)) == DBGERR_NONE)
  2666. {
  2667. PrintSymbol(uip);
  2668. }
  2669. }
  2670. else if (dwArgNum == 0)
  2671. {
  2672. ULONG64 Address_gReadyQueue = 0;
  2673. Address_gReadyQueue = GetExpression("ACPI!gReadyQueue");
  2674. if(Address_gReadyQueue != 0)
  2675. {
  2676. uip = 0;
  2677. if(InitTypeRead(Address_gReadyQueue, ACPI!_ctxtq) == 0)
  2678. {
  2679. uip = ReadField(pctxtCurrent);
  2680. }
  2681. if (uip != 0)
  2682. {
  2683. if(InitTypeRead(uip, ACPI!_ctxt) != 0)
  2684. {
  2685. DBG_ERROR(("Failed to initialize context %I64x", uip));
  2686. rc = DBGERR_CMD_FAILED;
  2687. }
  2688. else
  2689. {
  2690. PrintSymbol(ReadField(pbOp));
  2691. }
  2692. }
  2693. else
  2694. {
  2695. DBG_ERROR(("no current context"));
  2696. rc = DBGERR_CMD_FAILED;
  2697. }
  2698. }
  2699. else
  2700. {
  2701. DBG_ERROR(("Failed to get address of gReadyQueue"));
  2702. rc = DBGERR_CMD_FAILED;
  2703. }
  2704. }
  2705. return rc;
  2706. } //AMLIDbgLN
  2707. /***LP AMLIDbgP - Trace and step over an AML instruction
  2708. *
  2709. * ENTRY
  2710. * pArg -> argument type entry
  2711. * pszArg -> argument string
  2712. * dwArgNum - argument number
  2713. * dwNonSWArgs - number of non-switch arguments
  2714. *
  2715. * EXIT-SUCCESS
  2716. * returns DBGERR_NONE
  2717. * EXIT-FAILURE
  2718. * returns negative error code
  2719. */
  2720. LONG LOCAL AMLIDbgP(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  2721. {
  2722. LONG rc = DBGERR_NONE;
  2723. DEREF(pArg);
  2724. DEREF(dwArgNum);
  2725. DEREF(dwNonSWArgs);
  2726. if (pszArg == NULL)
  2727. {
  2728. ULONG64 Address_gDebugger = 0;
  2729. ULONG DebuggerFlags = 0;
  2730. ULONG64 uip = FIELDADDROF("gDebugger", "DBGR", "dwfDebugger");
  2731. Address_gDebugger = GetExpression("ACPI!gDebugger");
  2732. if(Address_gDebugger != 0)
  2733. {
  2734. if(InitTypeRead(Address_gDebugger, ACPI!_dbgr) == 0)
  2735. {
  2736. DebuggerFlags = (ULONG)ReadField(dwfDebugger);
  2737. DebuggerFlags |= DBGF_STEP_OVER;
  2738. if (!WRITEMEMDWORD(uip, DebuggerFlags))
  2739. {
  2740. DBG_ERROR(("failed to write debugger flag at %I64x", uip));
  2741. rc = DBGERR_CMD_FAILED;
  2742. }
  2743. }
  2744. }
  2745. else
  2746. {
  2747. DBG_ERROR(("Failed to get address of gDebugger"));
  2748. rc = DBGERR_CMD_FAILED;
  2749. }
  2750. }
  2751. else
  2752. {
  2753. DBG_ERROR(("invalid step command"));
  2754. rc = DBGERR_INVALID_CMD;
  2755. }
  2756. return rc;
  2757. } //DebugStep
  2758. /***LP AMLIDbgR - Dump debugger context
  2759. *
  2760. * ENTRY
  2761. * pArg -> argument type entry
  2762. * pszArg -> argument string
  2763. * dwArgNum - argument number
  2764. * dwNonSWArgs - number of non-switch arguments
  2765. *
  2766. * EXIT-SUCCESS
  2767. * returns DBGERR_NONE
  2768. * EXIT-FAILURE
  2769. * returns negative error code
  2770. */
  2771. LONG LOCAL AMLIDbgR(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  2772. {
  2773. LONG rc = DBGERR_NONE;
  2774. ULONG64 uip;
  2775. DEREF(pArg);
  2776. DEREF(dwNonSWArgs);
  2777. if (pszArg != NULL)
  2778. {
  2779. if ((rc = EvalExpr(pszArg, &uip, NULL, NULL, NULL)) == DBGERR_NONE)
  2780. {
  2781. rc = DumpCtxt(uip);
  2782. }
  2783. }
  2784. else if (dwArgNum == 0)
  2785. {
  2786. rc = DumpCtxt(0);
  2787. }
  2788. return rc;
  2789. } //AMLIDbgR
  2790. /***LP DumpCtxt - Dump context
  2791. *
  2792. * ENTRY
  2793. * uipCtxt - Ctxt address
  2794. *
  2795. * EXIT
  2796. * None
  2797. */
  2798. LONG LOCAL DumpCtxt(ULONG64 uipCtxt)
  2799. {
  2800. LONG rc = DBGERR_NONE;
  2801. ULONG64 uipCurrentCtxt = READMEMULONG64(FIELDADDROF("gReadyQueue",
  2802. "_ctxtq",
  2803. "pctxtCurrent"));
  2804. ULONG64 uipCurrentThread = 0;
  2805. ULONG64 Ctxt;
  2806. BOOLEAN Debug = FALSE;
  2807. if(GetExpression("ACPI!gDebugger"))
  2808. {
  2809. uipCurrentThread = READMEMULONG64(FIELDADDROF("gReadyQueue",
  2810. "_ctxtq",
  2811. "pkthCurrent"));
  2812. Debug = TRUE;
  2813. }
  2814. if (uipCtxt == 0)
  2815. {
  2816. uipCtxt = uipCurrentCtxt;
  2817. }
  2818. if (uipCtxt == 0)
  2819. {
  2820. DBG_ERROR(("no current context"));
  2821. rc = DBGERR_CMD_FAILED;
  2822. }
  2823. else if (InitTypeRead(uipCtxt, ACPI!_ctxt) != 0)
  2824. {
  2825. DBG_ERROR(("failed to initialize context header at %p", uipCtxt));
  2826. rc = DBGERR_CMD_FAILED;
  2827. }
  2828. else if (ReadField(dwSig) != SIG_CTXT)
  2829. {
  2830. DBG_ERROR(("invalid context block at %p", uipCtxt));
  2831. rc = DBGERR_CMD_FAILED;
  2832. }
  2833. else
  2834. {
  2835. if(Debug)
  2836. {
  2837. char NSObject[MAX_NAME_LEN + 1] = {0};
  2838. char NSScope[MAX_NAME_LEN + 1] = {0};
  2839. if (ReadField(pnsObj))
  2840. {
  2841. if (StringCchCopy(NSObject, sizeof(NSObject), GetObjAddrPath(ReadField(pnsObj))) != S_OK)
  2842. {
  2843. NSObject[0] = 0;
  2844. }
  2845. }
  2846. //reinit because GetObjAddrPath() changes the initialization
  2847. InitTypeRead(uipCtxt, ACPI!_ctxt);
  2848. if(ReadField(pnsScope))
  2849. {
  2850. if (StringCchCopy(NSScope, sizeof(NSScope), GetObjAddrPath(ReadField(pnsScope))) != S_OK)
  2851. {
  2852. NSScope[0] = 0;
  2853. }
  2854. }
  2855. InitTypeRead(uipCtxt, ACPI!_ctxt);
  2856. PRINTF("\nContext=%I64x%c, Queue=%I64x, ResList=%I64x\n",
  2857. (ULONG64)uipCtxt,
  2858. (uipCtxt == uipCurrentCtxt)? '*': ' ',
  2859. ReadField(pplistCtxtQueue), ReadField(plistResources));
  2860. PRINTF("ThreadID=%I64x, Flags=%08x, pbOp=",
  2861. (uipCtxt == uipCurrentCtxt)? uipCurrentThread: 0,
  2862. (ULONG)ReadField(dwfCtxt));
  2863. PrintSymbol(ReadField(pbOp));
  2864. PRINTF("\n");
  2865. InitTypeRead(uipCtxt, ACPI!_ctxt);
  2866. PRINTF("StackTop=%I64x, UsedStackSize=%I64d bytes, FreeStackSize=%I64d bytes\n",
  2867. ReadField(LocalHeap.pbHeapEnd),
  2868. ReadField(pbCtxtEnd) - ReadField(LocalHeap.pbHeapEnd),
  2869. ReadField(LocalHeap.pbHeapEnd) - ReadField(LocalHeap.pbHeapTop));
  2870. PRINTF("LocalHeap=%I64x, CurrentHeap=%I64x, UsedHeapSize=%d bytes\n",
  2871. uipCtxt + (ULONG64)AMLI_FIELD_OFFSET("_ctxt", "LocalHeap"),
  2872. ReadField(pheapCurrent),
  2873. (ULONG)(ReadField(LocalHeap.pbHeapTop) -
  2874. (uipCtxt + AMLI_FIELD_OFFSET("_ctxt", "LocalHeap"))));
  2875. PRINTF("Object=%s, Scope=%s, ObjectOwner=%I64x, SyncLevel=%x\n",
  2876. ReadField(pnsObj)? NSObject: "<none>",
  2877. ReadField(pnsScope)? NSScope: "<none>",
  2878. ReadField(powner), (ULONG)ReadField(dwSyncLevel));
  2879. PRINTF("AsyncCallBack=%I64x, CallBackData=%I64x, CallBackContext=%I64x\n",
  2880. ReadField(pfnAsyncCallBack), ReadField(pdataCallBack),
  2881. ReadField(pvContext));
  2882. }
  2883. if ((VOID*)ReadField(pcall) != NULL)
  2884. {
  2885. ULONG64 Call;
  2886. Call = ReadField(pcall);
  2887. if (InitTypeRead(Call, ACPI!_call) != 0)
  2888. {
  2889. DBG_ERROR(("failed to Initialize call frame %p", Call));
  2890. rc = DBGERR_CMD_FAILED;
  2891. }
  2892. else
  2893. {
  2894. int i;
  2895. PRINTF("\nMethodObject=%s\n",
  2896. ReadField(pnsMethod)?
  2897. GetObjAddrPath(ReadField(pnsMethod)): "<none>");
  2898. if (ReadField(icArgs) > 0)
  2899. {
  2900. ULONG64 pArgs = 0;
  2901. for (i = 0; i < ReadField(icArgs); ++i)
  2902. {
  2903. pArgs = ReadField(pdataArgs) + (GetTypeSize("ACPI!_ObjData") * i);
  2904. PRINTF("%I64x: Arg%d=", pArgs, i);
  2905. AMLIDumpObject(&pArgs, NULL, 0);
  2906. InitTypeRead(Call, ACPI!_call);
  2907. }
  2908. }
  2909. for (i = 0; (rc == DBGERR_NONE) && (i < MAX_NUM_LOCALS); ++i)
  2910. {
  2911. ULONG64 Locals = Call + AMLI_FIELD_OFFSET("_call", "Locals") + (GetTypeSize("ACPI!_ObjData") * i);
  2912. PRINTF("%I64x: Local%d=", Locals, i);
  2913. AMLIDumpObject(&Locals, NULL, 0);
  2914. }
  2915. }
  2916. }
  2917. if (rc == DBGERR_NONE)
  2918. {
  2919. ULONG64 Result = uipCtxt + (ULONG64)AMLI_FIELD_OFFSET("_ctxt", "Result");
  2920. PRINTF("%I64x: RetObj=", Result);
  2921. AMLIDumpObject(&Result, NULL, 0);
  2922. }
  2923. if (InitTypeRead(uipCtxt, ACPI!_ctxt) != 0)
  2924. {
  2925. DBG_ERROR(("failed to re initialize context header (%p)", uipCtxt));
  2926. rc = DBGERR_CMD_FAILED;
  2927. }
  2928. if ((rc == DBGERR_NONE) && ((PULONG64)ReadField(plistResources) != NULL))
  2929. {
  2930. ULONG64 uip, uipNext;
  2931. ULONG64 Res;
  2932. PRINTF("\nResources Owned:\n");
  2933. for (uip = ReadField(plistResources) - AMLI_FIELD_OFFSET("_resource", "list");
  2934. uip != 0; uip = uipNext)
  2935. {
  2936. ULONG64 plistResources = ReadField(plistResources);
  2937. if (InitTypeRead(uip, ACPI!_resource) == 0)
  2938. {
  2939. uipNext = (ReadField(list.plistNext) != plistResources)?
  2940. ReadField(list.plistNext) - AMLI_FIELD_OFFSET("_resource", "list"): 0;
  2941. ASSERT(uipCtxt == ReadField(pctxtOwner));
  2942. PRINTF(" ResType=%s, ResObj=%I64x\n",
  2943. ReadField(dwResType) == RESTYPE_MUTEX? "Mutex": "Unknown",
  2944. ReadField(pvResObj));
  2945. }
  2946. else
  2947. {
  2948. DBG_ERROR(("failed to Initialize resource object at %x", uip));
  2949. rc = DBGERR_CMD_FAILED;
  2950. }
  2951. }
  2952. }
  2953. if (rc == DBGERR_NONE)
  2954. {
  2955. ULONG64 uipbOp = 0;
  2956. ULONG64 uipns = 0;
  2957. ULONG dwOffset = 0;
  2958. if (InitTypeRead(uipCtxt, ACPI!_ctxt) != 0)
  2959. {
  2960. DBG_ERROR(("failed to re initialize context header (%p)", uipCtxt));
  2961. rc = DBGERR_CMD_FAILED;
  2962. }
  2963. uipbOp = ReadField(pbOp);
  2964. if (uipbOp == 0)
  2965. {
  2966. if ((PULONG64)ReadField(pnsObj) != NULL)
  2967. {
  2968. uipns = ReadField(pnsObj);
  2969. dwOffset = 0;
  2970. }
  2971. }
  2972. else if (!FindObjSymbol(uipbOp, &uipns, &dwOffset))
  2973. {
  2974. DBG_ERROR(("failed to find symbol at %p", ReadField(pbOp)));
  2975. rc = DBGERR_CMD_FAILED;
  2976. }
  2977. if ((rc == DBGERR_NONE) && (uipns != 0))
  2978. {
  2979. PULONG64 pm = NULL;
  2980. if (InitTypeRead(uipns, ACPI!_NSObj) != 0)
  2981. {
  2982. DBG_ERROR(("failed to Initialize NameSpace object at %p", uipns));
  2983. rc = DBGERR_CMD_FAILED;
  2984. }
  2985. else if (ReadField(ObjData.dwDataType) == OBJTYPE_METHOD)
  2986. {
  2987. ULONG64 Obj = ReadField(ObjData);
  2988. ULONG64 DataBuff = ReadField(ObjData.pbDataBuff);
  2989. ULONG64 DataLen = ReadField(ObjData.dwDataLen);
  2990. pm = GetObjBuff(Obj);
  2991. if ( pm == NULL)
  2992. {
  2993. DBG_ERROR(("failed to read data buffer from objdata %p", Obj));
  2994. rc = DBGERR_CMD_FAILED;
  2995. }
  2996. else
  2997. {
  2998. PUCHAR pbOp = 0;
  2999. PUCHAR pbEnd = 0;
  3000. pbOp = (PUCHAR) pm ;
  3001. pbOp += (((ULONG)AMLI_FIELD_OFFSET("_MethodObj", "abCodeBuff")) + dwOffset);
  3002. pbEnd = (PUCHAR) pm ;
  3003. pbEnd += DataLen;
  3004. if (uipbOp == 0)
  3005. {
  3006. uipbOp = DataBuff + AMLI_FIELD_OFFSET("METHODOBJ", "abCodeBuff");
  3007. }
  3008. PRINTF("\nNext AML Pointer: ");
  3009. PrintSymbol(uipbOp);
  3010. PRINTF("\n");
  3011. rc = UnAsmScope(&pbOp,
  3012. pbEnd,
  3013. uipbOp,
  3014. &uipns,
  3015. 0,
  3016. 0);
  3017. PRINTF("\n");
  3018. LocalFree(pm);
  3019. }
  3020. }
  3021. }
  3022. }
  3023. }
  3024. return rc;
  3025. } //DumpCtxt
  3026. /***LP AMLIDbgU - Unassemble AML code
  3027. *
  3028. * ENTRY
  3029. * pArg -> argument type entry
  3030. * pszArg -> argument string
  3031. * dwArgNum - argument number
  3032. * dwNonSWArgs - number of non-switch arguments
  3033. *
  3034. * EXIT-SUCCESS
  3035. * returns DBGERR_NONE
  3036. * EXIT-FAILURE
  3037. * returns negative error code
  3038. */
  3039. LONG LOCAL AMLIDbgU(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  3040. ULONG dwNonSWArgs)
  3041. {
  3042. LONG rc = DBGERR_NONE;
  3043. static ULONG64 uipbOp = 0;
  3044. static PUCHAR pbBuff = NULL;
  3045. static ULONG dwBuffOffset = 0, dwBuffSize = 0;
  3046. static ULONG64 uipns = 0;
  3047. static ULONG64 NSO = 0;
  3048. DEREF(pArg);
  3049. DEREF(dwArgNum);
  3050. DEREF(dwNonSWArgs);
  3051. //
  3052. // User specified name space path or memory address
  3053. //
  3054. if (pszArg != NULL)
  3055. {
  3056. uipbOp = 0;
  3057. if (pbBuff != NULL)
  3058. {
  3059. LocalFree(pbBuff);
  3060. pbBuff = NULL;
  3061. dwBuffSize = 0;
  3062. uipns = 0;
  3063. }
  3064. gpnsCurUnAsmScope = 0;
  3065. rc = EvalExpr(pszArg, &uipbOp, NULL, &NSO, NULL);
  3066. if(NSO)
  3067. gpnsCurUnAsmScope = NSO;
  3068. }
  3069. else
  3070. {
  3071. if (uipbOp == 0)
  3072. {
  3073. ULONG64 ReadyQueue = 0;
  3074. ULONG64 uipCurrentCtxt = 0;
  3075. ReadyQueue = GetExpression("ACPI!gReadyQueue");
  3076. if(InitTypeRead(ReadyQueue, ACPI!_ctxtq))
  3077. DBG_ERROR(("Failed to Initialize gReadyQueue (%I64x)", ReadyQueue));
  3078. uipCurrentCtxt = ReadField(pctxtCurrent);
  3079. if(InitTypeRead(uipCurrentCtxt, ACPI!_ctxt))
  3080. DBG_ERROR(("Failed to Initialize pctxtCurrent (%I64x)", uipCurrentCtxt));
  3081. ASSERT(pbBuff == NULL);
  3082. if (uipCurrentCtxt != 0)
  3083. {
  3084. uipbOp = ReadField(pbOp);
  3085. if (uipbOp == 0)
  3086. {
  3087. uipns = ReadField(pnsObj);
  3088. if ((uipns != 0) &&
  3089. (InitTypeRead(uipns, ACPI!_NSObj) == 0) &&
  3090. (ReadField(ObjData.dwDataType) == OBJTYPE_METHOD))
  3091. {
  3092. uipbOp = ReadField(ObjData.pbDataBuff) +
  3093. (ULONG64)AMLI_FIELD_OFFSET("_MethodObj", "abCodeBuff");
  3094. }
  3095. }
  3096. }
  3097. }
  3098. if (uipbOp == 0)
  3099. {
  3100. DBG_ERROR(("invalid AML code address %I64x", uipbOp));
  3101. rc = DBGERR_CMD_FAILED;
  3102. }
  3103. else
  3104. {
  3105. BOOLEAN fContinueLast = FALSE;
  3106. if (pbBuff == NULL)
  3107. {
  3108. ULONG dwOffset = 0;
  3109. if (uipns == 0)
  3110. {
  3111. if (FindObjSymbol(uipbOp, &uipns, &dwOffset))
  3112. {
  3113. if (InitTypeRead(uipns, ACPI!_NSObj) != 0)
  3114. {
  3115. DBG_ERROR(("failed to initialize NameSpace object at %I64x",
  3116. uipns));
  3117. rc = DBGERR_CMD_FAILED;
  3118. }
  3119. }
  3120. }
  3121. if (rc == DBGERR_NONE)
  3122. {
  3123. if (uipns != 0)
  3124. {
  3125. dwBuffSize = (ULONG)ReadField(ObjData.dwDataLen) -
  3126. (ULONG)AMLI_FIELD_OFFSET("_MethodObj", "abCodeBuff") -
  3127. dwOffset;
  3128. }
  3129. else
  3130. {
  3131. //
  3132. // The uipbOp is not associated with any method object,
  3133. // so we must be unassembling some code in the middle
  3134. // of a DDB load. Set code length to 4K.
  3135. //
  3136. dwBuffSize = 4096;
  3137. }
  3138. dwBuffOffset = 0;
  3139. if ((pbBuff = LocalAlloc(LPTR, dwBuffSize)) == NULL)
  3140. {
  3141. DBG_ERROR(("failed to allocate code buffer (size=%d)",
  3142. dwBuffSize));
  3143. rc = DBGERR_CMD_FAILED;
  3144. }
  3145. else if (!ReadMemory(uipbOp, pbBuff, dwBuffSize, NULL))
  3146. {
  3147. DBG_ERROR(("failed to read AML code at %x (size=%d)",
  3148. uipbOp, dwBuffSize));
  3149. rc = DBGERR_CMD_FAILED;
  3150. }
  3151. }
  3152. }
  3153. else
  3154. {
  3155. fContinueLast = TRUE;
  3156. }
  3157. if (rc == DBGERR_NONE)
  3158. {
  3159. PUCHAR pbOp = pbBuff + dwBuffOffset;
  3160. rc = UnAsmScope(&pbOp,
  3161. pbBuff + dwBuffSize,
  3162. uipbOp + dwBuffOffset,
  3163. uipns? &uipns: NULL,
  3164. fContinueLast? -1: 0,
  3165. 0);
  3166. PRINTF("\n");
  3167. dwBuffOffset = (ULONG)(pbOp - pbBuff);
  3168. }
  3169. }
  3170. }
  3171. return rc;
  3172. } //AMLIDbgU
  3173. /***LP EvalExpr - Parse and evaluate debugger expression
  3174. *
  3175. * ENTRY
  3176. * pszArg -> expression argument
  3177. * puipValue -> to hold the result of expression
  3178. * pfPhysical -> set to TRUE if the expression is a physical address
  3179. * (NULL if don't allow physical address)
  3180. * puipns -> to hold the pointer of the nearest pns object
  3181. * pdwOffset -> to hold the offset of the address to the nearest pns object
  3182. *
  3183. * EXIT-SUCCESS
  3184. * returns DBGERR_NONE
  3185. * EXIT-FAILURE
  3186. * returns DBGERR_CMD_FAILED
  3187. */
  3188. LONG LOCAL EvalExpr(PSZ pszArg, PULONG64 puipValue, BOOLEAN *pfPhysical,
  3189. PULONG64 puipns, PULONG pdwOffset)
  3190. {
  3191. LONG rc = DBGERR_NONE;
  3192. ULONG64 uipns = 0;
  3193. ULONG dwOffset = 0;
  3194. ULONG64 NSObj = 0;
  3195. if (pfPhysical != NULL)
  3196. *pfPhysical = FALSE;
  3197. if ((pfPhysical != NULL) && (pszArg[0] == '%') && (pszArg[1] == '%'))
  3198. {
  3199. if (IsNumber(&pszArg[2], 16, puipValue))
  3200. {
  3201. *pfPhysical = TRUE;
  3202. }
  3203. else
  3204. {
  3205. DBG_ERROR(("invalid physical address - %s", pszArg));
  3206. rc = DBGERR_INVALID_CMD;
  3207. }
  3208. }
  3209. else if (!IsNumber(pszArg, 16, puipValue))
  3210. {
  3211. _strupr(pszArg);
  3212. if (GetNSObj(pszArg, NULL, &uipns, &NSObj,
  3213. NSF_LOCAL_SCOPE | NSF_WARN_NOTFOUND) == DBGERR_NONE)
  3214. {
  3215. InitTypeRead(NSObj, ACPI!_NSObj);
  3216. if (ReadField(ObjData.dwDataType) == OBJTYPE_METHOD)
  3217. {
  3218. ULONG64 Address = 0;
  3219. ULONG Offset = 80;
  3220. Address = ReadField(ObjData.pbDataBuff);
  3221. GetFieldOffset("ACPI!_MethodObj", "abCodeBuff", &Offset);
  3222. *puipValue = Address + (ULONG64)Offset;
  3223. }
  3224. else
  3225. {
  3226. DBG_ERROR(("object is not a method - %s", pszArg));
  3227. rc = DBGERR_INVALID_CMD;
  3228. }
  3229. }
  3230. }
  3231. else if (FindObjSymbol(*puipValue, &uipns, &dwOffset))
  3232. {
  3233. if (InitTypeRead(uipns, ACPI!_NSObj) == 0)
  3234. {
  3235. ULONG Offset = 0;
  3236. GetFieldOffset("ACPI!_MethodObj", "abCodeBuff", &Offset);
  3237. if ((ReadField(ObjData.dwDataType)!= OBJTYPE_METHOD) ||
  3238. (dwOffset >= (ULONG)ReadField(ObjData.dwDataLen) - Offset))
  3239. {
  3240. uipns = 0;
  3241. dwOffset = 0;
  3242. }
  3243. }
  3244. else
  3245. {
  3246. DBG_ERROR(("failed to read NameSpace object at %x", uipns));
  3247. rc = DBGERR_CMD_FAILED;
  3248. }
  3249. }
  3250. if (rc == DBGERR_NONE)
  3251. {
  3252. if (puipns != NULL)
  3253. *puipns = uipns;
  3254. if (pdwOffset != NULL)
  3255. *pdwOffset = dwOffset;
  3256. }
  3257. return rc;
  3258. } //EvalExpr
  3259. /***LP FindObjSymbol - Find nearest object with given address
  3260. *
  3261. * ENTRY
  3262. * uipObj - address
  3263. * puipns -> to hold the nearest object address
  3264. * pdwOffset - to hold offset from the nearest object
  3265. *
  3266. * EXIT-SUCCESS
  3267. * returns TRUE - found a nearest object
  3268. * EXIT-FAILURE
  3269. * returns FALSE - cannot found nearest object
  3270. */
  3271. BOOLEAN LOCAL FindObjSymbol(ULONG64 uipObj, PULONG64 puipns, PULONG pdwOffset)
  3272. {
  3273. BOOLEAN rc = FALSE;
  3274. ULONG64 uip;
  3275. ULONG64 ObjSym;
  3276. ULONG64 NSObj;
  3277. ULONG64 Address = 0;
  3278. Address = GetExpression("ACPI!gDebugger");
  3279. if(Address != 0)
  3280. {
  3281. InitTypeRead(Address, ACPI!_dbgr);
  3282. for (uip = ReadField(posSymbolList);
  3283. (uip != 0) && (InitTypeRead(uip, ACPI!_objsym) == 0);
  3284. uip = ReadField(posNext))
  3285. {
  3286. if (uipObj <= ReadField(pbOp))
  3287. {
  3288. if ((uipObj < ReadField(pbOp)) && (ReadField(posPrev) != 0))
  3289. {
  3290. uip = ReadField(posPrev);
  3291. InitTypeRead(uip, ACPI!_objsym);
  3292. }
  3293. if (uipObj >= ReadField(pbOp))
  3294. {
  3295. *puipns = ReadField(pnsObj);
  3296. *pdwOffset = (ULONG)(uipObj - ReadField(pbOp));
  3297. rc = TRUE;
  3298. }
  3299. break;
  3300. }
  3301. }
  3302. }
  3303. else
  3304. {
  3305. DBG_ERROR(("Failed to get address of ACPI!gDebugger"));
  3306. }
  3307. return rc;
  3308. } //FindObjSymbol
  3309. /***LP AMLIDbgSet - Set debugger options
  3310. *
  3311. * ENTRY
  3312. * pArg -> argument type entry
  3313. * pszArg -> argument string
  3314. * dwArgNum - argument number
  3315. * dwNonSWArgs - number of non-switch arguments
  3316. *
  3317. * EXIT-SUCCESS
  3318. * returns DBGERR_NONE
  3319. * EXIT-FAILURE
  3320. * returns negative error code
  3321. */
  3322. LONG LOCAL AMLIDbgSet(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  3323. ULONG dwNonSWArgs)
  3324. {
  3325. LONG rc = DBGERR_NONE;
  3326. ULONG dwData1, dwData2;
  3327. ULONG64 Address_gDebugger = 0;
  3328. ULONG64 Address_gdwfAMLIInit = 0;
  3329. ULONG64 Address_gDebugger_dwfDebugger = 0;
  3330. DEREF(pArg);
  3331. DEREF(dwNonSWArgs);
  3332. Address_gDebugger = GetExpression("ACPI!gDebugger");
  3333. if (!(Address_gDebugger))
  3334. {
  3335. DBG_ERROR(("failed to to get the address of ACPI!gDegugger %I64x", Address_gDebugger));
  3336. }
  3337. Address_gdwfAMLIInit = GetExpression("ACPI!gdwfAMLIInit");
  3338. if (!(Address_gdwfAMLIInit))
  3339. {
  3340. DBG_ERROR(("failed to to get the address of ACPI!gdwfAMLIInit %I64x", Address_gdwfAMLIInit));
  3341. }
  3342. if(Address_gDebugger && Address_gdwfAMLIInit)
  3343. {
  3344. InitTypeRead(Address_gDebugger, ACPI!_dbgr);
  3345. dwData1 = (ULONG)ReadField(dwfDebugger);
  3346. dwData2 = READMEMDWORD(Address_gdwfAMLIInit);
  3347. if ((pszArg == NULL) && (dwArgNum == 0))
  3348. {
  3349. PRINTF("AMLTrace =%s\n",
  3350. (dwData1 & DBGF_AMLTRACE_ON)? "on": "off");
  3351. PRINTF("AMLDebugSpew =%s\n",
  3352. (dwData1 & DBGF_DEBUG_SPEW_ON)? "on": "off");
  3353. PRINTF("LoadDDBBreak =%s\n",
  3354. (dwData2 & AMLIIF_LOADDDB_BREAK)? "on": "off");
  3355. PRINTF("ErrorBreak =%s\n",
  3356. (dwData1 & DBGF_ERRBREAK_ON)? "on": "off");
  3357. PRINTF("VerboseMode =%s\n",
  3358. (dwData1 & DBGF_VERBOSE_ON)? "on": "off");
  3359. PRINTF("LogEvent =%s\n",
  3360. (dwData1 & DBGF_LOGEVENT_ON)? "on": "off");
  3361. PRINTF("LogSize =%d\n",
  3362. (ULONG)ReadField(dwLogSize));
  3363. }
  3364. else
  3365. {
  3366. dwData1 |= dwfDebuggerON;
  3367. dwData1 &= ~dwfDebuggerOFF;
  3368. dwData2 |= dwfAMLIInitON;
  3369. dwData2 &= ~dwfAMLIInitOFF;
  3370. if (!WRITEMEMDWORD(Address_gDebugger, dwData1))
  3371. {
  3372. DBG_ERROR(("failed to write debugger flags at %I64x", Address_gDebugger));
  3373. rc = DBGERR_CMD_FAILED;
  3374. }
  3375. else if (!WRITEMEMDWORD(Address_gdwfAMLIInit, dwData2))
  3376. {
  3377. DBG_ERROR(("failed to write init flags at %I64x", Address_gdwfAMLIInit));
  3378. rc = DBGERR_CMD_FAILED;
  3379. }
  3380. dwfDebuggerON = dwfDebuggerOFF = 0;
  3381. dwfAMLIInitON = dwfAMLIInitOFF = 0;
  3382. //
  3383. // Check to see if debug spew needs to be turned on. Turn on if needed.
  3384. //
  3385. if(dwData1 & DBGF_DEBUG_SPEW_ON)
  3386. {
  3387. rc = AMLITraceEnable(TRUE);
  3388. }
  3389. else
  3390. {
  3391. rc = AMLITraceEnable(FALSE);
  3392. }
  3393. }
  3394. }
  3395. else
  3396. {
  3397. rc = DBGERR_CMD_FAILED;
  3398. }
  3399. return rc;
  3400. } //AMLIDbgSet
  3401. /***LP AMLITraceEnable - Enable / Disable debug tracing
  3402. *
  3403. * ENTRY
  3404. * fEnable -> TRUE to Enable
  3405. *
  3406. * EXIT-SUCCESS
  3407. * returns DBGERR_NONE
  3408. * EXIT-FAILURE
  3409. * returns DBGERR_CMD_FAILED
  3410. */
  3411. LONG LOCAL AMLITraceEnable(BOOL fEnable)
  3412. {
  3413. LONG rc = DBGERR_NONE;
  3414. ULONG dwData;
  3415. ULONG64 Address_AMLI_KD_MASK;
  3416. Address_AMLI_KD_MASK = GetExpression("NT!Kd_AMLI_Mask");
  3417. if (!Address_AMLI_KD_MASK)
  3418. {
  3419. PRINTF("AMLITraceEnable: Could not find NT!Kd_AMLI_Mask\n");
  3420. }
  3421. if(fEnable)
  3422. {
  3423. dwData = 0xffffffff;
  3424. if (!WRITEMEMDWORD(Address_AMLI_KD_MASK, dwData))
  3425. {
  3426. DBG_ERROR(("AMLITraceEnable: failed to write kd_amli_mask at %x", Address_AMLI_KD_MASK));
  3427. rc = DBGERR_CMD_FAILED;
  3428. }
  3429. }
  3430. else
  3431. {
  3432. dwData = 0;
  3433. if (!WRITEMEMDWORD(Address_AMLI_KD_MASK, dwData))
  3434. {
  3435. DBG_ERROR(("AMLITraceEnable: failed to write kd_amli_mask at %x", Address_AMLI_KD_MASK));
  3436. rc = DBGERR_CMD_FAILED;
  3437. }
  3438. }
  3439. return rc;
  3440. }
  3441. /***LP AMLIGetObjectTypeName - get object type name
  3442. *
  3443. * ENTRY
  3444. * dwObjType - object type
  3445. *
  3446. * EXIT
  3447. * return object type name
  3448. */
  3449. PSZ LOCAL AMLIGetObjectTypeName(ULONG dwObjType)
  3450. {
  3451. PSZ psz = NULL;
  3452. int i;
  3453. static struct
  3454. {
  3455. ULONG dwObjType;
  3456. PSZ pszObjTypeName;
  3457. } ObjTypeTable[] =
  3458. {
  3459. OBJTYPE_UNKNOWN, "Unknown",
  3460. OBJTYPE_INTDATA, "Integer",
  3461. OBJTYPE_STRDATA, "String",
  3462. OBJTYPE_BUFFDATA, "Buffer",
  3463. OBJTYPE_PKGDATA, "Package",
  3464. OBJTYPE_FIELDUNIT, "FieldUnit",
  3465. OBJTYPE_DEVICE, "Device",
  3466. OBJTYPE_EVENT, "Event",
  3467. OBJTYPE_METHOD, "Method",
  3468. OBJTYPE_MUTEX, "Mutex",
  3469. OBJTYPE_OPREGION, "OpRegion",
  3470. OBJTYPE_POWERRES, "PowerResource",
  3471. OBJTYPE_PROCESSOR, "Processor",
  3472. OBJTYPE_THERMALZONE,"ThermalZone",
  3473. OBJTYPE_BUFFFIELD, "BuffField",
  3474. OBJTYPE_DDBHANDLE, "DDBHandle",
  3475. OBJTYPE_DEBUG, "Debug",
  3476. OBJTYPE_OBJALIAS, "ObjAlias",
  3477. OBJTYPE_DATAALIAS, "DataAlias",
  3478. OBJTYPE_BANKFIELD, "BankField",
  3479. OBJTYPE_FIELD, "Field",
  3480. OBJTYPE_INDEXFIELD, "IndexField",
  3481. OBJTYPE_DATA, "Data",
  3482. OBJTYPE_DATAFIELD, "DataField",
  3483. OBJTYPE_DATAOBJ, "DataObject",
  3484. 0, NULL
  3485. };
  3486. for (i = 0; ObjTypeTable[i].pszObjTypeName != NULL; ++i)
  3487. {
  3488. if (dwObjType == ObjTypeTable[i].dwObjType)
  3489. {
  3490. psz = ObjTypeTable[i].pszObjTypeName;
  3491. break;
  3492. }
  3493. }
  3494. return psz;
  3495. } //GetObjectTypeName
  3496. /***LP GetRegionSpaceName - get region space name
  3497. *
  3498. * ENTRY
  3499. * bRegionSpace - region space
  3500. *
  3501. * EXIT
  3502. * return object type name
  3503. */
  3504. PSZ LOCAL GetRegionSpaceName(UCHAR bRegionSpace)
  3505. {
  3506. PSZ psz = NULL;
  3507. int i;
  3508. static PSZ pszVendorDefined = "VendorDefined";
  3509. static struct
  3510. {
  3511. UCHAR bRegionSpace;
  3512. PSZ pszRegionSpaceName;
  3513. } RegionNameTable[] =
  3514. {
  3515. REGSPACE_MEM, "SystemMemory",
  3516. REGSPACE_IO, "SystemIO",
  3517. REGSPACE_PCICFG, "PCIConfigSpace",
  3518. REGSPACE_EC, "EmbeddedController",
  3519. REGSPACE_SMB, "SMBus",
  3520. 0, NULL
  3521. };
  3522. for (i = 0; RegionNameTable[i].pszRegionSpaceName != NULL; ++i)
  3523. {
  3524. if (bRegionSpace == RegionNameTable[i].bRegionSpace)
  3525. {
  3526. psz = RegionNameTable[i].pszRegionSpaceName;
  3527. break;
  3528. }
  3529. }
  3530. if (psz == NULL)
  3531. {
  3532. psz = pszVendorDefined;
  3533. }
  3534. return psz;
  3535. } //GetRegionSpaceName
  3536. /***LP PrintBuffData - Print buffer data
  3537. *
  3538. * ENTRY
  3539. * pb -> buffer
  3540. * dwLen - length of buffer
  3541. *
  3542. * EXIT
  3543. * None
  3544. */
  3545. VOID LOCAL PrintBuffData(PUCHAR pb, ULONG dwLen)
  3546. {
  3547. int i, j;
  3548. dprintf("{");
  3549. for (i = j = 0; i < (int)dwLen; ++i)
  3550. {
  3551. if (j == 0)
  3552. dprintf("\n\t0x%02x", pb[i]);
  3553. else
  3554. dprintf(",0x%02x", pb[i]);
  3555. j++;
  3556. if (j >= 14)
  3557. j = 0;
  3558. }
  3559. dprintf("}");
  3560. } //PrintBuffData
  3561. /***LP GetObjBuff - Allocate and read object buffer
  3562. *
  3563. * ENTRY
  3564. * ObjData -> object data
  3565. *
  3566. * EXIT
  3567. * return object data buffer
  3568. */
  3569. PULONG64 LOCAL GetObjBuff(ULONG64 ObjData)
  3570. {
  3571. PULONG64 DataBuffer = NULL;
  3572. if (InitTypeRead(ObjData, ACPI!_ObjData) != 0)
  3573. {
  3574. DBG_ERROR(("failed to Initialize ObjData (%p)", ObjData));
  3575. }
  3576. else
  3577. {
  3578. if ((DataBuffer = LocalAlloc(LPTR, (ULONG)ReadField(dwDataLen))) == NULL)
  3579. {
  3580. DBG_ERROR(("failed to allocate object buffer (size=%d)",
  3581. ReadField(dwDataLen)));
  3582. }
  3583. else if (!ReadMemory(ReadField(pbDataBuff),
  3584. DataBuffer,
  3585. (ULONG)ReadField(dwDataLen),
  3586. NULL))
  3587. {
  3588. DBG_ERROR(("failed to read object buffer at %p", ReadField(pbDataBuff)));
  3589. LocalFree(DataBuffer);
  3590. DataBuffer = NULL;
  3591. }
  3592. }
  3593. return DataBuffer;
  3594. } //GetObjBuff
  3595. /***LP IsNumber - Check if string is a number, if so return the number
  3596. *
  3597. * ENTRY
  3598. * pszStr -> string
  3599. * dwBase - base
  3600. * puipValue -> to hold the number
  3601. *
  3602. * EXIT-SUCCESS
  3603. * returns TRUE - the string is a number
  3604. * EXIT-FAILURE
  3605. * returns FALSE - the string is not a number
  3606. */
  3607. BOOLEAN LOCAL IsNumber(PSZ pszStr, ULONG dwBase, PULONG64 puipValue)
  3608. {
  3609. BOOLEAN rc=TRUE;
  3610. PSZ psz;
  3611. *puipValue = AMLIUtilStringToUlong64(pszStr, &psz, dwBase);
  3612. rc = ((psz != pszStr) && (*psz == '\0'))? TRUE: FALSE;
  3613. return rc;
  3614. } //IsNumber
  3615. /***LP PrintSymbol - Print the nearest symbol of a given address
  3616. *
  3617. * ENTRY
  3618. * uip - address
  3619. *
  3620. * EXIT
  3621. * None
  3622. */
  3623. VOID LOCAL PrintSymbol(ULONG64 uip)
  3624. {
  3625. ULONG64 uipns;
  3626. ULONG dwOffset;
  3627. PRINTF("%I64x", uip);
  3628. if (FindObjSymbol(uip, &uipns, &dwOffset))
  3629. {
  3630. PRINTF(":[%s", GetObjAddrPath(uipns));
  3631. if (dwOffset != 0)
  3632. {
  3633. PRINTF("+%x", dwOffset);
  3634. }
  3635. PRINTF("]");
  3636. }
  3637. } //PrintSymbol
  3638. /***EP DbgParseArgs - parse command arguments
  3639. *
  3640. * ENTRY
  3641. * pArgs -> command argument table
  3642. * pdwNumArgs -> to hold the number of arguments parsed
  3643. * pdwNonSWArgs -> to hold the number of non-switch arguments parsed
  3644. * pszTokenSeps -> token separator characters string
  3645. *
  3646. * EXIT-SUCCESS
  3647. * returns ARGERR_NONE
  3648. * EXIT-FAILURE
  3649. * returns negative error code
  3650. */
  3651. LONG LOCAL DbgParseArgs(PCMDARG ArgTable, PULONG pdwNumArgs,
  3652. PULONG pdwNonSWArgs, PSZ pszTokenSeps)
  3653. {
  3654. LONG rc = ARGERR_NONE;
  3655. PSZ psz;
  3656. *pdwNumArgs = 0;
  3657. *pdwNonSWArgs = 0;
  3658. while ((psz = strtok(NULL, pszTokenSeps)) != NULL)
  3659. {
  3660. (*pdwNumArgs)++;
  3661. if ((rc = DbgParseOneArg(ArgTable, psz, *pdwNumArgs, pdwNonSWArgs)) !=
  3662. ARGERR_NONE)
  3663. {
  3664. break;
  3665. }
  3666. }
  3667. return rc;
  3668. } //DbgParseArgs
  3669. /***LP DbgParseOneArg - parse one command argument
  3670. *
  3671. * ENTRY
  3672. * pArgs -> command argument table
  3673. * psz -> argument string
  3674. * dwArgNum - argument number
  3675. * pdwNonSWArgs -> to hold the number of non-switch arguments parsed
  3676. *
  3677. * EXIT-SUCCESS
  3678. * returns ARGERR_NONE
  3679. * EXIT-FAILURE
  3680. * returns negative error code
  3681. */
  3682. LONG LOCAL DbgParseOneArg(PCMDARG ArgTable, PSZ psz, ULONG dwArgNum,
  3683. PULONG pdwNonSWArgs)
  3684. {
  3685. LONG rc = ARGERR_NONE;
  3686. PCMDARG pArg;
  3687. PSZ pszEnd;
  3688. if ((pArg = DbgMatchArg(ArgTable, &psz, pdwNonSWArgs)) != NULL)
  3689. {
  3690. switch (pArg->dwArgType)
  3691. {
  3692. case AT_STRING:
  3693. case AT_NUM:
  3694. if (pArg->dwfArg & AF_SEP)
  3695. {
  3696. if ((*psz != '\0') &&
  3697. (strchr(pszOptionSeps, *psz) != NULL))
  3698. {
  3699. psz++;
  3700. }
  3701. else
  3702. {
  3703. ARG_ERROR(("argument missing option separator - %s",
  3704. psz));
  3705. rc = ARGERR_SEP_NOT_FOUND;
  3706. break;
  3707. }
  3708. }
  3709. if (pArg->dwArgType == AT_STRING)
  3710. {
  3711. *((PSZ *)pArg->pvArgData) = psz;
  3712. }
  3713. else
  3714. {
  3715. *((PLONG)pArg->pvArgData) =
  3716. strtol(psz, &pszEnd, pArg->dwArgParam);
  3717. if (psz == pszEnd)
  3718. {
  3719. ARG_ERROR(("invalid numeric argument - %s", psz));
  3720. rc = ARGERR_INVALID_NUMBER;
  3721. break;
  3722. }
  3723. }
  3724. if (pArg->pfnArg != NULL)
  3725. {
  3726. rc = pArg->pfnArg(pArg, psz, dwArgNum, *pdwNonSWArgs);
  3727. }
  3728. break;
  3729. case AT_ENABLE:
  3730. case AT_DISABLE:
  3731. if (pArg->dwArgType == AT_ENABLE)
  3732. *((PULONG)pArg->pvArgData) |= pArg->dwArgParam;
  3733. else
  3734. *((PULONG)pArg->pvArgData) &= ~pArg->dwArgParam;
  3735. if ((pArg->pfnArg != NULL) &&
  3736. (pArg->pfnArg(pArg, psz, dwArgNum, *pdwNonSWArgs) !=
  3737. ARGERR_NONE))
  3738. {
  3739. break;
  3740. }
  3741. if (*psz != '\0')
  3742. {
  3743. rc = DbgParseOneArg(ArgTable, psz, dwArgNum, pdwNonSWArgs);
  3744. }
  3745. break;
  3746. case AT_ACTION:
  3747. ASSERT(pArg->pfnArg != NULL);
  3748. rc = pArg->pfnArg(pArg, psz, dwArgNum, *pdwNonSWArgs);
  3749. break;
  3750. default:
  3751. ARG_ERROR(("invalid argument table"));
  3752. rc = ARGERR_ASSERT_FAILED;
  3753. }
  3754. }
  3755. else
  3756. {
  3757. ARG_ERROR(("invalid command argument - %s", psz));
  3758. rc = ARGERR_INVALID_ARG;
  3759. }
  3760. return rc;
  3761. } //DbgParseOneArg
  3762. /***LP DbgMatchArg - match argument type from argument table
  3763. *
  3764. * ENTRY
  3765. * ArgTable -> argument table
  3766. * ppsz -> argument string pointer
  3767. * pdwNonSWArgs -> to hold the number of non-switch arguments parsed
  3768. *
  3769. * EXIT-SUCCESS
  3770. * returns pointer to argument entry matched
  3771. * EXIT-FAILURE
  3772. * returns NULL
  3773. */
  3774. PCMDARG LOCAL DbgMatchArg(PCMDARG ArgTable, PSZ *ppsz, PULONG pdwNonSWArgs)
  3775. {
  3776. PCMDARG pArg;
  3777. for (pArg = ArgTable; pArg->dwArgType != AT_END; pArg++)
  3778. {
  3779. if (pArg->pszArgID == NULL) //NULL means match anything.
  3780. {
  3781. (*pdwNonSWArgs)++;
  3782. break;
  3783. }
  3784. else
  3785. {
  3786. ULONG dwLen;
  3787. if (strchr(pszSwitchChars, **ppsz) != NULL)
  3788. (*ppsz)++;
  3789. dwLen = strlen(pArg->pszArgID);
  3790. if (StrCmp(pArg->pszArgID, *ppsz, dwLen,
  3791. (BOOLEAN)((pArg->dwfArg & AF_NOI) != 0)) == 0)
  3792. {
  3793. (*ppsz) += dwLen;
  3794. break;
  3795. }
  3796. }
  3797. }
  3798. if (pArg->dwArgType == AT_END)
  3799. pArg = NULL;
  3800. return pArg;
  3801. } //DbgMatchArg
  3802. /***EP MemZero - Fill target buffer with zeros
  3803. *
  3804. * ENTRY
  3805. * uipAddr - target buffer address
  3806. * dwSize - target buffer size
  3807. *
  3808. * EXIT
  3809. * None
  3810. */
  3811. VOID MemZero(ULONG64 uipAddr, ULONG dwSize)
  3812. {
  3813. PULONG pbBuff;
  3814. //
  3815. // LPTR will zero init the buffer
  3816. //
  3817. if ((pbBuff = LocalAlloc(LPTR, dwSize)) != NULL)
  3818. {
  3819. if (!WriteMemory(uipAddr, pbBuff, dwSize, NULL))
  3820. {
  3821. DBG_ERROR(("MemZero: failed to write memory"));
  3822. }
  3823. LocalFree(pbBuff);
  3824. }
  3825. else
  3826. {
  3827. DBG_ERROR(("MemZero: failed to allocate buffer"));
  3828. }
  3829. } //MemZero
  3830. /***EP ReadMemByte - Read a byte from target address
  3831. *
  3832. * ENTRY
  3833. * uipAddr - target address
  3834. *
  3835. * EXIT
  3836. * None
  3837. */
  3838. BYTE ReadMemByte(ULONG64 uipAddr)
  3839. {
  3840. BYTE bData = 0;
  3841. if (!ReadMemory(uipAddr, &bData, sizeof(bData), NULL))
  3842. {
  3843. DBG_ERROR(("ReadMemByte: failed to read address %I64x", uipAddr));
  3844. }
  3845. return bData;
  3846. } //ReadMemByte
  3847. /***EP ReadMemWord - Read a word from target address
  3848. *
  3849. * ENTRY
  3850. * uipAddr - target address
  3851. *
  3852. * EXIT
  3853. * None
  3854. */
  3855. WORD ReadMemWord(ULONG64 uipAddr)
  3856. {
  3857. WORD wData = 0;
  3858. if (!ReadMemory(uipAddr, &wData, sizeof(wData), NULL))
  3859. {
  3860. DBG_ERROR(("ReadMemWord: failed to read address %I64x", uipAddr));
  3861. }
  3862. return wData;
  3863. } //ReadMemWord
  3864. /***EP ReadMemDWord - Read a dword from target address
  3865. *
  3866. * ENTRY
  3867. * uipAddr - target address
  3868. *
  3869. * EXIT
  3870. * None
  3871. */
  3872. DWORD ReadMemDWord(ULONG64 uipAddr)
  3873. {
  3874. DWORD dwData = 0;
  3875. if (!ReadMemory(uipAddr, &dwData, sizeof(dwData), NULL))
  3876. {
  3877. DBG_ERROR(("ReadMemDWord: failed to read address %I64x", uipAddr));
  3878. }
  3879. return dwData;
  3880. } //ReadMemDWord
  3881. /***EP ReadMemUlong64 - Read a ulong64 from target address
  3882. *
  3883. * ENTRY
  3884. * uipAddr - target address
  3885. *
  3886. * EXIT
  3887. * 64 bit address
  3888. */
  3889. ULONG64 ReadMemUlong64(ULONG64 uipAddr)
  3890. {
  3891. ULONG64 uipData = 0;
  3892. if (!ReadMemory(uipAddr, &uipData, sizeof(uipData), NULL))
  3893. {
  3894. DBG_ERROR(("ReadMemUlong64: failed to read address %I64x", uipAddr));
  3895. }
  3896. return uipData;
  3897. } //ReadMemUlongPtr
  3898. /***LP GetNSObj - Find a name space object
  3899. *
  3900. * ENTRY
  3901. * pszObjPath -> object path string
  3902. * pnsScope - object scope to start the search (NULL means root)
  3903. * puipns -> to hold the pnsobj address if found
  3904. * pns -> buffer to hold the object found
  3905. * dwfNS - flags
  3906. *
  3907. * EXIT-SUCCESS
  3908. * returns DBGERR_NONE
  3909. * EXIT-FAILURE
  3910. * returns DBGERR_ code
  3911. */
  3912. LONG LOCAL GetNSObj(PSZ pszObjPath, PULONG64 pnsScope, PULONG64 puipns,
  3913. PULONG64 pns, ULONG dwfNS)
  3914. {
  3915. LONG rc = DBGERR_NONE;
  3916. BOOLEAN fSearchUp = (BOOLEAN)(!(dwfNS & NSF_LOCAL_SCOPE) &&
  3917. (pszObjPath[0] != '\\') &&
  3918. (pszObjPath[0] != '^') &&
  3919. (StrLen(pszObjPath, -1) <= sizeof(NAMESEG)));
  3920. BOOLEAN fMatch = TRUE;
  3921. PSZ psz;
  3922. ULONG64 NSObj, NSChildObj;
  3923. ULONG64 NSScope, UIPns, NSO;
  3924. if(pnsScope)
  3925. NSScope = *pnsScope;
  3926. if(puipns)
  3927. UIPns = *puipns;
  3928. if(pns)
  3929. NSO = *pns;
  3930. if (*pszObjPath == '\\')
  3931. {
  3932. psz = &pszObjPath[1];
  3933. NSScope = 0;
  3934. }
  3935. else
  3936. {
  3937. if(NSScope)
  3938. {
  3939. if(InitTypeRead(NSScope, ACPI!_NSObj))
  3940. dprintf("GetNSObj: Failed to initialize NSScope (%I64x)\n", NSScope);
  3941. }
  3942. for (psz = pszObjPath;
  3943. (*psz == '^') && (NSScope != 0) &&
  3944. (ReadField(pnsParent) != 0);
  3945. psz++)
  3946. {
  3947. NSObj = ReadField(pnsParent);
  3948. if (!NSObj)
  3949. {
  3950. DBG_ERROR(("failed to read parent object at %I64x",
  3951. ReadField(pnsParent)));
  3952. rc = DBGERR_CMD_FAILED;
  3953. break;
  3954. }
  3955. else
  3956. {
  3957. NSScope = NSObj;
  3958. if(InitTypeRead(NSScope, ACPI!_NSObj))
  3959. dprintf("GetNSObj: Failed to initialize for NSScope (%I64x)\n", NSScope);
  3960. }
  3961. }
  3962. if ((rc == DBGERR_NONE) && (*psz == '^'))
  3963. {
  3964. if (dwfNS & NSF_WARN_NOTFOUND)
  3965. {
  3966. DBG_ERROR(("object %s not found", pszObjPath));
  3967. }
  3968. rc = DBGERR_CMD_FAILED;
  3969. }
  3970. }
  3971. if ((rc == DBGERR_NONE) && (NSScope == 0))
  3972. {
  3973. if (!ReadPointer(GetExpression("acpi!gpnsnamespaceroot"), &UIPns) ||
  3974. UIPns == 0)
  3975. {
  3976. DBG_ERROR(("failed to get root object address"));
  3977. rc = DBGERR_CMD_FAILED;
  3978. }
  3979. else
  3980. {
  3981. NSObj = UIPns;
  3982. NSScope = NSObj;
  3983. }
  3984. }
  3985. while ((rc == DBGERR_NONE) && (*psz != '\0'))
  3986. {
  3987. InitTypeRead(NSScope, ACPI!_NSObj);
  3988. if (ReadField(pnsFirstChild) == 0)
  3989. {
  3990. fMatch = FALSE;
  3991. }
  3992. else
  3993. {
  3994. PSZ pszEnd = strchr(psz, '.');
  3995. ULONG dwLen = (ULONG)(pszEnd? (pszEnd - psz): StrLen(psz, -1));
  3996. if (dwLen > sizeof(NAMESEG))
  3997. {
  3998. DBG_ERROR(("invalid name path %s", pszObjPath));
  3999. rc = DBGERR_CMD_FAILED;
  4000. }
  4001. else
  4002. {
  4003. NAMESEG dwName = NAMESEG_BLANK;
  4004. BOOLEAN fFound = FALSE;
  4005. ULONG64 uip;
  4006. ULONG64 uipFirstChild = ReadField(pnsFirstChild);
  4007. MEMCPY(&dwName, psz, dwLen);
  4008. //
  4009. // Search all siblings for a matching NameSeg.
  4010. //
  4011. for (uip = uipFirstChild;
  4012. ((uip != 0) && ((NSChildObj = uip) != 0) && (InitTypeRead(NSChildObj, ACPI!_NSObj) == 0));
  4013. uip = ((ULONG64)ReadField(list.plistNext) ==
  4014. uipFirstChild)?
  4015. 0: (ULONG64)ReadField(list.plistNext))
  4016. {
  4017. if ((ULONG)ReadField(dwNameSeg) == dwName)
  4018. {
  4019. UIPns = uip;
  4020. fFound = TRUE;
  4021. NSObj = NSChildObj;
  4022. NSScope = NSObj;
  4023. break;
  4024. }
  4025. }
  4026. if (fFound)
  4027. {
  4028. psz += dwLen;
  4029. if (*psz == '.')
  4030. {
  4031. psz++;
  4032. }
  4033. }
  4034. else
  4035. {
  4036. fMatch = FALSE;
  4037. }
  4038. }
  4039. }
  4040. if ((rc == DBGERR_NONE) && !fMatch)
  4041. {
  4042. InitTypeRead(NSScope, ACPI!_NSObj);
  4043. if (fSearchUp && ((NSObj = ReadField(pnsParent)) != 0))
  4044. {
  4045. fMatch = TRUE;
  4046. NSScope = NSObj;
  4047. }
  4048. else
  4049. {
  4050. if (dwfNS & NSF_WARN_NOTFOUND)
  4051. {
  4052. DBG_ERROR(("object %s not found", pszObjPath));
  4053. }
  4054. rc = DBGERR_CMD_FAILED;
  4055. }
  4056. }
  4057. }
  4058. if (rc != DBGERR_NONE)
  4059. {
  4060. UIPns = 0;
  4061. }
  4062. else
  4063. {
  4064. NSO = NSScope;
  4065. }
  4066. if(puipns)
  4067. *puipns = UIPns;
  4068. if(pnsScope)
  4069. *pnsScope = NSScope;
  4070. if(pns)
  4071. *pns = NSO;
  4072. return rc;
  4073. } //GetNSObj
  4074. /***LP NameSegString - convert a NameSeg to an ASCIIZ stri
  4075. *
  4076. * ENTRY
  4077. * dwNameSeg - NameSeg
  4078. *
  4079. * EXIT
  4080. * returns string
  4081. */
  4082. PSZ LOCAL NameSegString(ULONG dwNameSeg)
  4083. {
  4084. static char szNameSeg[sizeof(NAMESEG) + 1] = {0};
  4085. STRCPYN(szNameSeg, (PSZ)&dwNameSeg, sizeof(NAMESEG));
  4086. return szNameSeg;
  4087. } //NameSegString
  4088. /***LP UnAsmScope - Unassemble a scope
  4089. *
  4090. * ENTRY
  4091. * ppbOp -> Current Opcode pointer
  4092. * pbEnd -> end of scope
  4093. * uipbOp - Op address
  4094. * pnsScope - Scope object
  4095. * iLevel - level of indentation
  4096. * icLines - 1: unasm one line; 0: unasm all; -1: internal
  4097. *
  4098. * EXIT-SUCCESS
  4099. * returns UNASMERR_NONE
  4100. * EXIT-FAILURE
  4101. * returns negative error code
  4102. */
  4103. LONG LOCAL UnAsmScope(PUCHAR *ppbOp, PUCHAR pbEnd, ULONG64 uipbOp,
  4104. PULONG64 pnsScope, int iLevel, int icLines)
  4105. {
  4106. LONG rc = UNASMERR_NONE;
  4107. int icLinesLeft = icLines;
  4108. if (uipbOp != 0)
  4109. {
  4110. guipbOpXlate = uipbOp - (ULONG64)(*ppbOp);
  4111. }
  4112. if (pnsScope != NULL)
  4113. {
  4114. gpnsCurUnAsmScope = *pnsScope;
  4115. }
  4116. if (iLevel != -1)
  4117. {
  4118. giLevel = iLevel;
  4119. }
  4120. if (icLines < 0)
  4121. {
  4122. Indent(*ppbOp, giLevel);
  4123. PRINTF("{");
  4124. giLevel++;
  4125. }
  4126. else if (icLines == 0)
  4127. {
  4128. icLinesLeft = -1;
  4129. }
  4130. while (*ppbOp < pbEnd)
  4131. {
  4132. Indent(*ppbOp, giLevel);
  4133. if ((rc = UnAsmOpcode(ppbOp)) == UNASMERR_NONE)
  4134. {
  4135. if (icLinesLeft < 0)
  4136. {
  4137. continue;
  4138. }
  4139. if (--icLinesLeft == 0)
  4140. {
  4141. break;
  4142. }
  4143. }
  4144. else
  4145. {
  4146. break;
  4147. }
  4148. }
  4149. if ((rc == UNASMERR_NONE) && (icLines < 0))
  4150. {
  4151. giLevel--;
  4152. Indent(*ppbOp, giLevel);
  4153. PRINTF("}");
  4154. }
  4155. return rc;
  4156. } //UnAsmScope
  4157. /***LP Indent - Print indent level
  4158. *
  4159. * ENTRY
  4160. * pbOp -> opcode
  4161. * iLevel - indent level
  4162. *
  4163. * EXIT
  4164. * None
  4165. */
  4166. VOID LOCAL Indent(PUCHAR pbOp, int iLevel)
  4167. {
  4168. int i;
  4169. PRINTF("\n%I64x : ", (ULONG64)pbOp + guipbOpXlate);
  4170. for (i = 0; i < iLevel; ++i)
  4171. {
  4172. PRINTF("| ");
  4173. }
  4174. } //Indent
  4175. /***LP UnAsmOpcode - Unassemble an Opcode
  4176. *
  4177. * ENTRY
  4178. * ppbOp -> Opcode pointer
  4179. *
  4180. * EXIT-SUCCESS
  4181. * returns UNASMERR_NONE
  4182. * EXIT-FAILURE
  4183. * returns negative error code
  4184. */
  4185. LONG LOCAL UnAsmOpcode(PUCHAR *ppbOp)
  4186. {
  4187. LONG rc = UNASMERR_NONE;
  4188. ULONG dwOpcode;
  4189. UCHAR bOp;
  4190. PASLTERM pterm;
  4191. char szUnAsmArgTypes[MAX_ARGS + 1];
  4192. int i;
  4193. if (**ppbOp == OP_EXT_PREFIX)
  4194. {
  4195. (*ppbOp)++;
  4196. dwOpcode = (((ULONG)**ppbOp) << 8) | OP_EXT_PREFIX;
  4197. bOp = FindOpClass(**ppbOp, ExOpClassTable);
  4198. }
  4199. else
  4200. {
  4201. dwOpcode = (ULONG)(**ppbOp);
  4202. bOp = OpClassTable[**ppbOp];
  4203. }
  4204. switch (bOp)
  4205. {
  4206. case OPCLASS_DATA_OBJ:
  4207. rc = UnAsmDataObj(ppbOp);
  4208. break;
  4209. case OPCLASS_NAME_OBJ:
  4210. {
  4211. ULONG64 NSObj = 0;
  4212. if (((rc = UnAsmNameObj(ppbOp, &NSObj, NSTYPE_UNKNOWN)) ==
  4213. UNASMERR_NONE) &&
  4214. (InitTypeRead(NSObj, ACPI!_NSObj) == 0) &&
  4215. (ReadField(ObjData.dwDataType) == OBJTYPE_METHOD))
  4216. {
  4217. ULONG64 pm = ReadField(ObjData.pbDataBuff);
  4218. int iNumArgs;
  4219. if(InitTypeRead(pm, ACPI!_MethodObj))
  4220. {
  4221. DBG_ERROR(("UnAsmOpcode: Failed to initialize Objdata %I64", pm));
  4222. rc = UNASMERR_FATAL;
  4223. break;
  4224. }
  4225. if (pm != 0)
  4226. {
  4227. iNumArgs = ((UCHAR)ReadField(bMethodFlags) & METHOD_NUMARG_MASK);
  4228. for (i = 0; i < iNumArgs; ++i)
  4229. {
  4230. szUnAsmArgTypes[i] = 'C';
  4231. }
  4232. szUnAsmArgTypes[i] = '\0';
  4233. rc = UnAsmArgs(szUnAsmArgTypes, NULL, ppbOp, NULL);
  4234. }
  4235. }
  4236. break;
  4237. }
  4238. case OPCLASS_ARG_OBJ:
  4239. case OPCLASS_LOCAL_OBJ:
  4240. case OPCLASS_CODE_OBJ:
  4241. case OPCLASS_CONST_OBJ:
  4242. if ((pterm = FindOpTerm(dwOpcode)) == NULL)
  4243. {
  4244. DBG_ERROR(("UnAsmOpcode: invalid opcode 0x%x", dwOpcode));
  4245. rc = UNASMERR_FATAL;
  4246. }
  4247. else
  4248. {
  4249. (*ppbOp)++;
  4250. rc = UnAsmTermObj(pterm, ppbOp);
  4251. }
  4252. break;
  4253. default:
  4254. DBG_ERROR(("UnAsmOpcode: invalid opcode class %d", bOp));
  4255. rc = UNASMERR_FATAL;
  4256. }
  4257. return rc;
  4258. } //UnAsmOpcode
  4259. /***LP FindOpClass - Find opcode class of extended opcode
  4260. *
  4261. * ENTRY
  4262. * bOp - opcode
  4263. * pOpTable -> opcode table
  4264. *
  4265. * EXIT-SUCCESS
  4266. * returns opcode class
  4267. * EXIT-FAILURE
  4268. * returns OPCLASS_INVALID
  4269. */
  4270. UCHAR LOCAL FindOpClass(UCHAR bOp, POPMAP pOpTable)
  4271. {
  4272. UCHAR bOpClass = OPCLASS_INVALID;
  4273. while (pOpTable->bOpClass != 0)
  4274. {
  4275. if (bOp == pOpTable->bExOp)
  4276. {
  4277. bOpClass = pOpTable->bOpClass;
  4278. break;
  4279. }
  4280. else
  4281. {
  4282. pOpTable++;
  4283. }
  4284. }
  4285. return bOpClass;
  4286. } //FindOpClass
  4287. /***LP UnAsmDataObj - Unassemble data object
  4288. *
  4289. * ENTRY
  4290. * ppbOp -> opcode pointer
  4291. *
  4292. * EXIT-SUCCESS
  4293. * returns UNASMERR_NONE
  4294. * EXIT-FAILURE
  4295. * returns negative error code
  4296. */
  4297. LONG LOCAL UnAsmDataObj(PUCHAR *ppbOp)
  4298. {
  4299. LONG rc = UNASMERR_NONE;
  4300. UCHAR bOp = **ppbOp;
  4301. PSZ psz;
  4302. (*ppbOp)++;
  4303. switch (bOp)
  4304. {
  4305. case OP_BYTE:
  4306. PRINTF("0x%x", **ppbOp);
  4307. *ppbOp += sizeof(UCHAR);
  4308. break;
  4309. case OP_WORD:
  4310. PRINTF("0x%x", *((PUSHORT)*ppbOp));
  4311. *ppbOp += sizeof(USHORT);
  4312. break;
  4313. case OP_DWORD:
  4314. PRINTF("0x%x", *((PULONG)*ppbOp));
  4315. *ppbOp += sizeof(ULONG);
  4316. break;
  4317. case OP_STRING:
  4318. PRINTF("\"");
  4319. for (psz = (PSZ)*ppbOp; *psz != '\0'; psz++)
  4320. {
  4321. if (*psz == '\\')
  4322. {
  4323. PRINTF("\\");
  4324. }
  4325. PRINTF("%c", *psz);
  4326. }
  4327. PRINTF("\"");
  4328. *ppbOp += STRLEN((PSZ)*ppbOp) + 1;
  4329. break;
  4330. default:
  4331. DBG_ERROR(("UnAsmDataObj: unexpected opcode 0x%x", bOp));
  4332. rc = UNASMERR_INVALID_OPCODE;
  4333. }
  4334. return rc;
  4335. } //UnAsmDataObj
  4336. /***LP UnAsmNameObj - Unassemble name object
  4337. *
  4338. * ENTRY
  4339. * ppbOp -> opcode pointer
  4340. * pns -> to hold object found or created
  4341. * c - object type
  4342. *
  4343. * EXIT-SUCCESS
  4344. * returns UNASMERR_NONE
  4345. * EXIT-FAILURE
  4346. * returns negative error code
  4347. */
  4348. LONG LOCAL UnAsmNameObj(PUCHAR *ppbOp, PULONG64 pns, char c)
  4349. {
  4350. LONG rc = UNASMERR_NONE;
  4351. char szName[MAX_NAME_LEN + 1];
  4352. int iLen = 0;
  4353. szName[0] = '\0';
  4354. if (**ppbOp == OP_ROOT_PREFIX)
  4355. {
  4356. szName[iLen] = '\\';
  4357. iLen++;
  4358. (*ppbOp)++;
  4359. rc = UnAsmNameTail(ppbOp, szName, iLen);
  4360. }
  4361. else if (**ppbOp == OP_PARENT_PREFIX)
  4362. {
  4363. szName[iLen] = '^';
  4364. iLen++;
  4365. (*ppbOp)++;
  4366. while ((**ppbOp == OP_PARENT_PREFIX) && (iLen < MAX_NAME_LEN))
  4367. {
  4368. szName[iLen] = '^';
  4369. iLen++;
  4370. (*ppbOp)++;
  4371. }
  4372. if (**ppbOp == OP_PARENT_PREFIX)
  4373. {
  4374. DBG_ERROR(("UnAsmNameObj: name too long - \"%s\"", szName));
  4375. rc = UNASMERR_FATAL;
  4376. }
  4377. else
  4378. {
  4379. rc = UnAsmNameTail(ppbOp, szName, iLen);
  4380. }
  4381. }
  4382. else
  4383. {
  4384. rc = UnAsmNameTail(ppbOp, szName, iLen);
  4385. }
  4386. if (rc == UNASMERR_NONE)
  4387. {
  4388. ULONG64 uipns = 0;
  4389. ULONG64 NSObj = 0;
  4390. PRINTF("%s", szName);
  4391. rc = GetNSObj(szName, &gpnsCurUnAsmScope, &uipns, &NSObj, 0);
  4392. if (rc == UNASMERR_NONE)
  4393. {
  4394. if (pns != NULL)
  4395. {
  4396. *pns = NSObj;
  4397. }
  4398. if ((c == NSTYPE_SCOPE) && (uipns != 0))
  4399. {
  4400. gpnsCurUnAsmScope = *pns;
  4401. }
  4402. }
  4403. else
  4404. {
  4405. rc = UNASMERR_NONE;
  4406. }
  4407. }
  4408. return rc;
  4409. } //UnAsmNameObj
  4410. /***LP UnAsmNameTail - Parse AML name tail
  4411. *
  4412. * ENTRY
  4413. * ppbOp -> opcode pointer
  4414. * pszBuff -> to hold parsed name
  4415. * iLen - index to tail of pszBuff
  4416. *
  4417. * EXIT-SUCCESS
  4418. * returns UNASMERR_NONE
  4419. * EXIT-FAILURE
  4420. * returns negative error code
  4421. */
  4422. LONG LOCAL UnAsmNameTail(PUCHAR *ppbOp, PSZ pszBuff, int iLen)
  4423. {
  4424. LONG rc = UNASMERR_NONE;
  4425. int icNameSegs = 0;
  4426. //
  4427. // We do not check for invalid NameSeg characters here and assume that
  4428. // the compiler does its job not generating it.
  4429. //
  4430. if (**ppbOp == '\0')
  4431. {
  4432. //
  4433. // There is no NameTail (i.e. either NULL name or name with just
  4434. // prefixes.
  4435. //
  4436. (*ppbOp)++;
  4437. }
  4438. else if (**ppbOp == OP_MULTI_NAME_PREFIX)
  4439. {
  4440. (*ppbOp)++;
  4441. icNameSegs = (int)**ppbOp;
  4442. (*ppbOp)++;
  4443. }
  4444. else if (**ppbOp == OP_DUAL_NAME_PREFIX)
  4445. {
  4446. (*ppbOp)++;
  4447. icNameSegs = 2;
  4448. }
  4449. else
  4450. icNameSegs = 1;
  4451. while ((icNameSegs > 0) && (iLen + sizeof(NAMESEG) < MAX_NAME_LEN))
  4452. {
  4453. STRCPYN(&pszBuff[iLen], (PSZ)(*ppbOp), sizeof(NAMESEG));
  4454. iLen += sizeof(NAMESEG);
  4455. *ppbOp += sizeof(NAMESEG);
  4456. icNameSegs--;
  4457. if ((icNameSegs > 0) && (iLen + 1 < MAX_NAME_LEN))
  4458. {
  4459. pszBuff[iLen] = '.';
  4460. iLen++;
  4461. }
  4462. }
  4463. if (icNameSegs > 0)
  4464. {
  4465. DBG_ERROR(("UnAsmNameTail: name too long - %s", pszBuff));
  4466. rc = UNASMERR_FATAL;
  4467. }
  4468. else
  4469. {
  4470. pszBuff[iLen] = '\0';
  4471. }
  4472. return rc;
  4473. } //UnAsmNameTail
  4474. /***LP UnAsmTermObj - Unassemble term object
  4475. *
  4476. * ENTRY
  4477. * pterm -> term table entry
  4478. * ppbOp -> opcode pointer
  4479. *
  4480. * EXIT-SUCCESS
  4481. * returns UNASMERR_NONE
  4482. * EXIT-FAILURE
  4483. * returns negative error code
  4484. */
  4485. LONG LOCAL UnAsmTermObj(PASLTERM pterm, PUCHAR *ppbOp)
  4486. {
  4487. LONG rc = UNASMERR_NONE;
  4488. PUCHAR pbEnd = NULL;
  4489. ULONG64 pnsScopeSave = gpnsCurUnAsmScope;
  4490. ULONG64 NSObj = 0;
  4491. PRINTF("%s", pterm->pszID);
  4492. if (pterm->dwfTerm & TF_PACKAGE_LEN)
  4493. {
  4494. ParsePackageLen(ppbOp, &pbEnd);
  4495. }
  4496. if (pterm->pszUnAsmArgTypes != NULL)
  4497. {
  4498. rc = UnAsmArgs(pterm->pszUnAsmArgTypes, pterm->pszArgActions, ppbOp,
  4499. &NSObj);
  4500. }
  4501. if (rc == UNASMERR_NONE)
  4502. {
  4503. if (pterm->dwfTerm & TF_DATA_LIST)
  4504. {
  4505. rc = UnAsmDataList(ppbOp, pbEnd);
  4506. }
  4507. else if (pterm->dwfTerm & TF_PACKAGE_LIST)
  4508. {
  4509. rc = UnAsmPkgList(ppbOp, pbEnd);
  4510. }
  4511. else if (pterm->dwfTerm & TF_FIELD_LIST)
  4512. {
  4513. rc = UnAsmFieldList(ppbOp, pbEnd);
  4514. }
  4515. else if (pterm->dwfTerm & TF_PACKAGE_LEN)
  4516. {
  4517. if ((pterm->dwfTerm & TF_CHANGE_CHILDSCOPE) &&
  4518. ((InitTypeRead(NSObj, ACPI!_NSObj) == 0)&&
  4519. (ReadField(ObjData.dwDataType) != 0)))
  4520. {
  4521. gpnsCurUnAsmScope = NSObj;
  4522. }
  4523. rc = UnAsmScope(ppbOp, pbEnd, 0, NULL, -1, -1);
  4524. }
  4525. }
  4526. gpnsCurUnAsmScope = pnsScopeSave;
  4527. return rc;
  4528. } //UnAsmTermObj
  4529. /***LP UnAsmArgs - Unassemble arguments
  4530. *
  4531. * ENTRY
  4532. * pszUnArgTypes -> UnAsm ArgTypes string
  4533. * pszArgActions -> Arg Action types
  4534. * ppbOp -> opcode pointer
  4535. * pns -> to hold created object
  4536. *
  4537. * EXIT-SUCCESS
  4538. * returns UNASMERR_NONE
  4539. * EXIT-FAILURE
  4540. * returns negative error code
  4541. */
  4542. LONG LOCAL UnAsmArgs(PSZ pszUnAsmArgTypes, PSZ pszArgActions, PUCHAR *ppbOp,
  4543. PULONG64 pns)
  4544. {
  4545. LONG rc = UNASMERR_NONE;
  4546. static UCHAR bArgData = 0;
  4547. int iNumArgs, i ;
  4548. PASLTERM pterm;
  4549. iNumArgs = STRLEN(pszUnAsmArgTypes);
  4550. PRINTF("(");
  4551. for (i = 0; i < iNumArgs; ++i)
  4552. {
  4553. if (i != 0)
  4554. {
  4555. PRINTF(", ");
  4556. }
  4557. switch (pszUnAsmArgTypes[i])
  4558. {
  4559. case 'N':
  4560. ASSERT(pszArgActions != NULL);
  4561. rc = UnAsmNameObj(ppbOp, pns, pszArgActions[i]);
  4562. break;
  4563. case 'O':
  4564. if ((**ppbOp == OP_BUFFER) || (**ppbOp == OP_PACKAGE) ||
  4565. (OpClassTable[**ppbOp] == OPCLASS_CONST_OBJ))
  4566. {
  4567. pterm = FindOpTerm((ULONG)(**ppbOp));
  4568. ASSERT(pterm != NULL);
  4569. (*ppbOp)++;
  4570. if (pterm != NULL)
  4571. {
  4572. rc = UnAsmTermObj(pterm, ppbOp);
  4573. }
  4574. }
  4575. else
  4576. {
  4577. rc = UnAsmDataObj(ppbOp);
  4578. }
  4579. break;
  4580. case 'C':
  4581. rc = UnAsmOpcode(ppbOp);
  4582. break;
  4583. case 'B':
  4584. PRINTF("0x%x", **ppbOp);
  4585. *ppbOp += sizeof(UCHAR);
  4586. break;
  4587. case 'K':
  4588. case 'k':
  4589. if (pszUnAsmArgTypes[i] == 'K')
  4590. {
  4591. bArgData = **ppbOp;
  4592. }
  4593. if ((pszArgActions != NULL) && (pszArgActions[i] == '!'))
  4594. {
  4595. PRINTF("0x%x", **ppbOp & 0x07);
  4596. }
  4597. else
  4598. {
  4599. pterm = FindKeywordTerm(pszArgActions[i], bArgData);
  4600. ASSERT(pterm != NULL);
  4601. if (pterm != NULL)
  4602. {
  4603. PRINTF("%s", pterm->pszID);
  4604. }
  4605. }
  4606. if (pszUnAsmArgTypes[i] == 'K')
  4607. {
  4608. *ppbOp += sizeof(UCHAR);
  4609. }
  4610. break;
  4611. case 'W':
  4612. PRINTF("0x%x", *((PUSHORT)*ppbOp));
  4613. *ppbOp += sizeof(USHORT);
  4614. break;
  4615. case 'D':
  4616. PRINTF("0x%x", *((PULONG)*ppbOp));
  4617. *ppbOp += sizeof(ULONG);
  4618. break;
  4619. case 'S':
  4620. ASSERT(pszArgActions != NULL);
  4621. rc = UnAsmSuperName(ppbOp);
  4622. break;
  4623. default:
  4624. DBG_ERROR(("UnAsmOpcode: invalid ArgType '%c'",
  4625. pszUnAsmArgTypes[i]));
  4626. rc = UNASMERR_FATAL;
  4627. }
  4628. }
  4629. PRINTF(")");
  4630. return rc;
  4631. } //UnAsmArgs
  4632. /***LP UnAsmSuperName - Unassemble supername
  4633. *
  4634. * ENTRY
  4635. * ppbOp -> opcode pointer
  4636. *
  4637. * EXIT-SUCCESS
  4638. * returns UNASMERR_NONE
  4639. * EXIT-FAILURE
  4640. * returns negative error code
  4641. */
  4642. LONG LOCAL UnAsmSuperName(PUCHAR *ppbOp)
  4643. {
  4644. LONG rc = UNASMERR_NONE;
  4645. if (**ppbOp == 0)
  4646. {
  4647. (*ppbOp)++;
  4648. }
  4649. else if ((**ppbOp == OP_EXT_PREFIX) && (*(*ppbOp + 1) == EXOP_DEBUG))
  4650. {
  4651. PRINTF("Debug");
  4652. *ppbOp += 2;
  4653. }
  4654. else if (OpClassTable[**ppbOp] == OPCLASS_NAME_OBJ)
  4655. {
  4656. rc = UnAsmNameObj(ppbOp, NULL, NSTYPE_UNKNOWN);
  4657. }
  4658. else if ((**ppbOp == OP_INDEX) ||
  4659. (OpClassTable[**ppbOp] == OPCLASS_ARG_OBJ) ||
  4660. (OpClassTable[**ppbOp] == OPCLASS_LOCAL_OBJ))
  4661. {
  4662. rc = UnAsmOpcode(ppbOp);
  4663. }
  4664. else
  4665. {
  4666. DBG_ERROR(("UnAsmSuperName: invalid SuperName - 0x%02x", **ppbOp));
  4667. rc = UNASMERR_FATAL;
  4668. }
  4669. return rc;
  4670. } //UnAsmSuperName
  4671. /***LP UnAsmDataList - Unassemble data list
  4672. *
  4673. * ENTRY
  4674. * ppbOp -> opcode pointer
  4675. * pbEnd -> end of list
  4676. *
  4677. * EXIT-SUCCESS
  4678. * returns UNASMERR_NONE
  4679. * EXIT-FAILURE
  4680. * returns negative error code
  4681. */
  4682. LONG LOCAL UnAsmDataList(PUCHAR *ppbOp, PUCHAR pbEnd)
  4683. {
  4684. LONG rc = UNASMERR_NONE;
  4685. int i;
  4686. Indent(*ppbOp, giLevel);
  4687. PRINTF("{");
  4688. while (*ppbOp < pbEnd)
  4689. {
  4690. Indent(*ppbOp, 0);
  4691. PRINTF("0x%02x", **ppbOp);
  4692. (*ppbOp)++;
  4693. for (i = 1; (*ppbOp < pbEnd) && (i < 8); ++i)
  4694. {
  4695. PRINTF(", 0x%02x", **ppbOp);
  4696. (*ppbOp)++;
  4697. }
  4698. if (*ppbOp < pbEnd)
  4699. {
  4700. PRINTF(",");
  4701. }
  4702. }
  4703. Indent(*ppbOp, giLevel);
  4704. PRINTF("}");
  4705. return rc;
  4706. } //UnAsmDataList
  4707. /***LP UnAsmPkgList - Unassemble package list
  4708. *
  4709. * ENTRY
  4710. * ppbOp -> opcode pointer
  4711. * pbEnd -> end of list
  4712. *
  4713. * EXIT-SUCCESS
  4714. * returns UNASMERR_NONE
  4715. * EXIT-FAILURE
  4716. * returns negative error code
  4717. */
  4718. LONG LOCAL UnAsmPkgList(PUCHAR *ppbOp, PUCHAR pbEnd)
  4719. {
  4720. LONG rc = UNASMERR_NONE;
  4721. PASLTERM pterm;
  4722. Indent(*ppbOp, giLevel);
  4723. PRINTF("{");
  4724. giLevel++;
  4725. while (*ppbOp < pbEnd)
  4726. {
  4727. Indent(*ppbOp, giLevel);
  4728. if ((**ppbOp == OP_BUFFER) || (**ppbOp == OP_PACKAGE) ||
  4729. (OpClassTable[**ppbOp] == OPCLASS_CONST_OBJ))
  4730. {
  4731. pterm = FindOpTerm((ULONG)(**ppbOp));
  4732. ASSERT(pterm != NULL);
  4733. (*ppbOp)++;
  4734. if (pterm != NULL)
  4735. {
  4736. rc = UnAsmTermObj(pterm, ppbOp);
  4737. }
  4738. }
  4739. else if (OpClassTable[**ppbOp] == OPCLASS_NAME_OBJ)
  4740. {
  4741. rc = UnAsmNameObj(ppbOp, NULL, NSTYPE_UNKNOWN);
  4742. }
  4743. else
  4744. {
  4745. rc = UnAsmDataObj(ppbOp);
  4746. }
  4747. if (rc != UNASMERR_NONE)
  4748. {
  4749. break;
  4750. }
  4751. else if (*ppbOp < pbEnd)
  4752. {
  4753. PRINTF(",");
  4754. }
  4755. }
  4756. if (rc == UNASMERR_NONE)
  4757. {
  4758. giLevel--;
  4759. Indent(*ppbOp, giLevel);
  4760. PRINTF("}");
  4761. }
  4762. return rc;
  4763. } //UnAsmPkgList
  4764. /***LP UnAsmFieldList - Unassemble field list
  4765. *
  4766. * ENTRY
  4767. * ppbOp -> opcode pointer
  4768. * pbEnd -> end of list
  4769. *
  4770. * EXIT-SUCCESS
  4771. * returns UNASMERR_NONE
  4772. * EXIT-FAILURE
  4773. * returns negative error code
  4774. */
  4775. LONG LOCAL UnAsmFieldList(PUCHAR *ppbOp, PUCHAR pbEnd)
  4776. {
  4777. LONG rc = UNASMERR_NONE;
  4778. ULONG dwBitPos = 0;
  4779. Indent(*ppbOp, giLevel);
  4780. PRINTF("{");
  4781. giLevel++;
  4782. while (*ppbOp < pbEnd)
  4783. {
  4784. Indent(*ppbOp, giLevel);
  4785. if ((rc = UnAsmField(ppbOp, &dwBitPos)) == UNASMERR_NONE)
  4786. {
  4787. if (*ppbOp < pbEnd)
  4788. {
  4789. PRINTF(",");
  4790. }
  4791. }
  4792. else
  4793. {
  4794. break;
  4795. }
  4796. }
  4797. if (rc == UNASMERR_NONE)
  4798. {
  4799. giLevel--;
  4800. Indent(*ppbOp, giLevel);
  4801. PRINTF("}");
  4802. }
  4803. return rc;
  4804. } //UnAsmFieldList
  4805. /***LP UnAsmField - Unassemble field
  4806. *
  4807. * ENTRY
  4808. * ppbOp -> opcode pointer
  4809. * pdwBitPos -> to hold cumulative bit position
  4810. *
  4811. * EXIT-SUCCESS
  4812. * returns UNASMERR_NONE
  4813. * EXIT-FAILURE
  4814. * returns negative error code
  4815. */
  4816. LONG LOCAL UnAsmField(PUCHAR *ppbOp, PULONG pdwBitPos)
  4817. {
  4818. LONG rc = UNASMERR_NONE;
  4819. if (**ppbOp == 0x01)
  4820. {
  4821. PASLTERM pterm;
  4822. (*ppbOp)++;
  4823. pterm = FindKeywordTerm('A', **ppbOp);
  4824. if(pterm)
  4825. {
  4826. PRINTF("AccessAs(%s, 0x%x)", pterm->pszID, *(*ppbOp + 1));
  4827. }
  4828. *ppbOp += 2;
  4829. }
  4830. else
  4831. {
  4832. char szNameSeg[sizeof(NAMESEG) + 1];
  4833. ULONG dwcbBits;
  4834. if (**ppbOp == 0)
  4835. {
  4836. szNameSeg[0] = '\0';
  4837. (*ppbOp)++;
  4838. }
  4839. else
  4840. {
  4841. STRCPYN(szNameSeg, (PSZ)*ppbOp, sizeof(NAMESEG));
  4842. szNameSeg[4] = '\0';
  4843. *ppbOp += sizeof(NAMESEG);
  4844. }
  4845. dwcbBits = ParsePackageLen(ppbOp, NULL);
  4846. if (szNameSeg[0] == '\0')
  4847. {
  4848. if ((dwcbBits > 32) && (((*pdwBitPos + dwcbBits) % 8) == 0))
  4849. {
  4850. PRINTF("Offset(0x%x)", (*pdwBitPos + dwcbBits)/8);
  4851. }
  4852. else
  4853. {
  4854. PRINTF(", %d", dwcbBits);
  4855. }
  4856. }
  4857. else
  4858. {
  4859. PRINTF("%s, %d", szNameSeg, dwcbBits);
  4860. }
  4861. *pdwBitPos += dwcbBits;
  4862. }
  4863. return rc;
  4864. } //UnAsmField
  4865. /***LP FindOpTerm - Find opcode in TermTable
  4866. *
  4867. * ENTRY
  4868. * dwOpcode - opcode
  4869. *
  4870. * EXIT-SUCCESS
  4871. * returns TermTable entry pointer
  4872. * EXIT-FAILURE
  4873. * returns NULL
  4874. */
  4875. PASLTERM LOCAL FindOpTerm(ULONG dwOpcode)
  4876. {
  4877. PASLTERM pterm = NULL;
  4878. int i;
  4879. for (i = 0; TermTable[i].pszID != NULL; ++i)
  4880. {
  4881. if ((TermTable[i].dwOpcode == dwOpcode) &&
  4882. (TermTable[i].dwfTermClass &
  4883. (UTC_CONST_NAME | UTC_SHORT_NAME | UTC_NAMESPACE_MODIFIER |
  4884. UTC_DATA_OBJECT | UTC_NAMED_OBJECT | UTC_OPCODE_TYPE1 |
  4885. UTC_OPCODE_TYPE2)))
  4886. {
  4887. break;
  4888. }
  4889. }
  4890. if (TermTable[i].pszID != NULL)
  4891. {
  4892. pterm = &TermTable[i];
  4893. }
  4894. return pterm;
  4895. } //FindOpTerm
  4896. /***LP ParsePackageLen - parse package length
  4897. *
  4898. * ENTRY
  4899. * ppbOp -> instruction pointer
  4900. * ppbOpNext -> to hold pointer to next instruction (can be NULL)
  4901. *
  4902. * EXIT
  4903. * returns package length
  4904. */
  4905. ULONG LOCAL ParsePackageLen(PUCHAR *ppbOp, PUCHAR *ppbOpNext)
  4906. {
  4907. ULONG dwLen=0;
  4908. UCHAR bFollowCnt, i;
  4909. if (ppbOpNext != NULL)
  4910. *ppbOpNext = *ppbOp;
  4911. dwLen = (ULONG)(**ppbOp);
  4912. (*ppbOp)++;
  4913. bFollowCnt = (UCHAR)((dwLen & 0xc0) >> 6);
  4914. if (bFollowCnt != 0)
  4915. {
  4916. dwLen &= 0x0000000f;
  4917. for (i = 0; i < bFollowCnt; ++i)
  4918. {
  4919. dwLen |= (ULONG)(**ppbOp) << (i*8 + 4);
  4920. (*ppbOp)++;
  4921. }
  4922. }
  4923. if (ppbOpNext != NULL)
  4924. *ppbOpNext += dwLen;
  4925. return dwLen;
  4926. } //ParsePackageLen
  4927. /***LP FindKeywordTerm - Find keyword in TermTable
  4928. *
  4929. * ENTRY
  4930. * cKWGroup - keyword group
  4931. * bData - data to match keyword
  4932. *
  4933. * EXIT-SUCCESS
  4934. * returns TermTable entry pointer
  4935. * EXIT-FAILURE
  4936. * returns NULL
  4937. */
  4938. PASLTERM LOCAL FindKeywordTerm(char cKWGroup, UCHAR bData)
  4939. {
  4940. PASLTERM pterm = NULL;
  4941. int i;
  4942. for (i = 0; TermTable[i].pszID != NULL; ++i)
  4943. {
  4944. if ((TermTable[i].dwfTermClass == UTC_KEYWORD) &&
  4945. (TermTable[i].pszArgActions[0] == cKWGroup) &&
  4946. ((bData & (UCHAR)(TermTable[i].dwTermData >> 8)) ==
  4947. (UCHAR)(TermTable[i].dwTermData & 0xff)))
  4948. {
  4949. break;
  4950. }
  4951. }
  4952. if (TermTable[i].pszID != NULL)
  4953. {
  4954. pterm = &TermTable[i];
  4955. }
  4956. return pterm;
  4957. } //FindKeywordTerm
  4958. /***EP StrCat - concatenate strings
  4959. *
  4960. * ENTRY
  4961. * pszDst -> destination string
  4962. * pszSrc -> source string
  4963. * n - number of bytes to concatenate
  4964. *
  4965. * EXIT
  4966. * returns pszDst
  4967. */
  4968. PSZ LOCAL StrCat(PSZ pszDst, PSZ pszSrc, ULONG n)
  4969. {
  4970. ULONG dwSrcLen, dwDstLen;
  4971. ASSERT(pszDst != NULL);
  4972. ASSERT(pszSrc != NULL);
  4973. dwSrcLen = StrLen(pszSrc, n);
  4974. if ((n == (ULONG)(-1)) || (n > dwSrcLen))
  4975. n = dwSrcLen;
  4976. dwDstLen = StrLen(pszDst, (ULONG)(-1));
  4977. MEMCPY(&pszDst[dwDstLen], pszSrc, n);
  4978. pszDst[dwDstLen + n] = '\0';
  4979. return pszDst;
  4980. } //StrCat
  4981. /***EP StrLen - determine string length
  4982. *
  4983. * ENTRY
  4984. * psz -> string
  4985. * n - limiting length
  4986. *
  4987. * EXIT
  4988. * returns string length
  4989. */
  4990. ULONG LOCAL StrLen(PSZ psz, ULONG n)
  4991. {
  4992. ULONG dwLen;
  4993. ASSERT(psz != NULL);
  4994. if (n != (ULONG)-1)
  4995. n++;
  4996. for (dwLen = 0; (dwLen <= n) && (*psz != '\0'); psz++)
  4997. dwLen++;
  4998. return dwLen;
  4999. } //StrLen
  5000. /***EP StrCmp - compare strings
  5001. *
  5002. * ENTRY
  5003. * psz1 -> string 1
  5004. * psz2 -> string 2
  5005. * n - number of bytes to compare
  5006. * fMatchCase - TRUE if case sensitive
  5007. *
  5008. * EXIT
  5009. * returns 0 if string 1 == string 2
  5010. * <0 if string 1 < string 2
  5011. * >0 if string 1 > string 2
  5012. */
  5013. LONG LOCAL StrCmp(PSZ psz1, PSZ psz2, ULONG n, BOOLEAN fMatchCase)
  5014. {
  5015. LONG rc;
  5016. ULONG dwLen1, dwLen2;
  5017. ULONG i;
  5018. ASSERT(psz1 != NULL);
  5019. ASSERT(psz2 != NULL);
  5020. dwLen1 = StrLen(psz1, n);
  5021. dwLen2 = StrLen(psz2, n);
  5022. if (n == (ULONG)(-1))
  5023. n = (dwLen1 > dwLen2)? dwLen1: dwLen2;
  5024. if (fMatchCase)
  5025. {
  5026. for (i = 0, rc = 0;
  5027. (rc == 0) && (i < n) && (i < dwLen1) && (i < dwLen2);
  5028. ++i)
  5029. {
  5030. rc = (LONG)(psz1[i] - psz2[i]);
  5031. }
  5032. }
  5033. else
  5034. {
  5035. for (i = 0, rc = 0;
  5036. (rc == 0) && (i < n) && (i < dwLen1) && (i < dwLen2);
  5037. ++i)
  5038. {
  5039. rc = (LONG)(TOUPPER(psz1[i]) - TOUPPER(psz2[i]));
  5040. }
  5041. }
  5042. if ((rc == 0) && (i < n))
  5043. {
  5044. if (i < dwLen1)
  5045. rc = (LONG)psz1[i];
  5046. else if (i < dwLen2)
  5047. rc = (LONG)(-psz2[i]);
  5048. }
  5049. return rc;
  5050. } //StrCmp
  5051. /***EP StrCpy - copy string
  5052. *
  5053. * ENTRY
  5054. * pszDst -> destination string
  5055. * pszSrc -> source string
  5056. * n - number of bytes to copy
  5057. *
  5058. * EXIT
  5059. * returns pszDst
  5060. */
  5061. PSZ LOCAL StrCpy(PSZ pszDst, PSZ pszSrc, ULONG n)
  5062. {
  5063. ULONG dwSrcLen;
  5064. ASSERT(pszDst != NULL);
  5065. ASSERT(pszSrc != NULL);
  5066. dwSrcLen = StrLen(pszSrc, n);
  5067. if ((n == (ULONG)(-1)) || (n > dwSrcLen))
  5068. n = dwSrcLen;
  5069. MEMCPY(pszDst, pszSrc, n);
  5070. pszDst[n] = '\0';
  5071. return pszDst;
  5072. } //StrCpy
  5073. /***EP AMLIUtilStringToUlong64 - convert string to ULONG64
  5074. *
  5075. * ENTRY
  5076. * String -> String to convert.
  5077. * End -> Last char in string
  5078. * Base -> Base to use.
  5079. *
  5080. * EXIT
  5081. * returns ULONG64. In failure case End points to begining of string.
  5082. */
  5083. ULONG64
  5084. AMLIUtilStringToUlong64 (
  5085. PSZ String,
  5086. PSZ *End,
  5087. ULONG Base
  5088. )
  5089. {
  5090. UCHAR LowDword[9], HighDword[9];
  5091. ZeroMemory (HighDword, sizeof (HighDword));
  5092. ZeroMemory (LowDword, sizeof (LowDword));
  5093. if (strlen (String) > 8) {
  5094. memcpy (LowDword, (void *) &String[strlen (String) - 8], 8);
  5095. memcpy (HighDword, (void *) &String[0], strlen (String) - 8);
  5096. } else {
  5097. return strtoul (String, End, Base);
  5098. }
  5099. return ((ULONG64) strtoul (HighDword, 0, Base) << 32) + strtoul (LowDword, End, Base);
  5100. }
  5101. BOOL
  5102. GetPULONG64 (
  5103. IN PCHAR String,
  5104. IN PULONG64 Address
  5105. )
  5106. {
  5107. ULONG64 Location;
  5108. Location = GetExpression( String );
  5109. if (!Location) {
  5110. dprintf("Sorry: Unable to get %s.\n",String);
  5111. return FALSE;
  5112. }
  5113. return ReadPointer(Location, Address);
  5114. }
  5115. ULONG
  5116. AMLIGetFieldOffset(
  5117. IN PCHAR StructName,
  5118. IN PCHAR MemberName
  5119. )
  5120. {
  5121. ULONG Offset = 0;
  5122. GetFieldOffset(StructName, MemberName, &Offset);
  5123. return Offset;
  5124. }