/** @file
Legacy resource template

Copyright (c) 2013-2015 Intel Corporation.

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef LPC_DEV_ASI
#define LPC_DEV_ASI

Device(RTC)
{
    Name(_HID,EISAID("PNP0B00"))
    Name(BUF0,ResourceTemplate() {
        IO(Decode16,0x70,0x70,0x01,0x04)
        IO(Decode16,0x74,0x74,0x01,0x04)
    })
    Name(BUF1,ResourceTemplate() {
        IO(Decode16,0x70,0x70,0x01,0x04)
        IO(Decode16,0x74,0x74,0x01,0x04)
        IRQNoFlags(){8}
    })
    Method(_CRS,0,Serialized)
    {
        If (HPEA)
        {
            return (BUF0)
        }
        Else
        {
            return (BUF1)
        }
    }
}

Device(PIC)
{
    Name(_HID,EISAID("PNP0000"))

    Name(_CRS,ResourceTemplate() {
        IO(Decode16,0x20,0x20,0x01,0x1E)        // length of 1Eh includes all aliases
        IO(Decode16,0xA0,0xA0,0x01,0x1E)
        IO(Decode16,0x4D0,0x4D0,0x01,0x02)
    })
}

Device(TMR)
{
    Name(_HID,EISAID("PNP0100"))

    Name(BUF0,ResourceTemplate() {
        IO(Decode16,0x40,0x40,0x01,0x04)
        IO(Decode16,0x50,0x50,0x01,0x04)        // alias
    })
    Name(BUF1,ResourceTemplate() {
        IO(Decode16,0x40,0x40,0x01,0x04)
        IO(Decode16,0x50,0x50,0x01,0x04)        // alias
        IRQNoFlags(){0}
    })
    Method(_CRS,0,Serialized)
    {
        If (HPEA)
        {
            return (BUF0)
        }
        Else
        {
            return (BUF1)
        }
    }
}

Device(SPKR)
{
    Name(_HID,EISAID("PNP0800"))

    Name(_CRS,ResourceTemplate() {
        IO(Decode16,0x61,0x61,0x01,0x01)
    })
}

Device(XTRA)    // all "PNP0C02" devices- pieces that don't fit anywhere else
{
    Name(_HID,EISAID("PNP0C02"))        // Generic motherboard devices

    Name(CRS,
        ResourceTemplate()
        {
            IO(Decode16,0x2E,0x2E,0x01,0x02)
            IO(Decode16,0x4E,0x2E,0x01,0x02)
            IO(Decode16,0x63,0x61,0x01,0x01)
            IO(Decode16,0x65,0x61,0x01,0x01)
            IO(Decode16,0x67,0x61,0x01,0x01)
            IO(Decode16,0x80,0x80,0x01,0x01)
            IO(Decode16,0x84,0x84,0x01,0x04)
            IO(Decode16,0x88,0x88,0x01,0x01)
            IO(Decode16,0x8c,0x8c,0x01,0x03)
            IO(Decode16,0x92,0x92,0x01,0x01)

            IO(
              Decode16,
              0,
              0,
              0x01,
              0x10,
              FIX1
              )

            IO(
              Decode16,
              0,
              0,
              0x01,
              0x10,
              FIX2
              )

            IO(
              Decode16,
              0,
              0,
              0x01,
              0x40,
              FIX3
              )

           IO(
              Decode16,
              0,
              0,
              0x01,
              0x40,
              FIX5
              )

            IO(
              Decode16,
              0,
              0,
              0x01,
              0x40,
              FIX6
              )

        }
    )

    Method (_CRS, 0, NotSerialized) {
      CreateWordField (CRS, ^FIX1._MIN, MBR0)
      Store(\P1BB, MBR0)
      CreateWordField (CRS, ^FIX1._MAX, MBR1)
      Store(\P1BB, MBR1)
      CreateWordField (CRS, ^FIX2._MIN, MBR2)
      Store(\PBAB, MBR2)
      CreateWordField (CRS, ^FIX2._MAX, MBR3)
      Store(\PBAB, MBR3)
      CreateWordField (CRS, ^FIX3._MIN, MBR4)
      Store(\GP0B, MBR4)
      CreateWordField (CRS, ^FIX3._MAX, MBR5)
      Store(\GP0B, MBR5)
      CreateWordField (CRS, ^FIX5._MIN, MBR8)
      Store(\SMBB, MBR8)
      CreateWordField (CRS, ^FIX5._MAX, MBR9)
      Store(\SMBB, MBR9)
      CreateWordField (CRS, ^FIX6._MIN, MBRA)
      Store(\WDTB, MBRA)
      CreateWordField (CRS, ^FIX6._MAX, MBRB)
      Store(\WDTB, MBRB)
      return (CRS)
    }
}

Device(LGIO)  // Legacy GPIO.
{
    Name(_HID, "INT3488")
    Name(_CID, "INT3488")

    Name(CRS,
        ResourceTemplate()
        {
            IO(
              Decode16,
              0,
              0,
              0x01,
              0x48,
              FIX4
              )
        }
    )

    Method (_CRS, 0, NotSerialized) {
      CreateWordField (CRS, ^FIX4._MIN, MBR6)
      Store(\GPAB, MBR6)
      CreateWordField (CRS, ^FIX4._MAX, MBR7)
      Store(\GPAB, MBR7)
      return (CRS)
    }
}

Device(HPET)  // High Performance Event Timer
{
  Name(_HID,EISAID("PNP0103"))

  Name(BUF0,ResourceTemplate()
  {
    IRQNoFlags() {0}
    IRQNoFlags() {8}
    Memory32Fixed(ReadOnly, 0, 0, FIX1)
  })

  Method(_STA,0)
  {
    // Show this Device only if the OS is WINXP or beyond.

    If(LGreaterEqual(OSTP,WINDOWS_XP))
    {
      If(HPEA)
      {
        Return(0x000F)  // Enabled, do Display.
      }
    }
    Else
    {
      // OS = WIN98, WINME, or WIN2000.

      If(HPEA)
      {
        Return(0x000B)  // Enabled, don't Display.
      }
    }

    Return(0x0000)      // Return Nothing.
  }

  Method(_CRS,0,Serialized)
  {
    CreateDWordField (BUF0, ^FIX1._BAS, MBR0)
    Store(\HPTB, MBR0)
    CreateDWordField (BUF0, ^FIX1._LEN, MBR1)
    Store(\HPTS, MBR1)
    Return(BUF0)
  }
}

#endif