Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/namespace/nsobject.c
+++ new/usr/src/common/acpica/components/namespace/nsobject.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: nsobject - Utilities for objects attached to namespace
4 4 * table entries
5 5 *
6 6 ******************************************************************************/
7 7
8 8 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
9 + * Copyright (C) 2000 - 2013, Intel Corp.
10 10 * All rights reserved.
11 11 *
12 12 * Redistribution and use in source and binary forms, with or without
13 13 * modification, are permitted provided that the following conditions
14 14 * are met:
15 15 * 1. Redistributions of source code must retain the above copyright
16 16 * notice, this list of conditions, and the following disclaimer,
17 17 * without modification.
18 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 19 * substantially similar to the "NO WARRANTY" disclaimer below
20 20 * ("Disclaimer") and any redistribution must be conditioned upon
21 21 * including a substantially similar Disclaimer requirement for further
22 22 * binary redistribution.
23 23 * 3. Neither the names of the above-listed copyright holders nor the names
24 24 * of any contributors may be used to endorse or promote products derived
25 25 * from this software without specific prior written permission.
26 26 *
27 27 * Alternatively, this software may be distributed under the terms of the
28 28 * GNU General Public License ("GPL") version 2 as published by the Free
29 29 * Software Foundation.
30 30 *
31 31 * NO WARRANTY
32 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 42 * POSSIBILITY OF SUCH DAMAGES.
43 43 */
44 44
45 45
46 46 #define __NSOBJECT_C__
47 47
48 48 #include "acpi.h"
49 49 #include "accommon.h"
50 50 #include "acnamesp.h"
51 51
52 52
53 53 #define _COMPONENT ACPI_NAMESPACE
54 54 ACPI_MODULE_NAME ("nsobject")
55 55
56 56
57 57 /*******************************************************************************
58 58 *
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
59 59 * FUNCTION: AcpiNsAttachObject
60 60 *
61 61 * PARAMETERS: Node - Parent Node
62 62 * Object - Object to be attached
63 63 * Type - Type of object, or ACPI_TYPE_ANY if not
64 64 * known
65 65 *
66 66 * RETURN: Status
67 67 *
68 68 * DESCRIPTION: Record the given object as the value associated with the
69 - * name whose ACPI_HANDLE is passed. If Object is NULL
69 + * name whose ACPI_HANDLE is passed. If Object is NULL
70 70 * and Type is ACPI_TYPE_ANY, set the name as having no value.
71 71 * Note: Future may require that the Node->Flags field be passed
72 72 * as a parameter.
73 73 *
74 74 * MUTEX: Assumes namespace is locked
75 75 *
76 76 ******************************************************************************/
77 77
78 78 ACPI_STATUS
79 79 AcpiNsAttachObject (
80 80 ACPI_NAMESPACE_NODE *Node,
81 81 ACPI_OPERAND_OBJECT *Object,
82 82 ACPI_OBJECT_TYPE Type)
83 83 {
84 84 ACPI_OPERAND_OBJECT *ObjDesc;
85 85 ACPI_OPERAND_OBJECT *LastObjDesc;
86 86 ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY;
87 87
88 88
89 89 ACPI_FUNCTION_TRACE (NsAttachObject);
90 90
91 91
92 92 /*
93 93 * Parameter validation
94 94 */
95 95 if (!Node)
96 96 {
97 97 /* Invalid handle */
98 98
99 99 ACPI_ERROR ((AE_INFO, "Null NamedObj handle"));
100 100 return_ACPI_STATUS (AE_BAD_PARAMETER);
101 101 }
102 102
103 103 if (!Object && (ACPI_TYPE_ANY != Type))
104 104 {
105 105 /* Null object */
106 106
107 107 ACPI_ERROR ((AE_INFO,
108 108 "Null object, but type not ACPI_TYPE_ANY"));
109 109 return_ACPI_STATUS (AE_BAD_PARAMETER);
110 110 }
111 111
112 112 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
113 113 {
114 114 /* Not a name handle */
115 115
116 116 ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]",
117 117 Node, AcpiUtGetDescriptorName (Node)));
118 118 return_ACPI_STATUS (AE_BAD_PARAMETER);
119 119 }
120 120
121 121 /* Check if this object is already attached */
122 122
123 123 if (Node->Object == Object)
124 124 {
125 125 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
126 126 "Obj %p already installed in NameObj %p\n",
127 127 Object, Node));
128 128
129 129 return_ACPI_STATUS (AE_OK);
130 130 }
131 131
132 132 /* If null object, we will just install it */
133 133
134 134 if (!Object)
135 135 {
136 136 ObjDesc = NULL;
137 137 ObjectType = ACPI_TYPE_ANY;
138 138 }
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
139 139
140 140 /*
141 141 * If the source object is a namespace Node with an attached object,
142 142 * we will use that (attached) object
143 143 */
144 144 else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) &&
145 145 ((ACPI_NAMESPACE_NODE *) Object)->Object)
146 146 {
147 147 /*
148 148 * Value passed is a name handle and that name has a
149 - * non-null value. Use that name's value and type.
149 + * non-null value. Use that name's value and type.
150 150 */
151 151 ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object;
152 152 ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type;
153 153 }
154 154
155 155 /*
156 156 * Otherwise, we will use the parameter object, but we must type
157 157 * it first
158 158 */
159 159 else
160 160 {
161 161 ObjDesc = (ACPI_OPERAND_OBJECT *) Object;
162 162
163 163 /* Use the given type */
164 164
165 165 ObjectType = Type;
166 166 }
167 167
168 168 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
169 169 ObjDesc, Node, AcpiUtGetNodeName (Node)));
170 170
171 171 /* Detach an existing attached object if present */
172 172
173 173 if (Node->Object)
174 174 {
175 175 AcpiNsDetachObject (Node);
176 176 }
177 177
178 178 if (ObjDesc)
179 179 {
180 180 /*
181 181 * Must increment the new value's reference count
182 182 * (if it is an internal object)
183 183 */
184 184 AcpiUtAddReference (ObjDesc);
185 185
186 186 /*
187 187 * Handle objects with multiple descriptors - walk
188 188 * to the end of the descriptor list
189 189 */
190 190 LastObjDesc = ObjDesc;
191 191 while (LastObjDesc->Common.NextObject)
192 192 {
193 193 LastObjDesc = LastObjDesc->Common.NextObject;
194 194 }
195 195
196 196 /* Install the object at the front of the object list */
197 197
198 198 LastObjDesc->Common.NextObject = Node->Object;
199 199 }
200 200
201 201 Node->Type = (UINT8) ObjectType;
202 202 Node->Object = ObjDesc;
203 203
204 204 return_ACPI_STATUS (AE_OK);
205 205 }
206 206
207 207
208 208 /*******************************************************************************
209 209 *
210 210 * FUNCTION: AcpiNsDetachObject
211 211 *
212 212 * PARAMETERS: Node - A Namespace node whose object will be detached
213 213 *
214 214 * RETURN: None.
215 215 *
216 216 * DESCRIPTION: Detach/delete an object associated with a namespace node.
217 217 * if the object is an allocated object, it is freed.
218 218 * Otherwise, the field is simply cleared.
219 219 *
220 220 ******************************************************************************/
221 221
222 222 void
223 223 AcpiNsDetachObject (
224 224 ACPI_NAMESPACE_NODE *Node)
225 225 {
226 226 ACPI_OPERAND_OBJECT *ObjDesc;
227 227
228 228
229 229 ACPI_FUNCTION_TRACE (NsDetachObject);
230 230
231 231
232 232 ObjDesc = Node->Object;
233 233
234 234 if (!ObjDesc ||
235 235 (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
236 236 {
237 237 return_VOID;
238 238 }
239 239
240 240 if (Node->Flags & ANOBJ_ALLOCATED_BUFFER)
241 241 {
242 242 /* Free the dynamic aml buffer */
243 243
244 244 if (ObjDesc->Common.Type == ACPI_TYPE_METHOD)
245 245 {
246 246 ACPI_FREE (ObjDesc->Method.AmlStart);
247 247 }
248 248 }
249 249
250 250 /* Clear the entry in all cases */
251 251
252 252 Node->Object = NULL;
253 253 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
254 254 {
255 255 Node->Object = ObjDesc->Common.NextObject;
256 256 if (Node->Object &&
257 257 ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA))
258 258 {
259 259 Node->Object = Node->Object->Common.NextObject;
260 260 }
261 261 }
262 262
263 263 /* Reset the node type to untyped */
264 264
265 265 Node->Type = ACPI_TYPE_ANY;
266 266
267 267 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
268 268 Node, AcpiUtGetNodeName (Node), ObjDesc));
269 269
270 270 /* Remove one reference on the object (and all subobjects) */
271 271
272 272 AcpiUtRemoveReference (ObjDesc);
273 273 return_VOID;
274 274 }
275 275
276 276
277 277 /*******************************************************************************
278 278 *
279 279 * FUNCTION: AcpiNsGetAttachedObject
280 280 *
281 281 * PARAMETERS: Node - Namespace node
282 282 *
283 283 * RETURN: Current value of the object field from the Node whose
284 284 * handle is passed
285 285 *
286 286 * DESCRIPTION: Obtain the object attached to a namespace node.
287 287 *
288 288 ******************************************************************************/
289 289
290 290 ACPI_OPERAND_OBJECT *
291 291 AcpiNsGetAttachedObject (
292 292 ACPI_NAMESPACE_NODE *Node)
293 293 {
294 294 ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node);
295 295
296 296
297 297 if (!Node)
298 298 {
299 299 ACPI_WARNING ((AE_INFO, "Null Node ptr"));
300 300 return_PTR (NULL);
301 301 }
302 302
303 303 if (!Node->Object ||
304 304 ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) &&
305 305 (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) ||
306 306 ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA))
307 307 {
308 308 return_PTR (NULL);
309 309 }
310 310
311 311 return_PTR (Node->Object);
312 312 }
313 313
314 314
315 315 /*******************************************************************************
316 316 *
317 317 * FUNCTION: AcpiNsGetSecondaryObject
318 318 *
319 319 * PARAMETERS: Node - Namespace node
320 320 *
321 321 * RETURN: Current value of the object field from the Node whose
322 322 * handle is passed.
323 323 *
324 324 * DESCRIPTION: Obtain a secondary object associated with a namespace node.
325 325 *
326 326 ******************************************************************************/
327 327
328 328 ACPI_OPERAND_OBJECT *
329 329 AcpiNsGetSecondaryObject (
330 330 ACPI_OPERAND_OBJECT *ObjDesc)
331 331 {
332 332 ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);
333 333
334 334
335 335 if ((!ObjDesc) ||
336 336 (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) ||
337 337 (!ObjDesc->Common.NextObject) ||
338 338 ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
339 339 {
340 340 return_PTR (NULL);
341 341 }
342 342
343 343 return_PTR (ObjDesc->Common.NextObject);
344 344 }
345 345
346 346
↓ open down ↓ |
187 lines elided |
↑ open up ↑ |
347 347 /*******************************************************************************
348 348 *
349 349 * FUNCTION: AcpiNsAttachData
350 350 *
351 351 * PARAMETERS: Node - Namespace node
352 352 * Handler - Handler to be associated with the data
353 353 * Data - Data to be attached
354 354 *
355 355 * RETURN: Status
356 356 *
357 - * DESCRIPTION: Low-level attach data. Create and attach a Data object.
357 + * DESCRIPTION: Low-level attach data. Create and attach a Data object.
358 358 *
359 359 ******************************************************************************/
360 360
361 361 ACPI_STATUS
362 362 AcpiNsAttachData (
363 363 ACPI_NAMESPACE_NODE *Node,
364 364 ACPI_OBJECT_HANDLER Handler,
365 365 void *Data)
366 366 {
367 367 ACPI_OPERAND_OBJECT *PrevObjDesc;
368 368 ACPI_OPERAND_OBJECT *ObjDesc;
369 369 ACPI_OPERAND_OBJECT *DataDesc;
370 370
371 371
372 372 /* We only allow one attachment per handler */
373 373
374 374 PrevObjDesc = NULL;
375 375 ObjDesc = Node->Object;
376 376 while (ObjDesc)
377 377 {
378 378 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
379 379 (ObjDesc->Data.Handler == Handler))
380 380 {
381 381 return (AE_ALREADY_EXISTS);
382 382 }
383 383
384 384 PrevObjDesc = ObjDesc;
385 385 ObjDesc = ObjDesc->Common.NextObject;
386 386 }
387 387
388 388 /* Create an internal object for the data */
389 389
390 390 DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA);
391 391 if (!DataDesc)
392 392 {
393 393 return (AE_NO_MEMORY);
394 394 }
395 395
396 396 DataDesc->Data.Handler = Handler;
397 397 DataDesc->Data.Pointer = Data;
398 398
399 399 /* Install the data object */
400 400
401 401 if (PrevObjDesc)
402 402 {
403 403 PrevObjDesc->Common.NextObject = DataDesc;
404 404 }
405 405 else
406 406 {
407 407 Node->Object = DataDesc;
408 408 }
409 409
410 410 return (AE_OK);
411 411 }
412 412
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
413 413
414 414 /*******************************************************************************
415 415 *
416 416 * FUNCTION: AcpiNsDetachData
417 417 *
418 418 * PARAMETERS: Node - Namespace node
419 419 * Handler - Handler associated with the data
420 420 *
421 421 * RETURN: Status
422 422 *
423 - * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
423 + * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
424 424 * is responsible for the actual data.
425 425 *
426 426 ******************************************************************************/
427 427
428 428 ACPI_STATUS
429 429 AcpiNsDetachData (
430 430 ACPI_NAMESPACE_NODE *Node,
431 431 ACPI_OBJECT_HANDLER Handler)
432 432 {
433 433 ACPI_OPERAND_OBJECT *ObjDesc;
434 434 ACPI_OPERAND_OBJECT *PrevObjDesc;
435 435
436 436
437 437 PrevObjDesc = NULL;
438 438 ObjDesc = Node->Object;
439 439 while (ObjDesc)
440 440 {
441 441 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
442 442 (ObjDesc->Data.Handler == Handler))
443 443 {
444 444 if (PrevObjDesc)
445 445 {
446 446 PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
447 447 }
448 448 else
449 449 {
450 450 Node->Object = ObjDesc->Common.NextObject;
451 451 }
452 452
453 453 AcpiUtRemoveReference (ObjDesc);
454 454 return (AE_OK);
455 455 }
456 456
457 457 PrevObjDesc = ObjDesc;
458 458 ObjDesc = ObjDesc->Common.NextObject;
459 459 }
460 460
461 461 return (AE_NOT_FOUND);
462 462 }
463 463
464 464
465 465 /*******************************************************************************
466 466 *
467 467 * FUNCTION: AcpiNsGetAttachedData
468 468 *
469 469 * PARAMETERS: Node - Namespace node
470 470 * Handler - Handler associated with the data
471 471 * Data - Where the data is returned
472 472 *
473 473 * RETURN: Status
474 474 *
475 475 * DESCRIPTION: Low level interface to obtain data previously associated with
476 476 * a namespace node.
477 477 *
478 478 ******************************************************************************/
479 479
480 480 ACPI_STATUS
481 481 AcpiNsGetAttachedData (
482 482 ACPI_NAMESPACE_NODE *Node,
483 483 ACPI_OBJECT_HANDLER Handler,
484 484 void **Data)
485 485 {
486 486 ACPI_OPERAND_OBJECT *ObjDesc;
487 487
488 488
489 489 ObjDesc = Node->Object;
490 490 while (ObjDesc)
491 491 {
492 492 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
493 493 (ObjDesc->Data.Handler == Handler))
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
494 494 {
495 495 *Data = ObjDesc->Data.Pointer;
496 496 return (AE_OK);
497 497 }
498 498
499 499 ObjDesc = ObjDesc->Common.NextObject;
500 500 }
501 501
502 502 return (AE_NOT_FOUND);
503 503 }
504 -
505 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX