exdebug.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /******************************************************************************
  2. *
  3. * Module Name: exdebug - Support for stores to the AML Debug Object
  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. #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. ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
  75. /* Output must be enabled via the debug_object global or the dbg_level */
  76. if (!acpi_gbl_enable_aml_debug_object &&
  77. !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
  78. return_VOID;
  79. }
  80. /*
  81. * Print line header as long as we are not in the middle of an
  82. * object display
  83. */
  84. if (!((level > 0) && index == 0)) {
  85. acpi_os_printf("[ACPI Debug] %*s", level, " ");
  86. }
  87. /* Display the index for package output only */
  88. if (index > 0) {
  89. acpi_os_printf("(%.2u) ", index - 1);
  90. }
  91. if (!source_desc) {
  92. acpi_os_printf("[Null Object]\n");
  93. return_VOID;
  94. }
  95. if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
  96. acpi_os_printf("%s ",
  97. acpi_ut_get_object_type_name(source_desc));
  98. if (!acpi_ut_valid_internal_object(source_desc)) {
  99. acpi_os_printf("%p, Invalid Internal Object!\n",
  100. source_desc);
  101. return_VOID;
  102. }
  103. } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
  104. ACPI_DESC_TYPE_NAMED) {
  105. acpi_os_printf("%s: %p\n",
  106. acpi_ut_get_type_name(((struct
  107. acpi_namespace_node *)
  108. source_desc)->type),
  109. source_desc);
  110. return_VOID;
  111. } else {
  112. return_VOID;
  113. }
  114. /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
  115. switch (source_desc->common.type) {
  116. case ACPI_TYPE_INTEGER:
  117. /* Output correct integer width */
  118. if (acpi_gbl_integer_byte_width == 4) {
  119. acpi_os_printf("0x%8.8X\n",
  120. (u32)source_desc->integer.value);
  121. } else {
  122. acpi_os_printf("0x%8.8X%8.8X\n",
  123. ACPI_FORMAT_UINT64(source_desc->integer.
  124. value));
  125. }
  126. break;
  127. case ACPI_TYPE_BUFFER:
  128. acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
  129. acpi_ut_dump_buffer2(source_desc->buffer.pointer,
  130. (source_desc->buffer.length < 256) ?
  131. source_desc->buffer.length : 256,
  132. DB_BYTE_DISPLAY);
  133. break;
  134. case ACPI_TYPE_STRING:
  135. acpi_os_printf("[0x%.2X] \"%s\"\n",
  136. source_desc->string.length,
  137. source_desc->string.pointer);
  138. break;
  139. case ACPI_TYPE_PACKAGE:
  140. acpi_os_printf("[Contains 0x%.2X Elements]\n",
  141. source_desc->package.count);
  142. /* Output the entire contents of the package */
  143. for (i = 0; i < source_desc->package.count; i++) {
  144. acpi_ex_do_debug_object(source_desc->package.
  145. elements[i], level + 4, i + 1);
  146. }
  147. break;
  148. case ACPI_TYPE_LOCAL_REFERENCE:
  149. acpi_os_printf("[%s] ",
  150. acpi_ut_get_reference_name(source_desc));
  151. /* Decode the reference */
  152. switch (source_desc->reference.class) {
  153. case ACPI_REFCLASS_INDEX:
  154. acpi_os_printf("0x%X\n", source_desc->reference.value);
  155. break;
  156. case ACPI_REFCLASS_TABLE:
  157. /* Case for ddb_handle */
  158. acpi_os_printf("Table Index 0x%X\n",
  159. source_desc->reference.value);
  160. return;
  161. default:
  162. break;
  163. }
  164. acpi_os_printf(" ");
  165. /* Check for valid node first, then valid object */
  166. if (source_desc->reference.node) {
  167. if (ACPI_GET_DESCRIPTOR_TYPE
  168. (source_desc->reference.node) !=
  169. ACPI_DESC_TYPE_NAMED) {
  170. acpi_os_printf
  171. (" %p - Not a valid namespace node\n",
  172. source_desc->reference.node);
  173. } else {
  174. acpi_os_printf("Node %p [%4.4s] ",
  175. source_desc->reference.node,
  176. (source_desc->reference.node)->
  177. name.ascii);
  178. switch ((source_desc->reference.node)->type) {
  179. /* These types have no attached object */
  180. case ACPI_TYPE_DEVICE:
  181. acpi_os_printf("Device\n");
  182. break;
  183. case ACPI_TYPE_THERMAL:
  184. acpi_os_printf("Thermal Zone\n");
  185. break;
  186. default:
  187. acpi_ex_do_debug_object((source_desc->
  188. reference.
  189. node)->object,
  190. level + 4, 0);
  191. break;
  192. }
  193. }
  194. } else if (source_desc->reference.object) {
  195. if (ACPI_GET_DESCRIPTOR_TYPE
  196. (source_desc->reference.object) ==
  197. ACPI_DESC_TYPE_NAMED) {
  198. acpi_ex_do_debug_object(((struct
  199. acpi_namespace_node *)
  200. source_desc->reference.
  201. object)->object,
  202. level + 4, 0);
  203. } else {
  204. acpi_ex_do_debug_object(source_desc->reference.
  205. object, level + 4, 0);
  206. }
  207. }
  208. break;
  209. default:
  210. acpi_os_printf("%p\n", source_desc);
  211. break;
  212. }
  213. ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
  214. return_VOID;
  215. }
  216. #endif