Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/namespace/nsload.c
+++ new/usr/src/common/acpica/components/namespace/nsload.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: nsload - namespace loading/expanding/contracting procedures
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __NSLOAD_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acnamesp.h"
49 49 #include "acdispat.h"
50 50 #include "actables.h"
51 51
52 52
53 53 #define _COMPONENT ACPI_NAMESPACE
54 54 ACPI_MODULE_NAME ("nsload")
55 55
56 56 /* Local prototypes */
57 57
58 58 #ifdef ACPI_FUTURE_IMPLEMENTATION
59 59 ACPI_STATUS
60 60 AcpiNsUnloadNamespace (
61 61 ACPI_HANDLE Handle);
62 62
63 63 static ACPI_STATUS
64 64 AcpiNsDeleteSubtree (
65 65 ACPI_HANDLE StartHandle);
66 66 #endif
67 67
68 68
69 69 #ifndef ACPI_NO_METHOD_EXECUTION
70 70 /*******************************************************************************
71 71 *
72 72 * FUNCTION: AcpiNsLoadTable
73 73 *
74 74 * PARAMETERS: TableIndex - Index for table to be loaded
75 75 * Node - Owning NS node
76 76 *
77 77 * RETURN: Status
78 78 *
79 79 * DESCRIPTION: Load one ACPI table into the namespace
80 80 *
81 81 ******************************************************************************/
82 82
83 83 ACPI_STATUS
84 84 AcpiNsLoadTable (
85 85 UINT32 TableIndex,
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
86 86 ACPI_NAMESPACE_NODE *Node)
87 87 {
88 88 ACPI_STATUS Status;
89 89
90 90
91 91 ACPI_FUNCTION_TRACE (NsLoadTable);
92 92
93 93
94 94 /*
95 95 * Parse the table and load the namespace with all named
96 - * objects found within. Control methods are NOT parsed
97 - * at this time. In fact, the control methods cannot be
96 + * objects found within. Control methods are NOT parsed
97 + * at this time. In fact, the control methods cannot be
98 98 * parsed until the entire namespace is loaded, because
99 99 * if a control method makes a forward reference (call)
100 100 * to another control method, we can't continue parsing
101 101 * because we don't know how many arguments to parse next!
102 102 */
103 103 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
104 104 if (ACPI_FAILURE (Status))
105 105 {
106 106 return_ACPI_STATUS (Status);
107 107 }
108 108
109 109 /* If table already loaded into namespace, just return */
110 110
111 111 if (AcpiTbIsTableLoaded (TableIndex))
112 112 {
113 113 Status = AE_ALREADY_EXISTS;
114 114 goto Unlock;
115 115 }
116 116
117 117 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
118 118 "**** Loading table into namespace ****\n"));
119 119
120 120 Status = AcpiTbAllocateOwnerId (TableIndex);
121 121 if (ACPI_FAILURE (Status))
122 122 {
123 123 goto Unlock;
124 124 }
125 125
126 126 Status = AcpiNsParseTable (TableIndex, Node);
127 127 if (ACPI_SUCCESS (Status))
128 128 {
129 129 AcpiTbSetTableLoadedFlag (TableIndex, TRUE);
130 130 }
131 131 else
132 132 {
133 133 (void) AcpiTbReleaseOwnerId (TableIndex);
134 134 }
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
135 135
136 136 Unlock:
137 137 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
138 138
139 139 if (ACPI_FAILURE (Status))
140 140 {
141 141 return_ACPI_STATUS (Status);
142 142 }
143 143
144 144 /*
145 - * Now we can parse the control methods. We always parse
145 + * Now we can parse the control methods. We always parse
146 146 * them here for a sanity check, and if configured for
147 147 * just-in-time parsing, we delete the control method
148 148 * parse trees.
149 149 */
150 150 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
151 151 "**** Begin Table Method Parsing and Object Initialization\n"));
152 152
153 153 Status = AcpiDsInitializeObjects (TableIndex, Node);
154 154
155 155 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
156 156 "**** Completed Table Method Parsing and Object Initialization\n"));
157 157
158 158 return_ACPI_STATUS (Status);
159 159 }
160 160
161 161
162 162 #ifdef ACPI_OBSOLETE_FUNCTIONS
163 163 /*******************************************************************************
164 164 *
165 165 * FUNCTION: AcpiLoadNamespace
166 166 *
167 167 * PARAMETERS: None
168 168 *
169 169 * RETURN: Status
170 170 *
171 171 * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
172 172 * (DSDT points to either the BIOS or a buffer.)
173 173 *
174 174 ******************************************************************************/
175 175
176 176 ACPI_STATUS
177 177 AcpiNsLoadNamespace (
178 178 void)
179 179 {
180 180 ACPI_STATUS Status;
181 181
182 182
183 183 ACPI_FUNCTION_TRACE (AcpiLoadNameSpace);
184 184
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
185 185
186 186 /* There must be at least a DSDT installed */
187 187
188 188 if (AcpiGbl_DSDT == NULL)
189 189 {
190 190 ACPI_ERROR ((AE_INFO, "DSDT is not in memory"));
191 191 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
192 192 }
193 193
194 194 /*
195 - * Load the namespace. The DSDT is required,
195 + * Load the namespace. The DSDT is required,
196 196 * but the SSDT and PSDT tables are optional.
197 197 */
198 198 Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT);
199 199 if (ACPI_FAILURE (Status))
200 200 {
201 201 return_ACPI_STATUS (Status);
202 202 }
203 203
204 204 /* Ignore exceptions from these */
205 205
206 206 (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT);
207 207 (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT);
208 208
209 209 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
210 210 "ACPI Namespace successfully loaded at root %p\n",
211 211 AcpiGbl_RootNode));
212 212
213 213 return_ACPI_STATUS (Status);
214 214 }
215 215 #endif
216 216
217 217 #ifdef ACPI_FUTURE_IMPLEMENTATION
218 218 /*******************************************************************************
219 219 *
220 220 * FUNCTION: AcpiNsDeleteSubtree
221 221 *
222 222 * PARAMETERS: StartHandle - Handle in namespace where search begins
223 223 *
224 224 * RETURNS Status
225 225 *
226 226 * DESCRIPTION: Walks the namespace starting at the given handle and deletes
227 227 * all objects, entries, and scopes in the entire subtree.
228 228 *
229 229 * Namespace/Interpreter should be locked or the subsystem should
230 230 * be in shutdown before this routine is called.
231 231 *
232 232 ******************************************************************************/
233 233
234 234 static ACPI_STATUS
235 235 AcpiNsDeleteSubtree (
236 236 ACPI_HANDLE StartHandle)
237 237 {
238 238 ACPI_STATUS Status;
239 239 ACPI_HANDLE ChildHandle;
240 240 ACPI_HANDLE ParentHandle;
241 241 ACPI_HANDLE NextChildHandle;
242 242 ACPI_HANDLE Dummy;
243 243 UINT32 Level;
244 244
245 245
246 246 ACPI_FUNCTION_TRACE (NsDeleteSubtree);
247 247
248 248
249 249 ParentHandle = StartHandle;
250 250 ChildHandle = NULL;
251 251 Level = 1;
252 252
253 253 /*
254 254 * Traverse the tree of objects until we bubble back up
255 255 * to where we started.
256 256 */
257 257 while (Level > 0)
258 258 {
259 259 /* Attempt to get the next object in this scope */
260 260
261 261 Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle,
262 262 ChildHandle, &NextChildHandle);
263 263
264 264 ChildHandle = NextChildHandle;
265 265
266 266 /* Did we get a new object? */
267 267
268 268 if (ACPI_SUCCESS (Status))
269 269 {
270 270 /* Check if this object has any children */
271 271
272 272 if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle,
273 273 NULL, &Dummy)))
274 274 {
275 275 /*
276 276 * There is at least one child of this object,
277 277 * visit the object
278 278 */
279 279 Level++;
280 280 ParentHandle = ChildHandle;
281 281 ChildHandle = NULL;
282 282 }
283 283 }
284 284 else
285 285 {
286 286 /*
287 287 * No more children in this object, go back up to
288 288 * the object's parent
289 289 */
290 290 Level--;
291 291
292 292 /* Delete all children now */
293 293
294 294 AcpiNsDeleteChildren (ChildHandle);
295 295
296 296 ChildHandle = ParentHandle;
297 297 Status = AcpiGetParent (ParentHandle, &ParentHandle);
298 298 if (ACPI_FAILURE (Status))
299 299 {
300 300 return_ACPI_STATUS (Status);
301 301 }
302 302 }
303 303 }
304 304
305 305 /* Now delete the starting object, and we are done */
306 306
307 307 AcpiNsRemoveNode (ChildHandle);
308 308 return_ACPI_STATUS (AE_OK);
309 309 }
310 310
↓ open down ↓ |
105 lines elided |
↑ open up ↑ |
311 311
312 312 /*******************************************************************************
313 313 *
314 314 * FUNCTION: AcpiNsUnloadNameSpace
315 315 *
316 316 * PARAMETERS: Handle - Root of namespace subtree to be deleted
317 317 *
318 318 * RETURN: Status
319 319 *
320 320 * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
321 - * event. Deletes an entire subtree starting from (and
321 + * event. Deletes an entire subtree starting from (and
322 322 * including) the given handle.
323 323 *
324 324 ******************************************************************************/
325 325
326 326 ACPI_STATUS
327 327 AcpiNsUnloadNamespace (
328 328 ACPI_HANDLE Handle)
329 329 {
330 330 ACPI_STATUS Status;
331 331
332 332
333 333 ACPI_FUNCTION_TRACE (NsUnloadNameSpace);
334 334
335 335
336 336 /* Parameter validation */
337 337
338 338 if (!AcpiGbl_RootNode)
339 339 {
340 340 return_ACPI_STATUS (AE_NO_NAMESPACE);
341 341 }
342 342
343 343 if (!Handle)
344 344 {
345 345 return_ACPI_STATUS (AE_BAD_PARAMETER);
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
346 346 }
347 347
348 348 /* This function does the real work */
349 349
350 350 Status = AcpiNsDeleteSubtree (Handle);
351 351
352 352 return_ACPI_STATUS (Status);
353 353 }
354 354 #endif
355 355 #endif
356 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX