1/******************************************************************************
2 *
3 * Module Name: acpihelp.h - Include file for AcpiHelp utility
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2023, 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 MERCHANTABILITY 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 __ACPIHELP_H
45#define __ACPIHELP_H
46
47
48#include "acpi.h"
49#include "accommon.h"
50#include "acapps.h"
51
52#include <sys/types.h>
53#ifdef WIN32
54#include <io.h>
55#include <direct.h>
56#endif
57
58
59/*
60 * Global variables. Defined in ahmain.c only, externed in all other files
61 */
62#undef ACPI_GLOBAL
63#undef ACPI_INIT_GLOBAL
64
65#ifdef DEFINE_AHELP_GLOBALS
66#define ACPI_GLOBAL(type,name) \
67    extern type name; \
68    type name
69
70#define ACPI_INIT_GLOBAL(type,name,value) \
71    type name=value
72
73#else
74#ifndef ACPI_GLOBAL
75#define ACPI_GLOBAL(type,name) \
76    extern type name
77#endif
78
79#ifndef ACPI_INIT_GLOBAL
80#define ACPI_INIT_GLOBAL(type,name,value) \
81    extern type name
82#endif
83#endif
84
85
86#define AH_BUFFER_LENGTH                128
87#define AH_LINE_BUFFER_LENGTH           512
88#define AH_MAX_ASL_LINE_LENGTH          70
89#define AH_MAX_AML_LINE_LENGTH          100
90
91ACPI_GLOBAL (char,                      Gbl_Buffer[AH_BUFFER_LENGTH]);
92ACPI_GLOBAL (char,                      Gbl_LineBuffer[AH_LINE_BUFFER_LENGTH]);
93extern const AH_PREDEFINED_NAME         AslPredefinedInfo[];
94extern const AH_DEVICE_ID               AslDeviceIds[];
95
96
97#define AH_DISPLAY_EXCEPTION(Status, Name) \
98    printf ("%.4X: %s\n", Status, Name)
99
100#define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \
101    printf ("%.4X: %-28s (%s)\n", Status,\
102    Exception->Name, Exception->Description)
103
104
105typedef enum
106{
107    AH_DECODE_DEFAULT           = 0,
108    AH_DECODE_ASL,
109    AH_DECODE_ASL_KEYWORD,
110    AH_DECODE_PREDEFINED_NAME,
111    AH_DECODE_AML,
112    AH_DECODE_AML_OPCODE,
113    AH_DECODE_AML_TYPE,
114    AH_DECODE_ASL_AML,
115    AH_DECODE_EXCEPTION,
116
117    AH_DISPLAY_DEVICE_IDS,
118    AH_DISPLAY_UUIDS,
119    AH_DISPLAY_TABLES,
120    AH_DISPLAY_DIRECTIVES,
121    AH_DECODE_ASL_EXCEPTION
122
123} AH_OPTION_TYPES;
124
125typedef struct ah_aml_opcode
126{
127    UINT16          OpcodeRangeStart;
128    UINT16          OpcodeRangeEnd;
129    char            *OpcodeString;
130    char            *OpcodeName;
131    char            *Type;
132    char            *FixedArguments;
133    char            *VariableArguments;
134    char            *Grammar;
135
136} AH_AML_OPCODE;
137
138typedef struct ah_aml_type
139{
140    char            *Name;
141    char            *Description;
142
143} AH_AML_TYPE;
144
145typedef struct ah_asl_operator
146{
147    char            *Name;
148    char            *Syntax;
149    char            *Description;
150
151} AH_ASL_OPERATOR;
152
153typedef struct ah_asl_keyword
154{
155    char            *Name;
156    char            *Description;
157    char            *KeywordList;
158
159} AH_ASL_KEYWORD;
160
161typedef struct ah_directive_info
162{
163    char            *Name;
164    char            *Description;
165
166} AH_DIRECTIVE_INFO;
167
168
169/* Externals for various data tables */
170
171extern const AH_AML_OPCODE          Gbl_AmlOpcodeInfo[];
172extern const AH_AML_TYPE            Gbl_AmlTypesInfo[];
173extern const AH_ASL_OPERATOR        Gbl_AslOperatorInfo[];
174extern const AH_ASL_KEYWORD         Gbl_AslKeywordInfo[];
175extern const AH_UUID                Gbl_AcpiUuids[];
176extern const AH_DIRECTIVE_INFO      Gbl_PreprocessorDirectives[];
177extern const AH_TABLE               AcpiGbl_SupportedTables[];
178
179
180void
181AhFindAmlOpcode (
182    char                    *Name);
183
184void
185AhDecodeAmlOpcode (
186    char                    *Name);
187
188void
189AhDecodeException (
190    char                    *Name);
191
192void
193AhDecodeAslException (
194    char                    *Name);
195
196void
197AhFindPredefinedNames (
198    char                    *Name);
199
200void
201AhFindAslAndAmlOperators (
202    char                    *Name);
203
204UINT32
205AhFindAslOperators (
206    char                    *Name);
207
208void
209AhFindAslKeywords (
210    char                    *Name);
211
212void
213AhFindAmlTypes (
214    char                    *Name);
215
216void
217AhDisplayDeviceIds (
218    char                    *Name);
219
220void
221AhDisplayTables (
222    void);
223
224const AH_TABLE *
225AcpiAhGetTableInfo (
226    char                    *Signature);
227
228void
229AhDisplayUuids (
230    void);
231
232void
233AhDisplayDirectives (
234    void);
235
236void
237AhPrintOneField (
238    UINT32                  Indent,
239    UINT32                  CurrentPosition,
240    UINT32                  MaxPosition,
241    const char              *Field);
242
243#endif /* __ACPIHELP_H */
244