exdump.c 30 KB

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