nsxfeval.c revision 117521
1/******************************************************************************* 2 * 3 * Module Name: nsxfeval - Public interfaces to the ACPI subsystem 4 * ACPI Object evaluation interfaces 5 * $Revision: 10 $ 6 * 7 ******************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 14 * All rights reserved. 15 * 16 * 2. License 17 * 18 * 2.1. This is your license from Intel Corp. under its intellectual property 19 * rights. You may have additional license terms from the party that provided 20 * you this software, covering your right to use that party's intellectual 21 * property rights. 22 * 23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24 * copy of the source code appearing in this file ("Covered Code") an 25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26 * base code distributed originally by Intel ("Original Intel Code") to copy, 27 * make derivatives, distribute, use and display any portion of the Covered 28 * Code in any form, with the right to sublicense such rights; and 29 * 30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31 * license (with the right to sublicense), under only those claims of Intel 32 * patents that are infringed by the Original Intel Code, to make, use, sell, 33 * offer to sell, and import the Covered Code and derivative works thereof 34 * solely to the minimum extent necessary to exercise the above copyright 35 * license, and in no event shall the patent license extend to any additions 36 * to or modifications of the Original Intel Code. No other license or right 37 * is granted directly or by implication, estoppel or otherwise; 38 * 39 * The above copyright and patent license is granted only if the following 40 * conditions are met: 41 * 42 * 3. Conditions 43 * 44 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45 * Redistribution of source code of any substantial portion of the Covered 46 * Code or modification with rights to further distribute source must include 47 * the above Copyright Notice, the above License, this list of Conditions, 48 * and the following Disclaimer and Export Compliance provision. In addition, 49 * Licensee must cause all Covered Code to which Licensee contributes to 50 * contain a file documenting the changes Licensee made to create that Covered 51 * Code and the date of any change. Licensee must include in that file the 52 * documentation of any changes made by any predecessor Licensee. Licensee 53 * must include a prominent statement that the modification is derived, 54 * directly or indirectly, from Original Intel Code. 55 * 56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57 * Redistribution of source code of any substantial portion of the Covered 58 * Code or modification without rights to further distribute source must 59 * include the following Disclaimer and Export Compliance provision in the 60 * documentation and/or other materials provided with distribution. In 61 * addition, Licensee may not authorize further sublicense of source of any 62 * portion of the Covered Code, and must include terms to the effect that the 63 * license from Licensee to its licensee is limited to the intellectual 64 * property embodied in the software Licensee provides to its licensee, and 65 * not to intellectual property embodied in modifications its licensee may 66 * make. 67 * 68 * 3.3. Redistribution of Executable. Redistribution in executable form of any 69 * substantial portion of the Covered Code or modification must reproduce the 70 * above Copyright Notice, and the following Disclaimer and Export Compliance 71 * provision in the documentation and/or other materials provided with the 72 * distribution. 73 * 74 * 3.4. Intel retains all right, title, and interest in and to the Original 75 * Intel Code. 76 * 77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78 * Intel shall be used in advertising or otherwise to promote the sale, use or 79 * other dealings in products derived from or relating to the Covered Code 80 * without prior written authorization from Intel. 81 * 82 * 4. Disclaimer and Export Compliance 83 * 84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118 119#define __NSXFEVAL_C__ 120 121#include "acpi.h" 122#include "acnamesp.h" 123 124 125#define _COMPONENT ACPI_NAMESPACE 126 ACPI_MODULE_NAME ("nsxfeval") 127 128 129/******************************************************************************* 130 * 131 * FUNCTION: AcpiEvaluateObjectTyped 132 * 133 * PARAMETERS: Handle - Object handle (optional) 134 * *Pathname - Object pathname (optional) 135 * **ExternalParams - List of parameters to pass to method, 136 * terminated by NULL. May be NULL 137 * if no parameters are being passed. 138 * *ReturnBuffer - Where to put method's return value (if 139 * any). If NULL, no value is returned. 140 * ReturnType - Expected type of return object 141 * 142 * RETURN: Status 143 * 144 * DESCRIPTION: Find and evaluate the given object, passing the given 145 * parameters if necessary. One of "Handle" or "Pathname" must 146 * be valid (non-null) 147 * 148 ******************************************************************************/ 149 150ACPI_STATUS 151AcpiEvaluateObjectTyped ( 152 ACPI_HANDLE Handle, 153 ACPI_STRING Pathname, 154 ACPI_OBJECT_LIST *ExternalParams, 155 ACPI_BUFFER *ReturnBuffer, 156 ACPI_OBJECT_TYPE ReturnType) 157{ 158 ACPI_STATUS Status; 159 BOOLEAN MustFree = FALSE; 160 161 162 ACPI_FUNCTION_TRACE ("AcpiEvaluateObjectTyped"); 163 164 165 /* Return buffer must be valid */ 166 167 if (!ReturnBuffer) 168 { 169 return_ACPI_STATUS (AE_BAD_PARAMETER); 170 } 171 172 if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) 173 { 174 MustFree = TRUE; 175 } 176 177 /* Evaluate the object */ 178 179 Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); 180 if (ACPI_FAILURE (Status)) 181 { 182 return_ACPI_STATUS (Status); 183 } 184 185 /* Type ANY means "don't care" */ 186 187 if (ReturnType == ACPI_TYPE_ANY) 188 { 189 return_ACPI_STATUS (AE_OK); 190 } 191 192 if (ReturnBuffer->Length == 0) 193 { 194 /* Error because caller specifically asked for a return value */ 195 196 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 197 "No return value\n")); 198 199 return_ACPI_STATUS (AE_NULL_OBJECT); 200 } 201 202 /* Examine the object type returned from EvaluateObject */ 203 204 if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) 205 { 206 return_ACPI_STATUS (AE_OK); 207 } 208 209 /* Return object type does not match requested type */ 210 211 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 212 "Incorrect return type [%s] requested [%s]\n", 213 AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), 214 AcpiUtGetTypeName (ReturnType))); 215 216 if (MustFree) 217 { 218 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 219 220 AcpiOsFree (ReturnBuffer->Pointer); 221 ReturnBuffer->Pointer = NULL; 222 } 223 224 ReturnBuffer->Length = 0; 225 return_ACPI_STATUS (AE_TYPE); 226} 227 228 229/******************************************************************************* 230 * 231 * FUNCTION: AcpiEvaluateObject 232 * 233 * PARAMETERS: Handle - Object handle (optional) 234 * *Pathname - Object pathname (optional) 235 * **ExternalParams - List of parameters to pass to method, 236 * terminated by NULL. May be NULL 237 * if no parameters are being passed. 238 * *ReturnBuffer - Where to put method's return value (if 239 * any). If NULL, no value is returned. 240 * 241 * RETURN: Status 242 * 243 * DESCRIPTION: Find and evaluate the given object, passing the given 244 * parameters if necessary. One of "Handle" or "Pathname" must 245 * be valid (non-null) 246 * 247 ******************************************************************************/ 248 249ACPI_STATUS 250AcpiEvaluateObject ( 251 ACPI_HANDLE Handle, 252 ACPI_STRING Pathname, 253 ACPI_OBJECT_LIST *ExternalParams, 254 ACPI_BUFFER *ReturnBuffer) 255{ 256 ACPI_STATUS Status; 257 ACPI_OPERAND_OBJECT **InternalParams = NULL; 258 ACPI_OPERAND_OBJECT *InternalReturnObj = NULL; 259 ACPI_SIZE BufferSpaceNeeded; 260 UINT32 i; 261 262 263 ACPI_FUNCTION_TRACE ("AcpiEvaluateObject"); 264 265 266 /* 267 * If there are parameters to be passed to the object 268 * (which must be a control method), the external objects 269 * must be converted to internal objects 270 */ 271 if (ExternalParams && ExternalParams->Count) 272 { 273 /* 274 * Allocate a new parameter block for the internal objects 275 * Add 1 to count to allow for null terminated internal list 276 */ 277 InternalParams = ACPI_MEM_CALLOCATE (((ACPI_SIZE) ExternalParams->Count + 1) * 278 sizeof (void *)); 279 if (!InternalParams) 280 { 281 return_ACPI_STATUS (AE_NO_MEMORY); 282 } 283 284 /* 285 * Convert each external object in the list to an 286 * internal object 287 */ 288 for (i = 0; i < ExternalParams->Count; i++) 289 { 290 Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i], 291 &InternalParams[i]); 292 if (ACPI_FAILURE (Status)) 293 { 294 AcpiUtDeleteInternalObjectList (InternalParams); 295 return_ACPI_STATUS (Status); 296 } 297 } 298 InternalParams[ExternalParams->Count] = NULL; 299 } 300 301 /* 302 * Three major cases: 303 * 1) Fully qualified pathname 304 * 2) No handle, not fully qualified pathname (error) 305 * 3) Valid handle 306 */ 307 if ((Pathname) && 308 (AcpiNsValidRootPrefix (Pathname[0]))) 309 { 310 /* 311 * The path is fully qualified, just evaluate by name 312 */ 313 Status = AcpiNsEvaluateByName (Pathname, InternalParams, 314 &InternalReturnObj); 315 } 316 else if (!Handle) 317 { 318 /* 319 * A handle is optional iff a fully qualified pathname 320 * is specified. Since we've already handled fully 321 * qualified names above, this is an error 322 */ 323 if (!Pathname) 324 { 325 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 326 "Both Handle and Pathname are NULL\n")); 327 } 328 else 329 { 330 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 331 "Handle is NULL and Pathname is relative\n")); 332 } 333 334 Status = AE_BAD_PARAMETER; 335 } 336 else 337 { 338 /* 339 * We get here if we have a handle -- and if we have a 340 * pathname it is relative. The handle will be validated 341 * in the lower procedures 342 */ 343 if (!Pathname) 344 { 345 /* 346 * The null pathname case means the handle is for 347 * the actual object to be evaluated 348 */ 349 Status = AcpiNsEvaluateByHandle (Handle, InternalParams, 350 &InternalReturnObj); 351 } 352 else 353 { 354 /* 355 * Both a Handle and a relative Pathname 356 */ 357 Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams, 358 &InternalReturnObj); 359 } 360 } 361 362 363 /* 364 * If we are expecting a return value, and all went well above, 365 * copy the return value to an external object. 366 */ 367 if (ReturnBuffer) 368 { 369 if (!InternalReturnObj) 370 { 371 ReturnBuffer->Length = 0; 372 } 373 else 374 { 375 if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED) 376 { 377 /* 378 * If we received a NS Node as a return object, this means that 379 * the object we are evaluating has nothing interesting to 380 * return (such as a mutex, etc.) We return an error because 381 * these types are essentially unsupported by this interface. 382 * We don't check up front because this makes it easier to add 383 * support for various types at a later date if necessary. 384 */ 385 Status = AE_TYPE; 386 InternalReturnObj = NULL; /* No need to delete a NS Node */ 387 ReturnBuffer->Length = 0; 388 } 389 390 if (ACPI_SUCCESS (Status)) 391 { 392 /* 393 * Find out how large a buffer is needed 394 * to contain the returned object 395 */ 396 Status = AcpiUtGetObjectSize (InternalReturnObj, 397 &BufferSpaceNeeded); 398 if (ACPI_SUCCESS (Status)) 399 { 400 /* Validate/Allocate/Clear caller buffer */ 401 402 Status = AcpiUtInitializeBuffer (ReturnBuffer, BufferSpaceNeeded); 403 if (ACPI_FAILURE (Status)) 404 { 405 /* 406 * Caller's buffer is too small or a new one can't be allocated 407 */ 408 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 409 "Needed buffer size %X, %s\n", 410 (UINT32) BufferSpaceNeeded, AcpiFormatException (Status))); 411 } 412 else 413 { 414 /* 415 * We have enough space for the object, build it 416 */ 417 Status = AcpiUtCopyIobjectToEobject (InternalReturnObj, 418 ReturnBuffer); 419 } 420 } 421 } 422 } 423 } 424 425 /* Delete the return and parameter objects */ 426 427 if (InternalReturnObj) 428 { 429 /* 430 * Delete the internal return object. (Or at least 431 * decrement the reference count by one) 432 */ 433 AcpiUtRemoveReference (InternalReturnObj); 434 } 435 436 /* 437 * Free the input parameter list (if we created one), 438 */ 439 if (InternalParams) 440 { 441 /* Free the allocated parameter block */ 442 443 AcpiUtDeleteInternalObjectList (InternalParams); 444 } 445 446 return_ACPI_STATUS (Status); 447} 448 449 450/******************************************************************************* 451 * 452 * FUNCTION: AcpiWalkNamespace 453 * 454 * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for 455 * StartObject - Handle in namespace where search begins 456 * MaxDepth - Depth to which search is to reach 457 * UserFunction - Called when an object of "Type" is found 458 * Context - Passed to user function 459 * ReturnValue - Location where return value of 460 * UserFunction is put if terminated early 461 * 462 * RETURNS Return value from the UserFunction if terminated early. 463 * Otherwise, returns NULL. 464 * 465 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, 466 * starting (and ending) at the object specified by StartHandle. 467 * The UserFunction is called whenever an object that matches 468 * the type parameter is found. If the user function returns 469 * a non-zero value, the search is terminated immediately and this 470 * value is returned to the caller. 471 * 472 * The point of this procedure is to provide a generic namespace 473 * walk routine that can be called from multiple places to 474 * provide multiple services; the User Function can be tailored 475 * to each task, whether it is a print function, a compare 476 * function, etc. 477 * 478 ******************************************************************************/ 479 480ACPI_STATUS 481AcpiWalkNamespace ( 482 ACPI_OBJECT_TYPE Type, 483 ACPI_HANDLE StartObject, 484 UINT32 MaxDepth, 485 ACPI_WALK_CALLBACK UserFunction, 486 void *Context, 487 void **ReturnValue) 488{ 489 ACPI_STATUS Status; 490 491 492 ACPI_FUNCTION_TRACE ("AcpiWalkNamespace"); 493 494 495 /* Parameter validation */ 496 497 if ((Type > ACPI_TYPE_EXTERNAL_MAX) || 498 (!MaxDepth) || 499 (!UserFunction)) 500 { 501 return_ACPI_STATUS (AE_BAD_PARAMETER); 502 } 503 504 /* 505 * Lock the namespace around the walk. 506 * The namespace will be unlocked/locked around each call 507 * to the user function - since this function 508 * must be allowed to make Acpi calls itself. 509 */ 510 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 511 if (ACPI_FAILURE (Status)) 512 { 513 return_ACPI_STATUS (Status); 514 } 515 516 Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, ACPI_NS_WALK_UNLOCK, 517 UserFunction, Context, ReturnValue); 518 519 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 520 return_ACPI_STATUS (Status); 521} 522 523 524/******************************************************************************* 525 * 526 * FUNCTION: AcpiNsGetDeviceCallback 527 * 528 * PARAMETERS: Callback from AcpiGetDevice 529 * 530 * RETURN: Status 531 * 532 * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- 533 * present devices, or if they specified a HID, it filters based 534 * on that. 535 * 536 ******************************************************************************/ 537 538static ACPI_STATUS 539AcpiNsGetDeviceCallback ( 540 ACPI_HANDLE ObjHandle, 541 UINT32 NestingLevel, 542 void *Context, 543 void **ReturnValue) 544{ 545 ACPI_GET_DEVICES_INFO *Info = Context; 546 ACPI_STATUS Status; 547 ACPI_NAMESPACE_NODE *Node; 548 UINT32 Flags; 549 ACPI_DEVICE_ID Hid; 550 ACPI_COMPATIBLE_ID_LIST *Cid; 551 ACPI_NATIVE_UINT i; 552 553 554 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 555 if (ACPI_FAILURE (Status)) 556 { 557 return (Status); 558 } 559 560 Node = AcpiNsMapHandleToNode (ObjHandle); 561 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 562 if (ACPI_FAILURE (Status)) 563 { 564 return (Status); 565 } 566 567 if (!Node) 568 { 569 return (AE_BAD_PARAMETER); 570 } 571 572 /* Run _STA to determine if device is present */ 573 574 Status = AcpiUtExecute_STA (Node, &Flags); 575 if (ACPI_FAILURE (Status)) 576 { 577 return (AE_CTRL_DEPTH); 578 } 579 580 if (!(Flags & 0x01)) 581 { 582 /* Don't return at the device or children of the device if not there */ 583 584 return (AE_CTRL_DEPTH); 585 } 586 587 /* Filter based on device HID & CID */ 588 589 if (Info->Hid != NULL) 590 { 591 Status = AcpiUtExecute_HID (Node, &Hid); 592 if (Status == AE_NOT_FOUND) 593 { 594 return (AE_OK); 595 } 596 else if (ACPI_FAILURE (Status)) 597 { 598 return (AE_CTRL_DEPTH); 599 } 600 601 if (ACPI_STRNCMP (Hid.Value, Info->Hid, sizeof (Hid.Value)) != 0) 602 { 603 /* Get the list of Compatible IDs */ 604 605 Status = AcpiUtExecute_CID (Node, &Cid); 606 if (Status == AE_NOT_FOUND) 607 { 608 return (AE_OK); 609 } 610 else if (ACPI_FAILURE (Status)) 611 { 612 return (AE_CTRL_DEPTH); 613 } 614 615 /* Walk the CID list */ 616 617 for (i = 0; i < Cid->Count; i++) 618 { 619 if (ACPI_STRNCMP (Cid->Id[i].Value, Info->Hid, 620 sizeof (ACPI_COMPATIBLE_ID)) != 0) 621 { 622 ACPI_MEM_FREE (Cid); 623 return (AE_OK); 624 } 625 } 626 ACPI_MEM_FREE (Cid); 627 } 628 } 629 630 Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); 631 return (Status); 632} 633 634 635/******************************************************************************* 636 * 637 * FUNCTION: AcpiGetDevices 638 * 639 * PARAMETERS: HID - HID to search for. Can be NULL. 640 * UserFunction - Called when a matching object is found 641 * Context - Passed to user function 642 * ReturnValue - Location where return value of 643 * UserFunction is put if terminated early 644 * 645 * RETURNS Return value from the UserFunction if terminated early. 646 * Otherwise, returns NULL. 647 * 648 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, 649 * starting (and ending) at the object specified by StartHandle. 650 * The UserFunction is called whenever an object of type 651 * Device is found. If the user function returns 652 * a non-zero value, the search is terminated immediately and this 653 * value is returned to the caller. 654 * 655 * This is a wrapper for WalkNamespace, but the callback performs 656 * additional filtering. Please see AcpiGetDeviceCallback. 657 * 658 ******************************************************************************/ 659 660ACPI_STATUS 661AcpiGetDevices ( 662 char *HID, 663 ACPI_WALK_CALLBACK UserFunction, 664 void *Context, 665 void **ReturnValue) 666{ 667 ACPI_STATUS Status; 668 ACPI_GET_DEVICES_INFO Info; 669 670 671 ACPI_FUNCTION_TRACE ("AcpiGetDevices"); 672 673 674 /* Parameter validation */ 675 676 if (!UserFunction) 677 { 678 return_ACPI_STATUS (AE_BAD_PARAMETER); 679 } 680 681 /* 682 * We're going to call their callback from OUR callback, so we need 683 * to know what it is, and their context parameter. 684 */ 685 Info.Context = Context; 686 Info.UserFunction = UserFunction; 687 Info.Hid = HID; 688 689 /* 690 * Lock the namespace around the walk. 691 * The namespace will be unlocked/locked around each call 692 * to the user function - since this function 693 * must be allowed to make Acpi calls itself. 694 */ 695 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 696 if (ACPI_FAILURE (Status)) 697 { 698 return_ACPI_STATUS (Status); 699 } 700 701 Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, 702 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 703 ACPI_NS_WALK_UNLOCK, 704 AcpiNsGetDeviceCallback, &Info, 705 ReturnValue); 706 707 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 708 return_ACPI_STATUS (Status); 709} 710 711 712/******************************************************************************* 713 * 714 * FUNCTION: AcpiAttachData 715 * 716 * PARAMETERS: ObjHandle - Namespace node 717 * Handler - Handler for this attachment 718 * Data - Pointer to data to be attached 719 * 720 * RETURN: Status 721 * 722 * DESCRIPTION: Attach arbitrary data and handler to a namespace node. 723 * 724 ******************************************************************************/ 725 726ACPI_STATUS 727AcpiAttachData ( 728 ACPI_HANDLE ObjHandle, 729 ACPI_OBJECT_HANDLER Handler, 730 void *Data) 731{ 732 ACPI_NAMESPACE_NODE *Node; 733 ACPI_STATUS Status; 734 735 736 /* Parameter validation */ 737 738 if (!ObjHandle || 739 !Handler || 740 !Data) 741 { 742 return (AE_BAD_PARAMETER); 743 } 744 745 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 746 if (ACPI_FAILURE (Status)) 747 { 748 return (Status); 749 } 750 751 /* Convert and validate the handle */ 752 753 Node = AcpiNsMapHandleToNode (ObjHandle); 754 if (!Node) 755 { 756 Status = AE_BAD_PARAMETER; 757 goto UnlockAndExit; 758 } 759 760 Status = AcpiNsAttachData (Node, Handler, Data); 761 762UnlockAndExit: 763 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 764 return (Status); 765} 766 767 768/******************************************************************************* 769 * 770 * FUNCTION: AcpiDetachData 771 * 772 * PARAMETERS: ObjHandle - Namespace node handle 773 * Handler - Handler used in call to AcpiAttachData 774 * 775 * RETURN: Status 776 * 777 * DESCRIPTION: Remove data that was previously attached to a node. 778 * 779 ******************************************************************************/ 780 781ACPI_STATUS 782AcpiDetachData ( 783 ACPI_HANDLE ObjHandle, 784 ACPI_OBJECT_HANDLER Handler) 785{ 786 ACPI_NAMESPACE_NODE *Node; 787 ACPI_STATUS Status; 788 789 790 /* Parameter validation */ 791 792 if (!ObjHandle || 793 !Handler) 794 { 795 return (AE_BAD_PARAMETER); 796 } 797 798 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 799 if (ACPI_FAILURE (Status)) 800 { 801 return (Status); 802 } 803 804 /* Convert and validate the handle */ 805 806 Node = AcpiNsMapHandleToNode (ObjHandle); 807 if (!Node) 808 { 809 Status = AE_BAD_PARAMETER; 810 goto UnlockAndExit; 811 } 812 813 Status = AcpiNsDetachData (Node, Handler); 814 815UnlockAndExit: 816 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 817 return (Status); 818} 819 820 821/******************************************************************************* 822 * 823 * FUNCTION: AcpiGetData 824 * 825 * PARAMETERS: ObjHandle - Namespace node 826 * Handler - Handler used in call to AttachData 827 * Data - Where the data is returned 828 * 829 * RETURN: Status 830 * 831 * DESCRIPTION: Retrieve data that was previously attached to a namespace node. 832 * 833 ******************************************************************************/ 834 835ACPI_STATUS 836AcpiGetData ( 837 ACPI_HANDLE ObjHandle, 838 ACPI_OBJECT_HANDLER Handler, 839 void **Data) 840{ 841 ACPI_NAMESPACE_NODE *Node; 842 ACPI_STATUS Status; 843 844 845 /* Parameter validation */ 846 847 if (!ObjHandle || 848 !Handler || 849 !Data) 850 { 851 return (AE_BAD_PARAMETER); 852 } 853 854 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); 855 if (ACPI_FAILURE (Status)) 856 { 857 return (Status); 858 } 859 860 /* Convert and validate the handle */ 861 862 Node = AcpiNsMapHandleToNode (ObjHandle); 863 if (!Node) 864 { 865 Status = AE_BAD_PARAMETER; 866 goto UnlockAndExit; 867 } 868 869 Status = AcpiNsGetAttachedData (Node, Handler, Data); 870 871UnlockAndExit: 872 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); 873 return (Status); 874} 875 876 877