xref: /titanic_41/usr/src/uts/intel/sys/acpi/acapps.h (revision de5d74c22760a6d2cefd94d0e7f0fd87214fb71f)
17c478bd9Sstevel@tonic-gate /******************************************************************************
27c478bd9Sstevel@tonic-gate  *
37c478bd9Sstevel@tonic-gate  * Module Name: acapps - common include for ACPI applications/tools
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  *****************************************************************************/
67c478bd9Sstevel@tonic-gate 
726f3cdf0SGordon Ross /*
8*de5d74c2SJerry Jelinek  * Copyright (C) 2000 - 2016, Intel Corp.
97c478bd9Sstevel@tonic-gate  * All rights reserved.
107c478bd9Sstevel@tonic-gate  *
1126f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross  * are met:
1426f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross  *    without modification.
1726f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross  *    binary redistribution.
2226f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross  *    from this software without specific prior written permission.
257c478bd9Sstevel@tonic-gate  *
2626f3cdf0SGordon Ross  * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross  * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross  * Software Foundation.
297c478bd9Sstevel@tonic-gate  *
3026f3cdf0SGordon Ross  * NO WARRANTY
3126f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross  * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross  */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifndef _ACAPPS
457c478bd9Sstevel@tonic-gate #define _ACAPPS
467c478bd9Sstevel@tonic-gate 
47*de5d74c2SJerry Jelinek #include <stdio.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #ifdef _MSC_VER                 /* disable some level-4 warnings */
507c478bd9Sstevel@tonic-gate #pragma warning(disable:4100)   /* warning C4100: unreferenced formal parameter */
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate 
5326f3cdf0SGordon Ross /* Common info for tool signons */
5426f3cdf0SGordon Ross 
5526f3cdf0SGordon Ross #define ACPICA_NAME                 "Intel ACPI Component Architecture"
56*de5d74c2SJerry Jelinek #define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2016 Intel Corporation"
5726f3cdf0SGordon Ross 
5826f3cdf0SGordon Ross #if ACPI_MACHINE_WIDTH == 64
5926f3cdf0SGordon Ross #define ACPI_WIDTH          "-64"
6026f3cdf0SGordon Ross 
6126f3cdf0SGordon Ross #elif ACPI_MACHINE_WIDTH == 32
6226f3cdf0SGordon Ross #define ACPI_WIDTH          "-32"
6326f3cdf0SGordon Ross 
6426f3cdf0SGordon Ross #else
6526f3cdf0SGordon Ross #error unknown ACPI_MACHINE_WIDTH
6626f3cdf0SGordon Ross #define ACPI_WIDTH          "-??"
6726f3cdf0SGordon Ross 
6826f3cdf0SGordon Ross #endif
6926f3cdf0SGordon Ross 
7026f3cdf0SGordon Ross /* Macros for signons and file headers */
7126f3cdf0SGordon Ross 
7226f3cdf0SGordon Ross #define ACPI_COMMON_SIGNON(UtilityName) \
73*de5d74c2SJerry Jelinek     "\n%s\n%s version %8.8X%s\n%s\n\n", \
7426f3cdf0SGordon Ross     ACPICA_NAME, \
75*de5d74c2SJerry Jelinek     UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
7626f3cdf0SGordon Ross     ACPICA_COPYRIGHT
7726f3cdf0SGordon Ross 
7826f3cdf0SGordon Ross #define ACPI_COMMON_HEADER(UtilityName, Prefix) \
79*de5d74c2SJerry Jelinek     "%s%s\n%s%s version %8.8X%s\n%s%s\n%s\n", \
8026f3cdf0SGordon Ross     Prefix, ACPICA_NAME, \
81*de5d74c2SJerry Jelinek     Prefix, UtilityName, ((UINT32) ACPI_CA_VERSION), ACPI_WIDTH, \
8226f3cdf0SGordon Ross     Prefix, ACPICA_COPYRIGHT, \
8326f3cdf0SGordon Ross     Prefix
8426f3cdf0SGordon Ross 
85*de5d74c2SJerry Jelinek /* Macros for usage messages */
86*de5d74c2SJerry Jelinek 
87*de5d74c2SJerry Jelinek #define ACPI_USAGE_HEADER(Usage) \
88*de5d74c2SJerry Jelinek     AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage);
89*de5d74c2SJerry Jelinek 
90*de5d74c2SJerry Jelinek #define ACPI_USAGE_TEXT(Description) \
91*de5d74c2SJerry Jelinek     AcpiOsPrintf (Description);
92*de5d74c2SJerry Jelinek 
93*de5d74c2SJerry Jelinek #define ACPI_OPTION(Name, Description) \
94*de5d74c2SJerry Jelinek     AcpiOsPrintf ("  %-20s%s\n", Name, Description);
95*de5d74c2SJerry Jelinek 
96*de5d74c2SJerry Jelinek 
97*de5d74c2SJerry Jelinek /* Check for unexpected exceptions */
98*de5d74c2SJerry Jelinek 
99*de5d74c2SJerry Jelinek #define ACPI_CHECK_STATUS(Name, Status, Expected) \
100*de5d74c2SJerry Jelinek     if (Status != Expected) \
101*de5d74c2SJerry Jelinek     { \
102*de5d74c2SJerry Jelinek         AcpiOsPrintf ("Unexpected %s from %s (%s-%d)\n", \
103*de5d74c2SJerry Jelinek             AcpiFormatException (Status), #Name, _AcpiModuleName, __LINE__); \
104*de5d74c2SJerry Jelinek     }
105*de5d74c2SJerry Jelinek 
106*de5d74c2SJerry Jelinek /* Check for unexpected non-AE_OK errors */
107*de5d74c2SJerry Jelinek 
108*de5d74c2SJerry Jelinek 
109*de5d74c2SJerry Jelinek #define ACPI_CHECK_OK(Name, Status)   ACPI_CHECK_STATUS (Name, Status, AE_OK);
110*de5d74c2SJerry Jelinek 
11127f7c583Smyers #define FILE_SUFFIX_DISASSEMBLY     "dsl"
112*de5d74c2SJerry Jelinek #define FILE_SUFFIX_BINARY_TABLE    ".dat" /* Needs the dot */
113*de5d74c2SJerry Jelinek 
114*de5d74c2SJerry Jelinek 
115*de5d74c2SJerry Jelinek /* acfileio */
116*de5d74c2SJerry Jelinek 
117*de5d74c2SJerry Jelinek ACPI_STATUS
118*de5d74c2SJerry Jelinek AcGetAllTablesFromFile (
119*de5d74c2SJerry Jelinek     char                    *Filename,
120*de5d74c2SJerry Jelinek     UINT8                   GetOnlyAmlTables,
121*de5d74c2SJerry Jelinek     ACPI_NEW_TABLE_DESC     **ReturnListHead);
122*de5d74c2SJerry Jelinek 
123*de5d74c2SJerry Jelinek BOOLEAN
124*de5d74c2SJerry Jelinek AcIsFileBinary (
125*de5d74c2SJerry Jelinek     FILE                    *File);
126*de5d74c2SJerry Jelinek 
127*de5d74c2SJerry Jelinek ACPI_STATUS
128*de5d74c2SJerry Jelinek AcValidateTableHeader (
129*de5d74c2SJerry Jelinek     FILE                    *File,
130*de5d74c2SJerry Jelinek     long                    TableOffset);
131*de5d74c2SJerry Jelinek 
132*de5d74c2SJerry Jelinek 
133*de5d74c2SJerry Jelinek /* Values for GetOnlyAmlTables */
134*de5d74c2SJerry Jelinek 
135*de5d74c2SJerry Jelinek #define ACPI_GET_ONLY_AML_TABLES    TRUE
136*de5d74c2SJerry Jelinek #define ACPI_GET_ALL_TABLES         FALSE
13727f7c583Smyers 
1387c478bd9Sstevel@tonic-gate 
13957190917SDana Myers /*
14057190917SDana Myers  * getopt
14157190917SDana Myers  */
1427c478bd9Sstevel@tonic-gate int
1437c478bd9Sstevel@tonic-gate AcpiGetopt(
1447c478bd9Sstevel@tonic-gate     int                     argc,
1457c478bd9Sstevel@tonic-gate     char                    **argv,
1467c478bd9Sstevel@tonic-gate     char                    *opts);
1477c478bd9Sstevel@tonic-gate 
148*de5d74c2SJerry Jelinek int
149*de5d74c2SJerry Jelinek AcpiGetoptArgument (
150*de5d74c2SJerry Jelinek     int                     argc,
151*de5d74c2SJerry Jelinek     char                    **argv);
152*de5d74c2SJerry Jelinek 
15357190917SDana Myers extern int                  AcpiGbl_Optind;
15426f3cdf0SGordon Ross extern int                  AcpiGbl_Opterr;
155*de5d74c2SJerry Jelinek extern int                  AcpiGbl_SubOptChar;
15657190917SDana Myers extern char                 *AcpiGbl_Optarg;
15757190917SDana Myers 
15857190917SDana Myers 
15927f7c583Smyers /*
160*de5d74c2SJerry Jelinek  * cmfsize - Common get file size function
16127f7c583Smyers  */
162*de5d74c2SJerry Jelinek UINT32
163*de5d74c2SJerry Jelinek CmGetFileSize (
164*de5d74c2SJerry Jelinek     ACPI_FILE               File);
16557190917SDana Myers 
1667c478bd9Sstevel@tonic-gate 
16727f7c583Smyers /*
16827f7c583Smyers  * adwalk
16927f7c583Smyers  */
17027f7c583Smyers void
17127f7c583Smyers AcpiDmCrossReferenceNamespace (
17227f7c583Smyers     ACPI_PARSE_OBJECT       *ParseTreeRoot,
173aa2aa9a6SDana Myers     ACPI_NAMESPACE_NODE     *NamespaceRoot,
174aa2aa9a6SDana Myers     ACPI_OWNER_ID           OwnerId);
17527f7c583Smyers 
17627f7c583Smyers void
17727f7c583Smyers AcpiDmDumpTree (
17827f7c583Smyers     ACPI_PARSE_OBJECT       *Origin);
17927f7c583Smyers 
18027f7c583Smyers void
18127f7c583Smyers AcpiDmFindOrphanMethods (
18227f7c583Smyers     ACPI_PARSE_OBJECT       *Origin);
18327f7c583Smyers 
18427f7c583Smyers void
18527f7c583Smyers AcpiDmFinishNamespaceLoad (
18627f7c583Smyers     ACPI_PARSE_OBJECT       *ParseTreeRoot,
187aa2aa9a6SDana Myers     ACPI_NAMESPACE_NODE     *NamespaceRoot,
188aa2aa9a6SDana Myers     ACPI_OWNER_ID           OwnerId);
18927f7c583Smyers 
19027f7c583Smyers void
19127f7c583Smyers AcpiDmConvertResourceIndexes (
19227f7c583Smyers     ACPI_PARSE_OBJECT       *ParseTreeRoot,
19327f7c583Smyers     ACPI_NAMESPACE_NODE     *NamespaceRoot);
19427f7c583Smyers 
19557190917SDana Myers 
19627f7c583Smyers /*
19727f7c583Smyers  * adfile
19827f7c583Smyers  */
19927f7c583Smyers ACPI_STATUS
20027f7c583Smyers AdInitialize (
20127f7c583Smyers     void);
20227f7c583Smyers 
20327f7c583Smyers char *
20427f7c583Smyers FlGenerateFilename (
20527f7c583Smyers     char                    *InputFilename,
20627f7c583Smyers     char                    *Suffix);
20727f7c583Smyers 
20827f7c583Smyers ACPI_STATUS
20927f7c583Smyers FlSplitInputPathname (
21027f7c583Smyers     char                    *InputPath,
21127f7c583Smyers     char                    **OutDirectoryPath,
21227f7c583Smyers     char                    **OutFilename);
21327f7c583Smyers 
21427f7c583Smyers char *
21527f7c583Smyers AdGenerateFilename (
21627f7c583Smyers     char                    *Prefix,
21727f7c583Smyers     char                    *TableId);
21827f7c583Smyers 
21927f7c583Smyers void
22027f7c583Smyers AdWriteTable (
22127f7c583Smyers     ACPI_TABLE_HEADER       *Table,
22227f7c583Smyers     UINT32                  Length,
22327f7c583Smyers     char                    *TableName,
22427f7c583Smyers     char                    *OemTableId);
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate #endif /* _ACAPPS */
227