xref: /titanic_44/usr/src/uts/intel/io/acpica/parser/psopinfo.c (revision cb56572868bfc488bbd3ab847b09db2a25554d44)
1*cb565728SJerry Jelinek /******************************************************************************
2*cb565728SJerry Jelinek  *
3*cb565728SJerry Jelinek  * Module Name: psopinfo - AML opcode information functions and dispatch tables
4*cb565728SJerry Jelinek  *
5*cb565728SJerry Jelinek  *****************************************************************************/
6*cb565728SJerry Jelinek 
7*cb565728SJerry Jelinek /*
8*cb565728SJerry Jelinek  * Copyright (C) 2000 - 2016, Intel Corp.
9*cb565728SJerry Jelinek  * All rights reserved.
10*cb565728SJerry Jelinek  *
11*cb565728SJerry Jelinek  * Redistribution and use in source and binary forms, with or without
12*cb565728SJerry Jelinek  * modification, are permitted provided that the following conditions
13*cb565728SJerry Jelinek  * are met:
14*cb565728SJerry Jelinek  * 1. Redistributions of source code must retain the above copyright
15*cb565728SJerry Jelinek  *    notice, this list of conditions, and the following disclaimer,
16*cb565728SJerry Jelinek  *    without modification.
17*cb565728SJerry Jelinek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*cb565728SJerry Jelinek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*cb565728SJerry Jelinek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*cb565728SJerry Jelinek  *    including a substantially similar Disclaimer requirement for further
21*cb565728SJerry Jelinek  *    binary redistribution.
22*cb565728SJerry Jelinek  * 3. Neither the names of the above-listed copyright holders nor the names
23*cb565728SJerry Jelinek  *    of any contributors may be used to endorse or promote products derived
24*cb565728SJerry Jelinek  *    from this software without specific prior written permission.
25*cb565728SJerry Jelinek  *
26*cb565728SJerry Jelinek  * Alternatively, this software may be distributed under the terms of the
27*cb565728SJerry Jelinek  * GNU General Public License ("GPL") version 2 as published by the Free
28*cb565728SJerry Jelinek  * Software Foundation.
29*cb565728SJerry Jelinek  *
30*cb565728SJerry Jelinek  * NO WARRANTY
31*cb565728SJerry Jelinek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*cb565728SJerry Jelinek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*cb565728SJerry Jelinek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*cb565728SJerry Jelinek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*cb565728SJerry Jelinek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*cb565728SJerry Jelinek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*cb565728SJerry Jelinek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*cb565728SJerry Jelinek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*cb565728SJerry Jelinek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*cb565728SJerry Jelinek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*cb565728SJerry Jelinek  * POSSIBILITY OF SUCH DAMAGES.
42*cb565728SJerry Jelinek  */
43*cb565728SJerry Jelinek 
44*cb565728SJerry Jelinek #include "acpi.h"
45*cb565728SJerry Jelinek #include "accommon.h"
46*cb565728SJerry Jelinek #include "acparser.h"
47*cb565728SJerry Jelinek #include "acopcode.h"
48*cb565728SJerry Jelinek #include "amlcode.h"
49*cb565728SJerry Jelinek 
50*cb565728SJerry Jelinek 
51*cb565728SJerry Jelinek #define _COMPONENT          ACPI_PARSER
52*cb565728SJerry Jelinek         ACPI_MODULE_NAME    ("psopinfo")
53*cb565728SJerry Jelinek 
54*cb565728SJerry Jelinek 
55*cb565728SJerry Jelinek static const UINT8      AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6};
56*cb565728SJerry Jelinek 
57*cb565728SJerry Jelinek 
58*cb565728SJerry Jelinek /*******************************************************************************
59*cb565728SJerry Jelinek  *
60*cb565728SJerry Jelinek  * FUNCTION:    AcpiPsGetOpcodeInfo
61*cb565728SJerry Jelinek  *
62*cb565728SJerry Jelinek  * PARAMETERS:  Opcode              - The AML opcode
63*cb565728SJerry Jelinek  *
64*cb565728SJerry Jelinek  * RETURN:      A pointer to the info about the opcode.
65*cb565728SJerry Jelinek  *
66*cb565728SJerry Jelinek  * DESCRIPTION: Find AML opcode description based on the opcode.
67*cb565728SJerry Jelinek  *              NOTE: This procedure must ALWAYS return a valid pointer!
68*cb565728SJerry Jelinek  *
69*cb565728SJerry Jelinek  ******************************************************************************/
70*cb565728SJerry Jelinek 
71*cb565728SJerry Jelinek const ACPI_OPCODE_INFO *
AcpiPsGetOpcodeInfo(UINT16 Opcode)72*cb565728SJerry Jelinek AcpiPsGetOpcodeInfo (
73*cb565728SJerry Jelinek     UINT16                  Opcode)
74*cb565728SJerry Jelinek {
75*cb565728SJerry Jelinek #ifdef ACPI_DEBUG_OUTPUT
76*cb565728SJerry Jelinek     const char              *OpcodeName = "Unknown AML opcode";
77*cb565728SJerry Jelinek #endif
78*cb565728SJerry Jelinek 
79*cb565728SJerry Jelinek     ACPI_FUNCTION_NAME (PsGetOpcodeInfo);
80*cb565728SJerry Jelinek 
81*cb565728SJerry Jelinek 
82*cb565728SJerry Jelinek     /*
83*cb565728SJerry Jelinek      * Detect normal 8-bit opcode or extended 16-bit opcode
84*cb565728SJerry Jelinek      */
85*cb565728SJerry Jelinek     if (!(Opcode & 0xFF00))
86*cb565728SJerry Jelinek     {
87*cb565728SJerry Jelinek         /* Simple (8-bit) opcode: 0-255, can't index beyond table  */
88*cb565728SJerry Jelinek 
89*cb565728SJerry Jelinek         return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]);
90*cb565728SJerry Jelinek     }
91*cb565728SJerry Jelinek 
92*cb565728SJerry Jelinek     if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
93*cb565728SJerry Jelinek         (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE))
94*cb565728SJerry Jelinek     {
95*cb565728SJerry Jelinek         /* Valid extended (16-bit) opcode */
96*cb565728SJerry Jelinek 
97*cb565728SJerry Jelinek         return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]);
98*cb565728SJerry Jelinek     }
99*cb565728SJerry Jelinek 
100*cb565728SJerry Jelinek #if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT
101*cb565728SJerry Jelinek #include "asldefine.h"
102*cb565728SJerry Jelinek 
103*cb565728SJerry Jelinek     switch (Opcode)
104*cb565728SJerry Jelinek     {
105*cb565728SJerry Jelinek     case AML_RAW_DATA_BYTE:
106*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Byte-";
107*cb565728SJerry Jelinek         break;
108*cb565728SJerry Jelinek 
109*cb565728SJerry Jelinek     case AML_RAW_DATA_WORD:
110*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Word-";
111*cb565728SJerry Jelinek         break;
112*cb565728SJerry Jelinek 
113*cb565728SJerry Jelinek     case AML_RAW_DATA_DWORD:
114*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Dword-";
115*cb565728SJerry Jelinek         break;
116*cb565728SJerry Jelinek 
117*cb565728SJerry Jelinek     case AML_RAW_DATA_QWORD:
118*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Qword-";
119*cb565728SJerry Jelinek         break;
120*cb565728SJerry Jelinek 
121*cb565728SJerry Jelinek     case AML_RAW_DATA_BUFFER:
122*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Buffer-";
123*cb565728SJerry Jelinek         break;
124*cb565728SJerry Jelinek 
125*cb565728SJerry Jelinek     case AML_RAW_DATA_CHAIN:
126*cb565728SJerry Jelinek         OpcodeName = "-Raw Data Buffer Chain-";
127*cb565728SJerry Jelinek         break;
128*cb565728SJerry Jelinek 
129*cb565728SJerry Jelinek     case AML_PACKAGE_LENGTH:
130*cb565728SJerry Jelinek         OpcodeName = "-Package Length-";
131*cb565728SJerry Jelinek         break;
132*cb565728SJerry Jelinek 
133*cb565728SJerry Jelinek     case AML_UNASSIGNED_OPCODE:
134*cb565728SJerry Jelinek         OpcodeName = "-Unassigned Opcode-";
135*cb565728SJerry Jelinek         break;
136*cb565728SJerry Jelinek 
137*cb565728SJerry Jelinek     case AML_DEFAULT_ARG_OP:
138*cb565728SJerry Jelinek         OpcodeName = "-Default Arg-";
139*cb565728SJerry Jelinek         break;
140*cb565728SJerry Jelinek 
141*cb565728SJerry Jelinek     default:
142*cb565728SJerry Jelinek         break;
143*cb565728SJerry Jelinek     }
144*cb565728SJerry Jelinek #endif
145*cb565728SJerry Jelinek 
146*cb565728SJerry Jelinek     /* Unknown AML opcode */
147*cb565728SJerry Jelinek 
148*cb565728SJerry Jelinek     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
149*cb565728SJerry Jelinek         "%s [%4.4X]\n", OpcodeName, Opcode));
150*cb565728SJerry Jelinek 
151*cb565728SJerry Jelinek     return (&AcpiGbl_AmlOpInfo [_UNK]);
152*cb565728SJerry Jelinek }
153*cb565728SJerry Jelinek 
154*cb565728SJerry Jelinek 
155*cb565728SJerry Jelinek /*******************************************************************************
156*cb565728SJerry Jelinek  *
157*cb565728SJerry Jelinek  * FUNCTION:    AcpiPsGetOpcodeName
158*cb565728SJerry Jelinek  *
159*cb565728SJerry Jelinek  * PARAMETERS:  Opcode              - The AML opcode
160*cb565728SJerry Jelinek  *
161*cb565728SJerry Jelinek  * RETURN:      A pointer to the name of the opcode (ASCII String)
162*cb565728SJerry Jelinek  *              Note: Never returns NULL.
163*cb565728SJerry Jelinek  *
164*cb565728SJerry Jelinek  * DESCRIPTION: Translate an opcode into a human-readable string
165*cb565728SJerry Jelinek  *
166*cb565728SJerry Jelinek  ******************************************************************************/
167*cb565728SJerry Jelinek 
168*cb565728SJerry Jelinek const char *
AcpiPsGetOpcodeName(UINT16 Opcode)169*cb565728SJerry Jelinek AcpiPsGetOpcodeName (
170*cb565728SJerry Jelinek     UINT16                  Opcode)
171*cb565728SJerry Jelinek {
172*cb565728SJerry Jelinek #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
173*cb565728SJerry Jelinek 
174*cb565728SJerry Jelinek     const ACPI_OPCODE_INFO  *Op;
175*cb565728SJerry Jelinek 
176*cb565728SJerry Jelinek 
177*cb565728SJerry Jelinek     Op = AcpiPsGetOpcodeInfo (Opcode);
178*cb565728SJerry Jelinek 
179*cb565728SJerry Jelinek     /* Always guaranteed to return a valid pointer */
180*cb565728SJerry Jelinek 
181*cb565728SJerry Jelinek     return (Op->Name);
182*cb565728SJerry Jelinek 
183*cb565728SJerry Jelinek #else
184*cb565728SJerry Jelinek     return ("OpcodeName unavailable");
185*cb565728SJerry Jelinek 
186*cb565728SJerry Jelinek #endif
187*cb565728SJerry Jelinek }
188*cb565728SJerry Jelinek 
189*cb565728SJerry Jelinek 
190*cb565728SJerry Jelinek /*******************************************************************************
191*cb565728SJerry Jelinek  *
192*cb565728SJerry Jelinek  * FUNCTION:    AcpiPsGetArgumentCount
193*cb565728SJerry Jelinek  *
194*cb565728SJerry Jelinek  * PARAMETERS:  OpType              - Type associated with the AML opcode
195*cb565728SJerry Jelinek  *
196*cb565728SJerry Jelinek  * RETURN:      Argument count
197*cb565728SJerry Jelinek  *
198*cb565728SJerry Jelinek  * DESCRIPTION: Obtain the number of expected arguments for an AML opcode
199*cb565728SJerry Jelinek  *
200*cb565728SJerry Jelinek  ******************************************************************************/
201*cb565728SJerry Jelinek 
202*cb565728SJerry Jelinek UINT8
AcpiPsGetArgumentCount(UINT32 OpType)203*cb565728SJerry Jelinek AcpiPsGetArgumentCount (
204*cb565728SJerry Jelinek     UINT32                  OpType)
205*cb565728SJerry Jelinek {
206*cb565728SJerry Jelinek 
207*cb565728SJerry Jelinek     if (OpType <= AML_TYPE_EXEC_6A_0T_1R)
208*cb565728SJerry Jelinek     {
209*cb565728SJerry Jelinek         return (AcpiGbl_ArgumentCount[OpType]);
210*cb565728SJerry Jelinek     }
211*cb565728SJerry Jelinek 
212*cb565728SJerry Jelinek     return (0);
213*cb565728SJerry Jelinek }
214*cb565728SJerry Jelinek 
215*cb565728SJerry Jelinek 
216*cb565728SJerry Jelinek /*
217*cb565728SJerry Jelinek  * This table is directly indexed by the opcodes It returns
218*cb565728SJerry Jelinek  * an index into the opcode table (AcpiGbl_AmlOpInfo)
219*cb565728SJerry Jelinek  */
220*cb565728SJerry Jelinek const UINT8 AcpiGbl_ShortOpIndex[256] =
221*cb565728SJerry Jelinek {
222*cb565728SJerry Jelinek /*              0     1     2     3     4     5     6     7  */
223*cb565728SJerry Jelinek /*              8     9     A     B     C     D     E     F  */
224*cb565728SJerry Jelinek /* 0x00 */    0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
225*cb565728SJerry Jelinek /* 0x08 */    0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
226*cb565728SJerry Jelinek /* 0x10 */    0x08, 0x09, 0x0a, 0x6F, 0x0b, 0x81, _UNK, _UNK,
227*cb565728SJerry Jelinek /* 0x18 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
228*cb565728SJerry Jelinek /* 0x20 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
229*cb565728SJerry Jelinek /* 0x28 */    _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
230*cb565728SJerry Jelinek /* 0x30 */    0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
231*cb565728SJerry Jelinek /* 0x38 */    0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
232*cb565728SJerry Jelinek /* 0x40 */    _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
233*cb565728SJerry Jelinek /* 0x48 */    _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
234*cb565728SJerry Jelinek /* 0x50 */    _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
235*cb565728SJerry Jelinek /* 0x58 */    _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
236*cb565728SJerry Jelinek /* 0x60 */    0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
237*cb565728SJerry Jelinek /* 0x68 */    0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
238*cb565728SJerry Jelinek /* 0x70 */    0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
239*cb565728SJerry Jelinek /* 0x78 */    0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
240*cb565728SJerry Jelinek /* 0x80 */    0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
241*cb565728SJerry Jelinek /* 0x88 */    0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
242*cb565728SJerry Jelinek /* 0x90 */    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
243*cb565728SJerry Jelinek /* 0x98 */    0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
244*cb565728SJerry Jelinek /* 0xA0 */    0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
245*cb565728SJerry Jelinek /* 0xA8 */    0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
246*cb565728SJerry Jelinek /* 0xB0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
247*cb565728SJerry Jelinek /* 0xB8 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
248*cb565728SJerry Jelinek /* 0xC0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
249*cb565728SJerry Jelinek /* 0xC8 */    _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
250*cb565728SJerry Jelinek /* 0xD0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
251*cb565728SJerry Jelinek /* 0xD8 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
252*cb565728SJerry Jelinek /* 0xE0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
253*cb565728SJerry Jelinek /* 0xE8 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
254*cb565728SJerry Jelinek /* 0xF0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
255*cb565728SJerry Jelinek /* 0xF8 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
256*cb565728SJerry Jelinek };
257*cb565728SJerry Jelinek 
258*cb565728SJerry Jelinek /*
259*cb565728SJerry Jelinek  * This table is indexed by the second opcode of the extended opcode
260*cb565728SJerry Jelinek  * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo)
261*cb565728SJerry Jelinek  */
262*cb565728SJerry Jelinek const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] =
263*cb565728SJerry Jelinek {
264*cb565728SJerry Jelinek /*              0     1     2     3     4     5     6     7  */
265*cb565728SJerry Jelinek /*              8     9     A     B     C     D     E     F  */
266*cb565728SJerry Jelinek /* 0x00 */    _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
267*cb565728SJerry Jelinek /* 0x08 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
268*cb565728SJerry Jelinek /* 0x10 */    _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
269*cb565728SJerry Jelinek /* 0x18 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
270*cb565728SJerry Jelinek /* 0x20 */    0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
271*cb565728SJerry Jelinek /* 0x28 */    0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
272*cb565728SJerry Jelinek /* 0x30 */    0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
273*cb565728SJerry Jelinek /* 0x38 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
274*cb565728SJerry Jelinek /* 0x40 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
275*cb565728SJerry Jelinek /* 0x48 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
276*cb565728SJerry Jelinek /* 0x50 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
277*cb565728SJerry Jelinek /* 0x58 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
278*cb565728SJerry Jelinek /* 0x60 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
279*cb565728SJerry Jelinek /* 0x68 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
280*cb565728SJerry Jelinek /* 0x70 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
281*cb565728SJerry Jelinek /* 0x78 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
282*cb565728SJerry Jelinek /* 0x80 */    0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
283*cb565728SJerry Jelinek /* 0x88 */    0x7C,
284*cb565728SJerry Jelinek };
285