167754Smsmith/******************************************************************************* 267754Smsmith * 377424Smsmith * Module Name: rsio - IO and DMA resource descriptors 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 4767754Smsmith 4877424Smsmith#define _COMPONENT ACPI_RESOURCES 4991116Smsmith ACPI_MODULE_NAME ("rsio") 5067754Smsmith 5167754Smsmith 5267754Smsmith/******************************************************************************* 5367754Smsmith * 54151937Sjkim * AcpiRsConvertIo 5567754Smsmith * 5667754Smsmith ******************************************************************************/ 5767754Smsmith 58151937SjkimACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = 5967754Smsmith{ 60151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, 61151937Sjkim ACPI_RS_SIZE (ACPI_RESOURCE_IO), 62151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, 6367754Smsmith 64151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, 65151937Sjkim sizeof (AML_RESOURCE_IO), 66151937Sjkim 0}, 6767754Smsmith 68151937Sjkim /* Decode flag */ 6967754Smsmith 70151937Sjkim {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), 71151937Sjkim AML_OFFSET (Io.Flags), 72151937Sjkim 0}, 7367754Smsmith /* 74151937Sjkim * These fields are contiguous in both the source and destination: 75151937Sjkim * Address Alignment 76151937Sjkim * Length 77151937Sjkim * Minimum Base Address 78151937Sjkim * Maximum Base Address 7967754Smsmith */ 80151937Sjkim {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), 81151937Sjkim AML_OFFSET (Io.Alignment), 82151937Sjkim 2}, 8367754Smsmith 84151937Sjkim {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), 85151937Sjkim AML_OFFSET (Io.Minimum), 86151937Sjkim 2} 87151937Sjkim}; 8867754Smsmith 8967754Smsmith 90151937Sjkim/******************************************************************************* 91151937Sjkim * 92151937Sjkim * AcpiRsConvertFixedIo 93151937Sjkim * 94151937Sjkim ******************************************************************************/ 9567754Smsmith 96151937SjkimACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = 97151937Sjkim{ 98151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, 99151937Sjkim ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), 100151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, 10167754Smsmith 102151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, 103151937Sjkim sizeof (AML_RESOURCE_FIXED_IO), 104151937Sjkim 0}, 10567754Smsmith /* 106151937Sjkim * These fields are contiguous in both the source and destination: 107151937Sjkim * Base Address 108151937Sjkim * Length 10967754Smsmith */ 110151937Sjkim {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), 111151937Sjkim AML_OFFSET (FixedIo.AddressLength), 112151937Sjkim 1}, 11367754Smsmith 114151937Sjkim {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), 115151937Sjkim AML_OFFSET (FixedIo.Address), 116151937Sjkim 1} 117151937Sjkim}; 11867754Smsmith 11967754Smsmith 12067754Smsmith/******************************************************************************* 12167754Smsmith * 122151937Sjkim * AcpiRsConvertGenericReg 12367754Smsmith * 12467754Smsmith ******************************************************************************/ 12567754Smsmith 126151937SjkimACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = 12767754Smsmith{ 128151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, 129151937Sjkim ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), 130151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, 13167754Smsmith 132151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, 133151937Sjkim sizeof (AML_RESOURCE_GENERIC_REGISTER), 134151937Sjkim 0}, 13567754Smsmith /* 136151937Sjkim * These fields are contiguous in both the source and destination: 137151937Sjkim * Address Space ID 138151937Sjkim * Register Bit Width 139151937Sjkim * Register Bit Offset 140151937Sjkim * Access Size 14167754Smsmith */ 142151937Sjkim {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), 143151937Sjkim AML_OFFSET (GenericReg.AddressSpaceId), 144151937Sjkim 4}, 14567754Smsmith 146151937Sjkim /* Get the Register Address */ 14767754Smsmith 148151937Sjkim {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), 149151937Sjkim AML_OFFSET (GenericReg.Address), 150151937Sjkim 1} 151151937Sjkim}; 15267754Smsmith 15367754Smsmith 15467754Smsmith/******************************************************************************* 15567754Smsmith * 156151937Sjkim * AcpiRsConvertEndDpf 15767754Smsmith * 15867754Smsmith ******************************************************************************/ 15967754Smsmith 160151937SjkimACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = 16167754Smsmith{ 162151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, 163151937Sjkim ACPI_RS_SIZE_MIN, 164151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, 16567754Smsmith 166151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, 167151937Sjkim sizeof (AML_RESOURCE_END_DEPENDENT), 168151937Sjkim 0} 169151937Sjkim}; 17067754Smsmith 17167754Smsmith 17267754Smsmith/******************************************************************************* 17367754Smsmith * 174151937Sjkim * AcpiRsConvertEndTag 17567754Smsmith * 17667754Smsmith ******************************************************************************/ 17767754Smsmith 178151937SjkimACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = 17967754Smsmith{ 180151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, 181151937Sjkim ACPI_RS_SIZE_MIN, 182151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, 18367754Smsmith 18467754Smsmith /* 185151937Sjkim * Note: The checksum field is set to zero, meaning that the resource 186151937Sjkim * data is treated as if the checksum operation succeeded. 187151937Sjkim * (ACPI Spec 1.0b Section 6.4.2.8) 18867754Smsmith */ 189151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, 190151937Sjkim sizeof (AML_RESOURCE_END_TAG), 191151937Sjkim 0} 192151937Sjkim}; 19367754Smsmith 19467754Smsmith 19567754Smsmith/******************************************************************************* 19667754Smsmith * 197151937Sjkim * AcpiRsGetStartDpf 19867754Smsmith * 19967754Smsmith ******************************************************************************/ 20067754Smsmith 201193267SjkimACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = 20267754Smsmith{ 203151937Sjkim {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, 204151937Sjkim ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), 205151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, 20667754Smsmith 207151937Sjkim /* Defaults for Compatibility and Performance priorities */ 20867754Smsmith 209151937Sjkim {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 210151937Sjkim ACPI_ACCEPTABLE_CONFIGURATION, 211151937Sjkim 2}, 21267754Smsmith 213193267Sjkim /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ 214193267Sjkim 215193267Sjkim {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), 216193267Sjkim AML_OFFSET (StartDpf.DescriptorType), 217193267Sjkim 0}, 218193267Sjkim 219151937Sjkim /* All done if there is no flag byte present in the descriptor */ 22077424Smsmith 221151937Sjkim {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, 22267754Smsmith 223151937Sjkim /* Flag byte is present, get the flags */ 22467754Smsmith 225151937Sjkim {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 226151937Sjkim AML_OFFSET (StartDpf.Flags), 227151937Sjkim 0}, 22867754Smsmith 229151937Sjkim {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 230151937Sjkim AML_OFFSET (StartDpf.Flags), 231151937Sjkim 2} 232151937Sjkim}; 233100966Siwasaki 234100966Siwasaki 23567754Smsmith/******************************************************************************* 23667754Smsmith * 237151937Sjkim * AcpiRsSetStartDpf 23867754Smsmith * 23967754Smsmith ******************************************************************************/ 24067754Smsmith 241193267SjkimACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = 24267754Smsmith{ 243193267Sjkim /* Start with a default descriptor of length 1 */ 244193267Sjkim 245151937Sjkim {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, 246151937Sjkim sizeof (AML_RESOURCE_START_DEPENDENT), 247151937Sjkim ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, 24867754Smsmith 249151937Sjkim /* Set the default flag values */ 25067754Smsmith 251151937Sjkim {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 252151937Sjkim AML_OFFSET (StartDpf.Flags), 253151937Sjkim 0}, 25467754Smsmith 255151937Sjkim {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 256151937Sjkim AML_OFFSET (StartDpf.Flags), 257151937Sjkim 2}, 25867754Smsmith /* 259193267Sjkim * All done if the output descriptor length is required to be 1 260193267Sjkim * (i.e., optimization to 0 bytes cannot be attempted) 261193267Sjkim */ 262193267Sjkim {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 263193267Sjkim ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 264193267Sjkim 1}, 265193267Sjkim 266193267Sjkim /* Set length to 0 bytes (no flags byte) */ 267193267Sjkim 268193267Sjkim {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, 269193267Sjkim 270193267Sjkim /* 271193267Sjkim * All done if the output descriptor length is required to be 0. 272193267Sjkim * 273193267Sjkim * TBD: Perhaps we should check for error if input flags are not 274193267Sjkim * compatible with a 0-byte descriptor. 275193267Sjkim */ 276193267Sjkim {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 277193267Sjkim ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 278193267Sjkim 0}, 279193267Sjkim 280193267Sjkim /* Reset length to 1 byte (descriptor with flags byte) */ 281193267Sjkim 282193267Sjkim {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, 283193267Sjkim 284193267Sjkim 285193267Sjkim /* 286151937Sjkim * All done if flags byte is necessary -- if either priority value 287151937Sjkim * is not ACPI_ACCEPTABLE_CONFIGURATION 28867754Smsmith */ 289151937Sjkim {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 290151937Sjkim ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 291151937Sjkim ACPI_ACCEPTABLE_CONFIGURATION}, 29267754Smsmith 293151937Sjkim {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 294151937Sjkim ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 295151937Sjkim ACPI_ACCEPTABLE_CONFIGURATION}, 29667754Smsmith 297151937Sjkim /* Flag byte is not necessary */ 29867754Smsmith 299151937Sjkim {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} 300151937Sjkim}; 301