exdump.c 29 KB

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