exdump.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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 <acpi/acinterp.h>
  44. #include <acpi/amlcode.h>
  45. #include <acpi/acnamesp.h>
  46. #define _COMPONENT ACPI_EXECUTER
  47. ACPI_MODULE_NAME("exdump")
  48. /*
  49. * The following routines are used for debug output only
  50. */
  51. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  52. /* Local prototypes */
  53. static void acpi_ex_out_string(char *title, char *value);
  54. static void acpi_ex_out_pointer(char *title, void *value);
  55. static void
  56. acpi_ex_dump_object(union acpi_operand_object *obj_desc,
  57. struct acpi_exdump_info *info);
  58. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
  59. static void
  60. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  61. u32 level, u32 index);
  62. /*******************************************************************************
  63. *
  64. * Object Descriptor info tables
  65. *
  66. * Note: The first table entry must be an INIT opcode and must contain
  67. * the table length (number of table entries)
  68. *
  69. ******************************************************************************/
  70. static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
  71. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
  72. {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
  73. };
  74. static struct acpi_exdump_info acpi_ex_dump_string[4] = {
  75. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
  76. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
  77. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
  78. {ACPI_EXD_STRING, 0, NULL}
  79. };
  80. static struct acpi_exdump_info acpi_ex_dump_buffer[5] = {
  81. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
  82. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
  83. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
  84. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.node), "Parent Node"},
  85. {ACPI_EXD_BUFFER, 0, NULL}
  86. };
  87. static struct acpi_exdump_info acpi_ex_dump_package[5] = {
  88. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
  89. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
  90. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
  91. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
  92. {ACPI_EXD_PACKAGE, 0, NULL}
  93. };
  94. static struct acpi_exdump_info acpi_ex_dump_device[4] = {
  95. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
  96. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
  97. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify),
  98. "System Notify"},
  99. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify),
  100. "Device Notify"}
  101. };
  102. static struct acpi_exdump_info acpi_ex_dump_event[2] = {
  103. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
  104. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
  105. };
  106. static struct acpi_exdump_info acpi_ex_dump_method[8] = {
  107. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
  108. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"},
  109. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
  110. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
  111. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
  112. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
  113. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
  114. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
  115. };
  116. static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
  117. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
  118. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
  119. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
  120. {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
  121. "Acquire Depth"},
  122. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
  123. };
  124. static struct acpi_exdump_info acpi_ex_dump_region[7] = {
  125. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
  126. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
  127. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
  128. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
  129. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
  130. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"},
  131. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
  132. };
  133. static struct acpi_exdump_info acpi_ex_dump_power[5] = {
  134. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
  135. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
  136. "System Level"},
  137. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
  138. "Resource Order"},
  139. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify),
  140. "System Notify"},
  141. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify),
  142. "Device Notify"}
  143. };
  144. static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
  145. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
  146. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
  147. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.length), "Length"},
  148. {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
  149. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify),
  150. "System Notify"},
  151. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify),
  152. "Device Notify"},
  153. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
  154. };
  155. static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
  156. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
  157. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify),
  158. "System Notify"},
  159. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify),
  160. "Device Notify"},
  161. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
  162. };
  163. static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
  164. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
  165. {ACPI_EXD_FIELD, 0, NULL},
  166. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
  167. "Buffer Object"}
  168. };
  169. static struct acpi_exdump_info acpi_ex_dump_region_field[3] = {
  170. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
  171. {ACPI_EXD_FIELD, 0, NULL},
  172. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"}
  173. };
  174. static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
  175. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  176. {ACPI_EXD_FIELD, 0, NULL},
  177. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
  178. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
  179. "Region Object"},
  180. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
  181. };
  182. static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
  183. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
  184. {ACPI_EXD_FIELD, 0, NULL},
  185. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
  186. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
  187. "Index Object"},
  188. {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
  189. };
  190. static struct acpi_exdump_info acpi_ex_dump_reference[8] = {
  191. {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
  192. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.class), "Class"},
  193. {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
  194. {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"},
  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("Class Name",
  354. (char *)
  355. acpi_ut_get_reference_name
  356. (obj_desc));
  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. acpi_os_printf("Reference: [%s] ",
  419. acpi_ut_get_reference_name(obj_desc));
  420. switch (obj_desc->reference.class) {
  421. case ACPI_REFCLASS_DEBUG:
  422. acpi_os_printf("\n");
  423. break;
  424. case ACPI_REFCLASS_INDEX:
  425. acpi_os_printf("%p\n", obj_desc->reference.object);
  426. break;
  427. case ACPI_REFCLASS_TABLE:
  428. acpi_os_printf("Table Index %X\n",
  429. obj_desc->reference.value);
  430. break;
  431. case ACPI_REFCLASS_REFOF:
  432. acpi_os_printf("%p [%s]\n", obj_desc->reference.object,
  433. acpi_ut_get_type_name(((union
  434. acpi_operand_object
  435. *)
  436. obj_desc->
  437. reference.
  438. object)->common.
  439. type));
  440. break;
  441. case ACPI_REFCLASS_ARG:
  442. acpi_os_printf("%X", obj_desc->reference.value);
  443. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  444. /* Value is an Integer */
  445. acpi_os_printf(" value is [%8.8X%8.8x]",
  446. ACPI_FORMAT_UINT64(obj_desc->
  447. integer.
  448. value));
  449. }
  450. acpi_os_printf("\n");
  451. break;
  452. case ACPI_REFCLASS_LOCAL:
  453. acpi_os_printf("%X", obj_desc->reference.value);
  454. if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
  455. /* Value is an Integer */
  456. acpi_os_printf(" value is [%8.8X%8.8x]",
  457. ACPI_FORMAT_UINT64(obj_desc->
  458. integer.
  459. value));
  460. }
  461. acpi_os_printf("\n");
  462. break;
  463. case ACPI_REFCLASS_NAME:
  464. acpi_os_printf("- [%4.4s]\n",
  465. obj_desc->reference.node->name.ascii);
  466. break;
  467. default: /* Unknown reference class */
  468. acpi_os_printf("%2.2X\n", obj_desc->reference.class);
  469. break;
  470. }
  471. break;
  472. case ACPI_TYPE_BUFFER:
  473. acpi_os_printf("Buffer length %.2X @ %p\n",
  474. obj_desc->buffer.length,
  475. obj_desc->buffer.pointer);
  476. /* Debug only -- dump the buffer contents */
  477. if (obj_desc->buffer.pointer) {
  478. length = obj_desc->buffer.length;
  479. if (length > 128) {
  480. length = 128;
  481. }
  482. acpi_os_printf
  483. ("Buffer Contents: (displaying length 0x%.2X)\n",
  484. length);
  485. ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, length);
  486. }
  487. break;
  488. case ACPI_TYPE_INTEGER:
  489. acpi_os_printf("Integer %8.8X%8.8X\n",
  490. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  491. break;
  492. case ACPI_TYPE_PACKAGE:
  493. acpi_os_printf("Package [Len %X] ElementArray %p\n",
  494. obj_desc->package.count,
  495. obj_desc->package.elements);
  496. /*
  497. * If elements exist, package element pointer is valid,
  498. * and debug_level exceeds 1, dump package's elements.
  499. */
  500. if (obj_desc->package.count &&
  501. obj_desc->package.elements && acpi_dbg_level > 1) {
  502. for (index = 0; index < obj_desc->package.count;
  503. index++) {
  504. acpi_ex_dump_operand(obj_desc->package.
  505. elements[index],
  506. depth + 1);
  507. }
  508. }
  509. break;
  510. case ACPI_TYPE_REGION:
  511. acpi_os_printf("Region %s (%X)",
  512. acpi_ut_get_region_name(obj_desc->region.
  513. space_id),
  514. obj_desc->region.space_id);
  515. /*
  516. * If the address and length have not been evaluated,
  517. * don't print them.
  518. */
  519. if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
  520. acpi_os_printf("\n");
  521. } else {
  522. acpi_os_printf(" base %8.8X%8.8X Length %X\n",
  523. ACPI_FORMAT_NATIVE_UINT(obj_desc->region.
  524. address),
  525. obj_desc->region.length);
  526. }
  527. break;
  528. case ACPI_TYPE_STRING:
  529. acpi_os_printf("String length %X @ %p ",
  530. obj_desc->string.length,
  531. obj_desc->string.pointer);
  532. acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
  533. acpi_os_printf("\n");
  534. break;
  535. case ACPI_TYPE_LOCAL_BANK_FIELD:
  536. acpi_os_printf("BankField\n");
  537. break;
  538. case ACPI_TYPE_LOCAL_REGION_FIELD:
  539. acpi_os_printf
  540. ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
  541. obj_desc->field.bit_length,
  542. obj_desc->field.access_byte_width,
  543. obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
  544. obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
  545. obj_desc->field.base_byte_offset,
  546. obj_desc->field.start_field_bit_offset);
  547. acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
  548. break;
  549. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  550. acpi_os_printf("IndexField\n");
  551. break;
  552. case ACPI_TYPE_BUFFER_FIELD:
  553. acpi_os_printf("BufferField: %X bits at byte %X bit %X of\n",
  554. obj_desc->buffer_field.bit_length,
  555. obj_desc->buffer_field.base_byte_offset,
  556. obj_desc->buffer_field.start_field_bit_offset);
  557. if (!obj_desc->buffer_field.buffer_obj) {
  558. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
  559. } else
  560. if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
  561. != ACPI_TYPE_BUFFER) {
  562. acpi_os_printf("*not a Buffer*\n");
  563. } else {
  564. acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
  565. depth + 1);
  566. }
  567. break;
  568. case ACPI_TYPE_EVENT:
  569. acpi_os_printf("Event\n");
  570. break;
  571. case ACPI_TYPE_METHOD:
  572. acpi_os_printf("Method(%X) @ %p:%X\n",
  573. obj_desc->method.param_count,
  574. obj_desc->method.aml_start,
  575. obj_desc->method.aml_length);
  576. break;
  577. case ACPI_TYPE_MUTEX:
  578. acpi_os_printf("Mutex\n");
  579. break;
  580. case ACPI_TYPE_DEVICE:
  581. acpi_os_printf("Device\n");
  582. break;
  583. case ACPI_TYPE_POWER:
  584. acpi_os_printf("Power\n");
  585. break;
  586. case ACPI_TYPE_PROCESSOR:
  587. acpi_os_printf("Processor\n");
  588. break;
  589. case ACPI_TYPE_THERMAL:
  590. acpi_os_printf("Thermal\n");
  591. break;
  592. default:
  593. /* Unknown Type */
  594. acpi_os_printf("Unknown Type %X\n",
  595. ACPI_GET_OBJECT_TYPE(obj_desc));
  596. break;
  597. }
  598. return;
  599. }
  600. /*******************************************************************************
  601. *
  602. * FUNCTION: acpi_ex_dump_operands
  603. *
  604. * PARAMETERS: Operands - A list of Operand objects
  605. * opcode_name - AML opcode name
  606. * num_operands - Operand count for this opcode
  607. *
  608. * DESCRIPTION: Dump the operands associated with the opcode
  609. *
  610. ******************************************************************************/
  611. void
  612. acpi_ex_dump_operands(union acpi_operand_object **operands,
  613. const char *opcode_name, u32 num_operands)
  614. {
  615. ACPI_FUNCTION_NAME(ex_dump_operands);
  616. if (!opcode_name) {
  617. opcode_name = "UNKNOWN";
  618. }
  619. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  620. "**** Start operand dump for opcode [%s], %d operands\n",
  621. opcode_name, num_operands));
  622. if (num_operands == 0) {
  623. num_operands = 1;
  624. }
  625. /* Dump the individual operands */
  626. while (num_operands) {
  627. acpi_ex_dump_operand(*operands, 0);
  628. operands++;
  629. num_operands--;
  630. }
  631. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  632. "**** End operand dump for [%s]\n", opcode_name));
  633. return;
  634. }
  635. /*******************************************************************************
  636. *
  637. * FUNCTION: acpi_ex_out* functions
  638. *
  639. * PARAMETERS: Title - Descriptive text
  640. * Value - Value to be displayed
  641. *
  642. * DESCRIPTION: Object dump output formatting functions. These functions
  643. * reduce the number of format strings required and keeps them
  644. * all in one place for easy modification.
  645. *
  646. ******************************************************************************/
  647. static void acpi_ex_out_string(char *title, char *value)
  648. {
  649. acpi_os_printf("%20s : %s\n", title, value);
  650. }
  651. static void acpi_ex_out_pointer(char *title, void *value)
  652. {
  653. acpi_os_printf("%20s : %p\n", title, value);
  654. }
  655. /*******************************************************************************
  656. *
  657. * FUNCTION: acpi_ex_dump_namespace_node
  658. *
  659. * PARAMETERS: Node - Descriptor to dump
  660. * Flags - Force display if TRUE
  661. *
  662. * DESCRIPTION: Dumps the members of the given.Node
  663. *
  664. ******************************************************************************/
  665. void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
  666. {
  667. ACPI_FUNCTION_ENTRY();
  668. if (!flags) {
  669. if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
  670. && (_COMPONENT & acpi_dbg_layer))) {
  671. return;
  672. }
  673. }
  674. acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
  675. acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
  676. acpi_ex_out_pointer("Attached Object",
  677. acpi_ns_get_attached_object(node));
  678. acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
  679. acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
  680. acpi_ex_dump_node);
  681. }
  682. /*******************************************************************************
  683. *
  684. * FUNCTION: acpi_ex_dump_reference_obj
  685. *
  686. * PARAMETERS: Object - Descriptor to dump
  687. *
  688. * DESCRIPTION: Dumps a reference object
  689. *
  690. ******************************************************************************/
  691. static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
  692. {
  693. struct acpi_buffer ret_buf;
  694. acpi_status status;
  695. ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  696. if (obj_desc->reference.class == ACPI_REFCLASS_NAME) {
  697. acpi_os_printf(" %p ", obj_desc->reference.node);
  698. status =
  699. acpi_ns_handle_to_pathname(obj_desc->reference.node,
  700. &ret_buf);
  701. if (ACPI_FAILURE(status)) {
  702. acpi_os_printf(" Could not convert name to pathname\n");
  703. } else {
  704. acpi_os_printf("%s\n", (char *)ret_buf.pointer);
  705. ACPI_FREE(ret_buf.pointer);
  706. }
  707. } else if (obj_desc->reference.object) {
  708. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
  709. ACPI_DESC_TYPE_OPERAND) {
  710. acpi_os_printf(" Target: %p",
  711. obj_desc->reference.object);
  712. if (obj_desc->reference.class == ACPI_REFCLASS_TABLE) {
  713. acpi_os_printf(" Table Index: %X\n",
  714. obj_desc->reference.value);
  715. } else {
  716. acpi_os_printf(" Target: %p [%s]\n",
  717. obj_desc->reference.object,
  718. acpi_ut_get_type_name(((union
  719. acpi_operand_object
  720. *)
  721. obj_desc->
  722. reference.
  723. object)->
  724. common.
  725. type));
  726. }
  727. } else {
  728. acpi_os_printf(" Target: %p\n",
  729. obj_desc->reference.object);
  730. }
  731. }
  732. }
  733. /*******************************************************************************
  734. *
  735. * FUNCTION: acpi_ex_dump_package_obj
  736. *
  737. * PARAMETERS: obj_desc - Descriptor to dump
  738. * Level - Indentation Level
  739. * Index - Package index for this object
  740. *
  741. * DESCRIPTION: Dumps the elements of the package
  742. *
  743. ******************************************************************************/
  744. static void
  745. acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
  746. u32 level, u32 index)
  747. {
  748. u32 i;
  749. /* Indentation and index output */
  750. if (level > 0) {
  751. for (i = 0; i < level; i++) {
  752. acpi_os_printf(" ");
  753. }
  754. acpi_os_printf("[%.2d] ", index);
  755. }
  756. acpi_os_printf("%p ", obj_desc);
  757. /* Null package elements are allowed */
  758. if (!obj_desc) {
  759. acpi_os_printf("[Null Object]\n");
  760. return;
  761. }
  762. /* Packages may only contain a few object types */
  763. switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
  764. case ACPI_TYPE_INTEGER:
  765. acpi_os_printf("[Integer] = %8.8X%8.8X\n",
  766. ACPI_FORMAT_UINT64(obj_desc->integer.value));
  767. break;
  768. case ACPI_TYPE_STRING:
  769. acpi_os_printf("[String] Value: ");
  770. for (i = 0; i < obj_desc->string.length; i++) {
  771. acpi_os_printf("%c", obj_desc->string.pointer[i]);
  772. }
  773. acpi_os_printf("\n");
  774. break;
  775. case ACPI_TYPE_BUFFER:
  776. acpi_os_printf("[Buffer] Length %.2X = ",
  777. obj_desc->buffer.length);
  778. if (obj_desc->buffer.length) {
  779. acpi_ut_dump_buffer(ACPI_CAST_PTR
  780. (u8, obj_desc->buffer.pointer),
  781. obj_desc->buffer.length,
  782. DB_DWORD_DISPLAY, _COMPONENT);
  783. } else {
  784. acpi_os_printf("\n");
  785. }
  786. break;
  787. case ACPI_TYPE_PACKAGE:
  788. acpi_os_printf("[Package] Contains %d Elements:\n",
  789. obj_desc->package.count);
  790. for (i = 0; i < obj_desc->package.count; i++) {
  791. acpi_ex_dump_package_obj(obj_desc->package.elements[i],
  792. level + 1, i);
  793. }
  794. break;
  795. case ACPI_TYPE_LOCAL_REFERENCE:
  796. acpi_os_printf("[Object Reference] Type [%s] %2.2X",
  797. acpi_ut_get_reference_name(obj_desc),
  798. obj_desc->reference.class);
  799. acpi_ex_dump_reference_obj(obj_desc);
  800. break;
  801. default:
  802. acpi_os_printf("[Unknown Type] %X\n",
  803. ACPI_GET_OBJECT_TYPE(obj_desc));
  804. break;
  805. }
  806. }
  807. /*******************************************************************************
  808. *
  809. * FUNCTION: acpi_ex_dump_object_descriptor
  810. *
  811. * PARAMETERS: obj_desc - Descriptor to dump
  812. * Flags - Force display if TRUE
  813. *
  814. * DESCRIPTION: Dumps the members of the object descriptor given.
  815. *
  816. ******************************************************************************/
  817. void
  818. acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
  819. {
  820. ACPI_FUNCTION_TRACE(ex_dump_object_descriptor);
  821. if (!obj_desc) {
  822. return_VOID;
  823. }
  824. if (!flags) {
  825. if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
  826. && (_COMPONENT & acpi_dbg_layer))) {
  827. return_VOID;
  828. }
  829. }
  830. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
  831. acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
  832. obj_desc, flags);
  833. acpi_os_printf("\nAttached Object (%p):\n",
  834. ((struct acpi_namespace_node *)obj_desc)->
  835. object);
  836. acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
  837. obj_desc)->object, flags);
  838. return_VOID;
  839. }
  840. if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  841. acpi_os_printf
  842. ("ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
  843. obj_desc, acpi_ut_get_descriptor_name(obj_desc));
  844. return_VOID;
  845. }
  846. if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
  847. return_VOID;
  848. }
  849. /* Common Fields */
  850. acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
  851. /* Object-specific fields */
  852. acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
  853. return_VOID;
  854. }
  855. #endif