exdump.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. /******************************************************************************
  2. *
  3. * Module Name: exdump - Interpreter debug output routines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2007, 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
  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[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. case ACPI_EXD_ADDRESS:
  331. acpi_ex_out_pointer(name,
  332. *ACPI_CAST_PTR(void *, target));
  333. break;
  334. case ACPI_EXD_STRING:
  335. acpi_ut_print_string(obj_desc->string.pointer,
  336. ACPI_UINT8_MAX);
  337. acpi_os_printf("\n");
  338. break;
  339. case ACPI_EXD_BUFFER:
  340. ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
  341. obj_desc->buffer.length);
  342. break;
  343. case ACPI_EXD_PACKAGE:
  344. /* Dump the package contents */
  345. acpi_os_printf("\nPackage Contents:\n");
  346. acpi_ex_dump_package_obj(obj_desc, 0, 0);
  347. break;
  348. case ACPI_EXD_FIELD:
  349. acpi_ex_dump_object(obj_desc,
  350. acpi_ex_dump_field_common);
  351. break;
  352. case ACPI_EXD_REFERENCE:
  353. acpi_ex_out_string("Opcode",
  354. (acpi_ps_get_opcode_info
  355. (obj_desc->reference.opcode))->
  356. name);
  357. acpi_ex_dump_reference_obj(obj_desc);
  358. break;
  359. default:
  360. acpi_os_printf("**** Invalid table opcode [%X] ****\n",
  361. info->opcode);
  362. return;
  363. }
  364. info++;
  365. count--;
  366. }
  367. }
  368. /*******************************************************************************
  369. *
  370. * FUNCTION: acpi_ex_dump_operand
  371. *
  372. * PARAMETERS: *obj_desc - Pointer to entry to be dumped
  373. * Depth - Current nesting depth
  374. *
  375. * RETURN: None
  376. *
  377. * DESCRIPTION: Dump an operand object
  378. *
  379. ******************************************************************************/
  380. void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
  381. {
  382. u32 length;
  383. u32 index;
  384. ACPI_FUNCTION_NAME(ex_dump_operand)
  385. if (!((ACPI_LV_EXEC & acpi_dbg_level)
  386. && (_COMPONENT & acpi_dbg_layer))) {
  387. return;
  388. }
  389. if (!obj_desc) {
  390. /* This could be a null element of a package */
  391. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
  392. return;
  393. }
  394. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  395. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
  396. obj_desc));
  397. ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
  398. return;
  399. }
  400. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  401. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  402. "%p is not a node or operand object: [%s]\n",
  403. obj_desc,
  404. acpi_ut_get_descriptor_name(obj_desc)));
  405. ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object));
  406. return;
  407. }
  408. /* obj_desc is a valid object */
  409. if (depth > 0) {
  410. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ",
  411. depth, " ", depth, obj_desc));
  412. } else {
  413. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc));
  414. }
  415. /* Decode object type */
  416. switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
  417. case ACPI_TYPE_LOCAL_REFERENCE:
  418. switch (obj_desc->reference.opcode) {
  419. case AML_DEBUG_OP:
  420. acpi_os_printf("Reference: Debug\n");
  421. break;
  422. case AML_NAME_OP:
  423. ACPI_DUMP_PATHNAME(obj_desc->reference.object,
  424. "Reference: Name: ", ACPI_LV_INFO,
  425. _COMPONENT);
  426. ACPI_DUMP_ENTRY(obj_desc->reference.object,
  427. ACPI_LV_INFO);
  428. break;
  429. case AML_INDEX_OP:
  430. acpi_os_printf("Reference: Index %p\n",
  431. obj_desc->reference.object);
  432. break;
  433. case AML_REF_OF_OP:
  434. acpi_os_printf("Reference: (RefOf) %p\n",
  435. obj_desc->reference.object);
  436. break;
  437. case AML_ARG_OP:
  438. acpi_os_printf("Reference: Arg%d",
  439. obj_desc->reference.offset);
  440. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  441. /* Value is an Integer */
  442. acpi_os_printf(" value is [%8.8X%8.8x]",
  443. ACPI_FORMAT_UINT64(obj_desc->
  444. integer.
  445. value));
  446. }
  447. acpi_os_printf("\n");
  448. break;
  449. case AML_LOCAL_OP:
  450. acpi_os_printf("Reference: Local%d",
  451. obj_desc->reference.offset);
  452. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  453. /* Value is an Integer */
  454. acpi_os_printf(" value is [%8.8X%8.8x]",
  455. ACPI_FORMAT_UINT64(obj_desc->
  456. integer.
  457. value));
  458. }
  459. acpi_os_printf("\n");
  460. break;
  461. case AML_INT_NAMEPATH_OP:
  462. acpi_os_printf("Reference.Node->Name %X\n",
  463. obj_desc->reference.node->name.integer);
  464. break;
  465. default:
  466. /* Unknown opcode */
  467. acpi_os_printf("Unknown Reference opcode=%X\n",
  468. obj_desc->reference.opcode);
  469. break;
  470. }
  471. break;
  472. case ACPI_TYPE_BUFFER:
  473. acpi_os_printf("Buffer len %X @ %p\n",
  474. obj_desc->buffer.length,
  475. obj_desc->buffer.pointer);
  476. length = obj_desc->buffer.length;
  477. if (length > 64) {
  478. length = 64;
  479. }
  480. /* Debug only -- dump the buffer contents */
  481. if (obj_desc->buffer.pointer) {
  482. acpi_os_printf("Buffer Contents: ");
  483. for (index = 0; index < length; index++) {
  484. acpi_os_printf(" %02x",
  485. obj_desc->buffer.pointer[index]);
  486. }
  487. acpi_os_printf("\n");
  488. }
  489. break;
  490. case ACPI_TYPE_INTEGER:
  491. acpi_os_printf("Integer %8.8X%8.8X\n",
  492. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  493. break;
  494. case ACPI_TYPE_PACKAGE:
  495. acpi_os_printf("Package [Len %X] ElementArray %p\n",
  496. obj_desc->package.count,
  497. obj_desc->package.elements);
  498. /*
  499. * If elements exist, package element pointer is valid,
  500. * and debug_level exceeds 1, dump package's elements.
  501. */
  502. if (obj_desc->package.count &&
  503. obj_desc->package.elements && acpi_dbg_level > 1) {
  504. for (index = 0; index < obj_desc->package.count;
  505. index++) {
  506. acpi_ex_dump_operand(obj_desc->package.
  507. elements[index],
  508. depth + 1);
  509. }
  510. }
  511. break;
  512. case ACPI_TYPE_REGION:
  513. acpi_os_printf("Region %s (%X)",
  514. acpi_ut_get_region_name(obj_desc->region.
  515. space_id),
  516. obj_desc->region.space_id);
  517. /*
  518. * If the address and length have not been evaluated,
  519. * don't print them.
  520. */
  521. if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
  522. acpi_os_printf("\n");
  523. } else {
  524. acpi_os_printf(" base %8.8X%8.8X Length %X\n",
  525. ACPI_FORMAT_UINT64(obj_desc->region.
  526. address),
  527. obj_desc->region.length);
  528. }
  529. break;
  530. case ACPI_TYPE_STRING:
  531. acpi_os_printf("String length %X @ %p ",
  532. obj_desc->string.length,
  533. obj_desc->string.pointer);
  534. acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
  535. acpi_os_printf("\n");
  536. break;
  537. case ACPI_TYPE_LOCAL_BANK_FIELD:
  538. acpi_os_printf("BankField\n");
  539. break;
  540. case ACPI_TYPE_LOCAL_REGION_FIELD:
  541. acpi_os_printf
  542. ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
  543. obj_desc->field.bit_length,
  544. obj_desc->field.access_byte_width,
  545. obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
  546. obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
  547. obj_desc->field.base_byte_offset,
  548. obj_desc->field.start_field_bit_offset);
  549. acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
  550. break;
  551. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  552. acpi_os_printf("IndexField\n");
  553. break;
  554. case ACPI_TYPE_BUFFER_FIELD:
  555. acpi_os_printf("BufferField: %X bits at byte %X bit %X of\n",
  556. obj_desc->buffer_field.bit_length,
  557. obj_desc->buffer_field.base_byte_offset,
  558. obj_desc->buffer_field.start_field_bit_offset);
  559. if (!obj_desc->buffer_field.buffer_obj) {
  560. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
  561. } else
  562. if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
  563. != ACPI_TYPE_BUFFER) {
  564. acpi_os_printf("*not a Buffer*\n");
  565. } else {
  566. acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
  567. depth + 1);
  568. }
  569. break;
  570. case ACPI_TYPE_EVENT:
  571. acpi_os_printf("Event\n");
  572. break;
  573. case ACPI_TYPE_METHOD:
  574. acpi_os_printf("Method(%X) @ %p:%X\n",
  575. obj_desc->method.param_count,
  576. obj_desc->method.aml_start,
  577. obj_desc->method.aml_length);
  578. break;
  579. case ACPI_TYPE_MUTEX:
  580. acpi_os_printf("Mutex\n");
  581. break;
  582. case ACPI_TYPE_DEVICE:
  583. acpi_os_printf("Device\n");
  584. break;
  585. case ACPI_TYPE_POWER:
  586. acpi_os_printf("Power\n");
  587. break;
  588. case ACPI_TYPE_PROCESSOR:
  589. acpi_os_printf("Processor\n");
  590. break;
  591. case ACPI_TYPE_THERMAL:
  592. acpi_os_printf("Thermal\n");
  593. break;
  594. default:
  595. /* Unknown Type */
  596. acpi_os_printf("Unknown Type %X\n",
  597. ACPI_GET_OBJECT_TYPE(obj_desc));
  598. break;
  599. }
  600. return;
  601. }
  602. /*******************************************************************************
  603. *
  604. * FUNCTION: acpi_ex_dump_operands
  605. *
  606. * PARAMETERS: Operands - Operand list
  607. * interpreter_mode - Load or Exec
  608. * Ident - Identification
  609. * num_levels - # of stack entries to dump above line
  610. * Note - Output notation
  611. * module_name - Caller's module name
  612. * line_number - Caller's invocation line number
  613. *
  614. * DESCRIPTION: Dump the object stack
  615. *
  616. ******************************************************************************/
  617. void
  618. acpi_ex_dump_operands(union acpi_operand_object **operands,
  619. acpi_interpreter_mode interpreter_mode,
  620. char *ident,
  621. u32 num_levels,
  622. char *note, char *module_name, u32 line_number)
  623. {
  624. acpi_native_uint i;
  625. ACPI_FUNCTION_NAME(ex_dump_operands);
  626. if (!ident) {
  627. ident = "?";
  628. }
  629. if (!note) {
  630. note = "?";
  631. }
  632. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  633. "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
  634. ident, num_levels));
  635. if (num_levels == 0) {
  636. num_levels = 1;
  637. }
  638. /* Dump the operand stack starting at the top */
  639. for (i = 0; num_levels > 0; i--, num_levels--) {
  640. acpi_ex_dump_operand(operands[i], 0);
  641. }
  642. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  643. "************* Operand Stack dump from %s(%d), %s\n",
  644. module_name, line_number, note));
  645. return;
  646. }
  647. /*******************************************************************************
  648. *
  649. * FUNCTION: acpi_ex_out* functions
  650. *
  651. * PARAMETERS: Title - Descriptive text
  652. * Value - Value to be displayed
  653. *
  654. * DESCRIPTION: Object dump output formatting functions. These functions
  655. * reduce the number of format strings required and keeps them
  656. * all in one place for easy modification.
  657. *
  658. ******************************************************************************/
  659. static void acpi_ex_out_string(char *title, char *value)
  660. {
  661. acpi_os_printf("%20s : %s\n", title, value);
  662. }
  663. static void acpi_ex_out_pointer(char *title, void *value)
  664. {
  665. acpi_os_printf("%20s : %p\n", title, value);
  666. }
  667. /*******************************************************************************
  668. *
  669. * FUNCTION: acpi_ex_dump_namespace_node
  670. *
  671. * PARAMETERS: Node - Descriptor to dump
  672. * Flags - Force display if TRUE
  673. *
  674. * DESCRIPTION: Dumps the members of the given.Node
  675. *
  676. ******************************************************************************/
  677. void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
  678. {
  679. ACPI_FUNCTION_ENTRY();
  680. if (!flags) {
  681. if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
  682. && (_COMPONENT & acpi_dbg_layer))) {
  683. return;
  684. }
  685. }
  686. acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
  687. acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
  688. acpi_ex_out_pointer("Attached Object",
  689. acpi_ns_get_attached_object(node));
  690. acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
  691. acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
  692. acpi_ex_dump_node);
  693. }
  694. /*******************************************************************************
  695. *
  696. * FUNCTION: acpi_ex_dump_reference_obj
  697. *
  698. * PARAMETERS: Object - Descriptor to dump
  699. *
  700. * DESCRIPTION: Dumps a reference object
  701. *
  702. ******************************************************************************/
  703. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
  704. {
  705. struct acpi_buffer ret_buf;
  706. acpi_status status;
  707. ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  708. if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
  709. acpi_os_printf("Named Object %p ", obj_desc->reference.node);
  710. status =
  711. acpi_ns_handle_to_pathname(obj_desc->reference.node,
  712. &ret_buf);
  713. if (ACPI_FAILURE(status)) {
  714. acpi_os_printf("Could not convert name to pathname\n");
  715. } else {
  716. acpi_os_printf("%s\n", (char *)ret_buf.pointer);
  717. ACPI_FREE(ret_buf.pointer);
  718. }
  719. } else if (obj_desc->reference.object) {
  720. acpi_os_printf("\nReferenced Object: %p\n",
  721. obj_desc->reference.object);
  722. }
  723. }
  724. /*******************************************************************************
  725. *
  726. * FUNCTION: acpi_ex_dump_package_obj
  727. *
  728. * PARAMETERS: obj_desc - Descriptor to dump
  729. * Level - Indentation Level
  730. * Index - Package index for this object
  731. *
  732. * DESCRIPTION: Dumps the elements of the package
  733. *
  734. ******************************************************************************/
  735. static void
  736. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  737. u32 level, u32 index)
  738. {
  739. u32 i;
  740. /* Indentation and index output */
  741. if (level > 0) {
  742. for (i = 0; i < level; i++) {
  743. acpi_os_printf(" ");
  744. }
  745. acpi_os_printf("[%.2d] ", index);
  746. }
  747. acpi_os_printf("%p ", obj_desc);
  748. /* Null package elements are allowed */
  749. if (!obj_desc) {
  750. acpi_os_printf("[Null Object]\n");
  751. return;
  752. }
  753. /* Packages may only contain a few object types */
  754. switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
  755. case ACPI_TYPE_INTEGER:
  756. acpi_os_printf("[Integer] = %8.8X%8.8X\n",
  757. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  758. break;
  759. case ACPI_TYPE_STRING:
  760. acpi_os_printf("[String] Value: ");
  761. for (i = 0; i < obj_desc->string.length; i++) {
  762. acpi_os_printf("%c", obj_desc->string.pointer[i]);
  763. }
  764. acpi_os_printf("\n");
  765. break;
  766. case ACPI_TYPE_BUFFER:
  767. acpi_os_printf("[Buffer] Length %.2X = ",
  768. obj_desc->buffer.length);
  769. if (obj_desc->buffer.length) {
  770. acpi_ut_dump_buffer(ACPI_CAST_PTR
  771. (u8, obj_desc->buffer.pointer),
  772. obj_desc->buffer.length,
  773. DB_DWORD_DISPLAY, _COMPONENT);
  774. } else {
  775. acpi_os_printf("\n");
  776. }
  777. break;
  778. case ACPI_TYPE_PACKAGE:
  779. acpi_os_printf("[Package] Contains %d Elements:\n",
  780. obj_desc->package.count);
  781. for (i = 0; i < obj_desc->package.count; i++) {
  782. acpi_ex_dump_package_obj(obj_desc->package.elements[i],
  783. level + 1, i);
  784. }
  785. break;
  786. case ACPI_TYPE_LOCAL_REFERENCE:
  787. acpi_os_printf("[Object Reference] ");
  788. acpi_ex_dump_reference_obj(obj_desc);
  789. break;
  790. default:
  791. acpi_os_printf("[Unknown Type] %X\n",
  792. ACPI_GET_OBJECT_TYPE(obj_desc));
  793. break;
  794. }
  795. }
  796. /*******************************************************************************
  797. *
  798. * FUNCTION: acpi_ex_dump_object_descriptor
  799. *
  800. * PARAMETERS: obj_desc - Descriptor to dump
  801. * Flags - Force display if TRUE
  802. *
  803. * DESCRIPTION: Dumps the members of the object descriptor given.
  804. *
  805. ******************************************************************************/
  806. void
  807. acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
  808. {
  809. ACPI_FUNCTION_TRACE(ex_dump_object_descriptor);
  810. if (!obj_desc) {
  811. return_VOID;
  812. }
  813. if (!flags) {
  814. if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
  815. && (_COMPONENT & acpi_dbg_layer))) {
  816. return_VOID;
  817. }
  818. }
  819. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  820. acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
  821. obj_desc, flags);
  822. acpi_os_printf("\nAttached Object (%p):\n",
  823. ((struct acpi_namespace_node *)obj_desc)->
  824. object);
  825. acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
  826. obj_desc)->object, flags);
  827. return_VOID;
  828. }
  829. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  830. acpi_os_printf
  831. ("ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
  832. obj_desc, acpi_ut_get_descriptor_name(obj_desc));
  833. return_VOID;
  834. }
  835. if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
  836. return_VOID;
  837. }
  838. /* Common Fields */
  839. acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
  840. /* Object-specific fields */
  841. acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
  842. return_VOID;
  843. }
  844. #endif