rsio.c revision 306536
14374Slars/******************************************************************************* 24374Slars * 34374Slars * Module Name: rsio - IO and DMA resource descriptors 44374Slars * 511990Speter ******************************************************************************/ 611990Speter 711990Speter/* 834766Speter * Copyright (C) 2000 - 2016, Intel Corp. 911990Speter * All rights reserved. 1011990Speter * 1111990Speter * Redistribution and use in source and binary forms, with or without 1211990Speter * modification, are permitted provided that the following conditions 1311990Speter * are met: 144374Slars * 1. Redistributions of source code must retain the above copyright 154374Slars * notice, this list of conditions, and the following disclaimer, 1628597Speter * without modification. 1734766Speter * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1834766Speter * substantially similar to the "NO WARRANTY" disclaimer below 1934766Speter * ("Disclaimer") and any redistribution must be conditioned upon 2034766Speter * including a substantially similar Disclaimer requirement for further 214374Slars * binary redistribution. 2228597Speter * 3. Neither the names of the above-listed copyright holders nor the names 2328597Speter * of any contributors may be used to endorse or promote products derived 2428597Speter * from this software without specific prior written permission. 2528597Speter * 264374Slars * Alternatively, this software may be distributed under the terms of the 2728597Speter * GNU General Public License ("GPL") version 2 as published by the Free 2828597Speter * Software Foundation. 2928597Speter * 3028597Speter * NO WARRANTY 3128597Speter * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3228597Speter * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3328597Speter * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3428597Speter * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3528597Speter * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3628597Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3728597Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3828597Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3928597Speter * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4028597Speter * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4128597Speter * POSSIBILITY OF SUCH DAMAGES. 4228597Speter */ 4328597Speter 4428597Speter#include <contrib/dev/acpica/include/acpi.h> 4528597Speter#include <contrib/dev/acpica/include/accommon.h> 4628597Speter#include <contrib/dev/acpica/include/acresrc.h> 4728597Speter 4828597Speter#define _COMPONENT ACPI_RESOURCES 4928597Speter ACPI_MODULE_NAME ("rsio") 5028597Speter 5128597Speter 5211990Speter/******************************************************************************* 5311990Speter * 5411990Speter * AcpiRsConvertIo 5534766Speter * 5634766Speter ******************************************************************************/ 5734766Speter 5828597SpeterACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = 5934766Speter{ 6028597Speter {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, 6128597Speter ACPI_RS_SIZE (ACPI_RESOURCE_IO), 6228597Speter ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, 6328597Speter 6428597Speter {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, 6528597Speter sizeof (AML_RESOURCE_IO), 6628597Speter 0}, 6728597Speter 6828597Speter /* Decode flag */ 694374Slars 704374Slars {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), 714374Slars AML_OFFSET (Io.Flags), 724374Slars 0}, 734374Slars /* 744374Slars * These fields are contiguous in both the source and destination: 754374Slars * Address Alignment 7611990Speter * Length 7728597Speter * Minimum Base Address 784374Slars * Maximum Base Address 794374Slars */ 80119316Smarkm {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), 81119316Smarkm AML_OFFSET (Io.Alignment), 824374Slars 2}, 83119316Smarkm 84119316Smarkm {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), 8528597Speter AML_OFFSET (Io.Minimum), 86119316Smarkm 2} 874374Slars}; 884374Slars 89119316Smarkm 90119316Smarkm/******************************************************************************* 91119316Smarkm * 924374Slars * AcpiRsConvertFixedIo 934374Slars * 944374Slars ******************************************************************************/ 95119316Smarkm 96119316SmarkmACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = 974374Slars{ 984374Slars {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, 994374Slars ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), 1004374Slars ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, 1014374Slars 1024374Slars {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, 1034374Slars sizeof (AML_RESOURCE_FIXED_IO), 10411990Speter 0}, 10511990Speter /* 10611990Speter * These fields are contiguous in both the source and destination: 10711990Speter * Base Address 1084374Slars * Length 10911990Speter */ 1104374Slars {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), 1114374Slars AML_OFFSET (FixedIo.AddressLength), 112241737Sed 1}, 113241737Sed 114241737Sed {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), 115241737Sed AML_OFFSET (FixedIo.Address), 116241737Sed 1} 117241737Sed}; 118241737Sed 119241737Sed 120241737Sed/******************************************************************************* 121241737Sed * 122241737Sed * AcpiRsConvertGenericReg 123241737Sed * 124241737Sed ******************************************************************************/ 1254374Slars 126119316SmarkmACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = 127119316Smarkm{ 128241737Sed {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, 12911990Speter ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), 13011990Speter ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, 13111990Speter 13211990Speter {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, 133241737Sed sizeof (AML_RESOURCE_GENERIC_REGISTER), 1344374Slars 0}, 135241737Sed /* 136241737Sed * These fields are contiguous in both the source and destination: 137241737Sed * Address Space ID 1384374Slars * Register Bit Width 139241737Sed * Register Bit Offset 140241737Sed * Access Size 141241737Sed */ 142241737Sed {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), 14311990Speter AML_OFFSET (GenericReg.AddressSpaceId), 144241737Sed 4}, 14528597Speter 14692920Simp /* Get the Register Address */ 14792920Simp 14892920Simp {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), 149121784Skientzle AML_OFFSET (GenericReg.Address), 15092920Simp 1} 15192920Simp}; 15292920Simp 15392920Simp 15492920Simp/******************************************************************************* 15592920Simp * 15692920Simp * AcpiRsConvertEndDpf 15792920Simp * 15892920Simp ******************************************************************************/ 15992920Simp 160119316SmarkmACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = 161119316Smarkm{ 162119316Smarkm {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, 16392920Simp ACPI_RS_SIZE_MIN, 16492920Simp ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, 16592920Simp 166119316Smarkm {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, 16792920Simp sizeof (AML_RESOURCE_END_DEPENDENT), 168119316Smarkm 0} 169119316Smarkm}; 17092920Simp 171119316Smarkm 17292920Simp/******************************************************************************* 1734374Slars * 174119316Smarkm * AcpiRsConvertEndTag 175119316Smarkm * 17634766Speter ******************************************************************************/ 1774374Slars 1784374SlarsACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = 17934766Speter{ 18034766Speter {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, 1814374Slars ACPI_RS_SIZE_MIN, 1824374Slars ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, 18334766Speter 1844374Slars /* 185119316Smarkm * Note: The checksum field is set to zero, meaning that the resource 186119316Smarkm * data is treated as if the checksum operation succeeded. 18734766Speter * (ACPI Spec 1.0b Section 6.4.2.8) 1884374Slars */ 18934766Speter {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, 1904374Slars sizeof (AML_RESOURCE_END_TAG), 1914374Slars 0} 192176888Sdelphij}; 193176888Sdelphij 194176888Sdelphij 195176888Sdelphij/******************************************************************************* 1964374Slars * 197176888Sdelphij * AcpiRsGetStartDpf 1984374Slars * 1994374Slars ******************************************************************************/ 200119316Smarkm 20134766SpeterACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = 2024374Slars{ 2034374Slars {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, 20411990Speter ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), 2054374Slars ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, 206176888Sdelphij 20734766Speter /* Defaults for Compatibility and Performance priorities */ 20834766Speter 20934766Speter {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 21034766Speter ACPI_ACCEPTABLE_CONFIGURATION, 21128597Speter 2}, 212176888Sdelphij 213176888Sdelphij /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ 214176888Sdelphij 215176888Sdelphij {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), 21634766Speter AML_OFFSET (StartDpf.DescriptorType), 2174374Slars 0}, 218176888Sdelphij 219176888Sdelphij /* All done if there is no flag byte present in the descriptor */ 220176888Sdelphij 221176888Sdelphij {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, 222176888Sdelphij 223176888Sdelphij /* Flag byte is present, get the flags */ 224176888Sdelphij 225176888Sdelphij {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 226176888Sdelphij AML_OFFSET (StartDpf.Flags), 227176888Sdelphij 0}, 228176888Sdelphij 229176888Sdelphij {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 23034766Speter AML_OFFSET (StartDpf.Flags), 23128597Speter 2} 23234766Speter}; 23334766Speter 23434766Speter 23534766Speter/******************************************************************************* 23634766Speter * 23734766Speter * AcpiRsSetStartDpf 23834766Speter * 23934766Speter ******************************************************************************/ 240176888Sdelphij 241176888SdelphijACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = 24234766Speter{ 2434374Slars /* Start with a default descriptor of length 1 */ 244176888Sdelphij 245176888Sdelphij {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, 246176888Sdelphij sizeof (AML_RESOURCE_START_DEPENDENT), 247176888Sdelphij ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, 24834766Speter 2494374Slars /* Set the default flag values */ 250176888Sdelphij 251176888Sdelphij {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 252176888Sdelphij AML_OFFSET (StartDpf.Flags), 253176888Sdelphij 0}, 25434766Speter 2554374Slars {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 256176888Sdelphij AML_OFFSET (StartDpf.Flags), 257176888Sdelphij 2}, 25834766Speter /* 25934766Speter * All done if the output descriptor length is required to be 1 260176888Sdelphij * (i.e., optimization to 0 bytes cannot be attempted) 261176888Sdelphij */ 26234766Speter {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 26334766Speter ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 26434766Speter 1}, 26534766Speter 26634766Speter /* Set length to 0 bytes (no flags byte) */ 26734766Speter 26834766Speter {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, 269176888Sdelphij 270176888Sdelphij /* 271176888Sdelphij * All done if the output descriptor length is required to be 0. 272176888Sdelphij * 27311990Speter * TBD: Perhaps we should check for error if input flags are not 27411990Speter * compatible with a 0-byte descriptor. 27511990Speter */ 27611990Speter {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 27711990Speter ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 2784374Slars 0}, 27934766Speter 28034766Speter /* Reset length to 1 byte (descriptor with flags byte) */ 2814374Slars 28234766Speter {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, 28334766Speter 28434766Speter 28534766Speter /* 28634766Speter * All done if flags byte is necessary -- if either priority value 2874374Slars * is not ACPI_ACCEPTABLE_CONFIGURATION 28834766Speter */ 289176888Sdelphij {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 2904374Slars ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 291176888Sdelphij ACPI_ACCEPTABLE_CONFIGURATION}, 292176888Sdelphij 293176888Sdelphij {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 294176888Sdelphij ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 29534766Speter ACPI_ACCEPTABLE_CONFIGURATION}, 296176888Sdelphij 297176888Sdelphij /* Flag byte is not necessary */ 298176888Sdelphij 299176888Sdelphij {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} 300176888Sdelphij}; 3014374Slars