acutils.h revision 80062
1/****************************************************************************** 2 * 3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures 4 * $Revision: 104 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#ifndef _ACUTILS_H 118#define _ACUTILS_H 119 120 121typedef 122ACPI_STATUS (*ACPI_PKG_CALLBACK) ( 123 UINT8 ObjectType, 124 ACPI_OPERAND_OBJECT *SourceObject, 125 ACPI_GENERIC_STATE *State, 126 void *Context); 127 128 129ACPI_STATUS 130AcpiUtWalkPackageTree ( 131 ACPI_OPERAND_OBJECT *SourceObject, 132 void *TargetObject, 133 ACPI_PKG_CALLBACK WalkCallback, 134 void *Context); 135 136 137typedef struct acpi_pkg_info 138{ 139 UINT8 *FreeSpace; 140 UINT32 Length; 141 UINT32 ObjectSpace; 142 UINT32 NumPackages; 143} ACPI_PKG_INFO; 144 145#define REF_INCREMENT (UINT16) 0 146#define REF_DECREMENT (UINT16) 1 147#define REF_FORCE_DELETE (UINT16) 2 148 149/* AcpiUtDumpBuffer */ 150 151#define DB_BYTE_DISPLAY 1 152#define DB_WORD_DISPLAY 2 153#define DB_DWORD_DISPLAY 4 154#define DB_QWORD_DISPLAY 8 155 156 157/* Global initialization interfaces */ 158 159void 160AcpiUtInitGlobals ( 161 void); 162 163void 164AcpiUtTerminate ( 165 void); 166 167 168/* 169 * UtInit - miscellaneous initialization and shutdown 170 */ 171 172ACPI_STATUS 173AcpiUtHardwareInitialize ( 174 void); 175 176ACPI_STATUS 177AcpiUtSubsystemShutdown ( 178 void); 179 180ACPI_STATUS 181AcpiUtValidateFadt ( 182 void); 183 184/* 185 * UtGlobal - Global data structures and procedures 186 */ 187 188#ifdef ACPI_DEBUG 189 190NATIVE_CHAR * 191AcpiUtGetMutexName ( 192 UINT32 MutexId); 193 194NATIVE_CHAR * 195AcpiUtGetTypeName ( 196 UINT32 Type); 197 198NATIVE_CHAR * 199AcpiUtGetRegionName ( 200 UINT8 SpaceId); 201 202#endif 203 204 205BOOLEAN 206AcpiUtValidObjectType ( 207 UINT32 Type); 208 209ACPI_OWNER_ID 210AcpiUtAllocateOwnerId ( 211 UINT32 IdType); 212 213 214/* 215 * UtClib - Local implementations of C library functions 216 */ 217 218#ifndef ACPI_USE_SYSTEM_CLIBRARY 219 220UINT32 221AcpiUtStrlen ( 222 const NATIVE_CHAR *String); 223 224NATIVE_CHAR * 225AcpiUtStrcpy ( 226 NATIVE_CHAR *DstString, 227 const NATIVE_CHAR *SrcString); 228 229NATIVE_CHAR * 230AcpiUtStrncpy ( 231 NATIVE_CHAR *DstString, 232 const NATIVE_CHAR *SrcString, 233 NATIVE_UINT Count); 234 235UINT32 236AcpiUtStrncmp ( 237 const NATIVE_CHAR *String1, 238 const NATIVE_CHAR *String2, 239 NATIVE_UINT Count); 240 241UINT32 242AcpiUtStrcmp ( 243 const NATIVE_CHAR *String1, 244 const NATIVE_CHAR *String2); 245 246NATIVE_CHAR * 247AcpiUtStrcat ( 248 NATIVE_CHAR *DstString, 249 const NATIVE_CHAR *SrcString); 250 251NATIVE_CHAR * 252AcpiUtStrncat ( 253 NATIVE_CHAR *DstString, 254 const NATIVE_CHAR *SrcString, 255 NATIVE_UINT Count); 256 257UINT32 258AcpiUtStrtoul ( 259 const NATIVE_CHAR *String, 260 NATIVE_CHAR **Terminator, 261 UINT32 Base); 262 263NATIVE_CHAR * 264AcpiUtStrstr ( 265 NATIVE_CHAR *String1, 266 NATIVE_CHAR *String2); 267 268void * 269AcpiUtMemcpy ( 270 void *Dest, 271 const void *Src, 272 NATIVE_UINT Count); 273 274void * 275AcpiUtMemset ( 276 void *Dest, 277 NATIVE_UINT Value, 278 NATIVE_UINT Count); 279 280UINT32 281AcpiUtToUpper ( 282 UINT32 c); 283 284UINT32 285AcpiUtToLower ( 286 UINT32 c); 287 288#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 289 290/* 291 * UtCopy - Object construction and conversion interfaces 292 */ 293 294ACPI_STATUS 295AcpiUtBuildSimpleObject( 296 ACPI_OPERAND_OBJECT *Obj, 297 ACPI_OBJECT *UserObj, 298 UINT8 *DataSpace, 299 UINT32 *BufferSpaceUsed); 300 301ACPI_STATUS 302AcpiUtBuildPackageObject ( 303 ACPI_OPERAND_OBJECT *Obj, 304 UINT8 *Buffer, 305 UINT32 *SpaceUsed); 306 307ACPI_STATUS 308AcpiUtCopyIobjectToEobject ( 309 ACPI_OPERAND_OBJECT *Obj, 310 ACPI_BUFFER *RetBuffer); 311 312ACPI_STATUS 313AcpiUtCopyEsimpleToIsimple( 314 ACPI_OBJECT *UserObj, 315 ACPI_OPERAND_OBJECT *Obj); 316 317ACPI_STATUS 318AcpiUtCopyEobjectToIobject ( 319 ACPI_OBJECT *Obj, 320 ACPI_OPERAND_OBJECT *InternalObj); 321 322ACPI_STATUS 323AcpiUtCopyISimpleToIsimple ( 324 ACPI_OPERAND_OBJECT *SourceObj, 325 ACPI_OPERAND_OBJECT *DestObj); 326 327ACPI_STATUS 328AcpiUtCopyIpackageToIpackage ( 329 ACPI_OPERAND_OBJECT *SourceObj, 330 ACPI_OPERAND_OBJECT *DestObj, 331 ACPI_WALK_STATE *WalkState); 332 333 334/* 335 * UtCreate - Object creation 336 */ 337 338ACPI_STATUS 339AcpiUtUpdateObjectReference ( 340 ACPI_OPERAND_OBJECT *Object, 341 UINT16 Action); 342 343ACPI_OPERAND_OBJECT * 344_UtCreateInternalObject ( 345 NATIVE_CHAR *ModuleName, 346 UINT32 LineNumber, 347 UINT32 ComponentId, 348 ACPI_OBJECT_TYPE8 Type); 349 350 351/* 352 * UtDebug - Debug interfaces 353 */ 354 355UINT32 356GetDebugLevel ( 357 void); 358 359void 360SetDebugLevel ( 361 UINT32 level); 362 363void 364FunctionTrace ( 365 NATIVE_CHAR *ModuleName, 366 UINT32 LineNumber, 367 UINT32 ComponentId, 368 NATIVE_CHAR *FunctionName); 369 370void 371FunctionTracePtr ( 372 NATIVE_CHAR *ModuleName, 373 UINT32 LineNumber, 374 UINT32 ComponentId, 375 NATIVE_CHAR *FunctionName, 376 void *Pointer); 377 378void 379FunctionTraceU32 ( 380 NATIVE_CHAR *ModuleName, 381 UINT32 LineNumber, 382 UINT32 ComponentId, 383 NATIVE_CHAR *FunctionName, 384 UINT32 Integer); 385 386void 387FunctionTraceStr ( 388 NATIVE_CHAR *ModuleName, 389 UINT32 LineNumber, 390 UINT32 ComponentId, 391 NATIVE_CHAR *FunctionName, 392 NATIVE_CHAR *String); 393 394void 395FunctionExit ( 396 NATIVE_CHAR *ModuleName, 397 UINT32 LineNumber, 398 UINT32 ComponentId, 399 NATIVE_CHAR *FunctionName); 400 401void 402FunctionStatusExit ( 403 NATIVE_CHAR *ModuleName, 404 UINT32 LineNumber, 405 UINT32 ComponentId, 406 NATIVE_CHAR *FunctionName, 407 ACPI_STATUS Status); 408 409void 410FunctionValueExit ( 411 NATIVE_CHAR *ModuleName, 412 UINT32 LineNumber, 413 UINT32 ComponentId, 414 NATIVE_CHAR *FunctionName, 415 ACPI_INTEGER Value); 416 417void 418FunctionPtrExit ( 419 NATIVE_CHAR *ModuleName, 420 UINT32 LineNumber, 421 UINT32 ComponentId, 422 NATIVE_CHAR *FunctionName, 423 UINT8 *Ptr); 424 425void 426DebugPrintPrefix ( 427 NATIVE_CHAR *ModuleName, 428 UINT32 LineNumber); 429 430void 431DebugPrint ( 432 NATIVE_CHAR *ModuleName, 433 UINT32 LineNumber, 434 UINT32 ComponentId, 435 UINT32 PrintLevel, 436 NATIVE_CHAR *Format, ...); 437 438void 439DebugPrintRaw ( 440 NATIVE_CHAR *Format, ...); 441 442void 443_ReportInfo ( 444 NATIVE_CHAR *ModuleName, 445 UINT32 LineNumber, 446 UINT32 ComponentId); 447 448void 449_ReportError ( 450 NATIVE_CHAR *ModuleName, 451 UINT32 LineNumber, 452 UINT32 ComponentId); 453 454void 455_ReportWarning ( 456 NATIVE_CHAR *ModuleName, 457 UINT32 LineNumber, 458 UINT32 ComponentId); 459 460void 461AcpiUtDumpBuffer ( 462 UINT8 *Buffer, 463 UINT32 Count, 464 UINT32 Display, 465 UINT32 componentId); 466 467 468/* 469 * UtDelete - Object deletion 470 */ 471 472void 473AcpiUtDeleteInternalObj ( 474 ACPI_OPERAND_OBJECT *Object); 475 476void 477AcpiUtDeleteInternalPackageObject ( 478 ACPI_OPERAND_OBJECT *Object); 479 480void 481AcpiUtDeleteInternalSimpleObject ( 482 ACPI_OPERAND_OBJECT *Object); 483 484ACPI_STATUS 485AcpiUtDeleteInternalObjectList ( 486 ACPI_OPERAND_OBJECT **ObjList); 487 488 489/* 490 * UtEval - object evaluation 491 */ 492 493/* Method name strings */ 494 495#define METHOD_NAME__HID "_HID" 496#define METHOD_NAME__UID "_UID" 497#define METHOD_NAME__ADR "_ADR" 498#define METHOD_NAME__STA "_STA" 499#define METHOD_NAME__REG "_REG" 500#define METHOD_NAME__SEG "_SEG" 501#define METHOD_NAME__BBN "_BBN" 502 503 504ACPI_STATUS 505AcpiUtEvaluateNumericObject ( 506 NATIVE_CHAR *ObjectName, 507 ACPI_NAMESPACE_NODE *DeviceNode, 508 ACPI_INTEGER *Address); 509 510ACPI_STATUS 511AcpiUtExecute_HID ( 512 ACPI_NAMESPACE_NODE *DeviceNode, 513 ACPI_DEVICE_ID *Hid); 514 515ACPI_STATUS 516AcpiUtExecute_STA ( 517 ACPI_NAMESPACE_NODE *DeviceNode, 518 UINT32 *StatusFlags); 519 520ACPI_STATUS 521AcpiUtExecute_UID ( 522 ACPI_NAMESPACE_NODE *DeviceNode, 523 ACPI_DEVICE_ID *Uid); 524 525 526/* 527 * UtMutex - mutual exclusion interfaces 528 */ 529 530ACPI_STATUS 531AcpiUtMutexInitialize ( 532 void); 533 534void 535AcpiUtMutexTerminate ( 536 void); 537 538ACPI_STATUS 539AcpiUtCreateMutex ( 540 ACPI_MUTEX_HANDLE MutexId); 541 542ACPI_STATUS 543AcpiUtDeleteMutex ( 544 ACPI_MUTEX_HANDLE MutexId); 545 546ACPI_STATUS 547AcpiUtAcquireMutex ( 548 ACPI_MUTEX_HANDLE MutexId); 549 550ACPI_STATUS 551AcpiUtReleaseMutex ( 552 ACPI_MUTEX_HANDLE MutexId); 553 554 555/* 556 * UtObject - internal object create/delete/cache routines 557 */ 558 559void * 560_UtAllocateObjectDesc ( 561 NATIVE_CHAR *ModuleName, 562 UINT32 LineNumber, 563 UINT32 ComponentId); 564 565#define AcpiUtCreateInternalObject(t) _UtCreateInternalObject(_THIS_MODULE,__LINE__,_COMPONENT,t) 566#define AcpiUtAllocateObjectDesc() _UtAllocateObjectDesc(_THIS_MODULE,__LINE__,_COMPONENT) 567 568void 569AcpiUtDeleteObjectDesc ( 570 ACPI_OPERAND_OBJECT *Object); 571 572BOOLEAN 573AcpiUtValidInternalObject ( 574 void *Object); 575 576 577/* 578 * UtRefCnt - Object reference count management 579 */ 580 581void 582AcpiUtAddReference ( 583 ACPI_OPERAND_OBJECT *Object); 584 585void 586AcpiUtRemoveReference ( 587 ACPI_OPERAND_OBJECT *Object); 588 589/* 590 * UtSize - Object size routines 591 */ 592 593ACPI_STATUS 594AcpiUtGetSimpleObjectSize ( 595 ACPI_OPERAND_OBJECT *Obj, 596 UINT32 *ObjLength); 597 598ACPI_STATUS 599AcpiUtGetPackageObjectSize ( 600 ACPI_OPERAND_OBJECT *Obj, 601 UINT32 *ObjLength); 602 603ACPI_STATUS 604AcpiUtGetObjectSize( 605 ACPI_OPERAND_OBJECT *Obj, 606 UINT32 *ObjLength); 607 608 609/* 610 * UtState - Generic state creation/cache routines 611 */ 612 613void 614AcpiUtPushGenericState ( 615 ACPI_GENERIC_STATE **ListHead, 616 ACPI_GENERIC_STATE *State); 617 618ACPI_GENERIC_STATE * 619AcpiUtPopGenericState ( 620 ACPI_GENERIC_STATE **ListHead); 621 622 623ACPI_GENERIC_STATE * 624AcpiUtCreateGenericState ( 625 void); 626 627ACPI_GENERIC_STATE * 628AcpiUtCreateUpdateState ( 629 ACPI_OPERAND_OBJECT *Object, 630 UINT16 Action); 631 632ACPI_GENERIC_STATE * 633AcpiUtCreatePkgState ( 634 void *InternalObject, 635 void *ExternalObject, 636 UINT16 Index); 637 638ACPI_STATUS 639AcpiUtCreateUpdateStateAndPush ( 640 ACPI_OPERAND_OBJECT *Object, 641 UINT16 Action, 642 ACPI_GENERIC_STATE **StateList); 643 644ACPI_STATUS 645AcpiUtCreatePkgStateAndPush ( 646 void *InternalObject, 647 void *ExternalObject, 648 UINT16 Index, 649 ACPI_GENERIC_STATE **StateList); 650 651ACPI_GENERIC_STATE * 652AcpiUtCreateControlState ( 653 void); 654 655void 656AcpiUtDeleteGenericState ( 657 ACPI_GENERIC_STATE *State); 658 659void 660AcpiUtDeleteGenericStateCache ( 661 void); 662 663void 664AcpiUtDeleteObjectCache ( 665 void); 666 667/* 668 * Ututils 669 */ 670 671BOOLEAN 672AcpiUtValidAcpiName ( 673 UINT32 Name); 674 675BOOLEAN 676AcpiUtValidAcpiCharacter ( 677 NATIVE_CHAR Character); 678 679NATIVE_CHAR * 680AcpiUtStrupr ( 681 NATIVE_CHAR *SrcString); 682 683ACPI_STATUS 684AcpiUtResolvePackageReferences ( 685 ACPI_OPERAND_OBJECT *ObjDesc); 686 687 688#ifdef ACPI_DEBUG 689void 690AcpiUtDisplayInitPathname ( 691 ACPI_HANDLE ObjHandle, 692 char *Path); 693 694#endif 695 696 697/* 698 * Memory allocation functions and related macros. 699 * Macros that expand to include filename and line number 700 */ 701 702void * 703AcpiUtAllocate ( 704 UINT32 Size, 705 UINT32 Component, 706 NATIVE_CHAR *Module, 707 UINT32 Line); 708 709void * 710AcpiUtCallocate ( 711 UINT32 Size, 712 UINT32 Component, 713 NATIVE_CHAR *Module, 714 UINT32 Line); 715 716void 717AcpiUtFree ( 718 void *Address, 719 UINT32 Component, 720 NATIVE_CHAR *Module, 721 UINT32 Line); 722 723void 724AcpiUtInitStaticObject ( 725 ACPI_OPERAND_OBJECT *ObjDesc); 726 727 728#ifdef ACPI_DBG_TRACK_ALLOCATIONS 729void 730AcpiUtDumpAllocationInfo ( 731 void); 732 733void 734AcpiUtDumpCurrentAllocations ( 735 UINT32 Component, 736 NATIVE_CHAR *Module); 737#endif 738 739 740 741#endif /* _ACUTILS_H */ 742