Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygennsobject.c
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * 00003 * Module Name: nsobject - Utilities for objects attached to namespace 00004 * table entries 00005 * 00006 ******************************************************************************/ 00007 00008 /****************************************************************************** 00009 * 00010 * 1. Copyright Notice 00011 * 00012 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00013 * All rights reserved. 00014 * 00015 * 2. License 00016 * 00017 * 2.1. This is your license from Intel Corp. under its intellectual property 00018 * rights. You may have additional license terms from the party that provided 00019 * you this software, covering your right to use that party's intellectual 00020 * property rights. 00021 * 00022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00023 * copy of the source code appearing in this file ("Covered Code") an 00024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00025 * base code distributed originally by Intel ("Original Intel Code") to copy, 00026 * make derivatives, distribute, use and display any portion of the Covered 00027 * Code in any form, with the right to sublicense such rights; and 00028 * 00029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00030 * license (with the right to sublicense), under only those claims of Intel 00031 * patents that are infringed by the Original Intel Code, to make, use, sell, 00032 * offer to sell, and import the Covered Code and derivative works thereof 00033 * solely to the minimum extent necessary to exercise the above copyright 00034 * license, and in no event shall the patent license extend to any additions 00035 * to or modifications of the Original Intel Code. No other license or right 00036 * is granted directly or by implication, estoppel or otherwise; 00037 * 00038 * The above copyright and patent license is granted only if the following 00039 * conditions are met: 00040 * 00041 * 3. Conditions 00042 * 00043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00044 * Redistribution of source code of any substantial portion of the Covered 00045 * Code or modification with rights to further distribute source must include 00046 * the above Copyright Notice, the above License, this list of Conditions, 00047 * and the following Disclaimer and Export Compliance provision. In addition, 00048 * Licensee must cause all Covered Code to which Licensee contributes to 00049 * contain a file documenting the changes Licensee made to create that Covered 00050 * Code and the date of any change. Licensee must include in that file the 00051 * documentation of any changes made by any predecessor Licensee. Licensee 00052 * must include a prominent statement that the modification is derived, 00053 * directly or indirectly, from Original Intel Code. 00054 * 00055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00056 * Redistribution of source code of any substantial portion of the Covered 00057 * Code or modification without rights to further distribute source must 00058 * include the following Disclaimer and Export Compliance provision in the 00059 * documentation and/or other materials provided with distribution. In 00060 * addition, Licensee may not authorize further sublicense of source of any 00061 * portion of the Covered Code, and must include terms to the effect that the 00062 * license from Licensee to its licensee is limited to the intellectual 00063 * property embodied in the software Licensee provides to its licensee, and 00064 * not to intellectual property embodied in modifications its licensee may 00065 * make. 00066 * 00067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00068 * substantial portion of the Covered Code or modification must reproduce the 00069 * above Copyright Notice, and the following Disclaimer and Export Compliance 00070 * provision in the documentation and/or other materials provided with the 00071 * distribution. 00072 * 00073 * 3.4. Intel retains all right, title, and interest in and to the Original 00074 * Intel Code. 00075 * 00076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00077 * Intel shall be used in advertising or otherwise to promote the sale, use or 00078 * other dealings in products derived from or relating to the Covered Code 00079 * without prior written authorization from Intel. 00080 * 00081 * 4. Disclaimer and Export Compliance 00082 * 00083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00089 * PARTICULAR PURPOSE. 00090 * 00091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00098 * LIMITED REMEDY. 00099 * 00100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00101 * software or system incorporating such software without first obtaining any 00102 * required license or other approval from the U. S. Department of Commerce or 00103 * any other agency or department of the United States Government. In the 00104 * event Licensee exports any such software from the United States or 00105 * re-exports any such software from a foreign destination, Licensee shall 00106 * ensure that the distribution and export/re-export of the software is in 00107 * compliance with all laws, regulations, orders, or other restrictions of the 00108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00109 * any of its subsidiaries will export/re-export any technical data, process, 00110 * software, or service, directly or indirectly, to any country for which the 00111 * United States government or any agency thereof requires an export license, 00112 * other governmental approval, or letter of assurance, without first obtaining 00113 * such license, approval or letter. 00114 * 00115 *****************************************************************************/ 00116 00117 00118 #define __NSOBJECT_C__ 00119 00120 #include "acpi.h" 00121 #include "accommon.h" 00122 #include "acnamesp.h" 00123 00124 00125 #define _COMPONENT ACPI_NAMESPACE 00126 ACPI_MODULE_NAME ("nsobject") 00127 00128 00129 /******************************************************************************* 00130 * 00131 * FUNCTION: AcpiNsAttachObject 00132 * 00133 * PARAMETERS: Node - Parent Node 00134 * Object - Object to be attached 00135 * Type - Type of object, or ACPI_TYPE_ANY if not 00136 * known 00137 * 00138 * RETURN: Status 00139 * 00140 * DESCRIPTION: Record the given object as the value associated with the 00141 * name whose ACPI_HANDLE is passed. If Object is NULL 00142 * and Type is ACPI_TYPE_ANY, set the name as having no value. 00143 * Note: Future may require that the Node->Flags field be passed 00144 * as a parameter. 00145 * 00146 * MUTEX: Assumes namespace is locked 00147 * 00148 ******************************************************************************/ 00149 00150 ACPI_STATUS 00151 AcpiNsAttachObject ( 00152 ACPI_NAMESPACE_NODE *Node, 00153 ACPI_OPERAND_OBJECT *Object, 00154 ACPI_OBJECT_TYPE Type) 00155 { 00156 ACPI_OPERAND_OBJECT *ObjDesc; 00157 ACPI_OPERAND_OBJECT *LastObjDesc; 00158 ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; 00159 00160 00161 ACPI_FUNCTION_TRACE (NsAttachObject); 00162 00163 00164 /* 00165 * Parameter validation 00166 */ 00167 if (!Node) 00168 { 00169 /* Invalid handle */ 00170 00171 ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); 00172 return_ACPI_STATUS (AE_BAD_PARAMETER); 00173 } 00174 00175 if (!Object && (ACPI_TYPE_ANY != Type)) 00176 { 00177 /* Null object */ 00178 00179 ACPI_ERROR ((AE_INFO, 00180 "Null object, but type not ACPI_TYPE_ANY")); 00181 return_ACPI_STATUS (AE_BAD_PARAMETER); 00182 } 00183 00184 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 00185 { 00186 /* Not a name handle */ 00187 00188 ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", 00189 Node, AcpiUtGetDescriptorName (Node))); 00190 return_ACPI_STATUS (AE_BAD_PARAMETER); 00191 } 00192 00193 /* Check if this object is already attached */ 00194 00195 if (Node->Object == Object) 00196 { 00197 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00198 "Obj %p already installed in NameObj %p\n", 00199 Object, Node)); 00200 00201 return_ACPI_STATUS (AE_OK); 00202 } 00203 00204 /* If null object, we will just install it */ 00205 00206 if (!Object) 00207 { 00208 ObjDesc = NULL; 00209 ObjectType = ACPI_TYPE_ANY; 00210 } 00211 00212 /* 00213 * If the source object is a namespace Node with an attached object, 00214 * we will use that (attached) object 00215 */ 00216 else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && 00217 ((ACPI_NAMESPACE_NODE *) Object)->Object) 00218 { 00219 /* 00220 * Value passed is a name handle and that name has a 00221 * non-null value. Use that name's value and type. 00222 */ 00223 ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; 00224 ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; 00225 } 00226 00227 /* 00228 * Otherwise, we will use the parameter object, but we must type 00229 * it first 00230 */ 00231 else 00232 { 00233 ObjDesc = (ACPI_OPERAND_OBJECT *) Object; 00234 00235 /* Use the given type */ 00236 00237 ObjectType = Type; 00238 } 00239 00240 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", 00241 ObjDesc, Node, AcpiUtGetNodeName (Node))); 00242 00243 /* Detach an existing attached object if present */ 00244 00245 if (Node->Object) 00246 { 00247 AcpiNsDetachObject (Node); 00248 } 00249 00250 if (ObjDesc) 00251 { 00252 /* 00253 * Must increment the new value's reference count 00254 * (if it is an internal object) 00255 */ 00256 AcpiUtAddReference (ObjDesc); 00257 00258 /* 00259 * Handle objects with multiple descriptors - walk 00260 * to the end of the descriptor list 00261 */ 00262 LastObjDesc = ObjDesc; 00263 while (LastObjDesc->Common.NextObject) 00264 { 00265 LastObjDesc = LastObjDesc->Common.NextObject; 00266 } 00267 00268 /* Install the object at the front of the object list */ 00269 00270 LastObjDesc->Common.NextObject = Node->Object; 00271 } 00272 00273 Node->Type = (UINT8) ObjectType; 00274 Node->Object = ObjDesc; 00275 00276 return_ACPI_STATUS (AE_OK); 00277 } 00278 00279 00280 /******************************************************************************* 00281 * 00282 * FUNCTION: AcpiNsDetachObject 00283 * 00284 * PARAMETERS: Node - A Namespace node whose object will be detached 00285 * 00286 * RETURN: None. 00287 * 00288 * DESCRIPTION: Detach/delete an object associated with a namespace node. 00289 * if the object is an allocated object, it is freed. 00290 * Otherwise, the field is simply cleared. 00291 * 00292 ******************************************************************************/ 00293 00294 void 00295 AcpiNsDetachObject ( 00296 ACPI_NAMESPACE_NODE *Node) 00297 { 00298 ACPI_OPERAND_OBJECT *ObjDesc; 00299 00300 00301 ACPI_FUNCTION_TRACE (NsDetachObject); 00302 00303 00304 ObjDesc = Node->Object; 00305 00306 if (!ObjDesc || 00307 (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) 00308 { 00309 return_VOID; 00310 } 00311 00312 if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) 00313 { 00314 /* Free the dynamic aml buffer */ 00315 00316 if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) 00317 { 00318 ACPI_FREE (ObjDesc->Method.AmlStart); 00319 } 00320 } 00321 00322 /* Clear the entry in all cases */ 00323 00324 Node->Object = NULL; 00325 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) 00326 { 00327 Node->Object = ObjDesc->Common.NextObject; 00328 if (Node->Object && 00329 ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) 00330 { 00331 Node->Object = Node->Object->Common.NextObject; 00332 } 00333 } 00334 00335 /* Reset the node type to untyped */ 00336 00337 Node->Type = ACPI_TYPE_ANY; 00338 00339 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", 00340 Node, AcpiUtGetNodeName (Node), ObjDesc)); 00341 00342 /* Remove one reference on the object (and all subobjects) */ 00343 00344 AcpiUtRemoveReference (ObjDesc); 00345 return_VOID; 00346 } 00347 00348 00349 /******************************************************************************* 00350 * 00351 * FUNCTION: AcpiNsGetAttachedObject 00352 * 00353 * PARAMETERS: Node - Namespace node 00354 * 00355 * RETURN: Current value of the object field from the Node whose 00356 * handle is passed 00357 * 00358 * DESCRIPTION: Obtain the object attached to a namespace node. 00359 * 00360 ******************************************************************************/ 00361 00362 ACPI_OPERAND_OBJECT * 00363 AcpiNsGetAttachedObject ( 00364 ACPI_NAMESPACE_NODE *Node) 00365 { 00366 ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); 00367 00368 00369 if (!Node) 00370 { 00371 ACPI_WARNING ((AE_INFO, "Null Node ptr")); 00372 return_PTR (NULL); 00373 } 00374 00375 if (!Node->Object || 00376 ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && 00377 (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || 00378 ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) 00379 { 00380 return_PTR (NULL); 00381 } 00382 00383 return_PTR (Node->Object); 00384 } 00385 00386 00387 /******************************************************************************* 00388 * 00389 * FUNCTION: AcpiNsGetSecondaryObject 00390 * 00391 * PARAMETERS: Node - Namespace node 00392 * 00393 * RETURN: Current value of the object field from the Node whose 00394 * handle is passed. 00395 * 00396 * DESCRIPTION: Obtain a secondary object associated with a namespace node. 00397 * 00398 ******************************************************************************/ 00399 00400 ACPI_OPERAND_OBJECT * 00401 AcpiNsGetSecondaryObject ( 00402 ACPI_OPERAND_OBJECT *ObjDesc) 00403 { 00404 ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); 00405 00406 00407 if ((!ObjDesc) || 00408 (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || 00409 (!ObjDesc->Common.NextObject) || 00410 ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) 00411 { 00412 return_PTR (NULL); 00413 } 00414 00415 return_PTR (ObjDesc->Common.NextObject); 00416 } 00417 00418 00419 /******************************************************************************* 00420 * 00421 * FUNCTION: AcpiNsAttachData 00422 * 00423 * PARAMETERS: Node - Namespace node 00424 * Handler - Handler to be associated with the data 00425 * Data - Data to be attached 00426 * 00427 * RETURN: Status 00428 * 00429 * DESCRIPTION: Low-level attach data. Create and attach a Data object. 00430 * 00431 ******************************************************************************/ 00432 00433 ACPI_STATUS 00434 AcpiNsAttachData ( 00435 ACPI_NAMESPACE_NODE *Node, 00436 ACPI_OBJECT_HANDLER Handler, 00437 void *Data) 00438 { 00439 ACPI_OPERAND_OBJECT *PrevObjDesc; 00440 ACPI_OPERAND_OBJECT *ObjDesc; 00441 ACPI_OPERAND_OBJECT *DataDesc; 00442 00443 00444 /* We only allow one attachment per handler */ 00445 00446 PrevObjDesc = NULL; 00447 ObjDesc = Node->Object; 00448 while (ObjDesc) 00449 { 00450 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 00451 (ObjDesc->Data.Handler == Handler)) 00452 { 00453 return (AE_ALREADY_EXISTS); 00454 } 00455 00456 PrevObjDesc = ObjDesc; 00457 ObjDesc = ObjDesc->Common.NextObject; 00458 } 00459 00460 /* Create an internal object for the data */ 00461 00462 DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); 00463 if (!DataDesc) 00464 { 00465 return (AE_NO_MEMORY); 00466 } 00467 00468 DataDesc->Data.Handler = Handler; 00469 DataDesc->Data.Pointer = Data; 00470 00471 /* Install the data object */ 00472 00473 if (PrevObjDesc) 00474 { 00475 PrevObjDesc->Common.NextObject = DataDesc; 00476 } 00477 else 00478 { 00479 Node->Object = DataDesc; 00480 } 00481 00482 return (AE_OK); 00483 } 00484 00485 00486 /******************************************************************************* 00487 * 00488 * FUNCTION: AcpiNsDetachData 00489 * 00490 * PARAMETERS: Node - Namespace node 00491 * Handler - Handler associated with the data 00492 * 00493 * RETURN: Status 00494 * 00495 * DESCRIPTION: Low-level detach data. Delete the data node, but the caller 00496 * is responsible for the actual data. 00497 * 00498 ******************************************************************************/ 00499 00500 ACPI_STATUS 00501 AcpiNsDetachData ( 00502 ACPI_NAMESPACE_NODE *Node, 00503 ACPI_OBJECT_HANDLER Handler) 00504 { 00505 ACPI_OPERAND_OBJECT *ObjDesc; 00506 ACPI_OPERAND_OBJECT *PrevObjDesc; 00507 00508 00509 PrevObjDesc = NULL; 00510 ObjDesc = Node->Object; 00511 while (ObjDesc) 00512 { 00513 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 00514 (ObjDesc->Data.Handler == Handler)) 00515 { 00516 if (PrevObjDesc) 00517 { 00518 PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; 00519 } 00520 else 00521 { 00522 Node->Object = ObjDesc->Common.NextObject; 00523 } 00524 00525 AcpiUtRemoveReference (ObjDesc); 00526 return (AE_OK); 00527 } 00528 00529 PrevObjDesc = ObjDesc; 00530 ObjDesc = ObjDesc->Common.NextObject; 00531 } 00532 00533 return (AE_NOT_FOUND); 00534 } 00535 00536 00537 /******************************************************************************* 00538 * 00539 * FUNCTION: AcpiNsGetAttachedData 00540 * 00541 * PARAMETERS: Node - Namespace node 00542 * Handler - Handler associated with the data 00543 * Data - Where the data is returned 00544 * 00545 * RETURN: Status 00546 * 00547 * DESCRIPTION: Low level interface to obtain data previously associated with 00548 * a namespace node. 00549 * 00550 ******************************************************************************/ 00551 00552 ACPI_STATUS 00553 AcpiNsGetAttachedData ( 00554 ACPI_NAMESPACE_NODE *Node, 00555 ACPI_OBJECT_HANDLER Handler, 00556 void **Data) 00557 { 00558 ACPI_OPERAND_OBJECT *ObjDesc; 00559 00560 00561 ObjDesc = Node->Object; 00562 while (ObjDesc) 00563 { 00564 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && 00565 (ObjDesc->Data.Handler == Handler)) 00566 { 00567 *Data = ObjDesc->Data.Pointer; 00568 return (AE_OK); 00569 } 00570 00571 ObjDesc = ObjDesc->Common.NextObject; 00572 } 00573 00574 return (AE_NOT_FOUND); 00575 } 00576 00577 Generated on Sat May 19 2012 04:25:16 for ReactOS by
1.7.6.1
|