exdump.c 29 KB

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