1244971Sjkim/****************************************************************************** 2244971Sjkim * 3244971Sjkim * Module Name: psopinfo - AML opcode information functions and dispatch tables 4244971Sjkim * 5244971Sjkim *****************************************************************************/ 6244971Sjkim 7244971Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 9244971Sjkim * All rights reserved. 10244971Sjkim * 11244971Sjkim * Redistribution and use in source and binary forms, with or without 12244971Sjkim * modification, are permitted provided that the following conditions 13244971Sjkim * are met: 14244971Sjkim * 1. Redistributions of source code must retain the above copyright 15244971Sjkim * notice, this list of conditions, and the following disclaimer, 16244971Sjkim * without modification. 17244971Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18244971Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19244971Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20244971Sjkim * including a substantially similar Disclaimer requirement for further 21244971Sjkim * binary redistribution. 22244971Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23244971Sjkim * of any contributors may be used to endorse or promote products derived 24244971Sjkim * from this software without specific prior written permission. 25244971Sjkim * 26244971Sjkim * Alternatively, this software may be distributed under the terms of the 27244971Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28244971Sjkim * Software Foundation. 29244971Sjkim * 30244971Sjkim * NO WARRANTY 31244971Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32244971Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33244971Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34244971Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35244971Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36244971Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37244971Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38244971Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39244971Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40244971Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41244971Sjkim * POSSIBILITY OF SUCH DAMAGES. 42244971Sjkim */ 43244971Sjkim 44245582Sjkim#include <contrib/dev/acpica/include/acpi.h> 45245582Sjkim#include <contrib/dev/acpica/include/accommon.h> 46245582Sjkim#include <contrib/dev/acpica/include/acparser.h> 47245582Sjkim#include <contrib/dev/acpica/include/acopcode.h> 48245582Sjkim#include <contrib/dev/acpica/include/amlcode.h> 49244971Sjkim 50244971Sjkim 51244971Sjkim#define _COMPONENT ACPI_PARSER 52244971Sjkim ACPI_MODULE_NAME ("psopinfo") 53244971Sjkim 54244971Sjkim 55244971Sjkimstatic const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6}; 56244971Sjkim 57244971Sjkim 58244971Sjkim/******************************************************************************* 59244971Sjkim * 60244971Sjkim * FUNCTION: AcpiPsGetOpcodeInfo 61244971Sjkim * 62244971Sjkim * PARAMETERS: Opcode - The AML opcode 63244971Sjkim * 64244971Sjkim * RETURN: A pointer to the info about the opcode. 65244971Sjkim * 66244971Sjkim * DESCRIPTION: Find AML opcode description based on the opcode. 67244971Sjkim * NOTE: This procedure must ALWAYS return a valid pointer! 68244971Sjkim * 69244971Sjkim ******************************************************************************/ 70244971Sjkim 71244971Sjkimconst ACPI_OPCODE_INFO * 72244971SjkimAcpiPsGetOpcodeInfo ( 73244971Sjkim UINT16 Opcode) 74244971Sjkim{ 75281075Sdim#ifdef ACPI_DEBUG_OUTPUT 76281075Sdim const char *OpcodeName = "Unknown AML opcode"; 77281075Sdim#endif 78281075Sdim 79244971Sjkim ACPI_FUNCTION_NAME (PsGetOpcodeInfo); 80244971Sjkim 81244971Sjkim 82244971Sjkim /* 83244971Sjkim * Detect normal 8-bit opcode or extended 16-bit opcode 84244971Sjkim */ 85244971Sjkim if (!(Opcode & 0xFF00)) 86244971Sjkim { 87244971Sjkim /* Simple (8-bit) opcode: 0-255, can't index beyond table */ 88244971Sjkim 89244971Sjkim return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]); 90244971Sjkim } 91244971Sjkim 92244971Sjkim if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) && 93244971Sjkim (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE)) 94244971Sjkim { 95244971Sjkim /* Valid extended (16-bit) opcode */ 96244971Sjkim 97244971Sjkim return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); 98244971Sjkim } 99244971Sjkim 100281075Sdim#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT 101281075Sdim#include <contrib/dev/acpica/compiler/asldefine.h> 102281075Sdim 103281075Sdim switch (Opcode) 104281075Sdim { 105281075Sdim case AML_RAW_DATA_BYTE: 106281075Sdim OpcodeName = "-Raw Data Byte-"; 107281075Sdim break; 108281075Sdim 109281075Sdim case AML_RAW_DATA_WORD: 110281075Sdim OpcodeName = "-Raw Data Word-"; 111281075Sdim break; 112281075Sdim 113281075Sdim case AML_RAW_DATA_DWORD: 114281075Sdim OpcodeName = "-Raw Data Dword-"; 115281075Sdim break; 116281075Sdim 117281075Sdim case AML_RAW_DATA_QWORD: 118281075Sdim OpcodeName = "-Raw Data Qword-"; 119281075Sdim break; 120281075Sdim 121281075Sdim case AML_RAW_DATA_BUFFER: 122281075Sdim OpcodeName = "-Raw Data Buffer-"; 123281075Sdim break; 124281075Sdim 125281075Sdim case AML_RAW_DATA_CHAIN: 126281075Sdim OpcodeName = "-Raw Data Buffer Chain-"; 127281075Sdim break; 128281075Sdim 129281075Sdim case AML_PACKAGE_LENGTH: 130281075Sdim OpcodeName = "-Package Length-"; 131281075Sdim break; 132281075Sdim 133281075Sdim case AML_UNASSIGNED_OPCODE: 134281075Sdim OpcodeName = "-Unassigned Opcode-"; 135281075Sdim break; 136281075Sdim 137281075Sdim case AML_DEFAULT_ARG_OP: 138281075Sdim OpcodeName = "-Default Arg-"; 139281075Sdim break; 140281075Sdim 141281075Sdim default: 142281075Sdim break; 143281075Sdim } 144281075Sdim#endif 145281075Sdim 146244971Sjkim /* Unknown AML opcode */ 147244971Sjkim 148244971Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 149281075Sdim "%s [%4.4X]\n", OpcodeName, Opcode)); 150244971Sjkim 151244971Sjkim return (&AcpiGbl_AmlOpInfo [_UNK]); 152244971Sjkim} 153244971Sjkim 154244971Sjkim 155244971Sjkim/******************************************************************************* 156244971Sjkim * 157244971Sjkim * FUNCTION: AcpiPsGetOpcodeName 158244971Sjkim * 159244971Sjkim * PARAMETERS: Opcode - The AML opcode 160244971Sjkim * 161244971Sjkim * RETURN: A pointer to the name of the opcode (ASCII String) 162244971Sjkim * Note: Never returns NULL. 163244971Sjkim * 164244971Sjkim * DESCRIPTION: Translate an opcode into a human-readable string 165244971Sjkim * 166244971Sjkim ******************************************************************************/ 167244971Sjkim 168306536Sjkimconst char * 169244971SjkimAcpiPsGetOpcodeName ( 170244971Sjkim UINT16 Opcode) 171244971Sjkim{ 172244971Sjkim#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) 173244971Sjkim 174244971Sjkim const ACPI_OPCODE_INFO *Op; 175244971Sjkim 176244971Sjkim 177244971Sjkim Op = AcpiPsGetOpcodeInfo (Opcode); 178244971Sjkim 179244971Sjkim /* Always guaranteed to return a valid pointer */ 180244971Sjkim 181244971Sjkim return (Op->Name); 182244971Sjkim 183244971Sjkim#else 184244971Sjkim return ("OpcodeName unavailable"); 185244971Sjkim 186244971Sjkim#endif 187244971Sjkim} 188244971Sjkim 189244971Sjkim 190244971Sjkim/******************************************************************************* 191244971Sjkim * 192244971Sjkim * FUNCTION: AcpiPsGetArgumentCount 193244971Sjkim * 194244971Sjkim * PARAMETERS: OpType - Type associated with the AML opcode 195244971Sjkim * 196244971Sjkim * RETURN: Argument count 197244971Sjkim * 198244971Sjkim * DESCRIPTION: Obtain the number of expected arguments for an AML opcode 199244971Sjkim * 200244971Sjkim ******************************************************************************/ 201244971Sjkim 202244971SjkimUINT8 203244971SjkimAcpiPsGetArgumentCount ( 204244971Sjkim UINT32 OpType) 205244971Sjkim{ 206244971Sjkim 207244971Sjkim if (OpType <= AML_TYPE_EXEC_6A_0T_1R) 208244971Sjkim { 209244971Sjkim return (AcpiGbl_ArgumentCount[OpType]); 210244971Sjkim } 211244971Sjkim 212244971Sjkim return (0); 213244971Sjkim} 214244971Sjkim 215244971Sjkim 216244971Sjkim/* 217244971Sjkim * This table is directly indexed by the opcodes It returns 218244971Sjkim * an index into the opcode table (AcpiGbl_AmlOpInfo) 219244971Sjkim */ 220244971Sjkimconst UINT8 AcpiGbl_ShortOpIndex[256] = 221244971Sjkim{ 222244971Sjkim/* 0 1 2 3 4 5 6 7 */ 223244971Sjkim/* 8 9 A B C D E F */ 224244971Sjkim/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, 225244971Sjkim/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, 226281687Sjkim/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, 0x81, _UNK, _UNK, 227244971Sjkim/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 228244971Sjkim/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 229244971Sjkim/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, 230244971Sjkim/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, 231244971Sjkim/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 232244971Sjkim/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 233244971Sjkim/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 234244971Sjkim/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 235244971Sjkim/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, 236244971Sjkim/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 237244971Sjkim/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, 238244971Sjkim/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 239244971Sjkim/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 240244971Sjkim/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, 241244971Sjkim/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, 242244971Sjkim/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, 243244971Sjkim/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, 244244971Sjkim/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, 245244971Sjkim/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 246244971Sjkim/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 247244971Sjkim/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 248244971Sjkim/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 249244971Sjkim/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, 250244971Sjkim/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 251244971Sjkim/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 252244971Sjkim/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 253244971Sjkim/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 254244971Sjkim/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 255244971Sjkim/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, 256244971Sjkim}; 257244971Sjkim 258244971Sjkim/* 259244971Sjkim * This table is indexed by the second opcode of the extended opcode 260244971Sjkim * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) 261244971Sjkim */ 262244971Sjkimconst UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = 263244971Sjkim{ 264244971Sjkim/* 0 1 2 3 4 5 6 7 */ 265244971Sjkim/* 8 9 A B C D E F */ 266244971Sjkim/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, 267244971Sjkim/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 268244971Sjkim/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, 269244971Sjkim/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, 270244971Sjkim/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 271244971Sjkim/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, 272244971Sjkim/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, 273244971Sjkim/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 274244971Sjkim/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 275244971Sjkim/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 276244971Sjkim/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 277244971Sjkim/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 278244971Sjkim/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 279244971Sjkim/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 280244971Sjkim/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 281244971Sjkim/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 282244971Sjkim/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 283244971Sjkim/* 0x88 */ 0x7C, 284244971Sjkim}; 285