dsinit.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /******************************************************************************
  2. *
  3. * Module Name: dsinit - Object initialization namespace walk
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, 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/acdispat.h>
  44. #include <acpi/acnamesp.h>
  45. #define _COMPONENT ACPI_DISPATCHER
  46. ACPI_MODULE_NAME("dsinit")
  47. /* Local prototypes */
  48. static acpi_status
  49. acpi_ds_init_one_object(acpi_handle obj_handle,
  50. u32 level, void *context, void **return_value);
  51. /*******************************************************************************
  52. *
  53. * FUNCTION: acpi_ds_init_one_object
  54. *
  55. * PARAMETERS: obj_handle - Node for the object
  56. * Level - Current nesting level
  57. * Context - Points to a init info struct
  58. * return_value - Not used
  59. *
  60. * RETURN: Status
  61. *
  62. * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
  63. * within the namespace.
  64. *
  65. * Currently, the only objects that require initialization are:
  66. * 1) Methods
  67. * 2) Operation Regions
  68. *
  69. ******************************************************************************/
  70. static acpi_status
  71. acpi_ds_init_one_object(acpi_handle obj_handle,
  72. u32 level, void *context, void **return_value)
  73. {
  74. struct acpi_init_walk_info *info =
  75. (struct acpi_init_walk_info *)context;
  76. struct acpi_namespace_node *node =
  77. (struct acpi_namespace_node *)obj_handle;
  78. acpi_object_type type;
  79. acpi_status status;
  80. ACPI_FUNCTION_ENTRY();
  81. /*
  82. * We are only interested in NS nodes owned by the table that
  83. * was just loaded
  84. */
  85. if (node->owner_id != info->table_desc->owner_id) {
  86. return (AE_OK);
  87. }
  88. info->object_count++;
  89. /* And even then, we are only interested in a few object types */
  90. type = acpi_ns_get_type(obj_handle);
  91. switch (type) {
  92. case ACPI_TYPE_REGION:
  93. status = acpi_ds_initialize_region(obj_handle);
  94. if (ACPI_FAILURE(status)) {
  95. ACPI_EXCEPTION((AE_INFO, status,
  96. "During Region initialization %p [%4.4s]",
  97. obj_handle,
  98. acpi_ut_get_node_name(obj_handle)));
  99. }
  100. info->op_region_count++;
  101. break;
  102. case ACPI_TYPE_METHOD:
  103. /*
  104. * Set the execution data width (32 or 64) based upon the
  105. * revision number of the parent ACPI table.
  106. * TBD: This is really for possible future support of integer width
  107. * on a per-table basis. Currently, we just use a global for the width.
  108. */
  109. if (info->table_desc->pointer->revision == 1) {
  110. node->flags |= ANOBJ_DATA_WIDTH_32;
  111. }
  112. #ifdef ACPI_INIT_PARSE_METHODS
  113. /*
  114. * Note 11/2005: Removed this code to parse all methods during table
  115. * load because it causes problems if there are any errors during the
  116. * parse. Also, it seems like overkill and we probably don't want to
  117. * abort a table load because of an issue with a single method.
  118. */
  119. /*
  120. * Print a dot for each method unless we are going to print
  121. * the entire pathname
  122. */
  123. if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
  124. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
  125. }
  126. /*
  127. * Always parse methods to detect errors, we will delete
  128. * the parse tree below
  129. */
  130. status = acpi_ds_parse_method(obj_handle);
  131. if (ACPI_FAILURE(status)) {
  132. ACPI_ERROR((AE_INFO,
  133. "Method %p [%4.4s] - parse failure, %s",
  134. obj_handle,
  135. acpi_ut_get_node_name(obj_handle),
  136. acpi_format_exception(status)));
  137. /* This parse failed, but we will continue parsing more methods */
  138. }
  139. #endif
  140. info->method_count++;
  141. break;
  142. case ACPI_TYPE_DEVICE:
  143. info->device_count++;
  144. break;
  145. default:
  146. break;
  147. }
  148. /*
  149. * We ignore errors from above, and always return OK, since
  150. * we don't want to abort the walk on a single error.
  151. */
  152. return (AE_OK);
  153. }
  154. /*******************************************************************************
  155. *
  156. * FUNCTION: acpi_ds_initialize_objects
  157. *
  158. * PARAMETERS: table_desc - Descriptor for parent ACPI table
  159. * start_node - Root of subtree to be initialized.
  160. *
  161. * RETURN: Status
  162. *
  163. * DESCRIPTION: Walk the namespace starting at "start_node" and perform any
  164. * necessary initialization on the objects found therein
  165. *
  166. ******************************************************************************/
  167. acpi_status
  168. acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
  169. struct acpi_namespace_node * start_node)
  170. {
  171. acpi_status status;
  172. struct acpi_init_walk_info info;
  173. ACPI_FUNCTION_TRACE("ds_initialize_objects");
  174. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  175. "**** Starting initialization of namespace objects ****\n"));
  176. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
  177. info.method_count = 0;
  178. info.op_region_count = 0;
  179. info.object_count = 0;
  180. info.device_count = 0;
  181. info.table_desc = table_desc;
  182. /* Walk entire namespace from the supplied root */
  183. status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
  184. acpi_ds_init_one_object, &info, NULL);
  185. if (ACPI_FAILURE(status)) {
  186. ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
  187. }
  188. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
  189. "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
  190. table_desc->pointer->signature,
  191. table_desc->owner_id, info.object_count,
  192. info.device_count, info.method_count,
  193. info.op_region_count));
  194. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  195. "%hd Methods, %hd Regions\n", info.method_count,
  196. info.op_region_count));
  197. return_ACPI_STATUS(AE_OK);
  198. }