exdump.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  1. /******************************************************************************
  2. *
  3. * Module Name: exdump - Interpreter debug output routines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/acinterp.h>
  44. #include <acpi/amlcode.h>
  45. #include <acpi/acnamesp.h>
  46. #include <acpi/acparser.h>
  47. #define _COMPONENT ACPI_EXECUTER
  48. ACPI_MODULE_NAME("exdump")
  49. /*
  50. * The following routines are used for debug output only
  51. */
  52. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  53. /* Local prototypes */
  54. static void acpi_ex_out_string(char *title, char *value);
  55. static void acpi_ex_out_pointer(char *title, void *value);
  56. static void acpi_ex_out_address(char *title, acpi_physical_address value);
  57. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
  58. static void
  59. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  60. u32 level, u32 index);
  61. /*******************************************************************************
  62. *
  63. * Object Descriptor info tables
  64. *
  65. * Note: The first table entry must be an INIT opcode and must contain
  66. * the table length (number of table entries)
  67. *
  68. ******************************************************************************/
  69. static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
  70. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
  71. {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
  72. };
  73. static struct acpi_exdump_info acpi_ex_dump_string[4] = {
  74. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
  75. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
  76. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
  77. {ACPI_EXD_STRING, 0, NULL}
  78. };
  79. static struct acpi_exdump_info acpi_ex_dump_buffer[4] = {
  80. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
  81. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
  82. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
  83. {ACPI_EXD_BUFFER, 0, NULL}
  84. };
  85. static struct acpi_exdump_info acpi_ex_dump_package[5] = {
  86. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
  87. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
  88. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
  89. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
  90. {ACPI_EXD_PACKAGE, 0, NULL}
  91. };
  92. static struct acpi_exdump_info acpi_ex_dump_device[4] = {
  93. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
  94. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
  95. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify),
  96. "System Notify"},
  97. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify),
  98. "Device Notify"}
  99. };
  100. static struct acpi_exdump_info acpi_ex_dump_event[2] = {
  101. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
  102. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
  103. };
  104. static struct acpi_exdump_info acpi_ex_dump_method[8] = {
  105. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
  106. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"},
  107. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
  108. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
  109. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
  110. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
  111. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
  112. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
  113. };
  114. static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
  115. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
  116. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
  117. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
  118. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
  119. "Acquire Depth"},
  120. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"}
  121. };
  122. static struct acpi_exdump_info acpi_ex_dump_region[7] = {
  123. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
  124. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
  125. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
  126. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
  127. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
  128. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"},
  129. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
  130. };
  131. static struct acpi_exdump_info acpi_ex_dump_power[5] = {
  132. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
  133. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
  134. "System Level"},
  135. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
  136. "Resource Order"},
  137. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify),
  138. "System Notify"},
  139. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify),
  140. "Device Notify"}
  141. };
  142. static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
  143. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
  144. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
  145. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.length), "Length"},
  146. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
  147. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify),
  148. "System Notify"},
  149. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify),
  150. "Device Notify"},
  151. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
  152. };
  153. static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
  154. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
  155. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify),
  156. "System Notify"},
  157. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify),
  158. "Device Notify"},
  159. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
  160. };
  161. static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
  162. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
  163. {ACPI_EXD_FIELD, 0, NULL},
  164. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
  165. "Buffer Object"}
  166. };
  167. static struct acpi_exdump_info acpi_ex_dump_region_field[3] = {
  168. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
  169. {ACPI_EXD_FIELD, 0, NULL},
  170. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"}
  171. };
  172. static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
  173. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  174. {ACPI_EXD_FIELD, 0, NULL},
  175. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
  176. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
  177. "Region Object"},
  178. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
  179. };
  180. static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
  181. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  182. {ACPI_EXD_FIELD, 0, NULL},
  183. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
  184. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
  185. "Index Object"},
  186. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
  187. };
  188. static struct acpi_exdump_info acpi_ex_dump_reference[7] = {
  189. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
  190. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
  191. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"},
  192. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
  193. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"},
  194. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
  195. {ACPI_EXD_REFERENCE, 0, NULL}
  196. };
  197. static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
  198. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
  199. NULL},
  200. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
  201. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"},
  202. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list),
  203. "Region List"},
  204. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"},
  205. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
  206. };
  207. static struct acpi_exdump_info acpi_ex_dump_notify[3] = {
  208. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
  209. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"},
  210. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"}
  211. };
  212. /* Miscellaneous tables */
  213. static struct acpi_exdump_info acpi_ex_dump_common[4] = {
  214. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
  215. {ACPI_EXD_TYPE, 0, NULL},
  216. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
  217. "Reference Count"},
  218. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"}
  219. };
  220. static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
  221. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL},
  222. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags),
  223. "Field Flags"},
  224. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width),
  225. "Access Byte Width"},
  226. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length),
  227. "Bit Length"},
  228. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset),
  229. "Field Bit Offset"},
  230. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
  231. "Base Byte Offset"},
  232. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
  233. };
  234. static struct acpi_exdump_info acpi_ex_dump_node[6] = {
  235. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
  236. {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
  237. {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
  238. {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count),
  239. "Reference Count"},
  240. {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"},
  241. {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"}
  242. };
  243. /* Dispatch table, indexed by object type */
  244. static struct acpi_exdump_info *acpi_ex_dump_info[] = {
  245. NULL,
  246. acpi_ex_dump_integer,
  247. acpi_ex_dump_string,
  248. acpi_ex_dump_buffer,
  249. acpi_ex_dump_package,
  250. NULL,
  251. acpi_ex_dump_device,
  252. acpi_ex_dump_event,
  253. acpi_ex_dump_method,
  254. acpi_ex_dump_mutex,
  255. acpi_ex_dump_region,
  256. acpi_ex_dump_power,
  257. acpi_ex_dump_processor,
  258. acpi_ex_dump_thermal,
  259. acpi_ex_dump_buffer_field,
  260. NULL,
  261. NULL,
  262. acpi_ex_dump_region_field,
  263. acpi_ex_dump_bank_field,
  264. acpi_ex_dump_index_field,
  265. acpi_ex_dump_reference,
  266. NULL,
  267. NULL,
  268. acpi_ex_dump_notify,
  269. acpi_ex_dump_address_handler,
  270. NULL,
  271. NULL,
  272. NULL
  273. };
  274. /*******************************************************************************
  275. *
  276. * FUNCTION: acpi_ex_dump_object
  277. *
  278. * PARAMETERS: obj_desc - Descriptor to dump
  279. * Info - Info table corresponding to this object
  280. * type
  281. *
  282. * RETURN: None
  283. *
  284. * DESCRIPTION: Walk the info table for this object
  285. *
  286. ******************************************************************************/
  287. static void
  288. acpi_ex_dump_object(union acpi_operand_object *obj_desc,
  289. struct acpi_exdump_info *info)
  290. {
  291. u8 *target;
  292. char *name;
  293. u8 count;
  294. if (!info) {
  295. acpi_os_printf
  296. ("ex_dump_object: Display not implemented for object type %s\n",
  297. acpi_ut_get_object_type_name(obj_desc));
  298. return;
  299. }
  300. /* First table entry must contain the table length (# of table entries) */
  301. count = info->offset;
  302. while (count) {
  303. target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
  304. name = info->name;
  305. switch (info->opcode) {
  306. case ACPI_EXD_INIT:
  307. break;
  308. case ACPI_EXD_TYPE:
  309. acpi_ex_out_string("Type",
  310. acpi_ut_get_object_type_name
  311. (obj_desc));
  312. break;
  313. case ACPI_EXD_UINT8:
  314. acpi_os_printf("%20s : %2.2X\n", name, *target);
  315. break;
  316. case ACPI_EXD_UINT16:
  317. acpi_os_printf("%20s : %4.4X\n", name,
  318. ACPI_GET16(target));
  319. break;
  320. case ACPI_EXD_UINT32:
  321. acpi_os_printf("%20s : %8.8X\n", name,
  322. ACPI_GET32(target));
  323. break;
  324. case ACPI_EXD_UINT64:
  325. acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
  326. ACPI_FORMAT_UINT64(ACPI_GET64(target)));
  327. break;
  328. case ACPI_EXD_POINTER:
  329. acpi_ex_out_pointer(name,
  330. *ACPI_CAST_PTR(void *, target));
  331. break;
  332. case ACPI_EXD_ADDRESS:
  333. acpi_ex_out_address(name,
  334. *ACPI_CAST_PTR
  335. (acpi_physical_address, target));
  336. break;
  337. case ACPI_EXD_STRING:
  338. acpi_ut_print_string(obj_desc->string.pointer,
  339. ACPI_UINT8_MAX);
  340. acpi_os_printf("\n");
  341. break;
  342. case ACPI_EXD_BUFFER:
  343. ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
  344. obj_desc->buffer.length);
  345. break;
  346. case ACPI_EXD_PACKAGE:
  347. /* Dump the package contents */
  348. acpi_os_printf("\nPackage Contents:\n");
  349. acpi_ex_dump_package_obj(obj_desc, 0, 0);
  350. break;
  351. case ACPI_EXD_FIELD:
  352. acpi_ex_dump_object(obj_desc,
  353. acpi_ex_dump_field_common);
  354. break;
  355. case ACPI_EXD_REFERENCE:
  356. acpi_ex_out_string("Opcode",
  357. (acpi_ps_get_opcode_info
  358. (obj_desc->reference.opcode))->
  359. name);
  360. acpi_ex_dump_reference_obj(obj_desc);
  361. break;
  362. default:
  363. acpi_os_printf("**** Invalid table opcode [%X] ****\n",
  364. info->opcode);
  365. return;
  366. }
  367. info++;
  368. count--;
  369. }
  370. }
  371. /*******************************************************************************
  372. *
  373. * FUNCTION: acpi_ex_dump_operand
  374. *
  375. * PARAMETERS: *obj_desc - Pointer to entry to be dumped
  376. * Depth - Current nesting depth
  377. *
  378. * RETURN: None
  379. *
  380. * DESCRIPTION: Dump an operand object
  381. *
  382. ******************************************************************************/
  383. void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
  384. {
  385. u32 length;
  386. u32 index;
  387. ACPI_FUNCTION_NAME("ex_dump_operand")
  388. if (!
  389. ((ACPI_LV_EXEC & acpi_dbg_level)
  390. && (_COMPONENT & acpi_dbg_layer))) {
  391. return;
  392. }
  393. if (!obj_desc) {
  394. /* This could be a null element of a package */
  395. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
  396. return;
  397. }
  398. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  399. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
  400. obj_desc));
  401. ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
  402. return;
  403. }
  404. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  405. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  406. "%p is not a node or operand object: [%s]\n",
  407. obj_desc,
  408. acpi_ut_get_descriptor_name(obj_desc)));
  409. ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object));
  410. return;
  411. }
  412. /* obj_desc is a valid object */
  413. if (depth > 0) {
  414. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ",
  415. depth, " ", depth, obj_desc));
  416. } else {
  417. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc));
  418. }
  419. /* Decode object type */
  420. switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
  421. case ACPI_TYPE_LOCAL_REFERENCE:
  422. switch (obj_desc->reference.opcode) {
  423. case AML_DEBUG_OP:
  424. acpi_os_printf("Reference: Debug\n");
  425. break;
  426. case AML_NAME_OP:
  427. ACPI_DUMP_PATHNAME(obj_desc->reference.object,
  428. "Reference: Name: ", ACPI_LV_INFO,
  429. _COMPONENT);
  430. ACPI_DUMP_ENTRY(obj_desc->reference.object,
  431. ACPI_LV_INFO);
  432. break;
  433. case AML_INDEX_OP:
  434. acpi_os_printf("Reference: Index %p\n",
  435. obj_desc->reference.object);
  436. break;
  437. case AML_REF_OF_OP:
  438. acpi_os_printf("Reference: (ref_of) %p\n",
  439. obj_desc->reference.object);
  440. break;
  441. case AML_ARG_OP:
  442. acpi_os_printf("Reference: Arg%d",
  443. obj_desc->reference.offset);
  444. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  445. /* Value is an Integer */
  446. acpi_os_printf(" value is [%8.8X%8.8x]",
  447. ACPI_FORMAT_UINT64(obj_desc->
  448. integer.
  449. value));
  450. }
  451. acpi_os_printf("\n");
  452. break;
  453. case AML_LOCAL_OP:
  454. acpi_os_printf("Reference: Local%d",
  455. obj_desc->reference.offset);
  456. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  457. /* Value is an Integer */
  458. acpi_os_printf(" value is [%8.8X%8.8x]",
  459. ACPI_FORMAT_UINT64(obj_desc->
  460. integer.
  461. value));
  462. }
  463. acpi_os_printf("\n");
  464. break;
  465. case AML_INT_NAMEPATH_OP:
  466. acpi_os_printf("Reference.Node->Name %X\n",
  467. obj_desc->reference.node->name.integer);
  468. break;
  469. default:
  470. /* Unknown opcode */
  471. acpi_os_printf("Unknown Reference opcode=%X\n",
  472. obj_desc->reference.opcode);
  473. break;
  474. }
  475. break;
  476. case ACPI_TYPE_BUFFER:
  477. acpi_os_printf("Buffer len %X @ %p\n",
  478. obj_desc->buffer.length,
  479. obj_desc->buffer.pointer);
  480. length = obj_desc->buffer.length;
  481. if (length > 64) {
  482. length = 64;
  483. }
  484. /* Debug only -- dump the buffer contents */
  485. if (obj_desc->buffer.pointer) {
  486. acpi_os_printf("Buffer Contents: ");
  487. for (index = 0; index < length; index++) {
  488. acpi_os_printf(" %02x",
  489. obj_desc->buffer.pointer[index]);
  490. }
  491. acpi_os_printf("\n");
  492. }
  493. break;
  494. case ACPI_TYPE_INTEGER:
  495. acpi_os_printf("Integer %8.8X%8.8X\n",
  496. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  497. break;
  498. case ACPI_TYPE_PACKAGE:
  499. acpi_os_printf("Package [Len %X] element_array %p\n",
  500. obj_desc->package.count,
  501. obj_desc->package.elements);
  502. /*
  503. * If elements exist, package element pointer is valid,
  504. * and debug_level exceeds 1, dump package's elements.
  505. */
  506. if (obj_desc->package.count &&
  507. obj_desc->package.elements && acpi_dbg_level > 1) {
  508. for (index = 0; index < obj_desc->package.count;
  509. index++) {
  510. acpi_ex_dump_operand(obj_desc->package.
  511. elements[index],
  512. depth + 1);
  513. }
  514. }
  515. break;
  516. case ACPI_TYPE_REGION:
  517. acpi_os_printf("Region %s (%X)",
  518. acpi_ut_get_region_name(obj_desc->region.
  519. space_id),
  520. obj_desc->region.space_id);
  521. /*
  522. * If the address and length have not been evaluated,
  523. * don't print them.
  524. */
  525. if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
  526. acpi_os_printf("\n");
  527. } else {
  528. acpi_os_printf(" base %8.8X%8.8X Length %X\n",
  529. ACPI_FORMAT_UINT64(obj_desc->region.
  530. address),
  531. obj_desc->region.length);
  532. }
  533. break;
  534. case ACPI_TYPE_STRING:
  535. acpi_os_printf("String length %X @ %p ",
  536. obj_desc->string.length,
  537. obj_desc->string.pointer);
  538. acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
  539. acpi_os_printf("\n");
  540. break;
  541. case ACPI_TYPE_LOCAL_BANK_FIELD:
  542. acpi_os_printf("bank_field\n");
  543. break;
  544. case ACPI_TYPE_LOCAL_REGION_FIELD:
  545. acpi_os_printf
  546. ("region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
  547. obj_desc->field.bit_length,
  548. obj_desc->field.access_byte_width,
  549. obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
  550. obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
  551. obj_desc->field.base_byte_offset,
  552. obj_desc->field.start_field_bit_offset);
  553. acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
  554. break;
  555. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  556. acpi_os_printf("index_field\n");
  557. break;
  558. case ACPI_TYPE_BUFFER_FIELD:
  559. acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n",
  560. obj_desc->buffer_field.bit_length,
  561. obj_desc->buffer_field.base_byte_offset,
  562. obj_desc->buffer_field.start_field_bit_offset);
  563. if (!obj_desc->buffer_field.buffer_obj) {
  564. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
  565. } else
  566. if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
  567. != ACPI_TYPE_BUFFER) {
  568. acpi_os_printf("*not a Buffer*\n");
  569. } else {
  570. acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
  571. depth + 1);
  572. }
  573. break;
  574. case ACPI_TYPE_EVENT:
  575. acpi_os_printf("Event\n");
  576. break;
  577. case ACPI_TYPE_METHOD:
  578. acpi_os_printf("Method(%X) @ %p:%X\n",
  579. obj_desc->method.param_count,
  580. obj_desc->method.aml_start,
  581. obj_desc->method.aml_length);
  582. break;
  583. case ACPI_TYPE_MUTEX:
  584. acpi_os_printf("Mutex\n");
  585. break;
  586. case ACPI_TYPE_DEVICE:
  587. acpi_os_printf("Device\n");
  588. break;
  589. case ACPI_TYPE_POWER:
  590. acpi_os_printf("Power\n");
  591. break;
  592. case ACPI_TYPE_PROCESSOR:
  593. acpi_os_printf("Processor\n");
  594. break;
  595. case ACPI_TYPE_THERMAL:
  596. acpi_os_printf("Thermal\n");
  597. break;
  598. default:
  599. /* Unknown Type */
  600. acpi_os_printf("Unknown Type %X\n",
  601. ACPI_GET_OBJECT_TYPE(obj_desc));
  602. break;
  603. }
  604. return;
  605. }
  606. /*******************************************************************************
  607. *
  608. * FUNCTION: acpi_ex_dump_operands
  609. *
  610. * PARAMETERS: Operands - Operand list
  611. * interpreter_mode - Load or Exec
  612. * Ident - Identification
  613. * num_levels - # of stack entries to dump above line
  614. * Note - Output notation
  615. * module_name - Caller's module name
  616. * line_number - Caller's invocation line number
  617. *
  618. * DESCRIPTION: Dump the object stack
  619. *
  620. ******************************************************************************/
  621. void
  622. acpi_ex_dump_operands(union acpi_operand_object **operands,
  623. acpi_interpreter_mode interpreter_mode,
  624. char *ident,
  625. u32 num_levels,
  626. char *note, char *module_name, u32 line_number)
  627. {
  628. acpi_native_uint i;
  629. ACPI_FUNCTION_NAME("ex_dump_operands");
  630. if (!ident) {
  631. ident = "?";
  632. }
  633. if (!note) {
  634. note = "?";
  635. }
  636. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  637. "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
  638. ident, num_levels));
  639. if (num_levels == 0) {
  640. num_levels = 1;
  641. }
  642. /* Dump the operand stack starting at the top */
  643. for (i = 0; num_levels > 0; i--, num_levels--) {
  644. acpi_ex_dump_operand(operands[i], 0);
  645. }
  646. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  647. "************* Operand Stack dump from %s(%d), %s\n",
  648. module_name, line_number, note));
  649. return;
  650. }
  651. /*******************************************************************************
  652. *
  653. * FUNCTION: acpi_ex_out* functions
  654. *
  655. * PARAMETERS: Title - Descriptive text
  656. * Value - Value to be displayed
  657. *
  658. * DESCRIPTION: Object dump output formatting functions. These functions
  659. * reduce the number of format strings required and keeps them
  660. * all in one place for easy modification.
  661. *
  662. ******************************************************************************/
  663. static void acpi_ex_out_string(char *title, char *value)
  664. {
  665. acpi_os_printf("%20s : %s\n", title, value);
  666. }
  667. static void acpi_ex_out_pointer(char *title, void *value)
  668. {
  669. acpi_os_printf("%20s : %p\n", title, value);
  670. }
  671. static void acpi_ex_out_address(char *title, acpi_physical_address value)
  672. {
  673. #if ACPI_MACHINE_WIDTH == 16
  674. acpi_os_printf("%20s : %p\n", title, value);
  675. #else
  676. acpi_os_printf("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
  677. #endif
  678. }
  679. /*******************************************************************************
  680. *
  681. * FUNCTION: acpi_ex_dump_namespace_node
  682. *
  683. * PARAMETERS: Node - Descriptor to dump
  684. * Flags - Force display if TRUE
  685. *
  686. * DESCRIPTION: Dumps the members of the given.Node
  687. *
  688. ******************************************************************************/
  689. void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
  690. {
  691. ACPI_FUNCTION_ENTRY();
  692. if (!flags) {
  693. if (!
  694. ((ACPI_LV_OBJECTS & acpi_dbg_level)
  695. && (_COMPONENT & acpi_dbg_layer))) {
  696. return;
  697. }
  698. }
  699. acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
  700. acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
  701. acpi_ex_out_pointer("Attached Object",
  702. acpi_ns_get_attached_object(node));
  703. acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
  704. acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
  705. acpi_ex_dump_node);
  706. }
  707. /*******************************************************************************
  708. *
  709. * FUNCTION: acpi_ex_dump_reference_obj
  710. *
  711. * PARAMETERS: Object - Descriptor to dump
  712. *
  713. * DESCRIPTION: Dumps a reference object
  714. *
  715. ******************************************************************************/
  716. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
  717. {
  718. struct acpi_buffer ret_buf;
  719. acpi_status status;
  720. ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  721. if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
  722. acpi_os_printf("Named Object %p ", obj_desc->reference.node);
  723. status =
  724. acpi_ns_handle_to_pathname(obj_desc->reference.node,
  725. &ret_buf);
  726. if (ACPI_FAILURE(status)) {
  727. acpi_os_printf("Could not convert name to pathname\n");
  728. } else {
  729. acpi_os_printf("%s\n", (char *)ret_buf.pointer);
  730. ACPI_MEM_FREE(ret_buf.pointer);
  731. }
  732. } else if (obj_desc->reference.object) {
  733. acpi_os_printf("\nReferenced Object: %p\n",
  734. obj_desc->reference.object);
  735. }
  736. }
  737. /*******************************************************************************
  738. *
  739. * FUNCTION: acpi_ex_dump_package_obj
  740. *
  741. * PARAMETERS: obj_desc - Descriptor to dump
  742. * Level - Indentation Level
  743. * Index - Package index for this object
  744. *
  745. * DESCRIPTION: Dumps the elements of the package
  746. *
  747. ******************************************************************************/
  748. static void
  749. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  750. u32 level, u32 index)
  751. {
  752. u32 i;
  753. /* Indentation and index output */
  754. if (level > 0) {
  755. for (i = 0; i < level; i++) {
  756. acpi_os_printf(" ");
  757. }
  758. acpi_os_printf("[%.2d] ", index);
  759. }
  760. acpi_os_printf("%p ", obj_desc);
  761. /* Null package elements are allowed */
  762. if (!obj_desc) {
  763. acpi_os_printf("[Null Object]\n");
  764. return;
  765. }
  766. /* Packages may only contain a few object types */
  767. switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
  768. case ACPI_TYPE_INTEGER:
  769. acpi_os_printf("[Integer] = %8.8X%8.8X\n",
  770. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  771. break;
  772. case ACPI_TYPE_STRING:
  773. acpi_os_printf("[String] Value: ");
  774. for (i = 0; i < obj_desc->string.length; i++) {
  775. acpi_os_printf("%c", obj_desc->string.pointer[i]);
  776. }
  777. acpi_os_printf("\n");
  778. break;
  779. case ACPI_TYPE_BUFFER:
  780. acpi_os_printf("[Buffer] Length %.2X = ",
  781. obj_desc->buffer.length);
  782. if (obj_desc->buffer.length) {
  783. acpi_ut_dump_buffer(ACPI_CAST_PTR
  784. (u8, obj_desc->buffer.pointer),
  785. obj_desc->buffer.length,
  786. DB_DWORD_DISPLAY, _COMPONENT);
  787. } else {
  788. acpi_os_printf("\n");
  789. }
  790. break;
  791. case ACPI_TYPE_PACKAGE:
  792. acpi_os_printf("[Package] Contains %d Elements:\n",
  793. obj_desc->package.count);
  794. for (i = 0; i < obj_desc->package.count; i++) {
  795. acpi_ex_dump_package_obj(obj_desc->package.elements[i],
  796. level + 1, i);
  797. }
  798. break;
  799. case ACPI_TYPE_LOCAL_REFERENCE:
  800. acpi_os_printf("[Object Reference] ");
  801. acpi_ex_dump_reference_obj(obj_desc);
  802. break;
  803. default:
  804. acpi_os_printf("[Unknown Type] %X\n",
  805. ACPI_GET_OBJECT_TYPE(obj_desc));
  806. break;
  807. }
  808. }
  809. /*******************************************************************************
  810. *
  811. * FUNCTION: acpi_ex_dump_object_descriptor
  812. *
  813. * PARAMETERS: obj_desc - Descriptor to dump
  814. * Flags - Force display if TRUE
  815. *
  816. * DESCRIPTION: Dumps the members of the object descriptor given.
  817. *
  818. ******************************************************************************/
  819. void
  820. acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
  821. {
  822. ACPI_FUNCTION_TRACE("ex_dump_object_descriptor");
  823. if (!obj_desc) {
  824. return_VOID;
  825. }
  826. if (!flags) {
  827. if (!
  828. ((ACPI_LV_OBJECTS & acpi_dbg_level)
  829. && (_COMPONENT & acpi_dbg_layer))) {
  830. return_VOID;
  831. }
  832. }
  833. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  834. acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
  835. obj_desc, flags);
  836. acpi_os_printf("\nAttached Object (%p):\n",
  837. ((struct acpi_namespace_node *)obj_desc)->
  838. object);
  839. acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
  840. obj_desc)->object, flags);
  841. return_VOID;
  842. }
  843. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  844. acpi_os_printf
  845. ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
  846. obj_desc, acpi_ut_get_descriptor_name(obj_desc));
  847. return_VOID;
  848. }
  849. if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
  850. return_VOID;
  851. }
  852. /* Common Fields */
  853. acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
  854. /* Object-specific fields */
  855. acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
  856. return_VOID;
  857. }
  858. #endif