dsinit.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. info->method_count++;
  104. break;
  105. case ACPI_TYPE_DEVICE:
  106. info->device_count++;
  107. break;
  108. default:
  109. break;
  110. }
  111. /*
  112. * We ignore errors from above, and always return OK, since
  113. * we don't want to abort the walk on a single error.
  114. */
  115. return (AE_OK);
  116. }
  117. /*******************************************************************************
  118. *
  119. * FUNCTION: acpi_ds_initialize_objects
  120. *
  121. * PARAMETERS: table_desc - Descriptor for parent ACPI table
  122. * start_node - Root of subtree to be initialized.
  123. *
  124. * RETURN: Status
  125. *
  126. * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
  127. * necessary initialization on the objects found therein
  128. *
  129. ******************************************************************************/
  130. acpi_status
  131. acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
  132. struct acpi_namespace_node * start_node)
  133. {
  134. acpi_status status;
  135. struct acpi_init_walk_info info;
  136. ACPI_FUNCTION_TRACE(ds_initialize_objects);
  137. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  138. "**** Starting initialization of namespace objects ****\n"));
  139. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
  140. info.method_count = 0;
  141. info.op_region_count = 0;
  142. info.object_count = 0;
  143. info.device_count = 0;
  144. info.table_desc = table_desc;
  145. /* Walk entire namespace from the supplied root */
  146. status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
  147. acpi_ds_init_one_object, &info, NULL);
  148. if (ACPI_FAILURE(status)) {
  149. ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
  150. }
  151. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
  152. "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
  153. table_desc->pointer->signature,
  154. table_desc->owner_id, info.object_count,
  155. info.device_count, info.method_count,
  156. info.op_region_count));
  157. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  158. "%hd Methods, %hd Regions\n", info.method_count,
  159. info.op_region_count));
  160. return_ACPI_STATUS(AE_OK);
  161. }