xref: /titanic_52/usr/src/cmd/acpi/acpixtract/acpixtract.h (revision f64ca10231919db05e806441ccd6186ea9c6e734)
1 /******************************************************************************
2  *
3  * Module Name: acpixtract.h - Include for acpixtract utility
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, 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 #include "acpi.h"
45 #include "accommon.h"
46 #include "acapps.h"
47 #include <stdio.h>
48 
49 
50 #undef ACPI_GLOBAL
51 
52 #ifdef DEFINE_ACPIXTRACT_GLOBALS
53 #define ACPI_GLOBAL(type,name) \
54     extern type name; \
55     type name
56 
57 #else
58 #define ACPI_GLOBAL(type,name) \
59     extern type name
60 #endif
61 
62 
63 /* Options */
64 
65 #define AX_EXTRACT_ALL              0
66 #define AX_LIST_ALL                 1
67 #define AX_EXTRACT_SIGNATURE        2
68 #define AX_EXTRACT_AML_TABLES       3
69 #define AX_EXTRACT_MULTI_TABLE      4
70 
71 #define AX_OPTIONAL_TABLES          0
72 #define AX_REQUIRED_TABLE           1
73 
74 #define AX_UTILITY_NAME             "ACPI Binary Table Extraction Utility"
75 #define AX_SUPPORTED_OPTIONS        "ahlms:v"
76 #define AX_MULTI_TABLE_FILENAME     "amltables.dat"
77 #define AX_TABLE_INFO_FORMAT        "Acpi table [%4.4s] - %7u bytes written to %s\n"
78 
79 /* Extraction states */
80 
81 #define AX_STATE_FIND_HEADER        0
82 #define AX_STATE_EXTRACT_DATA       1
83 
84 /* Miscellaneous constants */
85 
86 #define AX_LINE_BUFFER_SIZE         256
87 #define AX_MIN_BLOCK_HEADER_LENGTH  6   /* strlen ("DSDT @") */
88 
89 
90 typedef struct AxTableInfo
91 {
92     UINT32                  Signature;
93     unsigned int            Instances;
94     unsigned int            NextInstance;
95     struct AxTableInfo      *Next;
96 
97 } AX_TABLE_INFO;
98 
99 
100 /* Globals */
101 
102 ACPI_GLOBAL (char,           Gbl_LineBuffer[AX_LINE_BUFFER_SIZE]);
103 ACPI_GLOBAL (char,           Gbl_HeaderBuffer[AX_LINE_BUFFER_SIZE]);
104 ACPI_GLOBAL (char,           Gbl_InstanceBuffer[AX_LINE_BUFFER_SIZE]);
105 
106 ACPI_GLOBAL (AX_TABLE_INFO, *Gbl_TableListHead);
107 ACPI_GLOBAL (char,           Gbl_OutputFilename[32]);
108 ACPI_GLOBAL (unsigned char,  Gbl_BinaryData[16]);
109 ACPI_GLOBAL (unsigned int,   Gbl_TableCount);
110 
111 /*
112  * acpixtract.c
113  */
114 int
115 AxExtractTables (
116     char                    *InputPathname,
117     char                    *Signature,
118     unsigned int            MinimumInstances);
119 
120 int
121 AxExtractToMultiAmlFile (
122     char                    *InputPathname);
123 
124 int
125 AxListTables (
126     char                    *InputPathname);
127 
128 
129 /*
130  * axutils.c
131  */
132 size_t
133 AxGetTableHeader (
134     FILE                    *InputFile,
135     unsigned char           *OutputData);
136 
137 unsigned int
138 AxCountTableInstances (
139     char                    *InputPathname,
140     char                    *Signature);
141 
142 unsigned int
143 AxGetNextInstance (
144     char                    *InputPathname,
145     char                    *Signature);
146 
147 void
148 AxNormalizeSignature (
149     char                    *Signature);
150 
151 void
152 AxCheckAscii (
153     char                    *Name,
154     int                     Count);
155 
156 int
157 AxIsEmptyLine (
158     char                    *Buffer);
159 
160 int
161 AxIsDataBlockHeader (
162     void);
163 
164 long
165 AxProcessOneTextLine (
166     FILE                    *OutputFile,
167     char                    *ThisSignature,
168     unsigned int            ThisTableBytesWritten);
169 
170 size_t
171 AxConvertLine (
172     char                    *InputLine,
173     unsigned char           *OutputData);
174