dsinit.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: dsinit - Object initialization namespace walk
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer #define __DSINIT_C__
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "acpi.h"
47 1.1.1.2.2.2 bouyer #include "accommon.h"
48 1.1.1.2.2.2 bouyer #include "acdispat.h"
49 1.1.1.2.2.2 bouyer #include "acnamesp.h"
50 1.1.1.2.2.2 bouyer #include "actables.h"
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_DISPATCHER
53 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("dsinit")
54 1.1.1.2.2.2 bouyer
55 1.1.1.2.2.2 bouyer /* Local prototypes */
56 1.1.1.2.2.2 bouyer
57 1.1.1.2.2.2 bouyer static ACPI_STATUS
58 1.1.1.2.2.2 bouyer AcpiDsInitOneObject (
59 1.1.1.2.2.2 bouyer ACPI_HANDLE ObjHandle,
60 1.1.1.2.2.2 bouyer UINT32 Level,
61 1.1.1.2.2.2 bouyer void *Context,
62 1.1.1.2.2.2 bouyer void **ReturnValue);
63 1.1.1.2.2.2 bouyer
64 1.1.1.2.2.2 bouyer
65 1.1.1.2.2.2 bouyer /*******************************************************************************
66 1.1.1.2.2.2 bouyer *
67 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsInitOneObject
68 1.1.1.2.2.2 bouyer *
69 1.1.1.2.2.2 bouyer * PARAMETERS: ObjHandle - Node for the object
70 1.1.1.2.2.2 bouyer * Level - Current nesting level
71 1.1.1.2.2.2 bouyer * Context - Points to a init info struct
72 1.1.1.2.2.2 bouyer * ReturnValue - Not used
73 1.1.1.2.2.2 bouyer *
74 1.1.1.2.2.2 bouyer * RETURN: Status
75 1.1.1.2.2.2 bouyer *
76 1.1.1.2.2.2 bouyer * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
77 1.1.1.2.2.2 bouyer * within the namespace.
78 1.1.1.2.2.2 bouyer *
79 1.1.1.2.2.2 bouyer * Currently, the only objects that require initialization are:
80 1.1.1.2.2.2 bouyer * 1) Methods
81 1.1.1.2.2.2 bouyer * 2) Operation Regions
82 1.1.1.2.2.2 bouyer *
83 1.1.1.2.2.2 bouyer ******************************************************************************/
84 1.1.1.2.2.2 bouyer
85 1.1.1.2.2.2 bouyer static ACPI_STATUS
86 1.1.1.2.2.2 bouyer AcpiDsInitOneObject (
87 1.1.1.2.2.2 bouyer ACPI_HANDLE ObjHandle,
88 1.1.1.2.2.2 bouyer UINT32 Level,
89 1.1.1.2.2.2 bouyer void *Context,
90 1.1.1.2.2.2 bouyer void **ReturnValue)
91 1.1.1.2.2.2 bouyer {
92 1.1.1.2.2.2 bouyer ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
93 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
94 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE Type;
95 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer
98 1.1.1.2.2.2 bouyer ACPI_FUNCTION_ENTRY ();
99 1.1.1.2.2.2 bouyer
100 1.1.1.2.2.2 bouyer
101 1.1.1.2.2.2 bouyer /*
102 1.1.1.2.2.2 bouyer * We are only interested in NS nodes owned by the table that
103 1.1.1.2.2.2 bouyer * was just loaded
104 1.1.1.2.2.2 bouyer */
105 1.1.1.2.2.2 bouyer if (Node->OwnerId != Info->OwnerId)
106 1.1.1.2.2.2 bouyer {
107 1.1.1.2.2.2 bouyer return (AE_OK);
108 1.1.1.2.2.2 bouyer }
109 1.1.1.2.2.2 bouyer
110 1.1.1.2.2.2 bouyer Info->ObjectCount++;
111 1.1.1.2.2.2 bouyer
112 1.1.1.2.2.2 bouyer /* And even then, we are only interested in a few object types */
113 1.1.1.2.2.2 bouyer
114 1.1.1.2.2.2 bouyer Type = AcpiNsGetType (ObjHandle);
115 1.1.1.2.2.2 bouyer
116 1.1.1.2.2.2 bouyer switch (Type)
117 1.1.1.2.2.2 bouyer {
118 1.1.1.2.2.2 bouyer case ACPI_TYPE_REGION:
119 1.1.1.2.2.2 bouyer
120 1.1.1.2.2.2 bouyer Status = AcpiDsInitializeRegion (ObjHandle);
121 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
122 1.1.1.2.2.2 bouyer {
123 1.1.1.2.2.2 bouyer ACPI_EXCEPTION ((AE_INFO, Status,
124 1.1.1.2.2.2 bouyer "During Region initialization %p [%4.4s]",
125 1.1.1.2.2.2 bouyer ObjHandle, AcpiUtGetNodeName (ObjHandle)));
126 1.1.1.2.2.2 bouyer }
127 1.1.1.2.2.2 bouyer
128 1.1.1.2.2.2 bouyer Info->OpRegionCount++;
129 1.1.1.2.2.2 bouyer break;
130 1.1.1.2.2.2 bouyer
131 1.1.1.2.2.2 bouyer
132 1.1.1.2.2.2 bouyer case ACPI_TYPE_METHOD:
133 1.1.1.2.2.2 bouyer
134 1.1.1.2.2.2 bouyer Info->MethodCount++;
135 1.1.1.2.2.2 bouyer break;
136 1.1.1.2.2.2 bouyer
137 1.1.1.2.2.2 bouyer
138 1.1.1.2.2.2 bouyer case ACPI_TYPE_DEVICE:
139 1.1.1.2.2.2 bouyer
140 1.1.1.2.2.2 bouyer Info->DeviceCount++;
141 1.1.1.2.2.2 bouyer break;
142 1.1.1.2.2.2 bouyer
143 1.1.1.2.2.2 bouyer
144 1.1.1.2.2.2 bouyer default:
145 1.1.1.2.2.2 bouyer break;
146 1.1.1.2.2.2 bouyer }
147 1.1.1.2.2.2 bouyer
148 1.1.1.2.2.2 bouyer /*
149 1.1.1.2.2.2 bouyer * We ignore errors from above, and always return OK, since
150 1.1.1.2.2.2 bouyer * we don't want to abort the walk on a single error.
151 1.1.1.2.2.2 bouyer */
152 1.1.1.2.2.2 bouyer return (AE_OK);
153 1.1.1.2.2.2 bouyer }
154 1.1.1.2.2.2 bouyer
155 1.1.1.2.2.2 bouyer
156 1.1.1.2.2.2 bouyer /*******************************************************************************
157 1.1.1.2.2.2 bouyer *
158 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsInitializeObjects
159 1.1.1.2.2.2 bouyer *
160 1.1.1.2.2.2 bouyer * PARAMETERS: TableDesc - Descriptor for parent ACPI table
161 1.1.1.2.2.2 bouyer * StartNode - Root of subtree to be initialized.
162 1.1.1.2.2.2 bouyer *
163 1.1.1.2.2.2 bouyer * RETURN: Status
164 1.1.1.2.2.2 bouyer *
165 1.1.1.2.2.2 bouyer * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
166 1.1.1.2.2.2 bouyer * necessary initialization on the objects found therein
167 1.1.1.2.2.2 bouyer *
168 1.1.1.2.2.2 bouyer ******************************************************************************/
169 1.1.1.2.2.2 bouyer
170 1.1.1.2.2.2 bouyer ACPI_STATUS
171 1.1.1.2.2.2 bouyer AcpiDsInitializeObjects (
172 1.1.1.2.2.2 bouyer UINT32 TableIndex,
173 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *StartNode)
174 1.1.1.2.2.2 bouyer {
175 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
176 1.1.1.2.2.2 bouyer ACPI_INIT_WALK_INFO Info;
177 1.1.1.2.2.2 bouyer ACPI_TABLE_HEADER *Table;
178 1.1.1.2.2.2 bouyer ACPI_OWNER_ID OwnerId;
179 1.1.1.2.2.2 bouyer
180 1.1.1.2.2.2 bouyer
181 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (DsInitializeObjects);
182 1.1.1.2.2.2 bouyer
183 1.1.1.2.2.2 bouyer
184 1.1.1.2.2.2 bouyer Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
185 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
186 1.1.1.2.2.2 bouyer {
187 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
188 1.1.1.2.2.2 bouyer }
189 1.1.1.2.2.2 bouyer
190 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
191 1.1.1.2.2.2 bouyer "**** Starting initialization of namespace objects ****\n"));
192 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
193 1.1.1.2.2.2 bouyer
194 1.1.1.2.2.2 bouyer /* Set all init info to zero */
195 1.1.1.2.2.2 bouyer
196 1.1.1.2.2.2 bouyer ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
197 1.1.1.2.2.2 bouyer
198 1.1.1.2.2.2 bouyer Info.OwnerId = OwnerId;
199 1.1.1.2.2.2 bouyer Info.TableIndex = TableIndex;
200 1.1.1.2.2.2 bouyer
201 1.1.1.2.2.2 bouyer /* Walk entire namespace from the supplied root */
202 1.1.1.2.2.2 bouyer
203 1.1.1.2.2.2 bouyer Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
204 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
205 1.1.1.2.2.2 bouyer {
206 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
207 1.1.1.2.2.2 bouyer }
208 1.1.1.2.2.2 bouyer
209 1.1.1.2.2.2 bouyer /*
210 1.1.1.2.2.2 bouyer * We don't use AcpiWalkNamespace since we do not want to acquire
211 1.1.1.2.2.2 bouyer * the namespace reader lock.
212 1.1.1.2.2.2 bouyer */
213 1.1.1.2.2.2 bouyer Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX,
214 1.1.1.2.2.2 bouyer ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL);
215 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
216 1.1.1.2.2.2 bouyer {
217 1.1.1.2.2.2 bouyer ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
218 1.1.1.2.2.2 bouyer }
219 1.1.1.2.2.2 bouyer (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
220 1.1.1.2.2.2 bouyer
221 1.1.1.2.2.2 bouyer Status = AcpiGetTableByIndex (TableIndex, &Table);
222 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
223 1.1.1.2.2.2 bouyer {
224 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
225 1.1.1.2.2.2 bouyer }
226 1.1.1.2.2.2 bouyer
227 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
228 1.1.1.2.2.2 bouyer "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n",
229 1.1.1.2.2.2 bouyer Table->Signature, OwnerId, Info.ObjectCount,
230 1.1.1.2.2.2 bouyer Info.DeviceCount, Info.MethodCount, Info.OpRegionCount));
231 1.1.1.2.2.2 bouyer
232 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
233 1.1.1.2.2.2 bouyer "%u Methods, %u Regions\n", Info.MethodCount, Info.OpRegionCount));
234 1.1.1.2.2.2 bouyer
235 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
236 1.1.1.2.2.2 bouyer }
237 1.1.1.2.2.2 bouyer
238 1.1.1.2.2.2 bouyer
239