/drivers/acpi/acpica/exdump.c

http://github.com/mirrors/linux · C · 1205 lines · 833 code · 237 blank · 135 comment · 91 complexity · 6e756d1e751ffcd117d8d21a3fe68a50 MD5 · raw file

  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: exdump - Interpreter debug output routines
  5. *
  6. * Copyright (C) 2000 - 2020, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "acinterp.h"
  12. #include "amlcode.h"
  13. #include "acnamesp.h"
  14. #define _COMPONENT ACPI_EXECUTER
  15. ACPI_MODULE_NAME("exdump")
  16. /*
  17. * The following routines are used for debug output only
  18. */
  19. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  20. /* Local prototypes */
  21. static void acpi_ex_out_string(const char *title, const char *value);
  22. static void acpi_ex_out_pointer(const char *title, const void *value);
  23. static void
  24. acpi_ex_dump_object(union acpi_operand_object *obj_desc,
  25. struct acpi_exdump_info *info);
  26. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
  27. static void
  28. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  29. u32 level, u32 index);
  30. /*******************************************************************************
  31. *
  32. * Object Descriptor info tables
  33. *
  34. * Note: The first table entry must be an INIT opcode and must contain
  35. * the table length (number of table entries)
  36. *
  37. ******************************************************************************/
  38. static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
  39. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
  40. {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
  41. };
  42. static struct acpi_exdump_info acpi_ex_dump_string[4] = {
  43. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
  44. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
  45. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
  46. {ACPI_EXD_STRING, 0, NULL}
  47. };
  48. static struct acpi_exdump_info acpi_ex_dump_buffer[5] = {
  49. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
  50. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
  51. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
  52. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(buffer.node), "Parent Node"},
  53. {ACPI_EXD_BUFFER, 0, NULL}
  54. };
  55. static struct acpi_exdump_info acpi_ex_dump_package[6] = {
  56. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
  57. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(package.node), "Parent Node"},
  58. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
  59. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Element Count"},
  60. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
  61. {ACPI_EXD_PACKAGE, 0, NULL}
  62. };
  63. static struct acpi_exdump_info acpi_ex_dump_device[4] = {
  64. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
  65. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[0]),
  66. "System Notify"},
  67. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[1]),
  68. "Device Notify"},
  69. {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(device.handler), "Handler"}
  70. };
  71. static struct acpi_exdump_info acpi_ex_dump_event[2] = {
  72. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
  73. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
  74. };
  75. static struct acpi_exdump_info acpi_ex_dump_method[9] = {
  76. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
  77. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.info_flags), "Info Flags"},
  78. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count),
  79. "Parameter Count"},
  80. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
  81. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
  82. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
  83. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
  84. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
  85. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
  86. };
  87. static struct acpi_exdump_info acpi_ex_dump_mutex[6] = {
  88. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
  89. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
  90. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.original_sync_level),
  91. "Original Sync Level"},
  92. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
  93. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
  94. "Acquire Depth"},
  95. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
  96. };
  97. static struct acpi_exdump_info acpi_ex_dump_region[8] = {
  98. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
  99. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
  100. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
  101. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(region.node), "Parent Node"},
  102. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
  103. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
  104. {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(region.handler), "Handler"},
  105. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
  106. };
  107. static struct acpi_exdump_info acpi_ex_dump_power[6] = {
  108. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
  109. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
  110. "System Level"},
  111. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
  112. "Resource Order"},
  113. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[0]),
  114. "System Notify"},
  115. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[1]),
  116. "Device Notify"},
  117. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.handler), "Handler"}
  118. };
  119. static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
  120. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
  121. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
  122. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.length), "Length"},
  123. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
  124. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[0]),
  125. "System Notify"},
  126. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[1]),
  127. "Device Notify"},
  128. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
  129. };
  130. static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
  131. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
  132. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[0]),
  133. "System Notify"},
  134. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[1]),
  135. "Device Notify"},
  136. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
  137. };
  138. static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
  139. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
  140. {ACPI_EXD_FIELD, 0, NULL},
  141. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
  142. "Buffer Object"}
  143. };
  144. static struct acpi_exdump_info acpi_ex_dump_region_field[5] = {
  145. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
  146. {ACPI_EXD_FIELD, 0, NULL},
  147. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(field.access_length), "AccessLength"},
  148. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"},
  149. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.resource_buffer),
  150. "ResourceBuffer"}
  151. };
  152. static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
  153. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  154. {ACPI_EXD_FIELD, 0, NULL},
  155. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
  156. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
  157. "Region Object"},
  158. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
  159. };
  160. static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
  161. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  162. {ACPI_EXD_FIELD, 0, NULL},
  163. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
  164. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
  165. "Index Object"},
  166. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
  167. };
  168. static struct acpi_exdump_info acpi_ex_dump_reference[9] = {
  169. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
  170. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.class), "Class"},
  171. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
  172. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"},
  173. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
  174. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(reference.node), "Node"},
  175. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
  176. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.index_pointer),
  177. "Index Pointer"},
  178. {ACPI_EXD_REFERENCE, 0, NULL}
  179. };
  180. static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
  181. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
  182. NULL},
  183. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
  184. {ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(address_space.next), "Next"},
  185. {ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET(address_space.region_list),
  186. "Region List"},
  187. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(address_space.node), "Node"},
  188. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
  189. };
  190. static struct acpi_exdump_info acpi_ex_dump_notify[7] = {
  191. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
  192. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(notify.node), "Node"},
  193. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(notify.handler_type), "Handler Type"},
  194. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.handler), "Handler"},
  195. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"},
  196. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[0]),
  197. "Next System Notify"},
  198. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[1]), "Next Device Notify"}
  199. };
  200. static struct acpi_exdump_info acpi_ex_dump_extra[6] = {
  201. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_extra), NULL},
  202. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.method_REG), "_REG Method"},
  203. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(extra.scope_node), "Scope Node"},
  204. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.region_context),
  205. "Region Context"},
  206. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.aml_start), "Aml Start"},
  207. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(extra.aml_length), "Aml Length"}
  208. };
  209. static struct acpi_exdump_info acpi_ex_dump_data[3] = {
  210. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_data), NULL},
  211. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.handler), "Handler"},
  212. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.pointer), "Raw Data"}
  213. };
  214. /* Miscellaneous tables */
  215. static struct acpi_exdump_info acpi_ex_dump_common[5] = {
  216. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
  217. {ACPI_EXD_TYPE, 0, NULL},
  218. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
  219. "Reference Count"},
  220. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"},
  221. {ACPI_EXD_LIST, ACPI_EXD_OFFSET(common.next_object), "Object List"}
  222. };
  223. static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
  224. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL},
  225. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags),
  226. "Field Flags"},
  227. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width),
  228. "Access Byte Width"},
  229. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length),
  230. "Bit Length"},
  231. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset),
  232. "Field Bit Offset"},
  233. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
  234. "Base Byte Offset"},
  235. {ACPI_EXD_NODE, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
  236. };
  237. static struct acpi_exdump_info acpi_ex_dump_node[7] = {
  238. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
  239. {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(flags), "Flags"},
  240. {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
  241. {ACPI_EXD_LIST, ACPI_EXD_NSOFFSET(object), "Object List"},
  242. {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(parent), "Parent"},
  243. {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(child), "Child"},
  244. {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(peer), "Peer"}
  245. };
  246. /* Dispatch table, indexed by object type */
  247. static struct acpi_exdump_info *acpi_ex_dump_info[] = {
  248. NULL,
  249. acpi_ex_dump_integer,
  250. acpi_ex_dump_string,
  251. acpi_ex_dump_buffer,
  252. acpi_ex_dump_package,
  253. NULL,
  254. acpi_ex_dump_device,
  255. acpi_ex_dump_event,
  256. acpi_ex_dump_method,
  257. acpi_ex_dump_mutex,
  258. acpi_ex_dump_region,
  259. acpi_ex_dump_power,
  260. acpi_ex_dump_processor,
  261. acpi_ex_dump_thermal,
  262. acpi_ex_dump_buffer_field,
  263. NULL,
  264. NULL,
  265. acpi_ex_dump_region_field,
  266. acpi_ex_dump_bank_field,
  267. acpi_ex_dump_index_field,
  268. acpi_ex_dump_reference,
  269. NULL,
  270. NULL,
  271. acpi_ex_dump_notify,
  272. acpi_ex_dump_address_handler,
  273. NULL,
  274. NULL,
  275. NULL,
  276. acpi_ex_dump_extra,
  277. acpi_ex_dump_data
  278. };
  279. /*******************************************************************************
  280. *
  281. * FUNCTION: acpi_ex_dump_object
  282. *
  283. * PARAMETERS: obj_desc - Descriptor to dump
  284. * info - Info table corresponding to this object
  285. * type
  286. *
  287. * RETURN: None
  288. *
  289. * DESCRIPTION: Walk the info table for this object
  290. *
  291. ******************************************************************************/
  292. static void
  293. acpi_ex_dump_object(union acpi_operand_object *obj_desc,
  294. struct acpi_exdump_info *info)
  295. {
  296. u8 *target;
  297. const char *name;
  298. u8 count;
  299. union acpi_operand_object *start;
  300. union acpi_operand_object *data = NULL;
  301. union acpi_operand_object *next;
  302. struct acpi_namespace_node *node;
  303. if (!info) {
  304. acpi_os_printf
  305. ("ExDumpObject: Display not implemented for object type %s\n",
  306. acpi_ut_get_object_type_name(obj_desc));
  307. return;
  308. }
  309. /* First table entry must contain the table length (# of table entries) */
  310. count = info->offset;
  311. while (count) {
  312. if (!obj_desc) {
  313. return;
  314. }
  315. target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
  316. name = info->name;
  317. switch (info->opcode) {
  318. case ACPI_EXD_INIT:
  319. break;
  320. case ACPI_EXD_TYPE:
  321. acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
  322. obj_desc->common.type,
  323. acpi_ut_get_object_type_name(obj_desc));
  324. break;
  325. case ACPI_EXD_UINT8:
  326. acpi_os_printf("%20s : %2.2X\n", name, *target);
  327. break;
  328. case ACPI_EXD_UINT16:
  329. acpi_os_printf("%20s : %4.4X\n", name,
  330. ACPI_GET16(target));
  331. break;
  332. case ACPI_EXD_UINT32:
  333. acpi_os_printf("%20s : %8.8X\n", name,
  334. ACPI_GET32(target));
  335. break;
  336. case ACPI_EXD_UINT64:
  337. acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
  338. ACPI_FORMAT_UINT64(ACPI_GET64(target)));
  339. break;
  340. case ACPI_EXD_POINTER:
  341. case ACPI_EXD_ADDRESS:
  342. acpi_ex_out_pointer(name,
  343. *ACPI_CAST_PTR(void *, target));
  344. break;
  345. case ACPI_EXD_STRING:
  346. acpi_ut_print_string(obj_desc->string.pointer,
  347. ACPI_UINT8_MAX);
  348. acpi_os_printf("\n");
  349. break;
  350. case ACPI_EXD_BUFFER:
  351. ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
  352. obj_desc->buffer.length);
  353. break;
  354. case ACPI_EXD_PACKAGE:
  355. /* Dump the package contents */
  356. acpi_os_printf("\nPackage Contents:\n");
  357. acpi_ex_dump_package_obj(obj_desc, 0, 0);
  358. break;
  359. case ACPI_EXD_FIELD:
  360. acpi_ex_dump_object(obj_desc,
  361. acpi_ex_dump_field_common);
  362. break;
  363. case ACPI_EXD_REFERENCE:
  364. acpi_ex_out_string("Class Name",
  365. acpi_ut_get_reference_name
  366. (obj_desc));
  367. acpi_ex_dump_reference_obj(obj_desc);
  368. break;
  369. case ACPI_EXD_LIST:
  370. start = *ACPI_CAST_PTR(void *, target);
  371. next = start;
  372. acpi_os_printf("%20s : %p ", name, next);
  373. if (next) {
  374. acpi_os_printf("%s (Type %2.2X)",
  375. acpi_ut_get_object_type_name
  376. (next), next->common.type);
  377. while (next->common.next_object) {
  378. if ((next->common.type ==
  379. ACPI_TYPE_LOCAL_DATA) && !data) {
  380. data = next;
  381. }
  382. next = next->common.next_object;
  383. acpi_os_printf("->%p(%s %2.2X)", next,
  384. acpi_ut_get_object_type_name
  385. (next),
  386. next->common.type);
  387. if ((next == start) || (next == data)) {
  388. acpi_os_printf
  389. ("\n**** Error: Object list appears to be circular linked");
  390. break;
  391. }
  392. }
  393. } else {
  394. acpi_os_printf("- No attached objects");
  395. }
  396. acpi_os_printf("\n");
  397. break;
  398. case ACPI_EXD_HDLR_LIST:
  399. start = *ACPI_CAST_PTR(void *, target);
  400. next = start;
  401. acpi_os_printf("%20s : %p", name, next);
  402. if (next) {
  403. acpi_os_printf("(%s %2.2X)",
  404. acpi_ut_get_object_type_name
  405. (next),
  406. next->address_space.space_id);
  407. while (next->address_space.next) {
  408. if ((next->common.type ==
  409. ACPI_TYPE_LOCAL_DATA) && !data) {
  410. data = next;
  411. }
  412. next = next->address_space.next;
  413. acpi_os_printf("->%p(%s %2.2X)", next,
  414. acpi_ut_get_object_type_name
  415. (next),
  416. next->address_space.
  417. space_id);
  418. if ((next == start) || (next == data)) {
  419. acpi_os_printf
  420. ("\n**** Error: Handler list appears to be circular linked");
  421. break;
  422. }
  423. }
  424. }
  425. acpi_os_printf("\n");
  426. break;
  427. case ACPI_EXD_RGN_LIST:
  428. start = *ACPI_CAST_PTR(void *, target);
  429. next = start;
  430. acpi_os_printf("%20s : %p", name, next);
  431. if (next) {
  432. acpi_os_printf("(%s %2.2X)",
  433. acpi_ut_get_object_type_name
  434. (next), next->common.type);
  435. while (next->region.next) {
  436. if ((next->common.type ==
  437. ACPI_TYPE_LOCAL_DATA) && !data) {
  438. data = next;
  439. }
  440. next = next->region.next;
  441. acpi_os_printf("->%p(%s %2.2X)", next,
  442. acpi_ut_get_object_type_name
  443. (next),
  444. next->common.type);
  445. if ((next == start) || (next == data)) {
  446. acpi_os_printf
  447. ("\n**** Error: Region list appears to be circular linked");
  448. break;
  449. }
  450. }
  451. }
  452. acpi_os_printf("\n");
  453. break;
  454. case ACPI_EXD_NODE:
  455. node =
  456. *ACPI_CAST_PTR(struct acpi_namespace_node *,
  457. target);
  458. acpi_os_printf("%20s : %p", name, node);
  459. if (node) {
  460. acpi_os_printf(" [%4.4s]", node->name.ascii);
  461. }
  462. acpi_os_printf("\n");
  463. break;
  464. default:
  465. acpi_os_printf("**** Invalid table opcode [%X] ****\n",
  466. info->opcode);
  467. return;
  468. }
  469. info++;
  470. count--;
  471. }
  472. }
  473. /*******************************************************************************
  474. *
  475. * FUNCTION: acpi_ex_dump_operand
  476. *
  477. * PARAMETERS: *obj_desc - Pointer to entry to be dumped
  478. * depth - Current nesting depth
  479. *
  480. * RETURN: None
  481. *
  482. * DESCRIPTION: Dump an operand object
  483. *
  484. ******************************************************************************/
  485. void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
  486. {
  487. u32 length;
  488. u32 index;
  489. ACPI_FUNCTION_NAME(ex_dump_operand);
  490. /* Check if debug output enabled */
  491. if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_EXEC, _COMPONENT)) {
  492. return;
  493. }
  494. if (!obj_desc) {
  495. /* This could be a null element of a package */
  496. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
  497. return;
  498. }
  499. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  500. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
  501. obj_desc));
  502. ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
  503. return;
  504. }
  505. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  506. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  507. "%p is not a node or operand object: [%s]\n",
  508. obj_desc,
  509. acpi_ut_get_descriptor_name(obj_desc)));
  510. ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object));
  511. return;
  512. }
  513. /* obj_desc is a valid object */
  514. if (depth > 0) {
  515. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p Refs=%u ",
  516. depth, " ", depth, obj_desc,
  517. obj_desc->common.reference_count));
  518. } else {
  519. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Refs=%u ",
  520. obj_desc, obj_desc->common.reference_count));
  521. }
  522. /* Decode object type */
  523. switch (obj_desc->common.type) {
  524. case ACPI_TYPE_LOCAL_REFERENCE:
  525. acpi_os_printf("Reference: [%s] ",
  526. acpi_ut_get_reference_name(obj_desc));
  527. switch (obj_desc->reference.class) {
  528. case ACPI_REFCLASS_DEBUG:
  529. acpi_os_printf("\n");
  530. break;
  531. case ACPI_REFCLASS_INDEX:
  532. acpi_os_printf("%p\n", obj_desc->reference.object);
  533. break;
  534. case ACPI_REFCLASS_TABLE:
  535. acpi_os_printf("Table Index %X\n",
  536. obj_desc->reference.value);
  537. break;
  538. case ACPI_REFCLASS_REFOF:
  539. acpi_os_printf("%p [%s]\n", obj_desc->reference.object,
  540. acpi_ut_get_type_name(((union
  541. acpi_operand_object
  542. *)
  543. obj_desc->
  544. reference.
  545. object)->common.
  546. type));
  547. break;
  548. case ACPI_REFCLASS_NAME:
  549. acpi_ut_repair_name(obj_desc->reference.node->name.
  550. ascii);
  551. acpi_os_printf("- [%4.4s] (Node %p)\n",
  552. obj_desc->reference.node->name.ascii,
  553. obj_desc->reference.node);
  554. break;
  555. case ACPI_REFCLASS_ARG:
  556. case ACPI_REFCLASS_LOCAL:
  557. acpi_os_printf("%X\n", obj_desc->reference.value);
  558. break;
  559. default: /* Unknown reference class */
  560. acpi_os_printf("%2.2X\n", obj_desc->reference.class);
  561. break;
  562. }
  563. break;
  564. case ACPI_TYPE_BUFFER:
  565. acpi_os_printf("Buffer length %.2X @ %p\n",
  566. obj_desc->buffer.length,
  567. obj_desc->buffer.pointer);
  568. /* Debug only -- dump the buffer contents */
  569. if (obj_desc->buffer.pointer) {
  570. length = obj_desc->buffer.length;
  571. if (length > 128) {
  572. length = 128;
  573. }
  574. acpi_os_printf
  575. ("Buffer Contents: (displaying length 0x%.2X)\n",
  576. length);
  577. ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, length);
  578. }
  579. break;
  580. case ACPI_TYPE_INTEGER:
  581. acpi_os_printf("Integer %8.8X%8.8X\n",
  582. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  583. break;
  584. case ACPI_TYPE_PACKAGE:
  585. acpi_os_printf("Package [Len %X] ElementArray %p\n",
  586. obj_desc->package.count,
  587. obj_desc->package.elements);
  588. /*
  589. * If elements exist, package element pointer is valid,
  590. * and debug_level exceeds 1, dump package's elements.
  591. */
  592. if (obj_desc->package.count &&
  593. obj_desc->package.elements && acpi_dbg_level > 1) {
  594. for (index = 0; index < obj_desc->package.count;
  595. index++) {
  596. acpi_ex_dump_operand(obj_desc->package.
  597. elements[index],
  598. depth + 1);
  599. }
  600. }
  601. break;
  602. case ACPI_TYPE_REGION:
  603. acpi_os_printf("Region %s (%X)",
  604. acpi_ut_get_region_name(obj_desc->region.
  605. space_id),
  606. obj_desc->region.space_id);
  607. /*
  608. * If the address and length have not been evaluated,
  609. * don't print them.
  610. */
  611. if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
  612. acpi_os_printf("\n");
  613. } else {
  614. acpi_os_printf(" base %8.8X%8.8X Length %X\n",
  615. ACPI_FORMAT_UINT64(obj_desc->region.
  616. address),
  617. obj_desc->region.length);
  618. }
  619. break;
  620. case ACPI_TYPE_STRING:
  621. acpi_os_printf("String length %X @ %p ",
  622. obj_desc->string.length,
  623. obj_desc->string.pointer);
  624. acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
  625. acpi_os_printf("\n");
  626. break;
  627. case ACPI_TYPE_LOCAL_BANK_FIELD:
  628. acpi_os_printf("BankField\n");
  629. break;
  630. case ACPI_TYPE_LOCAL_REGION_FIELD:
  631. acpi_os_printf
  632. ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
  633. "byte=%X bit=%X of below:\n", obj_desc->field.bit_length,
  634. obj_desc->field.access_byte_width,
  635. obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
  636. obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
  637. obj_desc->field.base_byte_offset,
  638. obj_desc->field.start_field_bit_offset);
  639. acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
  640. break;
  641. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  642. acpi_os_printf("IndexField\n");
  643. break;
  644. case ACPI_TYPE_BUFFER_FIELD:
  645. acpi_os_printf("BufferField: %X bits at byte %X bit %X of\n",
  646. obj_desc->buffer_field.bit_length,
  647. obj_desc->buffer_field.base_byte_offset,
  648. obj_desc->buffer_field.start_field_bit_offset);
  649. if (!obj_desc->buffer_field.buffer_obj) {
  650. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
  651. } else if ((obj_desc->buffer_field.buffer_obj)->common.type !=
  652. ACPI_TYPE_BUFFER) {
  653. acpi_os_printf("*not a Buffer*\n");
  654. } else {
  655. acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
  656. depth + 1);
  657. }
  658. break;
  659. case ACPI_TYPE_EVENT:
  660. acpi_os_printf("Event\n");
  661. break;
  662. case ACPI_TYPE_METHOD:
  663. acpi_os_printf("Method(%X) @ %p:%X\n",
  664. obj_desc->method.param_count,
  665. obj_desc->method.aml_start,
  666. obj_desc->method.aml_length);
  667. break;
  668. case ACPI_TYPE_MUTEX:
  669. acpi_os_printf("Mutex\n");
  670. break;
  671. case ACPI_TYPE_DEVICE:
  672. acpi_os_printf("Device\n");
  673. break;
  674. case ACPI_TYPE_POWER:
  675. acpi_os_printf("Power\n");
  676. break;
  677. case ACPI_TYPE_PROCESSOR:
  678. acpi_os_printf("Processor\n");
  679. break;
  680. case ACPI_TYPE_THERMAL:
  681. acpi_os_printf("Thermal\n");
  682. break;
  683. default:
  684. /* Unknown Type */
  685. acpi_os_printf("Unknown Type %X\n", obj_desc->common.type);
  686. break;
  687. }
  688. return;
  689. }
  690. /*******************************************************************************
  691. *
  692. * FUNCTION: acpi_ex_dump_operands
  693. *
  694. * PARAMETERS: operands - A list of Operand objects
  695. * opcode_name - AML opcode name
  696. * num_operands - Operand count for this opcode
  697. *
  698. * DESCRIPTION: Dump the operands associated with the opcode
  699. *
  700. ******************************************************************************/
  701. void
  702. acpi_ex_dump_operands(union acpi_operand_object **operands,
  703. const char *opcode_name, u32 num_operands)
  704. {
  705. ACPI_FUNCTION_TRACE(ex_dump_operands);
  706. if (!opcode_name) {
  707. opcode_name = "UNKNOWN";
  708. }
  709. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  710. "**** Start operand dump for opcode [%s], %u operands\n",
  711. opcode_name, num_operands));
  712. if (num_operands == 0) {
  713. num_operands = 1;
  714. }
  715. /* Dump the individual operands */
  716. while (num_operands) {
  717. acpi_ex_dump_operand(*operands, 0);
  718. operands++;
  719. num_operands--;
  720. }
  721. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  722. "**** End operand dump for [%s]\n", opcode_name));
  723. return_VOID;
  724. }
  725. /*******************************************************************************
  726. *
  727. * FUNCTION: acpi_ex_out* functions
  728. *
  729. * PARAMETERS: title - Descriptive text
  730. * value - Value to be displayed
  731. *
  732. * DESCRIPTION: Object dump output formatting functions. These functions
  733. * reduce the number of format strings required and keeps them
  734. * all in one place for easy modification.
  735. *
  736. ******************************************************************************/
  737. static void acpi_ex_out_string(const char *title, const char *value)
  738. {
  739. acpi_os_printf("%20s : %s\n", title, value);
  740. }
  741. static void acpi_ex_out_pointer(const char *title, const void *value)
  742. {
  743. acpi_os_printf("%20s : %p\n", title, value);
  744. }
  745. /*******************************************************************************
  746. *
  747. * FUNCTION: acpi_ex_dump_namespace_node
  748. *
  749. * PARAMETERS: node - Descriptor to dump
  750. * flags - Force display if TRUE
  751. *
  752. * DESCRIPTION: Dumps the members of the given.Node
  753. *
  754. ******************************************************************************/
  755. void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
  756. {
  757. ACPI_FUNCTION_ENTRY();
  758. if (!flags) {
  759. /* Check if debug output enabled */
  760. if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
  761. return;
  762. }
  763. }
  764. acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
  765. acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
  766. node->type, acpi_ut_get_type_name(node->type));
  767. acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
  768. acpi_ex_dump_node);
  769. }
  770. /*******************************************************************************
  771. *
  772. * FUNCTION: acpi_ex_dump_reference_obj
  773. *
  774. * PARAMETERS: object - Descriptor to dump
  775. *
  776. * DESCRIPTION: Dumps a reference object
  777. *
  778. ******************************************************************************/
  779. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
  780. {
  781. struct acpi_buffer ret_buf;
  782. acpi_status status;
  783. ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  784. if (obj_desc->reference.class == ACPI_REFCLASS_NAME) {
  785. acpi_os_printf(" %p ", obj_desc->reference.node);
  786. status = acpi_ns_handle_to_pathname(obj_desc->reference.node,
  787. &ret_buf, TRUE);
  788. if (ACPI_FAILURE(status)) {
  789. acpi_os_printf
  790. (" Could not convert name to pathname: %s\n",
  791. acpi_format_exception(status));
  792. } else {
  793. acpi_os_printf("%s: %s\n",
  794. acpi_ut_get_type_name(obj_desc->
  795. reference.node->
  796. type),
  797. (char *)ret_buf.pointer);
  798. ACPI_FREE(ret_buf.pointer);
  799. }
  800. } else if (obj_desc->reference.object) {
  801. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
  802. ACPI_DESC_TYPE_OPERAND) {
  803. acpi_os_printf("%22s %p", "Target :",
  804. obj_desc->reference.object);
  805. if (obj_desc->reference.class == ACPI_REFCLASS_TABLE) {
  806. acpi_os_printf(" Table Index: %X\n",
  807. obj_desc->reference.value);
  808. } else {
  809. acpi_os_printf(" [%s]\n",
  810. acpi_ut_get_type_name(((union
  811. acpi_operand_object
  812. *)
  813. obj_desc->
  814. reference.
  815. object)->
  816. common.
  817. type));
  818. }
  819. } else {
  820. acpi_os_printf(" Target: %p\n",
  821. obj_desc->reference.object);
  822. }
  823. }
  824. }
  825. /*******************************************************************************
  826. *
  827. * FUNCTION: acpi_ex_dump_package_obj
  828. *
  829. * PARAMETERS: obj_desc - Descriptor to dump
  830. * level - Indentation Level
  831. * index - Package index for this object
  832. *
  833. * DESCRIPTION: Dumps the elements of the package
  834. *
  835. ******************************************************************************/
  836. static void
  837. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  838. u32 level, u32 index)
  839. {
  840. u32 i;
  841. /* Indentation and index output */
  842. if (level > 0) {
  843. for (i = 0; i < level; i++) {
  844. acpi_os_printf(" ");
  845. }
  846. acpi_os_printf("[%.2d] ", index);
  847. }
  848. acpi_os_printf("%p ", obj_desc);
  849. /* Null package elements are allowed */
  850. if (!obj_desc) {
  851. acpi_os_printf("[Null Object]\n");
  852. return;
  853. }
  854. /* Packages may only contain a few object types */
  855. switch (obj_desc->common.type) {
  856. case ACPI_TYPE_INTEGER:
  857. acpi_os_printf("[Integer] = %8.8X%8.8X\n",
  858. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  859. break;
  860. case ACPI_TYPE_STRING:
  861. acpi_os_printf("[String] Value: ");
  862. acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
  863. acpi_os_printf("\n");
  864. break;
  865. case ACPI_TYPE_BUFFER:
  866. acpi_os_printf("[Buffer] Length %.2X = ",
  867. obj_desc->buffer.length);
  868. if (obj_desc->buffer.length) {
  869. acpi_ut_debug_dump_buffer(ACPI_CAST_PTR
  870. (u8,
  871. obj_desc->buffer.pointer),
  872. obj_desc->buffer.length,
  873. DB_DWORD_DISPLAY, _COMPONENT);
  874. } else {
  875. acpi_os_printf("\n");
  876. }
  877. break;
  878. case ACPI_TYPE_PACKAGE:
  879. acpi_os_printf("[Package] Contains %u Elements:\n",
  880. obj_desc->package.count);
  881. for (i = 0; i < obj_desc->package.count; i++) {
  882. acpi_ex_dump_package_obj(obj_desc->package.elements[i],
  883. level + 1, i);
  884. }
  885. break;
  886. case ACPI_TYPE_LOCAL_REFERENCE:
  887. acpi_os_printf("[Object Reference] Class [%s]",
  888. acpi_ut_get_reference_name(obj_desc));
  889. acpi_ex_dump_reference_obj(obj_desc);
  890. break;
  891. default:
  892. acpi_os_printf("[%s] Type: %2.2X\n",
  893. acpi_ut_get_type_name(obj_desc->common.type),
  894. obj_desc->common.type);
  895. break;
  896. }
  897. }
  898. /*******************************************************************************
  899. *
  900. * FUNCTION: acpi_ex_dump_object_descriptor
  901. *
  902. * PARAMETERS: obj_desc - Descriptor to dump
  903. * flags - Force display if TRUE
  904. *
  905. * DESCRIPTION: Dumps the members of the object descriptor given.
  906. *
  907. ******************************************************************************/
  908. void
  909. acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
  910. {
  911. ACPI_FUNCTION_TRACE(ex_dump_object_descriptor);
  912. if (!obj_desc) {
  913. return_VOID;
  914. }
  915. if (!flags) {
  916. /* Check if debug output enabled */
  917. if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
  918. return_VOID;
  919. }
  920. }
  921. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  922. acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
  923. obj_desc, flags);
  924. obj_desc = ((struct acpi_namespace_node *)obj_desc)->object;
  925. if (!obj_desc) {
  926. return_VOID;
  927. }
  928. acpi_os_printf("\nAttached Object %p", obj_desc);
  929. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  930. acpi_os_printf(" - Namespace Node");
  931. }
  932. acpi_os_printf(":\n");
  933. goto dump_object;
  934. }
  935. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  936. acpi_os_printf("%p is not an ACPI operand object: [%s]\n",
  937. obj_desc, acpi_ut_get_descriptor_name(obj_desc));
  938. return_VOID;
  939. }
  940. /* Validate the object type */
  941. if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
  942. acpi_os_printf("Not a known object type: %2.2X\n",
  943. obj_desc->common.type);
  944. return_VOID;
  945. }
  946. dump_object:
  947. if (!obj_desc) {
  948. return_VOID;
  949. }
  950. /* Common Fields */
  951. acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
  952. /* Object-specific fields */
  953. acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
  954. if (obj_desc->common.type == ACPI_TYPE_REGION) {
  955. obj_desc = obj_desc->common.next_object;
  956. if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
  957. acpi_os_printf
  958. ("Secondary object is not a known object type: %2.2X\n",
  959. obj_desc->common.type);
  960. return_VOID;
  961. }
  962. acpi_os_printf("\nExtra attached Object (%p):\n", obj_desc);
  963. acpi_ex_dump_object(obj_desc,
  964. acpi_ex_dump_info[obj_desc->common.type]);
  965. }
  966. return_VOID;
  967. }
  968. #endif