xref: /freebsd/sys/contrib/dev/acpica/include/acutils.h (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 /******************************************************************************
2  *
3  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #ifndef _ACUTILS_H
153 #define _ACUTILS_H
154 
155 
156 extern const UINT8                      AcpiGbl_ResourceAmlSizes[];
157 extern const UINT8                      AcpiGbl_ResourceAmlSerialBusSizes[];
158 
159 /* Strings used by the disassembler and debugger resource dump routines */
160 
161 #if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
162 
163 extern const char                       *AcpiGbl_BmDecode[];
164 extern const char                       *AcpiGbl_ConfigDecode[];
165 extern const char                       *AcpiGbl_ConsumeDecode[];
166 extern const char                       *AcpiGbl_DecDecode[];
167 extern const char                       *AcpiGbl_HeDecode[];
168 extern const char                       *AcpiGbl_IoDecode[];
169 extern const char                       *AcpiGbl_LlDecode[];
170 extern const char                       *AcpiGbl_MaxDecode[];
171 extern const char                       *AcpiGbl_MemDecode[];
172 extern const char                       *AcpiGbl_MinDecode[];
173 extern const char                       *AcpiGbl_MtpDecode[];
174 extern const char                       *AcpiGbl_PhyDecode[];
175 extern const char                       *AcpiGbl_RngDecode[];
176 extern const char                       *AcpiGbl_RwDecode[];
177 extern const char                       *AcpiGbl_ShrDecode[];
178 extern const char                       *AcpiGbl_SizDecode[];
179 extern const char                       *AcpiGbl_TrsDecode[];
180 extern const char                       *AcpiGbl_TtpDecode[];
181 extern const char                       *AcpiGbl_TypDecode[];
182 extern const char                       *AcpiGbl_PpcDecode[];
183 extern const char                       *AcpiGbl_IorDecode[];
184 extern const char                       *AcpiGbl_DtsDecode[];
185 extern const char                       *AcpiGbl_CtDecode[];
186 extern const char                       *AcpiGbl_SbtDecode[];
187 extern const char                       *AcpiGbl_AmDecode[];
188 extern const char                       *AcpiGbl_SmDecode[];
189 extern const char                       *AcpiGbl_WmDecode[];
190 extern const char                       *AcpiGbl_CphDecode[];
191 extern const char                       *AcpiGbl_CpoDecode[];
192 extern const char                       *AcpiGbl_DpDecode[];
193 extern const char                       *AcpiGbl_EdDecode[];
194 extern const char                       *AcpiGbl_BpbDecode[];
195 extern const char                       *AcpiGbl_SbDecode[];
196 extern const char                       *AcpiGbl_FcDecode[];
197 extern const char                       *AcpiGbl_PtDecode[];
198 extern const char                       *AcpiGbl_PtypDecode[];
199 #endif
200 
201 /*
202  * For the iASL compiler case, the output is redirected to stderr so that
203  * any of the various ACPI errors and warnings do not appear in the output
204  * files, for either the compiler or disassembler portions of the tool.
205  */
206 #ifdef ACPI_ASL_COMPILER
207 
208 #include <stdio.h>
209 
210 #define ACPI_MSG_REDIRECT_BEGIN \
211     FILE                    *OutputFile = AcpiGbl_OutputFile; \
212     AcpiOsRedirectOutput (stderr);
213 
214 #define ACPI_MSG_REDIRECT_END \
215     AcpiOsRedirectOutput (OutputFile);
216 
217 #else
218 /*
219  * non-iASL case - no redirection, nothing to do
220  */
221 #define ACPI_MSG_REDIRECT_BEGIN
222 #define ACPI_MSG_REDIRECT_END
223 #endif
224 
225 /*
226  * Common error message prefixes
227  */
228 #ifndef ACPI_MSG_ERROR
229 #define ACPI_MSG_ERROR          "ACPI Error: "
230 #endif
231 #ifndef ACPI_MSG_WARNING
232 #define ACPI_MSG_WARNING        "ACPI Warning: "
233 #endif
234 #ifndef ACPI_MSG_INFO
235 #define ACPI_MSG_INFO           "ACPI: "
236 #endif
237 
238 #ifndef ACPI_MSG_BIOS_ERROR
239 #define ACPI_MSG_BIOS_ERROR     "Firmware Error (ACPI): "
240 #endif
241 #ifndef ACPI_MSG_BIOS_WARNING
242 #define ACPI_MSG_BIOS_WARNING   "Firmware Warning (ACPI): "
243 #endif
244 
245 /*
246  * Common message suffix
247  */
248 #define ACPI_MSG_SUFFIX \
249     AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
250 
251 /* Flags to indicate implicit or explicit string-to-integer conversion */
252 
253 #define ACPI_IMPLICIT_CONVERSION        TRUE
254 #define ACPI_NO_IMPLICIT_CONVERSION     FALSE
255 
256 /* Types for Resource descriptor entries */
257 
258 #define ACPI_INVALID_RESOURCE           0
259 #define ACPI_FIXED_LENGTH               1
260 #define ACPI_VARIABLE_LENGTH            2
261 #define ACPI_SMALL_VARIABLE_LENGTH      3
262 
263 typedef
264 ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) (
265     UINT8                   *Aml,
266     UINT32                  Length,
267     UINT32                  Offset,
268     UINT8                   ResourceIndex,
269     void                    **Context);
270 
271 typedef
272 ACPI_STATUS (*ACPI_PKG_CALLBACK) (
273     UINT8                   ObjectType,
274     ACPI_OPERAND_OBJECT     *SourceObject,
275     ACPI_GENERIC_STATE      *State,
276     void                    *Context);
277 
278 typedef struct acpi_pkg_info
279 {
280     UINT8                   *FreeSpace;
281     ACPI_SIZE               Length;
282     UINT32                  ObjectSpace;
283     UINT32                  NumPackages;
284 
285 } ACPI_PKG_INFO;
286 
287 /* Object reference counts */
288 
289 #define REF_INCREMENT       (UINT16) 0
290 #define REF_DECREMENT       (UINT16) 1
291 
292 /* AcpiUtDumpBuffer */
293 
294 #define DB_BYTE_DISPLAY      0x01
295 #define DB_WORD_DISPLAY      0x02
296 #define DB_DWORD_DISPLAY     0x04
297 #define DB_QWORD_DISPLAY     0x08
298 #define DB_DISPLAY_DATA_ONLY 0x10
299 
300 
301 /*
302  * utascii - ASCII utilities
303  */
304 BOOLEAN
305 AcpiUtValidNameseg (
306     char                    *Signature);
307 
308 BOOLEAN
309 AcpiUtValidNameChar (
310     char                    Character,
311     UINT32                  Position);
312 
313 void
314 AcpiUtCheckAndRepairAscii (
315     UINT8                   *Name,
316     char                    *RepairedName,
317     UINT32                  Count);
318 
319 
320 /*
321  * utcksum - Checksum utilities
322  */
323 UINT8
324 AcpiUtGenerateChecksum (
325     void                    *Table,
326     UINT32                  Length,
327     UINT8                   OriginalChecksum);
328 
329 UINT8
330 AcpiUtChecksum (
331     UINT8                   *Buffer,
332     UINT32                  Length);
333 
334 ACPI_STATUS
335 AcpiUtVerifyCdatChecksum (
336     ACPI_TABLE_CDAT         *CdatTable,
337     UINT32                  Length);
338 
339 ACPI_STATUS
340 AcpiUtVerifyChecksum (
341     ACPI_TABLE_HEADER       *Table,
342     UINT32                  Length);
343 
344 
345 /*
346  * utnonansi - Non-ANSI C library functions
347  */
348 void
349 AcpiUtStrupr (
350     char                    *SrcString);
351 
352 void
353 AcpiUtStrlwr (
354     char                    *SrcString);
355 
356 int
357 AcpiUtStricmp (
358     char                    *String1,
359     char                    *String2);
360 
361 
362 /*
363  * utstrsuppt - string-to-integer conversion support functions
364  */
365 ACPI_STATUS
366 AcpiUtConvertOctalString (
367     char                    *String,
368     UINT64                  *ReturnValue);
369 
370 ACPI_STATUS
371 AcpiUtConvertDecimalString (
372     char                    *String,
373     UINT64                  *ReturnValuePtr);
374 
375 ACPI_STATUS
376 AcpiUtConvertHexString (
377     char                    *String,
378     UINT64                  *ReturnValuePtr);
379 
380 char
381 AcpiUtRemoveWhitespace (
382     char                    **String);
383 
384 char
385 AcpiUtRemoveLeadingZeros (
386     char                    **String);
387 
388 BOOLEAN
389 AcpiUtDetectHexPrefix (
390     char                    **String);
391 
392 void
393 AcpiUtRemoveHexPrefix (
394     char                    **String);
395 
396 BOOLEAN
397 AcpiUtDetectOctalPrefix (
398     char                    **String);
399 
400 
401 /*
402  * utstrtoul64 - string-to-integer conversion functions
403  */
404 ACPI_STATUS
405 AcpiUtStrtoul64 (
406     char                    *String,
407     UINT64                  *RetInteger);
408 
409 UINT64
410 AcpiUtExplicitStrtoul64 (
411     char                    *String);
412 
413 UINT64
414 AcpiUtImplicitStrtoul64 (
415     char                    *String);
416 
417 
418 /*
419  * utglobal - Global data structures and procedures
420  */
421 ACPI_STATUS
422 AcpiUtInitGlobals (
423     void);
424 
425 const char *
426 AcpiUtGetMutexName (
427     UINT32                  MutexId);
428 
429 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
430 
431 const char *
432 AcpiUtGetNotifyName (
433     UINT32                  NotifyValue,
434     ACPI_OBJECT_TYPE        Type);
435 #endif
436 
437 const char *
438 AcpiUtGetTypeName (
439     ACPI_OBJECT_TYPE        Type);
440 
441 const char *
442 AcpiUtGetNodeName (
443     void                    *Object);
444 
445 const char *
446 AcpiUtGetDescriptorName (
447     void                    *Object);
448 
449 const char *
450 AcpiUtGetReferenceName (
451     ACPI_OPERAND_OBJECT     *Object);
452 
453 const char *
454 AcpiUtGetObjectTypeName (
455     ACPI_OPERAND_OBJECT     *ObjDesc);
456 
457 const char *
458 AcpiUtGetRegionName (
459     UINT8                   SpaceId);
460 
461 const char *
462 AcpiUtGetEventName (
463     UINT32                  EventId);
464 
465 const char *
466 AcpiUtGetArgumentTypeName (
467     UINT32                  ArgType);
468 
469 char
470 AcpiUtHexToAsciiChar (
471     UINT64                  Integer,
472     UINT32                  Position);
473 
474 ACPI_STATUS
475 AcpiUtAsciiToHexByte (
476     char                    *TwoAsciiChars,
477     UINT8                   *ReturnByte);
478 
479 UINT8
480 AcpiUtAsciiCharToHex (
481     int                     HexChar);
482 
483 BOOLEAN
484 AcpiUtValidObjectType (
485     ACPI_OBJECT_TYPE        Type);
486 
487 
488 /*
489  * utinit - miscellaneous initialization and shutdown
490  */
491 ACPI_STATUS
492 AcpiUtHardwareInitialize (
493     void);
494 
495 void
496 AcpiUtSubsystemShutdown (
497     void);
498 
499 
500 /*
501  * utcopy - Object construction and conversion interfaces
502  */
503 ACPI_STATUS
504 AcpiUtBuildSimpleObject(
505     ACPI_OPERAND_OBJECT     *Obj,
506     ACPI_OBJECT             *UserObj,
507     UINT8                   *DataSpace,
508     UINT32                  *BufferSpaceUsed);
509 
510 ACPI_STATUS
511 AcpiUtBuildPackageObject (
512     ACPI_OPERAND_OBJECT     *Obj,
513     UINT8                   *Buffer,
514     UINT32                  *SpaceUsed);
515 
516 ACPI_STATUS
517 AcpiUtCopyIobjectToEobject (
518     ACPI_OPERAND_OBJECT     *Obj,
519     ACPI_BUFFER             *RetBuffer);
520 
521 ACPI_STATUS
522 AcpiUtCopyEobjectToIobject (
523     ACPI_OBJECT             *Obj,
524     ACPI_OPERAND_OBJECT     **InternalObj);
525 
526 ACPI_STATUS
527 AcpiUtCopyISimpleToIsimple (
528     ACPI_OPERAND_OBJECT     *SourceObj,
529     ACPI_OPERAND_OBJECT     *DestObj);
530 
531 ACPI_STATUS
532 AcpiUtCopyIobjectToIobject (
533     ACPI_OPERAND_OBJECT     *SourceDesc,
534     ACPI_OPERAND_OBJECT     **DestDesc,
535     ACPI_WALK_STATE         *WalkState);
536 
537 
538 /*
539  * utcreate - Object creation
540  */
541 ACPI_STATUS
542 AcpiUtUpdateObjectReference (
543     ACPI_OPERAND_OBJECT     *Object,
544     UINT16                  Action);
545 
546 
547 /*
548  * utdebug - Debug interfaces
549  */
550 void
551 AcpiUtInitStackPtrTrace (
552     void);
553 
554 void
555 AcpiUtTrackStackPtr (
556     void);
557 
558 void
559 AcpiUtTrace (
560     UINT32                  LineNumber,
561     const char              *FunctionName,
562     const char              *ModuleName,
563     UINT32                  ComponentId);
564 
565 void
566 AcpiUtTracePtr (
567     UINT32                  LineNumber,
568     const char              *FunctionName,
569     const char              *ModuleName,
570     UINT32                  ComponentId,
571     const void              *Pointer);
572 
573 void
574 AcpiUtTraceU32 (
575     UINT32                  LineNumber,
576     const char              *FunctionName,
577     const char              *ModuleName,
578     UINT32                  ComponentId,
579     UINT32                  Integer);
580 
581 void
582 AcpiUtTraceStr (
583     UINT32                  LineNumber,
584     const char              *FunctionName,
585     const char              *ModuleName,
586     UINT32                  ComponentId,
587     const char              *String);
588 
589 void
590 AcpiUtExit (
591     UINT32                  LineNumber,
592     const char              *FunctionName,
593     const char              *ModuleName,
594     UINT32                  ComponentId);
595 
596 void
597 AcpiUtStatusExit (
598     UINT32                  LineNumber,
599     const char              *FunctionName,
600     const char              *ModuleName,
601     UINT32                  ComponentId,
602     ACPI_STATUS             Status);
603 
604 void
605 AcpiUtValueExit (
606     UINT32                  LineNumber,
607     const char              *FunctionName,
608     const char              *ModuleName,
609     UINT32                  ComponentId,
610     UINT64                  Value);
611 
612 void
613 AcpiUtPtrExit (
614     UINT32                  LineNumber,
615     const char              *FunctionName,
616     const char              *ModuleName,
617     UINT32                  ComponentId,
618     UINT8                   *Ptr);
619 
620 void
621 AcpiUtStrExit (
622     UINT32                  LineNumber,
623     const char              *FunctionName,
624     const char              *ModuleName,
625     UINT32                  ComponentId,
626     const char              *String);
627 
628 void
629 AcpiUtDebugDumpBuffer (
630     UINT8                   *Buffer,
631     UINT32                  Count,
632     UINT32                  Display,
633     UINT32                  ComponentId);
634 
635 void
636 AcpiUtDumpBuffer (
637     UINT8                   *Buffer,
638     UINT32                  Count,
639     UINT32                  Display,
640     UINT32                  Offset);
641 
642 #ifdef ACPI_APPLICATION
643 void
644 AcpiUtDumpBufferToFile (
645     ACPI_FILE               File,
646     UINT8                   *Buffer,
647     UINT32                  Count,
648     UINT32                  Display,
649     UINT32                  BaseOffset);
650 #endif
651 
652 void
653 AcpiUtReportError (
654     char                    *ModuleName,
655     UINT32                  LineNumber);
656 
657 void
658 AcpiUtReportInfo (
659     char                    *ModuleName,
660     UINT32                  LineNumber);
661 
662 void
663 AcpiUtReportWarning (
664     char                    *ModuleName,
665     UINT32                  LineNumber);
666 
667 
668 /*
669  * utdelete - Object deletion and reference counts
670  */
671 void
672 AcpiUtAddReference (
673     ACPI_OPERAND_OBJECT     *Object);
674 
675 void
676 AcpiUtRemoveReference (
677     ACPI_OPERAND_OBJECT     *Object);
678 
679 void
680 AcpiUtDeleteInternalPackageObject (
681     ACPI_OPERAND_OBJECT     *Object);
682 
683 void
684 AcpiUtDeleteInternalSimpleObject (
685     ACPI_OPERAND_OBJECT     *Object);
686 
687 void
688 AcpiUtDeleteInternalObjectList (
689     ACPI_OPERAND_OBJECT     **ObjList);
690 
691 
692 /*
693  * uteval - object evaluation
694  */
695 ACPI_STATUS
696 AcpiUtEvaluateObject (
697     ACPI_NAMESPACE_NODE     *PrefixNode,
698     const char              *Path,
699     UINT32                  ExpectedReturnBtypes,
700     ACPI_OPERAND_OBJECT     **ReturnDesc);
701 
702 ACPI_STATUS
703 AcpiUtEvaluateNumericObject (
704     const char              *ObjectName,
705     ACPI_NAMESPACE_NODE     *DeviceNode,
706     UINT64                  *Value);
707 
708 ACPI_STATUS
709 AcpiUtExecute_STA (
710     ACPI_NAMESPACE_NODE     *DeviceNode,
711     UINT32                  *StatusFlags);
712 
713 ACPI_STATUS
714 AcpiUtExecutePowerMethods (
715     ACPI_NAMESPACE_NODE     *DeviceNode,
716     const char              **MethodNames,
717     UINT8                   MethodCount,
718     UINT8                   *OutValues);
719 
720 
721 /*
722  * utids - device ID support
723  */
724 ACPI_STATUS
725 AcpiUtExecute_HID (
726     ACPI_NAMESPACE_NODE     *DeviceNode,
727     ACPI_PNP_DEVICE_ID      **ReturnId);
728 
729 ACPI_STATUS
730 AcpiUtExecute_UID (
731     ACPI_NAMESPACE_NODE     *DeviceNode,
732     ACPI_PNP_DEVICE_ID      **ReturnId);
733 
734 ACPI_STATUS
735 AcpiUtExecute_CID (
736     ACPI_NAMESPACE_NODE     *DeviceNode,
737     ACPI_PNP_DEVICE_ID_LIST **ReturnCidList);
738 
739 ACPI_STATUS
740 AcpiUtExecute_CLS (
741     ACPI_NAMESPACE_NODE     *DeviceNode,
742     ACPI_PNP_DEVICE_ID      **ReturnId);
743 
744 
745 /*
746  * utlock - reader/writer locks
747  */
748 ACPI_STATUS
749 AcpiUtCreateRwLock (
750     ACPI_RW_LOCK            *Lock);
751 
752 void
753 AcpiUtDeleteRwLock (
754     ACPI_RW_LOCK            *Lock);
755 
756 ACPI_STATUS
757 AcpiUtAcquireReadLock (
758     ACPI_RW_LOCK            *Lock);
759 
760 ACPI_STATUS
761 AcpiUtReleaseReadLock (
762     ACPI_RW_LOCK            *Lock);
763 
764 ACPI_STATUS
765 AcpiUtAcquireWriteLock (
766     ACPI_RW_LOCK            *Lock);
767 
768 void
769 AcpiUtReleaseWriteLock (
770     ACPI_RW_LOCK            *Lock);
771 
772 
773 /*
774  * utobject - internal object create/delete/cache routines
775  */
776 ACPI_OPERAND_OBJECT  *
777 AcpiUtCreateInternalObjectDbg (
778     const char              *ModuleName,
779     UINT32                  LineNumber,
780     UINT32                  ComponentId,
781     ACPI_OBJECT_TYPE        Type);
782 
783 void *
784 AcpiUtAllocateObjectDescDbg (
785     const char              *ModuleName,
786     UINT32                  LineNumber,
787     UINT32                  ComponentId);
788 
789 #define AcpiUtCreateInternalObject(t)   AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t)
790 #define AcpiUtAllocateObjectDesc()      AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT)
791 
792 void
793 AcpiUtDeleteObjectDesc (
794     ACPI_OPERAND_OBJECT     *Object);
795 
796 BOOLEAN
797 AcpiUtValidInternalObject (
798     void                    *Object);
799 
800 ACPI_OPERAND_OBJECT *
801 AcpiUtCreatePackageObject (
802     UINT32                  Count);
803 
804 ACPI_OPERAND_OBJECT *
805 AcpiUtCreateIntegerObject (
806     UINT64                  Value);
807 
808 ACPI_OPERAND_OBJECT *
809 AcpiUtCreateBufferObject (
810     ACPI_SIZE               BufferSize);
811 
812 ACPI_OPERAND_OBJECT *
813 AcpiUtCreateStringObject (
814     ACPI_SIZE               StringSize);
815 
816 ACPI_STATUS
817 AcpiUtGetObjectSize(
818     ACPI_OPERAND_OBJECT     *Obj,
819     ACPI_SIZE               *ObjLength);
820 
821 
822 /*
823  * utosi - Support for the _OSI predefined control method
824  */
825 ACPI_STATUS
826 AcpiUtInitializeInterfaces (
827     void);
828 
829 ACPI_STATUS
830 AcpiUtInterfaceTerminate (
831     void);
832 
833 ACPI_STATUS
834 AcpiUtInstallInterface (
835     ACPI_STRING             InterfaceName);
836 
837 ACPI_STATUS
838 AcpiUtRemoveInterface (
839     ACPI_STRING             InterfaceName);
840 
841 ACPI_STATUS
842 AcpiUtUpdateInterfaces (
843     UINT8                   Action);
844 
845 ACPI_INTERFACE_INFO *
846 AcpiUtGetInterface (
847     ACPI_STRING             InterfaceName);
848 
849 ACPI_STATUS
850 AcpiUtOsiImplementation (
851     ACPI_WALK_STATE         *WalkState);
852 
853 
854 /*
855  * utpredef - support for predefined names
856  */
857 const ACPI_PREDEFINED_INFO *
858 AcpiUtGetNextPredefinedMethod (
859     const ACPI_PREDEFINED_INFO  *ThisName);
860 
861 const ACPI_PREDEFINED_INFO *
862 AcpiUtMatchPredefinedMethod (
863     char                        *Name);
864 
865 void
866 AcpiUtGetExpectedReturnTypes (
867     char                    *Buffer,
868     UINT32                  ExpectedBtypes);
869 
870 #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
871 const ACPI_PREDEFINED_INFO *
872 AcpiUtMatchResourceName (
873     char                        *Name);
874 
875 void
876 AcpiUtDisplayPredefinedMethod (
877     char                        *Buffer,
878     const ACPI_PREDEFINED_INFO  *ThisName,
879     BOOLEAN                     MultiLine);
880 
881 UINT32
882 AcpiUtGetResourceBitWidth (
883     char                    *Buffer,
884     UINT16                  Types);
885 #endif
886 
887 
888 /*
889  * utstate - Generic state creation/cache routines
890  */
891 void
892 AcpiUtPushGenericState (
893     ACPI_GENERIC_STATE      **ListHead,
894     ACPI_GENERIC_STATE      *State);
895 
896 ACPI_GENERIC_STATE *
897 AcpiUtPopGenericState (
898     ACPI_GENERIC_STATE      **ListHead);
899 
900 
901 ACPI_GENERIC_STATE *
902 AcpiUtCreateGenericState (
903     void);
904 
905 ACPI_THREAD_STATE *
906 AcpiUtCreateThreadState (
907     void);
908 
909 ACPI_GENERIC_STATE *
910 AcpiUtCreateUpdateState (
911     ACPI_OPERAND_OBJECT     *Object,
912     UINT16                  Action);
913 
914 ACPI_GENERIC_STATE *
915 AcpiUtCreatePkgState (
916     void                    *InternalObject,
917     void                    *ExternalObject,
918     UINT32                  Index);
919 
920 ACPI_STATUS
921 AcpiUtCreateUpdateStateAndPush (
922     ACPI_OPERAND_OBJECT     *Object,
923     UINT16                  Action,
924     ACPI_GENERIC_STATE      **StateList);
925 
926 ACPI_GENERIC_STATE *
927 AcpiUtCreateControlState (
928     void);
929 
930 void
931 AcpiUtDeleteGenericState (
932     ACPI_GENERIC_STATE      *State);
933 
934 
935 /*
936  * utmath
937  */
938 ACPI_STATUS
939 AcpiUtDivide (
940     UINT64                  InDividend,
941     UINT64                  InDivisor,
942     UINT64                  *OutQuotient,
943     UINT64                  *OutRemainder);
944 
945 ACPI_STATUS
946 AcpiUtShortDivide (
947     UINT64                  InDividend,
948     UINT32                  Divisor,
949     UINT64                  *OutQuotient,
950     UINT32                  *OutRemainder);
951 
952 ACPI_STATUS
953 AcpiUtShortMultiply (
954     UINT64                  InMultiplicand,
955     UINT32                  Multiplier,
956     UINT64                  *Outproduct);
957 
958 ACPI_STATUS
959 AcpiUtShortShiftLeft (
960     UINT64                  Operand,
961     UINT32                  Count,
962     UINT64                  *OutResult);
963 
964 ACPI_STATUS
965 AcpiUtShortShiftRight (
966     UINT64                  Operand,
967     UINT32                  Count,
968     UINT64                  *OutResult);
969 
970 
971 /*
972  * utmisc
973  */
974 const ACPI_EXCEPTION_INFO *
975 AcpiUtValidateException (
976     ACPI_STATUS             Status);
977 
978 BOOLEAN
979 AcpiUtIsPciRootBridge (
980     char                    *Id);
981 
982 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
983 BOOLEAN
984 AcpiUtIsAmlTable (
985     ACPI_TABLE_HEADER       *Table);
986 #endif
987 
988 ACPI_STATUS
989 AcpiUtWalkPackageTree (
990     ACPI_OPERAND_OBJECT     *SourceObject,
991     void                    *TargetObject,
992     ACPI_PKG_CALLBACK       WalkCallback,
993     void                    *Context);
994 
995 /* Values for Base above (16=Hex, 10=Decimal) */
996 
997 #define ACPI_ANY_BASE        0
998 
999 
1000 UINT32
1001 AcpiUtDwordByteSwap (
1002     UINT32                  Value);
1003 
1004 void
1005 AcpiUtSetIntegerWidth (
1006     UINT8                   Revision);
1007 
1008 #ifdef ACPI_DEBUG_OUTPUT
1009 void
1010 AcpiUtDisplayInitPathname (
1011     UINT8                   Type,
1012     ACPI_NAMESPACE_NODE     *ObjHandle,
1013     const char              *Path);
1014 #endif
1015 
1016 
1017 /*
1018  * utownerid - Support for Table/Method Owner IDs
1019  */
1020 ACPI_STATUS
1021 AcpiUtAllocateOwnerId (
1022     ACPI_OWNER_ID           *OwnerId);
1023 
1024 void
1025 AcpiUtReleaseOwnerId (
1026     ACPI_OWNER_ID           *OwnerId);
1027 
1028 
1029 /*
1030  * utresrc
1031  */
1032 ACPI_STATUS
1033 AcpiUtWalkAmlResources (
1034     ACPI_WALK_STATE         *WalkState,
1035     UINT8                   *Aml,
1036     ACPI_SIZE               AmlLength,
1037     ACPI_WALK_AML_CALLBACK  UserFunction,
1038     void                    **Context);
1039 
1040 ACPI_STATUS
1041 AcpiUtValidateResource (
1042     ACPI_WALK_STATE         *WalkState,
1043     void                    *Aml,
1044     UINT8                   *ReturnIndex);
1045 
1046 UINT32
1047 AcpiUtGetDescriptorLength (
1048     void                    *Aml);
1049 
1050 UINT16
1051 AcpiUtGetResourceLength (
1052     void                    *Aml);
1053 
1054 UINT8
1055 AcpiUtGetResourceHeaderLength (
1056     void                    *Aml);
1057 
1058 UINT8
1059 AcpiUtGetResourceType (
1060     void                    *Aml);
1061 
1062 ACPI_STATUS
1063 AcpiUtGetResourceEndTag (
1064     ACPI_OPERAND_OBJECT     *ObjDesc,
1065     UINT8                   **EndTag);
1066 
1067 
1068 /*
1069  * utstring - String and character utilities
1070  */
1071 void
1072 AcpiUtPrintString (
1073     char                    *String,
1074     UINT16                  MaxLength);
1075 
1076 #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
1077 void
1078 UtConvertBackslashes (
1079     char                    *Pathname);
1080 #endif
1081 
1082 void
1083 AcpiUtRepairName (
1084     char                    *Name);
1085 
1086 #if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) || defined (ACPI_DEBUG_OUTPUT)
1087 BOOLEAN
1088 AcpiUtSafeStrcpy (
1089     char                    *Dest,
1090     ACPI_SIZE               DestSize,
1091     char                    *Source);
1092 
1093 void
1094 AcpiUtSafeStrncpy (
1095     char                    *Dest,
1096     char                    *Source,
1097     ACPI_SIZE               DestSize);
1098 
1099 BOOLEAN
1100 AcpiUtSafeStrcat (
1101     char                    *Dest,
1102     ACPI_SIZE               DestSize,
1103     char                    *Source);
1104 
1105 BOOLEAN
1106 AcpiUtSafeStrncat (
1107     char                    *Dest,
1108     ACPI_SIZE               DestSize,
1109     char                    *Source,
1110     ACPI_SIZE               MaxTransferLength);
1111 #endif
1112 
1113 
1114 /*
1115  * utmutex - mutex support
1116  */
1117 ACPI_STATUS
1118 AcpiUtMutexInitialize (
1119     void);
1120 
1121 void
1122 AcpiUtMutexTerminate (
1123     void);
1124 
1125 ACPI_STATUS
1126 AcpiUtAcquireMutex (
1127     ACPI_MUTEX_HANDLE       MutexId);
1128 
1129 ACPI_STATUS
1130 AcpiUtReleaseMutex (
1131     ACPI_MUTEX_HANDLE       MutexId);
1132 
1133 
1134 /*
1135  * utalloc - memory allocation and object caching
1136  */
1137 ACPI_STATUS
1138 AcpiUtCreateCaches (
1139     void);
1140 
1141 ACPI_STATUS
1142 AcpiUtDeleteCaches (
1143     void);
1144 
1145 ACPI_STATUS
1146 AcpiUtValidateBuffer (
1147     ACPI_BUFFER             *Buffer);
1148 
1149 ACPI_STATUS
1150 AcpiUtInitializeBuffer (
1151     ACPI_BUFFER             *Buffer,
1152     ACPI_SIZE               RequiredLength);
1153 
1154 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1155 void *
1156 AcpiUtAllocateAndTrack (
1157     ACPI_SIZE               Size,
1158     UINT32                  Component,
1159     const char              *Module,
1160     UINT32                  Line);
1161 
1162 void *
1163 AcpiUtAllocateZeroedAndTrack (
1164     ACPI_SIZE               Size,
1165     UINT32                  Component,
1166     const char              *Module,
1167     UINT32                  Line);
1168 
1169 void
1170 AcpiUtFreeAndTrack (
1171     void                    *Address,
1172     UINT32                  Component,
1173     const char              *Module,
1174     UINT32                  Line);
1175 
1176 void
1177 AcpiUtDumpAllocationInfo (
1178     void);
1179 
1180 void
1181 AcpiUtDumpAllocations (
1182     UINT32                  Component,
1183     const char              *Module);
1184 
1185 ACPI_STATUS
1186 AcpiUtCreateList (
1187     const char              *ListName,
1188     UINT16                  ObjectSize,
1189     ACPI_MEMORY_LIST        **ReturnCache);
1190 
1191 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
1192 
1193 
1194 /*
1195  * utaddress - address range check
1196  */
1197 ACPI_STATUS
1198 AcpiUtAddAddressRange (
1199     ACPI_ADR_SPACE_TYPE     SpaceId,
1200     ACPI_PHYSICAL_ADDRESS   Address,
1201     UINT32                  Length,
1202     ACPI_NAMESPACE_NODE     *RegionNode);
1203 
1204 void
1205 AcpiUtRemoveAddressRange (
1206     ACPI_ADR_SPACE_TYPE     SpaceId,
1207     ACPI_NAMESPACE_NODE     *RegionNode);
1208 
1209 UINT32
1210 AcpiUtCheckAddressRange (
1211     ACPI_ADR_SPACE_TYPE     SpaceId,
1212     ACPI_PHYSICAL_ADDRESS   Address,
1213     UINT32                  Length,
1214     BOOLEAN                 Warn);
1215 
1216 void
1217 AcpiUtDeleteAddressLists (
1218     void);
1219 
1220 
1221 /*
1222  * utxferror - various error/warning output functions
1223  */
1224 ACPI_PRINTF_LIKE(5)
1225 void ACPI_INTERNAL_VAR_XFACE
1226 AcpiUtPredefinedWarning (
1227     const char              *ModuleName,
1228     UINT32                  LineNumber,
1229     char                    *Pathname,
1230     UINT16                  NodeFlags,
1231     const char              *Format,
1232     ...);
1233 
1234 ACPI_PRINTF_LIKE(5)
1235 void ACPI_INTERNAL_VAR_XFACE
1236 AcpiUtPredefinedInfo (
1237     const char              *ModuleName,
1238     UINT32                  LineNumber,
1239     char                    *Pathname,
1240     UINT16                  NodeFlags,
1241     const char              *Format,
1242     ...);
1243 
1244 ACPI_PRINTF_LIKE(5)
1245 void ACPI_INTERNAL_VAR_XFACE
1246 AcpiUtPredefinedBiosError (
1247     const char              *ModuleName,
1248     UINT32                  LineNumber,
1249     char                    *Pathname,
1250     UINT16                  NodeFlags,
1251     const char              *Format,
1252     ...);
1253 
1254 void
1255 AcpiUtPrefixedNamespaceError (
1256     const char              *ModuleName,
1257     UINT32                  LineNumber,
1258     ACPI_GENERIC_STATE      *PrefixScope,
1259     const char              *InternalName,
1260     ACPI_STATUS             LookupStatus);
1261 
1262 void
1263 AcpiUtMethodError (
1264     const char              *ModuleName,
1265     UINT32                  LineNumber,
1266     const char              *Message,
1267     ACPI_NAMESPACE_NODE     *Node,
1268     const char              *Path,
1269     ACPI_STATUS             LookupStatus);
1270 
1271 
1272 /*
1273  * Utility functions for ACPI names and IDs
1274  */
1275 const AH_PREDEFINED_NAME *
1276 AcpiAhMatchPredefinedName (
1277     char                    *Nameseg);
1278 
1279 const AH_DEVICE_ID *
1280 AcpiAhMatchHardwareId (
1281     char                    *Hid);
1282 
1283 const char *
1284 AcpiAhMatchUuid (
1285     UINT8                   *Data);
1286 
1287 
1288 /*
1289  * utuuid -- UUID support functions
1290  */
1291 #if (defined ACPI_ASL_COMPILER || defined ACPI_DISASSEMBLER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP)
1292 void
1293 AcpiUtConvertStringToUuid (
1294     char                    *InString,
1295     UINT8                   *UuidBuffer);
1296 
1297 ACPI_STATUS
1298 AcpiUtConvertUuidToString (
1299     char                    *UuidBuffer,
1300     char                    *OutString);
1301 #endif
1302 
1303 #endif /* _ACUTILS_H */
1304