|
||||
Warning, cross-references for /kernel/drivers/acpica/nsobject.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: nsobject - Utilities for objects attached to namespace 0004 * table entries 0005 * 0006 ******************************************************************************/ 0007 0008 /****************************************************************************** 0009 * 0010 * 1. Copyright Notice 0011 * 0012 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0013 * All rights reserved. 0014 * 0015 * 2. License 0016 * 0017 * 2.1. This is your license from Intel Corp. under its intellectual property 0018 * rights. You may have additional license terms from the party that provided 0019 * you this software, covering your right to use that party's intellectual 0020 * property rights. 0021 * 0022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0023 * copy of the source code appearing in this file ("Covered Code") an 0024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0025 * base code distributed originally by Intel ("Original Intel Code") to copy, 0026 * make derivatives, distribute, use and display any portion of the Covered 0027 * Code in any form, with the right to sublicense such rights; and 0028 * 0029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0030 * license (with the right to sublicense), under only those claims of Intel 0031 * patents that are infringed by the Original Intel Code, to make, use, sell, 0032 * offer to sell, and import the Covered Code and derivative works thereof 0033 * solely to the minimum extent necessary to exercise the above copyright 0034 * license, and in no event shall the patent license extend to any additions 0035 * to or modifications of the Original Intel Code. No other license or right 0036 * is granted directly or by implication, estoppel or otherwise; 0037 * 0038 * The above copyright and patent license is granted only if the following 0039 * conditions are met: 0040 * 0041 * 3. Conditions 0042 * 0043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0044 * Redistribution of source code of any substantial portion of the Covered 0045 * Code or modification with rights to further distribute source must include 0046 * the above Copyright Notice, the above License, this list of Conditions, 0047 * and the following Disclaimer and Export Compliance provision. In addition, 0048 * Licensee must cause all Covered Code to which Licensee contributes to 0049 * contain a file documenting the changes Licensee made to create that Covered 0050 * Code and the date of any change. Licensee must include in that file the 0051 * documentation of any changes made by any predecessor Licensee. Licensee 0052 * must include a prominent statement that the modification is derived, 0053 * directly or indirectly, from Original Intel Code. 0054 * 0055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0056 * Redistribution of source code of any substantial portion of the Covered 0057 * Code or modification without rights to further distribute source must 0058 * include the following Disclaimer and Export Compliance provision in the 0059 * documentation and/or other materials provided with distribution. In 0060 * addition, Licensee may not authorize further sublicense of source of any 0061 * portion of the Covered Code, and must include terms to the effect that the 0062 * license from Licensee to its licensee is limited to the intellectual 0063 * property embodied in the software Licensee provides to its licensee, and 0064 * not to intellectual property embodied in modifications its licensee may 0065 * make. 0066 * 0067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0068 * substantial portion of the Covered Code or modification must reproduce the 0069 * above Copyright Notice, and the following Disclaimer and Export Compliance 0070 * provision in the documentation and/or other materials provided with the 0071 * distribution. 0072 * 0073 * 3.4. Intel retains all right, title, and interest in and to the Original 0074 * Intel Code. 0075 * 0076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0077 * Intel shall be used in advertising or otherwise to promote the sale, use or 0078 * other dealings in products derived from or relating to the Covered Code 0079 * without prior written authorization from Intel. 0080 * 0081 * 4. Disclaimer and Export Compliance 0082 * 0083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0089 * PARTICULAR PURPOSE. 0090 * 0091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0098 * LIMITED REMEDY. 0099 * 0100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0101 * software or system incorporating such software without first obtaining any 0102 * required license or other approval from the U. S. Department of Commerce or 0103 * any other agency or department of the United States Government. In the 0104 * event Licensee exports any such software from the United States or 0105 * re-exports any such software from a foreign destination, Licensee shall 0106 * ensure that the distribution and export/re-export of the software is in 0107 * compliance with all laws, regulations, orders, or other restrictions of the 0108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0109 * any of its subsidiaries will export/re-export any technical data, process, 0110 * software, or service, directly or indirectly, to any country for which the 0111 * United States government or any agency thereof requires an export license, 0112 * other governmental approval, or letter of assurance, without first obtaining 0113 * such license, approval or letter. 0114 * 0115 *****************************************************************************/ 0116 0117 0118 #define __NSOBJECT_C__ 0119 0120 #include "acpi.h" 0121 #include "accommon.h" 0122 #include "acnamesp.h" 0123 0124 0125 #define _COMPONENT ACPI_NAMESPACE 0126 ACPI_MODULE_NAME ("nsobject") 0127 0128 0129 /******************************************************************************* 0130 * 0131 * FUNCTION: AcpiNsAttachObject 0132 * 0133 * PARAMETERS: Node - Parent Node 0134 * Object - Object to be attached 0135 * Type - Type of object, or ACPI_TYPE_ANY if not 0136 * known 0137 * 0138 * RETURN: Status 0139 * 0140 * DESCRIPTION: Record the given object as the value associated with the 0141 * name whose ACPI_HANDLE is passed. If Object is NULL 0142 * and Type is ACPI_TYPE_ANY, set the name as having no value. 0143 * Note: Future may require that the Node->Flags field be passed 0144 * as a parameter. 0145 * 0146 * MUTEX: Assumes namespace is locked 0147 * 0148 ******************************************************************************/ 0149 0150 ACPI_STATUS 0151 AcpiNsAttachObject ( 0152 ACPI_NAMESPACE_NODE *Node, 0153 ACPI_OPERAND_OBJECT *Object, 0154 ACPI_OBJECT_TYPE Type) 0155 { 0156 ACPI_OPERAND_OBJECT *ObjDesc; 0157 ACPI_OPERAND_OBJECT *LastObjDesc; 0158 ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; 0159 0160 0161 ACPI_FUNCTION_TRACE (NsAttachObject); 0162 0163 0164 /* 0165 * Parameter validation 0166 */ 0167 if (!Node) 0168 { 0169 /* Invalid handle */ 0170 0171 ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); 0172 return_ACPI_STATUS (AE_BAD_PARAMETER); 0173 } 0174 0175 if (!Object && (ACPI_TYPE_ANY != Type)) 0176 { 0177 /* Null object */ 0178 0179 ACPI_ERROR ((AE_INFO, 0180 "Null object, but type not ACPI_TYPE_ANY")); 0181 return_ACPI_STATUS (AE_BAD_PARAMETER); 0182 } 0183 0184 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 0185 { 0186 /* Not a name handle */ 0187 0188 ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", 0189 Node, AcpiUtGetDescriptorName (Node))); 0190 return_ACPI_STATUS (AE_BAD_PARAMETER); 0191 } 0192 0193 /* Check if this object is already attached */ 0194 0195 if (Node->Object == Object) 0196 { 0197 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 0198 "Obj %p already installed in NameObj %p\n", 0199 Object, Node)); 0200 0201 return_ACPI_STATUS (AE_OK); 0202 } 0203 0204 /* If null object, we will just install it */ 0205 0206 if (!Object) 0207 { 0208 ObjDesc = NULL; 0209 ObjectType = ACPI_TYPE_ANY; 0210 } 0211 0212 /* 0213 * If the source object is a namespace Node with an attached object, 0214 * we will use that (attached) object 0215 */ 0216 else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && 0217 ((ACPI_NAMESPACE_NODE *) Object)->Object) 0218 { 0219 /* 0220 * Value passed is a name handle and that name has a 0221 * non-null value. Use that name's value and type. 0222 */ 0223 ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; 0224 ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; 0225 } 0226 0227 /* 0228 * Otherwise, we will use the parameter object, but we must type 0229 * it first 0230 */ 0231 else 0232 { 0233 ObjDesc = (ACPI_OPERAND_OBJECT *) Object; 0234 0235 /* Use the given type */ 0236 0237 ObjectType = Type; 0238 } 0239 0240 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", 0241 ObjDesc, Node, AcpiUtGetNodeName (Node))); 0242 0243 /* Detach an existing attached object if present */ 0244 0245 if (Node->Object) 0246 { 0247 AcpiNsDetachObject (Node); 0248 } 0249 0250 if (ObjDesc) 0251 { 0252 /* 0253 * Must increment the new value's reference count 0254 * (if it is an internal object) 0255 */ 0256 AcpiUtAddReference (ObjDesc); 0257 0258 /* 0259 * Handle objects with multiple descriptors - walk 0260 * to the end of the descriptor list 0261 */ 0262 LastObjDesc = ObjDesc; 0263 while (LastObjDesc->Common.NextObject) 0264 { 0265 LastObjDesc = LastObjDesc->Common.NextObject; 0266 } 0267 0268 /* Install the object at the front of the object list */ 0269 0270 LastObjDesc->Common.NextObject = Node->Object; 0271 } 0272 0273 Node->Type = (UINT8) ObjectType; 0274 Node->Object = ObjDesc; 0275 0276 return_ACPI_STATUS (AE_OK); 0277 } 0278 0279 0280 /******************************************************************************* 0281 * 0282 * FUNCTION: AcpiNsDetachObject 0283 * 0284 * PARAMETERS: Node - A Namespace node whose object will be detached 0285 * 0286 * RETURN: None. 0287 * 0288 * DESCRIPTION: Detach/delete an object associated with a namespace node. 0289 * if the object is an allocated object, it is freed. 0290 * Otherwise, the field is simply cleared. 0291 * 0292 ******************************************************************************/ 0293 0294 void 0295 AcpiNsDetachObject ( 0296 ACPI_NAMESPACE_NODE *Node) 0297 { 0298 ACPI_OPERAND_OBJECT *ObjDesc; 0299 0300 0301 ACPI_FUNCTION_TRACE (NsDetachObject); 0302 0303 0304 ObjDesc = Node->Object; 0305 0306 if (!ObjDesc || 0307 (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) 0308 { 0309 return_VOID; 0310 } 0311 0312 if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) 0313 { 0314 /* Free the dynamic aml buffer */ 0315 0316 if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) 0317 { 0318 ACPI_FREE (ObjDesc->Method.AmlStart); 0319 } 0320 } 0321 0322 /* Clear the entry in all cases */ 0323 0324 Node->Object = NULL; 0325 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) 0326 { 0327 Node->Object = ObjDesc->Common.NextObject; 0328 if (Node->Object && 0329 ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) 0330 { 0331 Node->Object = Node->Object->Common.NextObject; 0332 } 0333 } 0334 0335 /* Reset the node type to untyped */ 0336 0337 Node->Type = ACPI_TYPE_ANY; 0338 0339 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", 0340 Node, AcpiUtGetNodeName (Node), ObjDesc)); 0341 0342 /* Remove one reference on the object (and all subobjects) */ 0343 0344 AcpiUtRemoveReference (ObjDesc); 0345 return_VOID; 0346 } 0347 0348 0349 /******************************************************************************* 0350 * 0351 * FUNCTION: AcpiNsGetAttachedObject 0352 * 0353 * PARAMETERS: Node - Namespace node 0354 * 0355 * RETURN: Current value of the object field from the Node whose 0356 * handle is passed 0357 * 0358 * DESCRIPTION: Obtain the object attached to a namespace node. 0359 * 0360 ******************************************************************************/ 0361 0362 ACPI_OPERAND_OBJECT * 0363 AcpiNsGetAttachedObject ( 0364 ACPI_NAMESPACE_NODE *Node) 0365 { 0366 ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); 0367 0368 0369 if (!Node) 0370 { 0371 ACPI_WARNING ((AE_INFO, "Null Node ptr")); 0372 return_PTR (NULL); 0373 } 0374 0375 if (!Node->Object || 0376 ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && 0377 (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || 0378 ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) 0379 { 0380 return_PTR (NULL); 0381 } 0382 0383 return_PTR (Node->Object); 0384 } 0385 0386 0387 /******************************************************************************* 0388 * 0389 * FUNCTION: AcpiNsGetSecondaryObject 0390 * 0391 * PARAMETERS: Node - Namespace node 0392 * 0393 * RETURN: Current value of the object field from the Node whose 0394 * handle is passed. 0395 * 0396 * DESCRIPTION: Obtain a secondary object associated with a namespace node. 0397 * 0398 ******************************************************************************/ 0399 0400 ACPI_OPERAND_OBJECT * 0401 AcpiNsGetSecondaryObject ( 0402 ACPI_OPERAND_OBJECT *ObjDesc) 0403 { 0404 ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); 0405 0406 0407 if ((!ObjDesc) || 0408 (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || 0409 (!ObjDesc->Common.NextObject) || 0410 ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) 0411 { 0412 return_PTR (NULL); 0413 } 0414 0415 return_PTR (ObjDesc->Common.NextObject); 0416 } 0417 0418 0419 /******************************************************************************* 0420 * 0421 * FUNCTION: AcpiNsAttachData 0422 * 0423 * PARAMETERS: Node - Namespace node 0424 * Handler - Handler to be associated with the data 0425 * Data - Data to be attached 0426 * 0427 * RETURN: Status 0428 * 0429 * DESCRIPTION: Low-level attach data. Create and attach a Data object. 0430 * 0431 ******************************************************************************/ 0432 0433 ACPI_STATUS 0434 AcpiNsAttachData ( 0435 ACPI_NAMESPACE_NODE *Node, 0436 ACPI_OBJECT_HANDLER Handler, 0437 void *Data) 0438 { 0439 ACPI_OPERAND_OBJECT *PrevObjDesc; 0440 ACPI_OPERAND_OBJECT *ObjDesc; 0441 ACPI_OPERAND_OBJECT *DataDesc; 0442 0443 0444 /* We only allow one attachment per handler */ 0445 0446 PrevObjDesc = NULL; 0447 ObjDesc = Node->Object; 0448 while (ObjDesc) 0449 { 0450 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 0451 (ObjDesc->Data.Handler == Handler)) 0452 { 0453 return (AE_ALREADY_EXISTS); 0454 } 0455 0456 PrevObjDesc = ObjDesc; 0457 ObjDesc = ObjDesc->Common.NextObject; 0458 } 0459 0460 /* Create an internal object for the data */ 0461 0462 DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); 0463 if (!DataDesc) 0464 { 0465 return (AE_NO_MEMORY); 0466 } 0467 0468 DataDesc->Data.Handler = Handler; 0469 DataDesc->Data.Pointer = Data; 0470 0471 /* Install the data object */ 0472 0473 if (PrevObjDesc) 0474 { 0475 PrevObjDesc->Common.NextObject = DataDesc; 0476 } 0477 else 0478 { 0479 Node->Object = DataDesc; 0480 } 0481 0482 return (AE_OK); 0483 } 0484 0485 0486 /******************************************************************************* 0487 * 0488 * FUNCTION: AcpiNsDetachData 0489 * 0490 * PARAMETERS: Node - Namespace node 0491 * Handler - Handler associated with the data 0492 * 0493 * RETURN: Status 0494 * 0495 * DESCRIPTION: Low-level detach data. Delete the data node, but the caller 0496 * is responsible for the actual data. 0497 * 0498 ******************************************************************************/ 0499 0500 ACPI_STATUS 0501 AcpiNsDetachData ( 0502 ACPI_NAMESPACE_NODE *Node, 0503 ACPI_OBJECT_HANDLER Handler) 0504 { 0505 ACPI_OPERAND_OBJECT *ObjDesc; 0506 ACPI_OPERAND_OBJECT *PrevObjDesc; 0507 0508 0509 PrevObjDesc = NULL; 0510 ObjDesc = Node->Object; 0511 while (ObjDesc) 0512 { 0513 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 0514 (ObjDesc->Data.Handler == Handler)) 0515 { 0516 if (PrevObjDesc) 0517 { 0518 PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; 0519 } 0520 else 0521 { 0522 Node->Object = ObjDesc->Common.NextObject; 0523 } 0524 0525 AcpiUtRemoveReference (ObjDesc); 0526 return (AE_OK); 0527 } 0528 0529 PrevObjDesc = ObjDesc; 0530 ObjDesc = ObjDesc->Common.NextObject; 0531 } 0532 0533 return (AE_NOT_FOUND); 0534 } 0535 0536 0537 /******************************************************************************* 0538 * 0539 * FUNCTION: AcpiNsGetAttachedData 0540 * 0541 * PARAMETERS: Node - Namespace node 0542 * Handler - Handler associated with the data 0543 * Data - Where the data is returned 0544 * 0545 * RETURN: Status 0546 * 0547 * DESCRIPTION: Low level interface to obtain data previously associated with 0548 * a namespace node. 0549 * 0550 ******************************************************************************/ 0551 0552 ACPI_STATUS 0553 AcpiNsGetAttachedData ( 0554 ACPI_NAMESPACE_NODE *Node, 0555 ACPI_OBJECT_HANDLER Handler, 0556 void **Data) 0557 { 0558 ACPI_OPERAND_OBJECT *ObjDesc; 0559 0560 0561 ObjDesc = Node->Object; 0562 while (ObjDesc) 0563 { 0564 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 0565 (ObjDesc->Data.Handler == Handler)) 0566 { 0567 *Data = ObjDesc->Data.Pointer; 0568 return (AE_OK); 0569 } 0570 0571 ObjDesc = ObjDesc->Common.NextObject; 0572 } 0573 0574 return (AE_NOT_FOUND); 0575 } 0576 0577
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |