exdump.c 30 KB

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