13446Smrj /******************************************************************************* 23446Smrj * 33446Smrj * Module Name: rsirq - IRQ resource descriptors 43446Smrj * 53446Smrj ******************************************************************************/ 63446Smrj 73446Smrj /****************************************************************************** 83446Smrj * 93446Smrj * 1. Copyright Notice 103446Smrj * 11*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 123446Smrj * All rights reserved. 133446Smrj * 143446Smrj * 2. License 153446Smrj * 163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 173446Smrj * rights. You may have additional license terms from the party that provided 183446Smrj * you this software, covering your right to use that party's intellectual 193446Smrj * property rights. 203446Smrj * 213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 223446Smrj * copy of the source code appearing in this file ("Covered Code") an 233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 253446Smrj * make derivatives, distribute, use and display any portion of the Covered 263446Smrj * Code in any form, with the right to sublicense such rights; and 273446Smrj * 283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 293446Smrj * license (with the right to sublicense), under only those claims of Intel 303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 313446Smrj * offer to sell, and import the Covered Code and derivative works thereof 323446Smrj * solely to the minimum extent necessary to exercise the above copyright 333446Smrj * license, and in no event shall the patent license extend to any additions 343446Smrj * to or modifications of the Original Intel Code. No other license or right 353446Smrj * is granted directly or by implication, estoppel or otherwise; 363446Smrj * 373446Smrj * The above copyright and patent license is granted only if the following 383446Smrj * conditions are met: 393446Smrj * 403446Smrj * 3. Conditions 413446Smrj * 423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 433446Smrj * Redistribution of source code of any substantial portion of the Covered 443446Smrj * Code or modification with rights to further distribute source must include 453446Smrj * the above Copyright Notice, the above License, this list of Conditions, 463446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 483446Smrj * contain a file documenting the changes Licensee made to create that Covered 493446Smrj * Code and the date of any change. Licensee must include in that file the 503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 513446Smrj * must include a prominent statement that the modification is derived, 523446Smrj * directly or indirectly, from Original Intel Code. 533446Smrj * 543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 553446Smrj * Redistribution of source code of any substantial portion of the Covered 563446Smrj * Code or modification without rights to further distribute source must 573446Smrj * include the following Disclaimer and Export Compliance provision in the 583446Smrj * documentation and/or other materials provided with distribution. In 593446Smrj * addition, Licensee may not authorize further sublicense of source of any 603446Smrj * portion of the Covered Code, and must include terms to the effect that the 613446Smrj * license from Licensee to its licensee is limited to the intellectual 623446Smrj * property embodied in the software Licensee provides to its licensee, and 633446Smrj * not to intellectual property embodied in modifications its licensee may 643446Smrj * make. 653446Smrj * 663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 673446Smrj * substantial portion of the Covered Code or modification must reproduce the 683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 693446Smrj * provision in the documentation and/or other materials provided with the 703446Smrj * distribution. 713446Smrj * 723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 733446Smrj * Intel Code. 743446Smrj * 753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 773446Smrj * other dealings in products derived from or relating to the Covered Code 783446Smrj * without prior written authorization from Intel. 793446Smrj * 803446Smrj * 4. Disclaimer and Export Compliance 813446Smrj * 823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 883446Smrj * PARTICULAR PURPOSE. 893446Smrj * 903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 973446Smrj * LIMITED REMEDY. 983446Smrj * 993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 1003446Smrj * software or system incorporating such software without first obtaining any 1013446Smrj * required license or other approval from the U. S. Department of Commerce or 1023446Smrj * any other agency or department of the United States Government. In the 1033446Smrj * event Licensee exports any such software from the United States or 1043446Smrj * re-exports any such software from a foreign destination, Licensee shall 1053446Smrj * ensure that the distribution and export/re-export of the software is in 1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1083446Smrj * any of its subsidiaries will export/re-export any technical data, process, 1093446Smrj * software, or service, directly or indirectly, to any country for which the 1103446Smrj * United States government or any agency thereof requires an export license, 1113446Smrj * other governmental approval, or letter of assurance, without first obtaining 1123446Smrj * such license, approval or letter. 1133446Smrj * 1143446Smrj *****************************************************************************/ 1153446Smrj 1163446Smrj #define __RSIRQ_C__ 1173446Smrj 1183446Smrj #include "acpi.h" 119*9980SDana.Myers@Sun.COM #include "accommon.h" 1203446Smrj #include "acresrc.h" 1213446Smrj 1223446Smrj #define _COMPONENT ACPI_RESOURCES 1233446Smrj ACPI_MODULE_NAME ("rsirq") 1243446Smrj 1253446Smrj 1263446Smrj /******************************************************************************* 1273446Smrj * 1283446Smrj * AcpiRsGetIrq 1293446Smrj * 1303446Smrj ******************************************************************************/ 1313446Smrj 1327851SDana.Myers@Sun.COM ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] = 1333446Smrj { 1343446Smrj {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, 1353446Smrj ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), 1363446Smrj ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)}, 1373446Smrj 1383446Smrj /* Get the IRQ mask (bytes 1:2) */ 1393446Smrj 1403446Smrj {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), 1413446Smrj AML_OFFSET (Irq.IrqMask), 1423446Smrj ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, 1433446Smrj 1443446Smrj /* Set default flags (others are zero) */ 1453446Smrj 1463446Smrj {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering), 1473446Smrj ACPI_EDGE_SENSITIVE, 1483446Smrj 1}, 1493446Smrj 1507851SDana.Myers@Sun.COM /* Get the descriptor length (2 or 3 for IRQ descriptor) */ 1517851SDana.Myers@Sun.COM 1527851SDana.Myers@Sun.COM {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength), 1537851SDana.Myers@Sun.COM AML_OFFSET (Irq.DescriptorType), 1547851SDana.Myers@Sun.COM 0}, 1557851SDana.Myers@Sun.COM 1563446Smrj /* All done if no flag byte present in descriptor */ 1573446Smrj 1583446Smrj {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, 1593446Smrj 1603446Smrj /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ 1613446Smrj 1623446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), 1633446Smrj AML_OFFSET (Irq.Flags), 1643446Smrj 0}, 1653446Smrj 1663446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), 1673446Smrj AML_OFFSET (Irq.Flags), 1683446Smrj 3}, 1693446Smrj 1703446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), 1713446Smrj AML_OFFSET (Irq.Flags), 1723446Smrj 4} 1733446Smrj }; 1743446Smrj 1753446Smrj 1763446Smrj /******************************************************************************* 1773446Smrj * 1783446Smrj * AcpiRsSetIrq 1793446Smrj * 1803446Smrj ******************************************************************************/ 1813446Smrj 1827851SDana.Myers@Sun.COM ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] = 1833446Smrj { 1847851SDana.Myers@Sun.COM /* Start with a default descriptor of length 3 */ 1857851SDana.Myers@Sun.COM 1863446Smrj {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, 1873446Smrj sizeof (AML_RESOURCE_IRQ), 1883446Smrj ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)}, 1893446Smrj 1903446Smrj /* Convert interrupt list to 16-bit IRQ bitmask */ 1913446Smrj 1923446Smrj {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), 1933446Smrj AML_OFFSET (Irq.IrqMask), 1943446Smrj ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, 1953446Smrj 1967851SDana.Myers@Sun.COM /* Set the flags byte */ 1973446Smrj 1983446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), 1993446Smrj AML_OFFSET (Irq.Flags), 2003446Smrj 0}, 2013446Smrj 2023446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), 2033446Smrj AML_OFFSET (Irq.Flags), 2043446Smrj 3}, 2053446Smrj 2063446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), 2073446Smrj AML_OFFSET (Irq.Flags), 2083446Smrj 4}, 2097851SDana.Myers@Sun.COM 2107851SDana.Myers@Sun.COM /* 2117851SDana.Myers@Sun.COM * All done if the output descriptor length is required to be 3 2127851SDana.Myers@Sun.COM * (i.e., optimization to 2 bytes cannot be attempted) 2137851SDana.Myers@Sun.COM */ 2147851SDana.Myers@Sun.COM {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 2157851SDana.Myers@Sun.COM ACPI_RS_OFFSET(Data.Irq.DescriptorLength), 2167851SDana.Myers@Sun.COM 3}, 2177851SDana.Myers@Sun.COM 2187851SDana.Myers@Sun.COM /* Set length to 2 bytes (no flags byte) */ 2197851SDana.Myers@Sun.COM 2207851SDana.Myers@Sun.COM {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}, 2217851SDana.Myers@Sun.COM 2227851SDana.Myers@Sun.COM /* 2237851SDana.Myers@Sun.COM * All done if the output descriptor length is required to be 2. 2247851SDana.Myers@Sun.COM * 2257851SDana.Myers@Sun.COM * TBD: Perhaps we should check for error if input flags are not 2267851SDana.Myers@Sun.COM * compatible with a 2-byte descriptor. 2277851SDana.Myers@Sun.COM */ 2287851SDana.Myers@Sun.COM {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 2297851SDana.Myers@Sun.COM ACPI_RS_OFFSET(Data.Irq.DescriptorLength), 2307851SDana.Myers@Sun.COM 2}, 2317851SDana.Myers@Sun.COM 2327851SDana.Myers@Sun.COM /* Reset length to 3 bytes (descriptor with flags byte) */ 2337851SDana.Myers@Sun.COM 2347851SDana.Myers@Sun.COM {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)}, 2357851SDana.Myers@Sun.COM 2363446Smrj /* 2373446Smrj * Check if the flags byte is necessary. Not needed if the flags are: 2383446Smrj * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE 2393446Smrj */ 2403446Smrj {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 2413446Smrj ACPI_RS_OFFSET (Data.Irq.Triggering), 2423446Smrj ACPI_EDGE_SENSITIVE}, 2433446Smrj 2443446Smrj {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 2453446Smrj ACPI_RS_OFFSET (Data.Irq.Polarity), 2463446Smrj ACPI_ACTIVE_HIGH}, 2473446Smrj 2483446Smrj {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 2493446Smrj ACPI_RS_OFFSET (Data.Irq.Sharable), 2503446Smrj ACPI_EXCLUSIVE}, 2513446Smrj 2527851SDana.Myers@Sun.COM /* We can optimize to a 2-byte IrqNoFlags() descriptor */ 2533446Smrj 2543446Smrj {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)} 2553446Smrj }; 2563446Smrj 2573446Smrj 2583446Smrj /******************************************************************************* 2593446Smrj * 2603446Smrj * AcpiRsConvertExtIrq 2613446Smrj * 2623446Smrj ******************************************************************************/ 2633446Smrj 2643446Smrj ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] = 2653446Smrj { 2663446Smrj {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, 2673446Smrj ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), 2683446Smrj ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)}, 2693446Smrj 2703446Smrj {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, 2713446Smrj sizeof (AML_RESOURCE_EXTENDED_IRQ), 2723446Smrj 0}, 2733446Smrj 2743446Smrj /* Flag bits */ 2753446Smrj 2763446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer), 2773446Smrj AML_OFFSET (ExtendedIrq.Flags), 2783446Smrj 0}, 2793446Smrj 2803446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering), 2813446Smrj AML_OFFSET (ExtendedIrq.Flags), 2823446Smrj 1}, 2833446Smrj 2843446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity), 2853446Smrj AML_OFFSET (ExtendedIrq.Flags), 2863446Smrj 2}, 2873446Smrj 2883446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable), 2893446Smrj AML_OFFSET (ExtendedIrq.Flags), 2903446Smrj 3}, 2913446Smrj 2923446Smrj /* IRQ Table length (Byte4) */ 2933446Smrj 2943446Smrj {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount), 2953446Smrj AML_OFFSET (ExtendedIrq.InterruptCount), 2963446Smrj sizeof (UINT32)}, 2973446Smrj 2983446Smrj /* Copy every IRQ in the table, each is 32 bits */ 2993446Smrj 3003446Smrj {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), 3013446Smrj AML_OFFSET (ExtendedIrq.Interrupts[0]), 3023446Smrj 0}, 3033446Smrj 3043446Smrj /* Optional ResourceSource (Index and String) */ 3053446Smrj 3063446Smrj {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource), 3073446Smrj ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), 3083446Smrj sizeof (AML_RESOURCE_EXTENDED_IRQ)} 3093446Smrj }; 3103446Smrj 3113446Smrj 3123446Smrj /******************************************************************************* 3133446Smrj * 3143446Smrj * AcpiRsConvertDma 3153446Smrj * 3163446Smrj ******************************************************************************/ 3173446Smrj 3183446Smrj ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] = 3193446Smrj { 3203446Smrj {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, 3213446Smrj ACPI_RS_SIZE (ACPI_RESOURCE_DMA), 3223446Smrj ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)}, 3233446Smrj 3243446Smrj {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, 3253446Smrj sizeof (AML_RESOURCE_DMA), 3263446Smrj 0}, 3273446Smrj 3283446Smrj /* Flags: transfer preference, bus mastering, channel speed */ 3293446Smrj 3303446Smrj {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer), 3313446Smrj AML_OFFSET (Dma.Flags), 3323446Smrj 0}, 3333446Smrj 3343446Smrj {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster), 3353446Smrj AML_OFFSET (Dma.Flags), 3363446Smrj 2}, 3373446Smrj 3383446Smrj {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type), 3393446Smrj AML_OFFSET (Dma.Flags), 3403446Smrj 5}, 3413446Smrj 3423446Smrj /* DMA channel mask bits */ 3433446Smrj 3443446Smrj {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]), 3453446Smrj AML_OFFSET (Dma.DmaChannelMask), 3463446Smrj ACPI_RS_OFFSET (Data.Dma.ChannelCount)} 3473446Smrj }; 3483446Smrj 349