exdebug.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /******************************************************************************
  2. *
  3. * Module Name: exdebug - Support for stores to the AML Debug Object
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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. #define _COMPONENT ACPI_EXECUTER
  46. ACPI_MODULE_NAME("exdebug")
  47. #ifndef ACPI_NO_ERROR_MESSAGES
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_ex_do_debug_object
  51. *
  52. * PARAMETERS: source_desc - Object to be output to "Debug Object"
  53. * level - Indentation level (used for packages)
  54. * index - Current package element, zero if not pkg
  55. *
  56. * RETURN: None
  57. *
  58. * DESCRIPTION: Handles stores to the AML Debug Object. For example:
  59. * Store(INT1, Debug)
  60. *
  61. * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
  62. *
  63. * This function is only enabled if acpi_gbl_enable_aml_debug_object is set, or
  64. * if ACPI_LV_DEBUG_OBJECT is set in the acpi_dbg_level. Thus, in the normal
  65. * operational case, stores to the debug object are ignored but can be easily
  66. * enabled if necessary.
  67. *
  68. ******************************************************************************/
  69. void
  70. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  71. u32 level, u32 index)
  72. {
  73. u32 i;
  74. u32 timer;
  75. ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
  76. /* Output must be enabled via the debug_object global or the dbg_level */
  77. if (!acpi_gbl_enable_aml_debug_object &&
  78. !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
  79. return_VOID;
  80. }
  81. /*
  82. * We will emit the current timer value (in microseconds) with each
  83. * debug output. Only need the lower 26 bits. This allows for 67
  84. * million microseconds or 67 seconds before rollover.
  85. */
  86. timer = ((u32)acpi_os_get_timer() / 10); /* (100 nanoseconds to microseconds) */
  87. timer &= 0x03FFFFFF;
  88. /*
  89. * Print line header as long as we are not in the middle of an
  90. * object display
  91. */
  92. if (!((level > 0) && index == 0)) {
  93. acpi_os_printf("[ACPI Debug %.8u] %*s", timer, level, " ");
  94. }
  95. /* Display the index for package output only */
  96. if (index > 0) {
  97. acpi_os_printf("(%.2u) ", index - 1);
  98. }
  99. if (!source_desc) {
  100. acpi_os_printf("[Null Object]\n");
  101. return_VOID;
  102. }
  103. if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
  104. acpi_os_printf("%s ",
  105. acpi_ut_get_object_type_name(source_desc));
  106. if (!acpi_ut_valid_internal_object(source_desc)) {
  107. acpi_os_printf("%p, Invalid Internal Object!\n",
  108. source_desc);
  109. return_VOID;
  110. }
  111. } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
  112. ACPI_DESC_TYPE_NAMED) {
  113. acpi_os_printf("%s: %p\n",
  114. acpi_ut_get_type_name(((struct
  115. acpi_namespace_node *)
  116. source_desc)->type),
  117. source_desc);
  118. return_VOID;
  119. } else {
  120. return_VOID;
  121. }
  122. /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
  123. switch (source_desc->common.type) {
  124. case ACPI_TYPE_INTEGER:
  125. /* Output correct integer width */
  126. if (acpi_gbl_integer_byte_width == 4) {
  127. acpi_os_printf("0x%8.8X\n",
  128. (u32)source_desc->integer.value);
  129. } else {
  130. acpi_os_printf("0x%8.8X%8.8X\n",
  131. ACPI_FORMAT_UINT64(source_desc->integer.
  132. value));
  133. }
  134. break;
  135. case ACPI_TYPE_BUFFER:
  136. acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
  137. acpi_ut_dump_buffer(source_desc->buffer.pointer,
  138. (source_desc->buffer.length < 256) ?
  139. source_desc->buffer.length : 256,
  140. DB_BYTE_DISPLAY, 0);
  141. break;
  142. case ACPI_TYPE_STRING:
  143. acpi_os_printf("[0x%.2X] \"%s\"\n",
  144. source_desc->string.length,
  145. source_desc->string.pointer);
  146. break;
  147. case ACPI_TYPE_PACKAGE:
  148. acpi_os_printf("[Contains 0x%.2X Elements]\n",
  149. source_desc->package.count);
  150. /* Output the entire contents of the package */
  151. for (i = 0; i < source_desc->package.count; i++) {
  152. acpi_ex_do_debug_object(source_desc->package.
  153. elements[i], level + 4, i + 1);
  154. }
  155. break;
  156. case ACPI_TYPE_LOCAL_REFERENCE:
  157. acpi_os_printf("[%s] ",
  158. acpi_ut_get_reference_name(source_desc));
  159. /* Decode the reference */
  160. switch (source_desc->reference.class) {
  161. case ACPI_REFCLASS_INDEX:
  162. acpi_os_printf("0x%X\n", source_desc->reference.value);
  163. break;
  164. case ACPI_REFCLASS_TABLE:
  165. /* Case for ddb_handle */
  166. acpi_os_printf("Table Index 0x%X\n",
  167. source_desc->reference.value);
  168. return_VOID;
  169. default:
  170. break;
  171. }
  172. acpi_os_printf(" ");
  173. /* Check for valid node first, then valid object */
  174. if (source_desc->reference.node) {
  175. if (ACPI_GET_DESCRIPTOR_TYPE
  176. (source_desc->reference.node) !=
  177. ACPI_DESC_TYPE_NAMED) {
  178. acpi_os_printf
  179. (" %p - Not a valid namespace node\n",
  180. source_desc->reference.node);
  181. } else {
  182. acpi_os_printf("Node %p [%4.4s] ",
  183. source_desc->reference.node,
  184. (source_desc->reference.node)->
  185. name.ascii);
  186. switch ((source_desc->reference.node)->type) {
  187. /* These types have no attached object */
  188. case ACPI_TYPE_DEVICE:
  189. acpi_os_printf("Device\n");
  190. break;
  191. case ACPI_TYPE_THERMAL:
  192. acpi_os_printf("Thermal Zone\n");
  193. break;
  194. default:
  195. acpi_ex_do_debug_object((source_desc->
  196. reference.
  197. node)->object,
  198. level + 4, 0);
  199. break;
  200. }
  201. }
  202. } else if (source_desc->reference.object) {
  203. if (ACPI_GET_DESCRIPTOR_TYPE
  204. (source_desc->reference.object) ==
  205. ACPI_DESC_TYPE_NAMED) {
  206. acpi_ex_do_debug_object(((struct
  207. acpi_namespace_node *)
  208. source_desc->reference.
  209. object)->object,
  210. level + 4, 0);
  211. } else {
  212. acpi_ex_do_debug_object(source_desc->reference.
  213. object, level + 4, 0);
  214. }
  215. }
  216. break;
  217. default:
  218. acpi_os_printf("%p\n", source_desc);
  219. break;
  220. }
  221. ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
  222. return_VOID;
  223. }
  224. #endif