dsinit.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /******************************************************************************
  2. *
  3. * Module Name: dsinit - Object initialization namespace walk
  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/acdispat.h>
  44. #include <acpi/acnamesp.h>
  45. #include <acpi/actables.h>
  46. #define _COMPONENT ACPI_DISPATCHER
  47. ACPI_MODULE_NAME("dsinit")
  48. /* Local prototypes */
  49. static acpi_status
  50. acpi_ds_init_one_object(acpi_handle obj_handle,
  51. u32 level, void *context, void **return_value);
  52. /*******************************************************************************
  53. *
  54. * FUNCTION: acpi_ds_init_one_object
  55. *
  56. * PARAMETERS: obj_handle - Node for the object
  57. * Level - Current nesting level
  58. * Context - Points to a init info struct
  59. * return_value - Not used
  60. *
  61. * RETURN: Status
  62. *
  63. * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
  64. * within the namespace.
  65. *
  66. * Currently, the only objects that require initialization are:
  67. * 1) Methods
  68. * 2) Operation Regions
  69. *
  70. ******************************************************************************/
  71. static acpi_status
  72. acpi_ds_init_one_object(acpi_handle obj_handle,
  73. u32 level, void *context, void **return_value)
  74. {
  75. struct acpi_init_walk_info *info =
  76. (struct acpi_init_walk_info *)context;
  77. struct acpi_namespace_node *node =
  78. (struct acpi_namespace_node *)obj_handle;
  79. acpi_object_type type;
  80. acpi_status status;
  81. ACPI_FUNCTION_ENTRY();
  82. /*
  83. * We are only interested in NS nodes owned by the table that
  84. * was just loaded
  85. */
  86. if (node->owner_id != info->owner_id) {
  87. return (AE_OK);
  88. }
  89. info->object_count++;
  90. /* And even then, we are only interested in a few object types */
  91. type = acpi_ns_get_type(obj_handle);
  92. switch (type) {
  93. case ACPI_TYPE_REGION:
  94. status = acpi_ds_initialize_region(obj_handle);
  95. if (ACPI_FAILURE(status)) {
  96. ACPI_EXCEPTION((AE_INFO, status,
  97. "During Region initialization %p [%4.4s]",
  98. obj_handle,
  99. acpi_ut_get_node_name(obj_handle)));
  100. }
  101. info->op_region_count++;
  102. break;
  103. case ACPI_TYPE_METHOD:
  104. info->method_count++;
  105. break;
  106. case ACPI_TYPE_DEVICE:
  107. info->device_count++;
  108. break;
  109. default:
  110. break;
  111. }
  112. /*
  113. * We ignore errors from above, and always return OK, since
  114. * we don't want to abort the walk on a single error.
  115. */
  116. return (AE_OK);
  117. }
  118. /*******************************************************************************
  119. *
  120. * FUNCTION: acpi_ds_initialize_objects
  121. *
  122. * PARAMETERS: table_desc - Descriptor for parent ACPI table
  123. * start_node - Root of subtree to be initialized.
  124. *
  125. * RETURN: Status
  126. *
  127. * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
  128. * necessary initialization on the objects found therein
  129. *
  130. ******************************************************************************/
  131. acpi_status
  132. acpi_ds_initialize_objects(u32 table_index,
  133. struct acpi_namespace_node * start_node)
  134. {
  135. acpi_status status;
  136. struct acpi_init_walk_info info;
  137. struct acpi_table_header *table;
  138. acpi_owner_id owner_id;
  139. ACPI_FUNCTION_TRACE(ds_initialize_objects);
  140. status = acpi_tb_get_owner_id(table_index, &owner_id);
  141. if (ACPI_FAILURE(status)) {
  142. return_ACPI_STATUS(status);
  143. }
  144. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  145. "**** Starting initialization of namespace objects ****\n"));
  146. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
  147. info.method_count = 0;
  148. info.op_region_count = 0;
  149. info.object_count = 0;
  150. info.device_count = 0;
  151. info.table_index = table_index;
  152. info.owner_id = owner_id;
  153. /* Walk entire namespace from the supplied root */
  154. status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
  155. acpi_ds_init_one_object, &info, NULL);
  156. if (ACPI_FAILURE(status)) {
  157. ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
  158. }
  159. status = acpi_get_table_by_index(table_index, &table);
  160. if (ACPI_FAILURE(status)) {
  161. return_ACPI_STATUS(status);
  162. }
  163. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
  164. "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
  165. table->signature, owner_id, info.object_count,
  166. info.device_count, info.method_count,
  167. info.op_region_count));
  168. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  169. "%hd Methods, %hd Regions\n", info.method_count,
  170. info.op_region_count));
  171. return_ACPI_STATUS(AE_OK);
  172. }