1 /******************************************************************************
2  *
3  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2018, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
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.
25  *
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.
29  *
30  * NO WARRANTY
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.
42  */
43 
44 #ifndef _ACUTILS_H
45 #define _ACUTILS_H
46 
47 
48 extern const UINT8                      AcpiGbl_ResourceAmlSizes[];
49 extern const UINT8                      AcpiGbl_ResourceAmlSerialBusSizes[];
50 
51 /* Strings used by the disassembler and debugger resource dump routines */
52 
53 #if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
54 
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[];
89 extern const char                       *AcpiGbl_PtypDecode[];
90 #endif
91 
92 /*
93  * For the iASL compiler case, the output is redirected to stderr so that
94  * any of the various ACPI errors and warnings do not appear in the output
95  * files, for either the compiler or disassembler portions of the tool.
96  */
97 #ifdef ACPI_ASL_COMPILER
98 
99 #include <stdio.h>
100 
101 #define ACPI_MSG_REDIRECT_BEGIN \
102     FILE                    *OutputFile = AcpiGbl_OutputFile; \
103     AcpiOsRedirectOutput (stderr);
104 
105 #define ACPI_MSG_REDIRECT_END \
106     AcpiOsRedirectOutput (OutputFile);
107 
108 #else
109 /*
110  * non-iASL case - no redirection, nothing to do
111  */
112 #define ACPI_MSG_REDIRECT_BEGIN
113 #define ACPI_MSG_REDIRECT_END
114 #endif
115 
116 /*
117  * Common error message prefixes
118  */
119 #ifndef ACPI_MSG_ERROR
120 #define ACPI_MSG_ERROR          "ACPI Error: "
121 #endif
122 #ifndef ACPI_MSG_WARNING
123 #define ACPI_MSG_WARNING        "ACPI Warning: "
124 #endif
125 #ifndef ACPI_MSG_INFO
126 #define ACPI_MSG_INFO           "ACPI: "
127 #endif
128 
129 #ifndef ACPI_MSG_BIOS_ERROR
130 #define ACPI_MSG_BIOS_ERROR     "Firmware Error (ACPI): "
131 #endif
132 #ifndef ACPI_MSG_BIOS_WARNING
133 #define ACPI_MSG_BIOS_WARNING   "Firmware Warning (ACPI): "
134 #endif
135 
136 /*
137  * Common message suffix
138  */
139 #define ACPI_MSG_SUFFIX \
140     AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
141 
142 /* Flags to indicate implicit or explicit string-to-integer conversion */
143 
144 #define ACPI_IMPLICIT_CONVERSION        TRUE
145 #define ACPI_NO_IMPLICIT_CONVERSION     FALSE
146 
147 /* Types for Resource descriptor entries */
148 
149 #define ACPI_INVALID_RESOURCE           0
150 #define ACPI_FIXED_LENGTH               1
151 #define ACPI_VARIABLE_LENGTH            2
152 #define ACPI_SMALL_VARIABLE_LENGTH      3
153 
154 typedef
155 ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) (
156     UINT8                   *Aml,
157     UINT32                  Length,
158     UINT32                  Offset,
159     UINT8                   ResourceIndex,
160     void                    **Context);
161 
162 typedef
163 ACPI_STATUS (*ACPI_PKG_CALLBACK) (
164     UINT8                   ObjectType,
165     ACPI_OPERAND_OBJECT     *SourceObject,
166     ACPI_GENERIC_STATE      *State,
167     void                    *Context);
168 
169 typedef struct acpi_pkg_info
170 {
171     UINT8                   *FreeSpace;
172     ACPI_SIZE               Length;
173     UINT32                  ObjectSpace;
174     UINT32                  NumPackages;
175 
176 } ACPI_PKG_INFO;
177 
178 /* Object reference counts */
179 
180 #define REF_INCREMENT       (UINT16) 0
181 #define REF_DECREMENT       (UINT16) 1
182 
183 /* AcpiUtDumpBuffer */
184 
185 #define DB_BYTE_DISPLAY     1
186 #define DB_WORD_DISPLAY     2
187 #define DB_DWORD_DISPLAY    4
188 #define DB_QWORD_DISPLAY    8
189 
190 
191 /*
192  * utascii - ASCII utilities
193  */
194 BOOLEAN
195 AcpiUtValidNameseg (
196     char                    *Signature);
197 
198 BOOLEAN
199 AcpiUtValidNameChar (
200     char                    Character,
201     UINT32                  Position);
202 
203 void
204 AcpiUtCheckAndRepairAscii (
205     UINT8                   *Name,
206     char                    *RepairedName,
207     UINT32                  Count);
208 
209 
210 /*
211  * utnonansi - Non-ANSI C library functions
212  */
213 void
214 AcpiUtStrupr (
215     char                    *SrcString);
216 
217 void
218 AcpiUtStrlwr (
219     char                    *SrcString);
220 
221 int
222 AcpiUtStricmp (
223     char                    *String1,
224     char                    *String2);
225 
226 
227 /*
228  * utstrsuppt - string-to-integer conversion support functions
229  */
230 ACPI_STATUS
231 AcpiUtConvertOctalString (
232     char                    *String,
233     UINT64                  *ReturnValue);
234 
235 ACPI_STATUS
236 AcpiUtConvertDecimalString (
237     char                    *String,
238     UINT64                  *ReturnValuePtr);
239 
240 ACPI_STATUS
241 AcpiUtConvertHexString (
242     char                    *String,
243     UINT64                  *ReturnValuePtr);
244 
245 char
246 AcpiUtRemoveWhitespace (
247     char                    **String);
248 
249 char
250 AcpiUtRemoveLeadingZeros (
251     char                    **String);
252 
253 BOOLEAN
254 AcpiUtDetectHexPrefix (
255     char                    **String);
256 
257 void
258 AcpiUtRemoveHexPrefix (
259     char                    **String);
260 
261 BOOLEAN
262 AcpiUtDetectOctalPrefix (
263     char                    **String);
264 
265 
266 /*
267  * utstrtoul64 - string-to-integer conversion functions
268  */
269 ACPI_STATUS
270 AcpiUtStrtoul64 (
271     char                    *String,
272     UINT64                  *RetInteger);
273 
274 UINT64
275 AcpiUtExplicitStrtoul64 (
276     char                    *String);
277 
278 UINT64
279 AcpiUtImplicitStrtoul64 (
280     char                    *String);
281 
282 
283 /*
284  * utglobal - Global data structures and procedures
285  */
286 ACPI_STATUS
287 AcpiUtInitGlobals (
288     void);
289 
290 const char *
291 AcpiUtGetMutexName (
292     UINT32                  MutexId);
293 
294 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
295 
296 const char *
297 AcpiUtGetNotifyName (
298     UINT32                  NotifyValue,
299     ACPI_OBJECT_TYPE        Type);
300 #endif
301 
302 const char *
303 AcpiUtGetTypeName (
304     ACPI_OBJECT_TYPE        Type);
305 
306 const char *
307 AcpiUtGetNodeName (
308     void                    *Object);
309 
310 const char *
311 AcpiUtGetDescriptorName (
312     void                    *Object);
313 
314 const char *
315 AcpiUtGetReferenceName (
316     ACPI_OPERAND_OBJECT     *Object);
317 
318 const char *
319 AcpiUtGetObjectTypeName (
320     ACPI_OPERAND_OBJECT     *ObjDesc);
321 
322 const char *
323 AcpiUtGetRegionName (
324     UINT8                   SpaceId);
325 
326 const char *
327 AcpiUtGetEventName (
328     UINT32                  EventId);
329 
330 const char *
331 AcpiUtGetArgumentTypeName (
332     UINT32                  ArgType);
333 
334 char
335 AcpiUtHexToAsciiChar (
336     UINT64                  Integer,
337     UINT32                  Position);
338 
339 ACPI_STATUS
340 AcpiUtAsciiToHexByte (
341     char                    *TwoAsciiChars,
342     UINT8                   *ReturnByte);
343 
344 UINT8
345 AcpiUtAsciiCharToHex (
346     int                     HexChar);
347 
348 BOOLEAN
349 AcpiUtValidObjectType (
350     ACPI_OBJECT_TYPE        Type);
351 
352 
353 /*
354  * utinit - miscellaneous initialization and shutdown
355  */
356 ACPI_STATUS
357 AcpiUtHardwareInitialize (
358     void);
359 
360 void
361 AcpiUtSubsystemShutdown (
362     void);
363 
364 
365 /*
366  * utcopy - Object construction and conversion interfaces
367  */
368 ACPI_STATUS
369 AcpiUtBuildSimpleObject(
370     ACPI_OPERAND_OBJECT     *Obj,
371     ACPI_OBJECT             *UserObj,
372     UINT8                   *DataSpace,
373     UINT32                  *BufferSpaceUsed);
374 
375 ACPI_STATUS
376 AcpiUtBuildPackageObject (
377     ACPI_OPERAND_OBJECT     *Obj,
378     UINT8                   *Buffer,
379     UINT32                  *SpaceUsed);
380 
381 ACPI_STATUS
382 AcpiUtCopyIobjectToEobject (
383     ACPI_OPERAND_OBJECT     *Obj,
384     ACPI_BUFFER             *RetBuffer);
385 
386 ACPI_STATUS
387 AcpiUtCopyEobjectToIobject (
388     ACPI_OBJECT             *Obj,
389     ACPI_OPERAND_OBJECT     **InternalObj);
390 
391 ACPI_STATUS
392 AcpiUtCopyISimpleToIsimple (
393     ACPI_OPERAND_OBJECT     *SourceObj,
394     ACPI_OPERAND_OBJECT     *DestObj);
395 
396 ACPI_STATUS
397 AcpiUtCopyIobjectToIobject (
398     ACPI_OPERAND_OBJECT     *SourceDesc,
399     ACPI_OPERAND_OBJECT     **DestDesc,
400     ACPI_WALK_STATE         *WalkState);
401 
402 
403 /*
404  * utcreate - Object creation
405  */
406 ACPI_STATUS
407 AcpiUtUpdateObjectReference (
408     ACPI_OPERAND_OBJECT     *Object,
409     UINT16                  Action);
410 
411 
412 /*
413  * utdebug - Debug interfaces
414  */
415 void
416 AcpiUtInitStackPtrTrace (
417     void);
418 
419 void
420 AcpiUtTrackStackPtr (
421     void);
422 
423 void
424 AcpiUtTrace (
425     UINT32                  LineNumber,
426     const char              *FunctionName,
427     const char              *ModuleName,
428     UINT32                  ComponentId);
429 
430 void
431 AcpiUtTracePtr (
432     UINT32                  LineNumber,
433     const char              *FunctionName,
434     const char              *ModuleName,
435     UINT32                  ComponentId,
436     const void              *Pointer);
437 
438 void
439 AcpiUtTraceU32 (
440     UINT32                  LineNumber,
441     const char              *FunctionName,
442     const char              *ModuleName,
443     UINT32                  ComponentId,
444     UINT32                  Integer);
445 
446 void
447 AcpiUtTraceStr (
448     UINT32                  LineNumber,
449     const char              *FunctionName,
450     const char              *ModuleName,
451     UINT32                  ComponentId,
452     const char              *String);
453 
454 void
455 AcpiUtExit (
456     UINT32                  LineNumber,
457     const char              *FunctionName,
458     const char              *ModuleName,
459     UINT32                  ComponentId);
460 
461 void
462 AcpiUtStatusExit (
463     UINT32                  LineNumber,
464     const char              *FunctionName,
465     const char              *ModuleName,
466     UINT32                  ComponentId,
467     ACPI_STATUS             Status);
468 
469 void
470 AcpiUtValueExit (
471     UINT32                  LineNumber,
472     const char              *FunctionName,
473     const char              *ModuleName,
474     UINT32                  ComponentId,
475     UINT64                  Value);
476 
477 void
478 AcpiUtPtrExit (
479     UINT32                  LineNumber,
480     const char              *FunctionName,
481     const char              *ModuleName,
482     UINT32                  ComponentId,
483     UINT8                   *Ptr);
484 
485 void
486 AcpiUtStrExit (
487     UINT32                  LineNumber,
488     const char              *FunctionName,
489     const char              *ModuleName,
490     UINT32                  ComponentId,
491     const char              *String);
492 
493 void
494 AcpiUtDebugDumpBuffer (
495     UINT8                   *Buffer,
496     UINT32                  Count,
497     UINT32                  Display,
498     UINT32                  ComponentId);
499 
500 void
501 AcpiUtDumpBuffer (
502     UINT8                   *Buffer,
503     UINT32                  Count,
504     UINT32                  Display,
505     UINT32                  Offset);
506 
507 #ifdef ACPI_APPLICATION
508 void
509 AcpiUtDumpBufferToFile (
510     ACPI_FILE               File,
511     UINT8                   *Buffer,
512     UINT32                  Count,
513     UINT32                  Display,
514     UINT32                  BaseOffset);
515 #endif
516 
517 void
518 AcpiUtReportError (
519     char                    *ModuleName,
520     UINT32                  LineNumber);
521 
522 void
523 AcpiUtReportInfo (
524     char                    *ModuleName,
525     UINT32                  LineNumber);
526 
527 void
528 AcpiUtReportWarning (
529     char                    *ModuleName,
530     UINT32                  LineNumber);
531 
532 
533 /*
534  * utdelete - Object deletion and reference counts
535  */
536 void
537 AcpiUtAddReference (
538     ACPI_OPERAND_OBJECT     *Object);
539 
540 void
541 AcpiUtRemoveReference (
542     ACPI_OPERAND_OBJECT     *Object);
543 
544 void
545 AcpiUtDeleteInternalPackageObject (
546     ACPI_OPERAND_OBJECT     *Object);
547 
548 void
549 AcpiUtDeleteInternalSimpleObject (
550     ACPI_OPERAND_OBJECT     *Object);
551 
552 void
553 AcpiUtDeleteInternalObjectList (
554     ACPI_OPERAND_OBJECT     **ObjList);
555 
556 
557 /*
558  * uteval - object evaluation
559  */
560 ACPI_STATUS
561 AcpiUtEvaluateObject (
562     ACPI_NAMESPACE_NODE     *PrefixNode,
563     const char              *Path,
564     UINT32                  ExpectedReturnBtypes,
565     ACPI_OPERAND_OBJECT     **ReturnDesc);
566 
567 ACPI_STATUS
568 AcpiUtEvaluateNumericObject (
569     const char              *ObjectName,
570     ACPI_NAMESPACE_NODE     *DeviceNode,
571     UINT64                  *Value);
572 
573 ACPI_STATUS
574 AcpiUtExecute_STA (
575     ACPI_NAMESPACE_NODE     *DeviceNode,
576     UINT32                  *StatusFlags);
577 
578 ACPI_STATUS
579 AcpiUtExecutePowerMethods (
580     ACPI_NAMESPACE_NODE     *DeviceNode,
581     const char              **MethodNames,
582     UINT8                   MethodCount,
583     UINT8                   *OutValues);
584 
585 
586 /*
587  * utids - device ID support
588  */
589 ACPI_STATUS
590 AcpiUtExecute_HID (
591     ACPI_NAMESPACE_NODE     *DeviceNode,
592     ACPI_PNP_DEVICE_ID      **ReturnId);
593 
594 ACPI_STATUS
595 AcpiUtExecute_UID (
596     ACPI_NAMESPACE_NODE     *DeviceNode,
597     ACPI_PNP_DEVICE_ID      **ReturnId);
598 
599 ACPI_STATUS
600 AcpiUtExecute_CID (
601     ACPI_NAMESPACE_NODE     *DeviceNode,
602     ACPI_PNP_DEVICE_ID_LIST **ReturnCidList);
603 
604 ACPI_STATUS
605 AcpiUtExecute_CLS (
606     ACPI_NAMESPACE_NODE     *DeviceNode,
607     ACPI_PNP_DEVICE_ID      **ReturnId);
608 
609 
610 /*
611  * utlock - reader/writer locks
612  */
613 ACPI_STATUS
614 AcpiUtCreateRwLock (
615     ACPI_RW_LOCK            *Lock);
616 
617 void
618 AcpiUtDeleteRwLock (
619     ACPI_RW_LOCK            *Lock);
620 
621 ACPI_STATUS
622 AcpiUtAcquireReadLock (
623     ACPI_RW_LOCK            *Lock);
624 
625 ACPI_STATUS
626 AcpiUtReleaseReadLock (
627     ACPI_RW_LOCK            *Lock);
628 
629 ACPI_STATUS
630 AcpiUtAcquireWriteLock (
631     ACPI_RW_LOCK            *Lock);
632 
633 void
634 AcpiUtReleaseWriteLock (
635     ACPI_RW_LOCK            *Lock);
636 
637 
638 /*
639  * utobject - internal object create/delete/cache routines
640  */
641 ACPI_OPERAND_OBJECT  *
642 AcpiUtCreateInternalObjectDbg (
643     const char              *ModuleName,
644     UINT32                  LineNumber,
645     UINT32                  ComponentId,
646     ACPI_OBJECT_TYPE        Type);
647 
648 void *
649 AcpiUtAllocateObjectDescDbg (
650     const char              *ModuleName,
651     UINT32                  LineNumber,
652     UINT32                  ComponentId);
653 
654 #define AcpiUtCreateInternalObject(t)   AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t)
655 #define AcpiUtAllocateObjectDesc()      AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT)
656 
657 void
658 AcpiUtDeleteObjectDesc (
659     ACPI_OPERAND_OBJECT     *Object);
660 
661 BOOLEAN
662 AcpiUtValidInternalObject (
663     void                    *Object);
664 
665 ACPI_OPERAND_OBJECT *
666 AcpiUtCreatePackageObject (
667     UINT32                  Count);
668 
669 ACPI_OPERAND_OBJECT *
670 AcpiUtCreateIntegerObject (
671     UINT64                  Value);
672 
673 ACPI_OPERAND_OBJECT *
674 AcpiUtCreateBufferObject (
675     ACPI_SIZE               BufferSize);
676 
677 ACPI_OPERAND_OBJECT *
678 AcpiUtCreateStringObject (
679     ACPI_SIZE               StringSize);
680 
681 ACPI_STATUS
682 AcpiUtGetObjectSize(
683     ACPI_OPERAND_OBJECT     *Obj,
684     ACPI_SIZE               *ObjLength);
685 
686 
687 /*
688  * utosi - Support for the _OSI predefined control method
689  */
690 ACPI_STATUS
691 AcpiUtInitializeInterfaces (
692     void);
693 
694 ACPI_STATUS
695 AcpiUtInterfaceTerminate (
696     void);
697 
698 ACPI_STATUS
699 AcpiUtInstallInterface (
700     ACPI_STRING             InterfaceName);
701 
702 ACPI_STATUS
703 AcpiUtRemoveInterface (
704     ACPI_STRING             InterfaceName);
705 
706 ACPI_STATUS
707 AcpiUtUpdateInterfaces (
708     UINT8                   Action);
709 
710 ACPI_INTERFACE_INFO *
711 AcpiUtGetInterface (
712     ACPI_STRING             InterfaceName);
713 
714 ACPI_STATUS
715 AcpiUtOsiImplementation (
716     ACPI_WALK_STATE         *WalkState);
717 
718 
719 /*
720  * utpredef - support for predefined names
721  */
722 const ACPI_PREDEFINED_INFO *
723 AcpiUtGetNextPredefinedMethod (
724     const ACPI_PREDEFINED_INFO  *ThisName);
725 
726 const ACPI_PREDEFINED_INFO *
727 AcpiUtMatchPredefinedMethod (
728     char                        *Name);
729 
730 void
731 AcpiUtGetExpectedReturnTypes (
732     char                    *Buffer,
733     UINT32                  ExpectedBtypes);
734 
735 #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
736 const ACPI_PREDEFINED_INFO *
737 AcpiUtMatchResourceName (
738     char                        *Name);
739 
740 void
741 AcpiUtDisplayPredefinedMethod (
742     char                        *Buffer,
743     const ACPI_PREDEFINED_INFO  *ThisName,
744     BOOLEAN                     MultiLine);
745 
746 UINT32
747 AcpiUtGetResourceBitWidth (
748     char                    *Buffer,
749     UINT16                  Types);
750 #endif
751 
752 
753 /*
754  * utstate - Generic state creation/cache routines
755  */
756 void
757 AcpiUtPushGenericState (
758     ACPI_GENERIC_STATE      **ListHead,
759     ACPI_GENERIC_STATE      *State);
760 
761 ACPI_GENERIC_STATE *
762 AcpiUtPopGenericState (
763     ACPI_GENERIC_STATE      **ListHead);
764 
765 
766 ACPI_GENERIC_STATE *
767 AcpiUtCreateGenericState (
768     void);
769 
770 ACPI_THREAD_STATE *
771 AcpiUtCreateThreadState (
772     void);
773 
774 ACPI_GENERIC_STATE *
775 AcpiUtCreateUpdateState (
776     ACPI_OPERAND_OBJECT     *Object,
777     UINT16                  Action);
778 
779 ACPI_GENERIC_STATE *
780 AcpiUtCreatePkgState (
781     void                    *InternalObject,
782     void                    *ExternalObject,
783     UINT32                  Index);
784 
785 ACPI_STATUS
786 AcpiUtCreateUpdateStateAndPush (
787     ACPI_OPERAND_OBJECT     *Object,
788     UINT16                  Action,
789     ACPI_GENERIC_STATE      **StateList);
790 
791 ACPI_GENERIC_STATE *
792 AcpiUtCreateControlState (
793     void);
794 
795 void
796 AcpiUtDeleteGenericState (
797     ACPI_GENERIC_STATE      *State);
798 
799 
800 /*
801  * utmath
802  */
803 ACPI_STATUS
804 AcpiUtDivide (
805     UINT64                  InDividend,
806     UINT64                  InDivisor,
807     UINT64                  *OutQuotient,
808     UINT64                  *OutRemainder);
809 
810 ACPI_STATUS
811 AcpiUtShortDivide (
812     UINT64                  InDividend,
813     UINT32                  Divisor,
814     UINT64                  *OutQuotient,
815     UINT32                  *OutRemainder);
816 
817 ACPI_STATUS
818 AcpiUtShortMultiply (
819     UINT64                  InMultiplicand,
820     UINT32                  Multiplier,
821     UINT64                  *Outproduct);
822 
823 ACPI_STATUS
824 AcpiUtShortShiftLeft (
825     UINT64                  Operand,
826     UINT32                  Count,
827     UINT64                  *OutResult);
828 
829 ACPI_STATUS
830 AcpiUtShortShiftRight (
831     UINT64                  Operand,
832     UINT32                  Count,
833     UINT64                  *OutResult);
834 
835 
836 /*
837  * utmisc
838  */
839 const ACPI_EXCEPTION_INFO *
840 AcpiUtValidateException (
841     ACPI_STATUS             Status);
842 
843 BOOLEAN
844 AcpiUtIsPciRootBridge (
845     char                    *Id);
846 
847 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
848 BOOLEAN
849 AcpiUtIsAmlTable (
850     ACPI_TABLE_HEADER       *Table);
851 #endif
852 
853 ACPI_STATUS
854 AcpiUtWalkPackageTree (
855     ACPI_OPERAND_OBJECT     *SourceObject,
856     void                    *TargetObject,
857     ACPI_PKG_CALLBACK       WalkCallback,
858     void                    *Context);
859 
860 /* Values for Base above (16=Hex, 10=Decimal) */
861 
862 #define ACPI_ANY_BASE        0
863 
864 
865 UINT32
866 AcpiUtDwordByteSwap (
867     UINT32                  Value);
868 
869 void
870 AcpiUtSetIntegerWidth (
871     UINT8                   Revision);
872 
873 #ifdef ACPI_DEBUG_OUTPUT
874 void
875 AcpiUtDisplayInitPathname (
876     UINT8                   Type,
877     ACPI_NAMESPACE_NODE     *ObjHandle,
878     const char              *Path);
879 #endif
880 
881 
882 /*
883  * utownerid - Support for Table/Method Owner IDs
884  */
885 ACPI_STATUS
886 AcpiUtAllocateOwnerId (
887     ACPI_OWNER_ID           *OwnerId);
888 
889 void
890 AcpiUtReleaseOwnerId (
891     ACPI_OWNER_ID           *OwnerId);
892 
893 
894 /*
895  * utresrc
896  */
897 ACPI_STATUS
898 AcpiUtWalkAmlResources (
899     ACPI_WALK_STATE         *WalkState,
900     UINT8                   *Aml,
901     ACPI_SIZE               AmlLength,
902     ACPI_WALK_AML_CALLBACK  UserFunction,
903     void                    **Context);
904 
905 ACPI_STATUS
906 AcpiUtValidateResource (
907     ACPI_WALK_STATE         *WalkState,
908     void                    *Aml,
909     UINT8                   *ReturnIndex);
910 
911 UINT32
912 AcpiUtGetDescriptorLength (
913     void                    *Aml);
914 
915 UINT16
916 AcpiUtGetResourceLength (
917     void                    *Aml);
918 
919 UINT8
920 AcpiUtGetResourceHeaderLength (
921     void                    *Aml);
922 
923 UINT8
924 AcpiUtGetResourceType (
925     void                    *Aml);
926 
927 ACPI_STATUS
928 AcpiUtGetResourceEndTag (
929     ACPI_OPERAND_OBJECT     *ObjDesc,
930     UINT8                   **EndTag);
931 
932 
933 /*
934  * utstring - String and character utilities
935  */
936 void
937 AcpiUtPrintString (
938     char                    *String,
939     UINT16                  MaxLength);
940 
941 #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
942 void
943 UtConvertBackslashes (
944     char                    *Pathname);
945 #endif
946 
947 void
948 AcpiUtRepairName (
949     char                    *Name);
950 
951 #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) || defined (ACPI_DEBUG_OUTPUT)
952 BOOLEAN
953 AcpiUtSafeStrcpy (
954     char                    *Dest,
955     ACPI_SIZE               DestSize,
956     char                    *Source);
957 
958 void
959 AcpiUtSafeStrncpy (
960     char                    *Dest,
961     char                    *Source,
962     ACPI_SIZE               DestSize);
963 
964 BOOLEAN
965 AcpiUtSafeStrcat (
966     char                    *Dest,
967     ACPI_SIZE               DestSize,
968     char                    *Source);
969 
970 BOOLEAN
971 AcpiUtSafeStrncat (
972     char                    *Dest,
973     ACPI_SIZE               DestSize,
974     char                    *Source,
975     ACPI_SIZE               MaxTransferLength);
976 #endif
977 
978 
979 /*
980  * utmutex - mutex support
981  */
982 ACPI_STATUS
983 AcpiUtMutexInitialize (
984     void);
985 
986 void
987 AcpiUtMutexTerminate (
988     void);
989 
990 ACPI_STATUS
991 AcpiUtAcquireMutex (
992     ACPI_MUTEX_HANDLE       MutexId);
993 
994 ACPI_STATUS
995 AcpiUtReleaseMutex (
996     ACPI_MUTEX_HANDLE       MutexId);
997 
998 
999 /*
1000  * utalloc - memory allocation and object caching
1001  */
1002 ACPI_STATUS
1003 AcpiUtCreateCaches (
1004     void);
1005 
1006 ACPI_STATUS
1007 AcpiUtDeleteCaches (
1008     void);
1009 
1010 ACPI_STATUS
1011 AcpiUtValidateBuffer (
1012     ACPI_BUFFER             *Buffer);
1013 
1014 ACPI_STATUS
1015 AcpiUtInitializeBuffer (
1016     ACPI_BUFFER             *Buffer,
1017     ACPI_SIZE               RequiredLength);
1018 
1019 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1020 void *
1021 AcpiUtAllocateAndTrack (
1022     ACPI_SIZE               Size,
1023     UINT32                  Component,
1024     const char              *Module,
1025     UINT32                  Line);
1026 
1027 void *
1028 AcpiUtAllocateZeroedAndTrack (
1029     ACPI_SIZE               Size,
1030     UINT32                  Component,
1031     const char              *Module,
1032     UINT32                  Line);
1033 
1034 void
1035 AcpiUtFreeAndTrack (
1036     void                    *Address,
1037     UINT32                  Component,
1038     const char              *Module,
1039     UINT32                  Line);
1040 
1041 void
1042 AcpiUtDumpAllocationInfo (
1043     void);
1044 
1045 void
1046 AcpiUtDumpAllocations (
1047     UINT32                  Component,
1048     const char              *Module);
1049 
1050 ACPI_STATUS
1051 AcpiUtCreateList (
1052     const char              *ListName,
1053     UINT16                  ObjectSize,
1054     ACPI_MEMORY_LIST        **ReturnCache);
1055 
1056 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
1057 
1058 
1059 /*
1060  * utaddress - address range check
1061  */
1062 ACPI_STATUS
1063 AcpiUtAddAddressRange (
1064     ACPI_ADR_SPACE_TYPE     SpaceId,
1065     ACPI_PHYSICAL_ADDRESS   Address,
1066     UINT32                  Length,
1067     ACPI_NAMESPACE_NODE     *RegionNode);
1068 
1069 void
1070 AcpiUtRemoveAddressRange (
1071     ACPI_ADR_SPACE_TYPE     SpaceId,
1072     ACPI_NAMESPACE_NODE     *RegionNode);
1073 
1074 UINT32
1075 AcpiUtCheckAddressRange (
1076     ACPI_ADR_SPACE_TYPE     SpaceId,
1077     ACPI_PHYSICAL_ADDRESS   Address,
1078     UINT32                  Length,
1079     BOOLEAN                 Warn);
1080 
1081 void
1082 AcpiUtDeleteAddressLists (
1083     void);
1084 
1085 
1086 /*
1087  * utxferror - various error/warning output functions
1088  */
1089 void ACPI_INTERNAL_VAR_XFACE
1090 AcpiUtPredefinedWarning (
1091     const char              *ModuleName,
1092     UINT32                  LineNumber,
1093     char                    *Pathname,
1094     UINT8                   NodeFlags,
1095     const char              *Format,
1096     ...);
1097 
1098 void ACPI_INTERNAL_VAR_XFACE
1099 AcpiUtPredefinedInfo (
1100     const char              *ModuleName,
1101     UINT32                  LineNumber,
1102     char                    *Pathname,
1103     UINT8                   NodeFlags,
1104     const char              *Format,
1105     ...);
1106 
1107 void ACPI_INTERNAL_VAR_XFACE
1108 AcpiUtPredefinedBiosError (
1109     const char              *ModuleName,
1110     UINT32                  LineNumber,
1111     char                    *Pathname,
1112     UINT8                   NodeFlags,
1113     const char              *Format,
1114     ...);
1115 
1116 void
1117 AcpiUtPrefixedNamespaceError (
1118     const char              *ModuleName,
1119     UINT32                  LineNumber,
1120     ACPI_GENERIC_STATE      *PrefixScope,
1121     const char              *InternalName,
1122     ACPI_STATUS             LookupStatus);
1123 
1124 void
1125 AcpiUtMethodError (
1126     const char              *ModuleName,
1127     UINT32                  LineNumber,
1128     const char              *Message,
1129     ACPI_NAMESPACE_NODE     *Node,
1130     const char              *Path,
1131     ACPI_STATUS             LookupStatus);
1132 
1133 
1134 /*
1135  * Utility functions for ACPI names and IDs
1136  */
1137 const AH_PREDEFINED_NAME *
1138 AcpiAhMatchPredefinedName (
1139     char                    *Nameseg);
1140 
1141 const AH_DEVICE_ID *
1142 AcpiAhMatchHardwareId (
1143     char                    *Hid);
1144 
1145 const char *
1146 AcpiAhMatchUuid (
1147     UINT8                   *Data);
1148 
1149 
1150 /*
1151  * utuuid -- UUID support functions
1152  */
1153 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP)
1154 void
1155 AcpiUtConvertStringToUuid (
1156     char                    *InString,
1157     UINT8                   *UuidBuffer);
1158 #endif
1159 
1160 #endif /* _ACUTILS_H */
1161