1 /******************************************************************************
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
48 extern const UINT8 AcpiGbl_ResourceAmlSizes
[];
49 extern const UINT8 AcpiGbl_ResourceAmlSerialBusSizes
[];
51 /* Strings used by the disassembler and debugger resource dump routines */
53 #if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
55 extern const char *AcpiGbl_BmDecode
[];
56 extern const char *AcpiGbl_ConfigDecode
[];
57 extern const char *AcpiGbl_ConsumeDecode
[];
58 extern const char *AcpiGbl_DecDecode
[];
59 extern const char *AcpiGbl_HeDecode
[];
60 extern const char *AcpiGbl_IoDecode
[];
61 extern const char *AcpiGbl_LlDecode
[];
62 extern const char *AcpiGbl_MaxDecode
[];
63 extern const char *AcpiGbl_MemDecode
[];
64 extern const char *AcpiGbl_MinDecode
[];
65 extern const char *AcpiGbl_MtpDecode
[];
66 extern const char *AcpiGbl_RngDecode
[];
67 extern const char *AcpiGbl_RwDecode
[];
68 extern const char *AcpiGbl_ShrDecode
[];
69 extern const char *AcpiGbl_SizDecode
[];
70 extern const char *AcpiGbl_TrsDecode
[];
71 extern const char *AcpiGbl_TtpDecode
[];
72 extern const char *AcpiGbl_TypDecode
[];
73 extern const char *AcpiGbl_PpcDecode
[];
74 extern const char *AcpiGbl_IorDecode
[];
75 extern const char *AcpiGbl_DtsDecode
[];
76 extern const char *AcpiGbl_CtDecode
[];
77 extern const char *AcpiGbl_SbtDecode
[];
78 extern const char *AcpiGbl_AmDecode
[];
79 extern const char *AcpiGbl_SmDecode
[];
80 extern const char *AcpiGbl_WmDecode
[];
81 extern const char *AcpiGbl_CphDecode
[];
82 extern const char *AcpiGbl_CpoDecode
[];
83 extern const char *AcpiGbl_DpDecode
[];
84 extern const char *AcpiGbl_EdDecode
[];
85 extern const char *AcpiGbl_BpbDecode
[];
86 extern const char *AcpiGbl_SbDecode
[];
87 extern const char *AcpiGbl_FcDecode
[];
88 extern const char *AcpiGbl_PtDecode
[];
92 * For the iASL compiler case, the output is redirected to stderr so that
93 * any of the various ACPI errors and warnings do not appear in the output
94 * files, for either the compiler or disassembler portions of the tool.
96 #ifdef ACPI_ASL_COMPILER
100 #define ACPI_MSG_REDIRECT_BEGIN \
101 FILE *OutputFile = AcpiGbl_OutputFile; \
102 AcpiOsRedirectOutput (stderr);
104 #define ACPI_MSG_REDIRECT_END \
105 AcpiOsRedirectOutput (OutputFile);
109 * non-iASL case - no redirection, nothing to do
111 #define ACPI_MSG_REDIRECT_BEGIN
112 #define ACPI_MSG_REDIRECT_END
116 * Common error message prefixes
118 #ifndef ACPI_MSG_ERROR
119 #define ACPI_MSG_ERROR "ACPI Error: "
121 #ifndef ACPI_MSG_EXCEPTION
122 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
124 #ifndef ACPI_MSG_WARNING
125 #define ACPI_MSG_WARNING "ACPI Warning: "
127 #ifndef ACPI_MSG_INFO
128 #define ACPI_MSG_INFO "ACPI: "
131 #ifndef ACPI_MSG_BIOS_ERROR
132 #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): "
134 #ifndef ACPI_MSG_BIOS_WARNING
135 #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): "
139 * Common message suffix
141 #define ACPI_MSG_SUFFIX \
142 AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
145 /* Types for Resource descriptor entries */
147 #define ACPI_INVALID_RESOURCE 0
148 #define ACPI_FIXED_LENGTH 1
149 #define ACPI_VARIABLE_LENGTH 2
150 #define ACPI_SMALL_VARIABLE_LENGTH 3
153 ACPI_STATUS (*ACPI_WALK_AML_CALLBACK
) (
161 ACPI_STATUS (*ACPI_PKG_CALLBACK
) (
163 ACPI_OPERAND_OBJECT
*SourceObject
,
164 ACPI_GENERIC_STATE
*State
,
167 typedef struct acpi_pkg_info
176 /* Object reference counts */
178 #define REF_INCREMENT (UINT16) 0
179 #define REF_DECREMENT (UINT16) 1
181 /* AcpiUtDumpBuffer */
183 #define DB_BYTE_DISPLAY 1
184 #define DB_WORD_DISPLAY 2
185 #define DB_DWORD_DISPLAY 4
186 #define DB_QWORD_DISPLAY 8
190 * utascii - ASCII utilities
197 AcpiUtValidNameChar (
202 AcpiUtCheckAndRepairAscii (
209 * utnonansi - Non-ANSI C library functions
228 UINT32 MaxIntegerByteWidth
,
231 /* Values for MaxIntegerByteWidth above */
233 #define ACPI_MAX32_BYTE_WIDTH 4
234 #define ACPI_MAX64_BYTE_WIDTH 8
238 * utglobal - Global data structures and procedures
244 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
251 AcpiUtGetNotifyName (
253 ACPI_OBJECT_TYPE Type
);
258 ACPI_OBJECT_TYPE Type
);
265 AcpiUtGetDescriptorName (
269 AcpiUtGetReferenceName (
270 ACPI_OPERAND_OBJECT
*Object
);
273 AcpiUtGetObjectTypeName (
274 ACPI_OPERAND_OBJECT
*ObjDesc
);
277 AcpiUtGetRegionName (
285 AcpiUtHexToAsciiChar (
290 AcpiUtAsciiCharToHex (
294 AcpiUtValidObjectType (
295 ACPI_OBJECT_TYPE Type
);
299 * utinit - miscellaneous initialization and shutdown
302 AcpiUtHardwareInitialize (
306 AcpiUtSubsystemShutdown (
311 * utcopy - Object construction and conversion interfaces
314 AcpiUtBuildSimpleObject(
315 ACPI_OPERAND_OBJECT
*Obj
,
316 ACPI_OBJECT
*UserObj
,
318 UINT32
*BufferSpaceUsed
);
321 AcpiUtBuildPackageObject (
322 ACPI_OPERAND_OBJECT
*Obj
,
327 AcpiUtCopyIobjectToEobject (
328 ACPI_OPERAND_OBJECT
*Obj
,
329 ACPI_BUFFER
*RetBuffer
);
332 AcpiUtCopyEobjectToIobject (
334 ACPI_OPERAND_OBJECT
**InternalObj
);
337 AcpiUtCopyISimpleToIsimple (
338 ACPI_OPERAND_OBJECT
*SourceObj
,
339 ACPI_OPERAND_OBJECT
*DestObj
);
342 AcpiUtCopyIobjectToIobject (
343 ACPI_OPERAND_OBJECT
*SourceDesc
,
344 ACPI_OPERAND_OBJECT
**DestDesc
,
345 ACPI_WALK_STATE
*WalkState
);
349 * utcreate - Object creation
352 AcpiUtUpdateObjectReference (
353 ACPI_OPERAND_OBJECT
*Object
,
358 * utdebug - Debug interfaces
361 AcpiUtInitStackPtrTrace (
365 AcpiUtTrackStackPtr (
371 const char *FunctionName
,
372 const char *ModuleName
,
378 const char *FunctionName
,
379 const char *ModuleName
,
381 const void *Pointer
);
386 const char *FunctionName
,
387 const char *ModuleName
,
394 const char *FunctionName
,
395 const char *ModuleName
,
402 const char *FunctionName
,
403 const char *ModuleName
,
409 const char *FunctionName
,
410 const char *ModuleName
,
417 const char *FunctionName
,
418 const char *ModuleName
,
425 const char *FunctionName
,
426 const char *ModuleName
,
433 const char *FunctionName
,
434 const char *ModuleName
,
439 AcpiUtDebugDumpBuffer (
452 #ifdef ACPI_APPLICATION
454 AcpiUtDumpBufferToFile (
473 AcpiUtReportWarning (
479 * utdelete - Object deletion and reference counts
483 ACPI_OPERAND_OBJECT
*Object
);
486 AcpiUtRemoveReference (
487 ACPI_OPERAND_OBJECT
*Object
);
490 AcpiUtDeleteInternalPackageObject (
491 ACPI_OPERAND_OBJECT
*Object
);
494 AcpiUtDeleteInternalSimpleObject (
495 ACPI_OPERAND_OBJECT
*Object
);
498 AcpiUtDeleteInternalObjectList (
499 ACPI_OPERAND_OBJECT
**ObjList
);
503 * uteval - object evaluation
506 AcpiUtEvaluateObject (
507 ACPI_NAMESPACE_NODE
*PrefixNode
,
509 UINT32 ExpectedReturnBtypes
,
510 ACPI_OPERAND_OBJECT
**ReturnDesc
);
513 AcpiUtEvaluateNumericObject (
514 const char *ObjectName
,
515 ACPI_NAMESPACE_NODE
*DeviceNode
,
520 ACPI_NAMESPACE_NODE
*DeviceNode
,
521 UINT32
*StatusFlags
);
524 AcpiUtExecutePowerMethods (
525 ACPI_NAMESPACE_NODE
*DeviceNode
,
526 const char **MethodNames
,
532 * utids - device ID support
536 ACPI_NAMESPACE_NODE
*DeviceNode
,
537 ACPI_PNP_DEVICE_ID
**ReturnId
);
541 ACPI_NAMESPACE_NODE
*DeviceNode
,
542 ACPI_PNP_DEVICE_ID
**ReturnId
);
546 ACPI_NAMESPACE_NODE
*DeviceNode
,
547 ACPI_PNP_DEVICE_ID_LIST
**ReturnCidList
);
551 ACPI_NAMESPACE_NODE
*DeviceNode
,
552 ACPI_PNP_DEVICE_ID
**ReturnId
);
556 * utlock - reader/writer locks
567 AcpiUtAcquireReadLock (
571 AcpiUtReleaseReadLock (
575 AcpiUtAcquireWriteLock (
579 AcpiUtReleaseWriteLock (
584 * utobject - internal object create/delete/cache routines
586 ACPI_OPERAND_OBJECT
*
587 AcpiUtCreateInternalObjectDbg (
588 const char *ModuleName
,
591 ACPI_OBJECT_TYPE Type
);
594 AcpiUtAllocateObjectDescDbg (
595 const char *ModuleName
,
599 #define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t)
600 #define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT)
603 AcpiUtDeleteObjectDesc (
604 ACPI_OPERAND_OBJECT
*Object
);
607 AcpiUtValidInternalObject (
610 ACPI_OPERAND_OBJECT
*
611 AcpiUtCreatePackageObject (
614 ACPI_OPERAND_OBJECT
*
615 AcpiUtCreateIntegerObject (
618 ACPI_OPERAND_OBJECT
*
619 AcpiUtCreateBufferObject (
620 ACPI_SIZE BufferSize
);
622 ACPI_OPERAND_OBJECT
*
623 AcpiUtCreateStringObject (
624 ACPI_SIZE StringSize
);
628 ACPI_OPERAND_OBJECT
*Obj
,
629 ACPI_SIZE
*ObjLength
);
633 * utosi - Support for the _OSI predefined control method
636 AcpiUtInitializeInterfaces (
640 AcpiUtInterfaceTerminate (
644 AcpiUtInstallInterface (
645 ACPI_STRING InterfaceName
);
648 AcpiUtRemoveInterface (
649 ACPI_STRING InterfaceName
);
652 AcpiUtUpdateInterfaces (
655 ACPI_INTERFACE_INFO
*
657 ACPI_STRING InterfaceName
);
660 AcpiUtOsiImplementation (
661 ACPI_WALK_STATE
*WalkState
);
665 * utpredef - support for predefined names
667 const ACPI_PREDEFINED_INFO
*
668 AcpiUtGetNextPredefinedMethod (
669 const ACPI_PREDEFINED_INFO
*ThisName
);
671 const ACPI_PREDEFINED_INFO
*
672 AcpiUtMatchPredefinedMethod (
676 AcpiUtGetExpectedReturnTypes (
678 UINT32 ExpectedBtypes
);
680 #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
681 const ACPI_PREDEFINED_INFO
*
682 AcpiUtMatchResourceName (
686 AcpiUtDisplayPredefinedMethod (
688 const ACPI_PREDEFINED_INFO
*ThisName
,
692 AcpiUtGetResourceBitWidth (
699 * utstate - Generic state creation/cache routines
702 AcpiUtPushGenericState (
703 ACPI_GENERIC_STATE
**ListHead
,
704 ACPI_GENERIC_STATE
*State
);
707 AcpiUtPopGenericState (
708 ACPI_GENERIC_STATE
**ListHead
);
712 AcpiUtCreateGenericState (
716 AcpiUtCreateThreadState (
720 AcpiUtCreateUpdateState (
721 ACPI_OPERAND_OBJECT
*Object
,
725 AcpiUtCreatePkgState (
726 void *InternalObject
,
727 void *ExternalObject
,
731 AcpiUtCreateUpdateStateAndPush (
732 ACPI_OPERAND_OBJECT
*Object
,
734 ACPI_GENERIC_STATE
**StateList
);
737 AcpiUtCreateControlState (
741 AcpiUtDeleteGenericState (
742 ACPI_GENERIC_STATE
*State
);
753 UINT64
*OutRemainder
);
760 UINT32
*OutRemainder
);
766 const ACPI_EXCEPTION_INFO
*
767 AcpiUtValidateException (
771 AcpiUtIsPciRootBridge (
774 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
777 ACPI_TABLE_HEADER
*Table
);
781 AcpiUtWalkPackageTree (
782 ACPI_OPERAND_OBJECT
*SourceObject
,
784 ACPI_PKG_CALLBACK WalkCallback
,
787 /* Values for Base above (16=Hex, 10=Decimal) */
789 #define ACPI_ANY_BASE 0
793 AcpiUtDwordByteSwap (
797 AcpiUtSetIntegerWidth (
800 #ifdef ACPI_DEBUG_OUTPUT
802 AcpiUtDisplayInitPathname (
804 ACPI_NAMESPACE_NODE
*ObjHandle
,
810 * utownerid - Support for Table/Method Owner IDs
813 AcpiUtAllocateOwnerId (
814 ACPI_OWNER_ID
*OwnerId
);
817 AcpiUtReleaseOwnerId (
818 ACPI_OWNER_ID
*OwnerId
);
825 AcpiUtWalkAmlResources (
826 ACPI_WALK_STATE
*WalkState
,
829 ACPI_WALK_AML_CALLBACK UserFunction
,
833 AcpiUtValidateResource (
834 ACPI_WALK_STATE
*WalkState
,
839 AcpiUtGetDescriptorLength (
843 AcpiUtGetResourceLength (
847 AcpiUtGetResourceHeaderLength (
851 AcpiUtGetResourceType (
855 AcpiUtGetResourceEndTag (
856 ACPI_OPERAND_OBJECT
*ObjDesc
,
861 * utstring - String and character utilities
868 #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
870 UtConvertBackslashes (
878 #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
896 ACPI_SIZE MaxTransferLength
);
901 * utmutex - mutex support
904 AcpiUtMutexInitialize (
908 AcpiUtMutexTerminate (
913 ACPI_MUTEX_HANDLE MutexId
);
917 ACPI_MUTEX_HANDLE MutexId
);
921 * utalloc - memory allocation and object caching
932 AcpiUtValidateBuffer (
933 ACPI_BUFFER
*Buffer
);
936 AcpiUtInitializeBuffer (
938 ACPI_SIZE RequiredLength
);
940 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
942 AcpiUtAllocateAndTrack (
949 AcpiUtAllocateZeroedAndTrack (
963 AcpiUtDumpAllocationInfo (
967 AcpiUtDumpAllocations (
973 const char *ListName
,
975 ACPI_MEMORY_LIST
**ReturnCache
);
977 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
981 * utaddress - address range check
984 AcpiUtAddAddressRange (
985 ACPI_ADR_SPACE_TYPE SpaceId
,
986 ACPI_PHYSICAL_ADDRESS Address
,
988 ACPI_NAMESPACE_NODE
*RegionNode
);
991 AcpiUtRemoveAddressRange (
992 ACPI_ADR_SPACE_TYPE SpaceId
,
993 ACPI_NAMESPACE_NODE
*RegionNode
);
996 AcpiUtCheckAddressRange (
997 ACPI_ADR_SPACE_TYPE SpaceId
,
998 ACPI_PHYSICAL_ADDRESS Address
,
1003 AcpiUtDeleteAddressLists (
1008 * utxferror - various error/warning output functions
1010 void ACPI_INTERNAL_VAR_XFACE
1011 AcpiUtPredefinedWarning (
1012 const char *ModuleName
,
1019 void ACPI_INTERNAL_VAR_XFACE
1020 AcpiUtPredefinedInfo (
1021 const char *ModuleName
,
1028 void ACPI_INTERNAL_VAR_XFACE
1029 AcpiUtPredefinedBiosError (
1030 const char *ModuleName
,
1038 AcpiUtNamespaceError (
1039 const char *ModuleName
,
1041 const char *InternalName
,
1042 ACPI_STATUS LookupStatus
);
1046 const char *ModuleName
,
1048 const char *Message
,
1049 ACPI_NAMESPACE_NODE
*Node
,
1051 ACPI_STATUS LookupStatus
);
1055 * Utility functions for ACPI names and IDs
1057 const AH_PREDEFINED_NAME
*
1058 AcpiAhMatchPredefinedName (
1061 const AH_DEVICE_ID
*
1062 AcpiAhMatchHardwareId (
1071 * utprint - printf/vprintf output functions
1097 #ifdef ACPI_APPLICATION
1113 * utuuid -- UUID support functions
1115 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP)
1117 AcpiUtConvertStringToUuid (
1122 #endif /* _ACUTILS_H */