]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Move IntelFrameworkModulePkg/Universal/Legacy8259Dxe to
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 1 Mar 2009 23:33:20 +0000 (23:33 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 1 Mar 2009 23:33:20 +0000 (23:33 +0000)
PcAtChipsetPkg/8259InterruptControllerDxe.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7746 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.c [deleted file]
IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.h [deleted file]
IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.inf [deleted file]
PcAtChipsetPkg/8259InterruptControllerDxe/8259.c [new file with mode: 0644]
PcAtChipsetPkg/8259InterruptControllerDxe/8259.h [new file with mode: 0644]
PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf [new file with mode: 0644]

diff --git a/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.c b/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.c
deleted file mode 100644 (file)
index 4ba196f..0000000
+++ /dev/null
@@ -1,605 +0,0 @@
-/**@file\r
-  This contains the installation function for the driver.\r
-  \r
-Copyright (c) 2005 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "8259.h"\r
-\r
-//\r
-// Global for the Legacy 8259 Protocol that is prodiced by this driver\r
-//\r
-EFI_LEGACY_8259_PROTOCOL  m8259 = {\r
-  Interrupt8259SetVectorBase,\r
-  Interrupt8259GetMask,\r
-  Interrupt8259SetMask,\r
-  Interrupt8259SetMode,\r
-  Interrupt8259GetVector,\r
-  Interrupt8259EnableIrq,\r
-  Interrupt8259DisableIrq,\r
-  Interrupt8259GetInterruptLine,\r
-  Interrupt8259EndOfInterrupt\r
-};\r
-\r
-//\r
-// Global for the handle that the Legacy 8259 Protocol is installed\r
-//\r
-EFI_HANDLE                m8259Handle             = NULL;\r
-\r
-UINT8                     mMasterBase             = 0xff;\r
-UINT8                     mSlaveBase              = 0xff;\r
-EFI_8259_MODE             mMode                   = Efi8259ProtectedMode;\r
-UINT16                    mProtectedModeMask      = 0xffff;\r
-UINT16                    mLegacyModeMask         = 0x06b8;\r
-UINT16                    mProtectedModeEdgeLevel = 0x0000;\r
-UINT16                    mLegacyModeEdgeLevel    = 0x0000;\r
-\r
-//\r
-// Worker Functions\r
-//\r
-VOID\r
-Interrupt8259WriteMask (\r
-  IN UINT16  Mask,\r
-  IN UINT16  EdgeLevel\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Sets the 8250 mask to the valud specified by Mask\r
-\r
-  Arguments:\r
-    Mask       - A 16 bit valute that represents the master and slave mask values\r
-\r
-  Returns:\r
-    None\r
-\r
-**/\r
-// TODO:    EdgeLevel - add argument and description to function comment\r
-{\r
-  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, (UINT8) Mask);\r
-  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8) (Mask >> 8));\r
-  IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8) EdgeLevel);\r
-  IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8) (EdgeLevel >> 8));\r
-}\r
-\r
-VOID\r
-Interrupt8259ReadMask (\r
-  IN UINT16  *Mask,\r
-  IN UINT16  *EdgeLevel\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Sets the 8250 mask to the valud specified by Mask\r
-\r
-  Arguments:\r
-    Mask       - A 16 bit valute that represents the master and slave mask values\r
-\r
-  Returns:\r
-    None\r
-\r
-**/\r
-// TODO:    EdgeLevel - add argument and description to function comment\r
-{\r
-  UINT16  MasterValue;\r
-  UINT16  SlaveValue;\r
-\r
-  if (Mask != NULL) {\r
-    MasterValue = IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);\r
-    SlaveValue  = IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);\r
-\r
-    *Mask = (UINT16) (MasterValue | (SlaveValue << 8));\r
-  }\r
-\r
-  if (EdgeLevel != NULL) {\r
-    MasterValue = IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER);\r
-    SlaveValue  = IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE);\r
-\r
-    *EdgeLevel = (UINT16) (MasterValue | (SlaveValue << 8));\r
-  }\r
-}\r
-//\r
-// Legacy 8259 Protocol Interface Function\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetVectorBase (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  UINT8                     MasterBase,\r
-  IN  UINT8                     SlaveBase\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Sets the base vector for the 8250 Master and Slave interrupt controllers\r
-\r
-  Arguments:\r
-    This       - Protocol instance pointer.\r
-    MasterBase - Base vector of the 8259 Master\r
-    SlaveBase  - Base vector of the 8259 Slave\r
-\r
-  Returns:\r
-    EFI_SUCCESS       - 8259 programmed\r
-\r
-**/\r
-{\r
-  UINT8 Mask;\r
-\r
-  if (SlaveBase != mSlaveBase) {\r
-    mSlaveBase = SlaveBase;\r
-\r
-    //\r
-    // Initialize Slave interrupt controller.\r
-    //\r
-    Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);\r
-    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, 0x11);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, mSlaveBase);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x02);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x01);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, Mask);\r
-  }\r
-\r
-  if (MasterBase != mMasterBase) {\r
-    mMasterBase = MasterBase;\r
-\r
-    //\r
-    // Initialize Master interrupt controller.\r
-    //\r
-    Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);\r
-    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, 0x11);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, mMasterBase);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x04);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x01);\r
-    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, Mask);\r
-  }\r
-\r
-  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, 0x20);\r
-  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, 0x20);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetMask (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  OUT UINT16                    *LegacyMask, OPTIONAL\r
-  OUT UINT16                    *LegacyEdgeLevel, OPTIONAL\r
-  OUT UINT16                    *ProtectedMask, OPTIONAL\r
-  OUT UINT16                    *ProtectedEdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Get the 8259 master and slave address that maps IRQ to processor interrupt \r
-    vector number. Get the Context of the device including the state of the\r
-    interrupt mask.\r
-\r
-  Arguments:\r
-    This       - Protocol instance pointer.\r
-\r
-  Returns:\r
-    EFI_SUCCESS       - 8259 programmed\r
-    EFI_DEVICE_ERROR  - Error writting to 8259\r
-\r
-**/\r
-// TODO:    LegacyMask - add argument and description to function comment\r
-// TODO:    LegacyEdgeLevel - add argument and description to function comment\r
-// TODO:    ProtectedMask - add argument and description to function comment\r
-// TODO:    ProtectedEdgeLevel - add argument and description to function comment\r
-{\r
-  if (LegacyMask != NULL) {\r
-    *LegacyMask = mLegacyModeMask;\r
-  }\r
-\r
-  if (LegacyEdgeLevel != NULL) {\r
-    *LegacyEdgeLevel = mLegacyModeEdgeLevel;\r
-  }\r
-\r
-  if (ProtectedMask != NULL) {\r
-    *ProtectedMask = mProtectedModeMask;\r
-  }\r
-\r
-  if (ProtectedEdgeLevel != NULL) {\r
-    *ProtectedEdgeLevel = mProtectedModeEdgeLevel;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetMask (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  IN  UINT16                    *LegacyMask, OPTIONAL\r
-  IN  UINT16                    *LegacyEdgeLevel, OPTIONAL\r
-  IN  UINT16                    *ProtectedMask, OPTIONAL\r
-  IN  UINT16                    *ProtectedEdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Set the 8259 interrupt and edge/level masks for legacy and/or protected \r
-    mode operation. This routine does not touch the hardware but only the\r
-    RAM copies of the masks.\r
-\r
-  Arguments:\r
-    This       - Protocol instance pointer.\r
-\r
-  Returns:\r
-    EFI_SUCCESS       - 8259 masks updated\r
-\r
-**/\r
-// TODO:    LegacyMask - add argument and description to function comment\r
-// TODO:    LegacyEdgeLevel - add argument and description to function comment\r
-// TODO:    ProtectedMask - add argument and description to function comment\r
-// TODO:    ProtectedEdgeLevel - add argument and description to function comment\r
-{\r
-  if (LegacyMask != NULL) {\r
-    mLegacyModeMask = *LegacyMask;\r
-  }\r
-\r
-  if (LegacyEdgeLevel != NULL) {\r
-    mLegacyModeEdgeLevel = *LegacyEdgeLevel;\r
-  }\r
-\r
-  if (ProtectedMask != NULL) {\r
-    mProtectedModeMask = *ProtectedMask;\r
-  }\r
-\r
-  if (ProtectedEdgeLevel != NULL) {\r
-    mProtectedModeEdgeLevel = *ProtectedEdgeLevel;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetMode (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  IN  EFI_8259_MODE             Mode,\r
-  IN  UINT16                    *Mask, OPTIONAL\r
-  IN  UINT16                    *EdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Set the 8259 master and slave address that maps IRQ to processor interrupt \r
-    vector number. Restore the Context of the device, so that the interrupt\r
-    mask is put back in it's previous mode.\r
-\r
-  Arguments:\r
-    This  - Protocol instance pointer.\r
-    Mode  - \r
-    Mask  -\r
-\r
-  Returns:\r
-    EFI_SUCCESS       - 8259 programmed\r
-    EFI_DEVICE_ERROR  - Error writting to 8259\r
-\r
-**/\r
-// TODO:    EdgeLevel - add argument and description to function comment\r
-// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
-{\r
-  if (Mode == mMode) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Mode == Efi8259LegacyMode) {\r
-    //\r
-    // Save the protected mode mask\r
-    //\r
-    Interrupt8259ReadMask (&mProtectedModeMask, &mProtectedModeEdgeLevel);\r
-\r
-    if (Mask != NULL) {\r
-      //\r
-      // Update the Mask for the new mode\r
-      //\r
-      mLegacyModeMask = *Mask;\r
-    }\r
-\r
-    if (EdgeLevel != NULL) {\r
-      //\r
-      // Update the Edge/Level triggered mask for the new mode\r
-      //\r
-      mLegacyModeEdgeLevel = *EdgeLevel;\r
-    }\r
-\r
-    mMode = Mode;\r
-\r
-    //\r
-    // Set 8259 Vector Base\r
-    //\r
-    //\r
-    Interrupt8259SetVectorBase (This, LEGACY_MODE_BASE_VECTOR_MASTER, LEGACY_MODE_BASE_VECTOR_SLAVE);\r
-\r
-    //\r
-    // Enable Interrupts\r
-    //\r
-    Interrupt8259WriteMask (mLegacyModeMask, mLegacyModeEdgeLevel);\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Mode == Efi8259ProtectedMode) {\r
-    //\r
-    // Save the legacy mode mask\r
-    //\r
-    Interrupt8259ReadMask (&mLegacyModeMask, &mLegacyModeEdgeLevel);\r
-    //\r
-    // Always force Timer to be enabled after return from 16-bit code.\r
-    // This always insures that on next entry, timer is counting.\r
-    //\r
-    mLegacyModeMask &= 0xFFFE;\r
-\r
-    if (Mask != NULL) {\r
-      //\r
-      // Update the Mask for the new mode\r
-      //\r
-      mProtectedModeMask = *Mask;\r
-    }\r
-\r
-    if (EdgeLevel != NULL) {\r
-      //\r
-      // Update the Edge/Level triggered mask for the new mode\r
-      //\r
-      mProtectedModeEdgeLevel = *EdgeLevel;\r
-    }\r
-\r
-    mMode = Mode;\r
-\r
-    //\r
-    // Set 8259 Vector Base\r
-    //\r
-    //\r
-    Interrupt8259SetVectorBase (This, PROTECTED_MODE_BASE_VECTOR_MASTER, PROTECTED_MODE_BASE_VECTOR_SLAVE);\r
-\r
-    //\r
-    // Enable Interrupts\r
-    //\r
-    Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetVector (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq,\r
-  OUT UINT8                     *Vector\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Convert from IRQ to processor interrupt vector number.\r
-\r
-  Arguments:\r
-    This    - Protocol instance pointer.\r
-    Irq     - 8259 IRQ0 - IRQ15\r
-    Vector  - Processor vector number that matches Irq\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The Vector matching Irq is returned\r
-    EFI_INVALID_PARAMETER - Irq not valid\r
-\r
-**/\r
-{\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Irq <= Efi8259Irq7) {\r
-    *Vector = (UINT8) (mMasterBase + Irq);\r
-  } else {\r
-    *Vector = (UINT8) (mSlaveBase + (Irq - Efi8259Irq8));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259EnableIrq (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq,\r
-  IN  BOOLEAN                   LevelTriggered\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Enable Irq by unmasking interrupt in 8259\r
-\r
-  Arguments:\r
-    This    - Protocol instance pointer.\r
-    Irq     - 8259 IRQ0 - IRQ15\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - Irq enabled on 8259\r
-    EFI_INVALID_PARAMETER - Irq not valid\r
-\r
-**/\r
-// TODO:    LevelTriggered - add argument and description to function comment\r
-{\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  mProtectedModeMask = (UINT16) (mProtectedModeMask & ~(1 << Irq));\r
-  if (LevelTriggered) {\r
-    mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel | (1 << Irq));\r
-  } else {\r
-    mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel & ~(1 << Irq));\r
-  }\r
-\r
-  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259DisableIrq (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Disable Irq by masking interrupt in 8259\r
-\r
-  Arguments:\r
-    This    - Protocol instance pointer.\r
-    Irq     - 8259 IRQ0 - IRQ15\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - Irq disabled on 8259\r
-    EFI_INVALID_PARAMETER - Irq not valid\r
-\r
-**/\r
-{\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  mProtectedModeMask      = (UINT16) (mProtectedModeMask | (1 << Irq));\r
-  mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel & ~(1 << Irq));\r
-\r
-  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetInterruptLine (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                PciHandle,\r
-  OUT UINT8                     *Vector\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    PciHandle represents a PCI config space of a PCI function. Vector \r
-    represents Interrupt Pin (from PCI config space) and it is the data\r
-    that is programmed into the Interrupt Line (from the PCI config space)\r
-    register.\r
-\r
-  Arguments:\r
-    This      - Protocol instance pointer.\r
-    PciHandle - PCI function to return vector for \r
-    Vector    - Vector for fucntion that matches \r
-\r
-  Returns:\r
-    EFI_SUCCESS           - A valid Vector is returned\r
-    EFI_INVALID_PARAMETER - PciHandle not valid\r
-\r
-**/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259EndOfInterrupt (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq\r
-  )\r
-/**\r
-\r
-  Routine Description:\r
-    Send an EOI to 8259\r
-\r
-  Arguments:\r
-    This    - Protocol instance pointer.\r
-    Irq     - 8259 IRQ0 - IRQ15\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - EOI successfully sent to 8259\r
-    EFI_INVALID_PARAMETER - Irq not valid\r
-\r
-**/\r
-{\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Irq >= Efi8259Irq8) {\r
-    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, LEGACY_8259_EOI);\r
-  }\r
-\r
-  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, LEGACY_8259_EOI);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Legacy 8259 Driver Entry Point\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-Install8259 (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-  \r
-\r
-Arguments:\r
-\r
-  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - Legacy 8259  Protocol Installed\r
-\r
-**/\r
-// TODO:    ImageHandle - add argument and description to function comment\r
-// TODO:    SystemTable - add argument and description to function comment\r
-{\r
-  EFI_STATUS   Status;\r
-  EFI_8259_IRQ Irq;\r
-\r
-  //\r
-  // Clear all pending interrupt\r
-  //\r
-  for (Irq = Efi8259Irq0; Irq <= Efi8259Irq15; Irq++) {\r
-    Interrupt8259EndOfInterrupt (&m8259, Irq);\r
-  }\r
-\r
-  //\r
-  // Set the 8259 Master base to 0x68 and the 8259 Slave base to 0x70\r
-  //\r
-  Status = Interrupt8259SetVectorBase (&m8259, PROTECTED_MODE_BASE_VECTOR_MASTER, PROTECTED_MODE_BASE_VECTOR_SLAVE);\r
-\r
-  //\r
-  // Set all 8259 interrupts to edge triggered and disabled\r
-  //\r
-  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
-\r
-  //\r
-  // Install 8259 Protocol onto a new handle\r
-  //\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &m8259Handle,\r
-                  &gEfiLegacy8259ProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &m8259\r
-                  );\r
-  return Status;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.h b/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.h
deleted file mode 100644 (file)
index f77494c..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/**\r
-\r
-Copyright (c) 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  8259.h\r
-\r
-Abstract:\r
-\r
-  Driver implementing the Tiano Legacy 8259 Protocol\r
-\r
-**/\r
-\r
-#ifndef _8259_H__\r
-#define _8259_H__\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Protocol/Legacy8259.h>\r
-\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-\r
-//\r
-// 8259 Hardware definitions\r
-//\r
-#define LEGACY_MODE_BASE_VECTOR_MASTER                    0x08\r
-#define LEGACY_MODE_BASE_VECTOR_SLAVE                     0x70\r
-\r
-#define PROTECTED_MODE_BASE_VECTOR_MASTER                 0x68\r
-#define PROTECTED_MODE_BASE_VECTOR_SLAVE                  0x70\r
-\r
-#define LEGACY_8259_CONTROL_REGISTER_MASTER               0x20\r
-#define LEGACY_8259_MASK_REGISTER_MASTER                  0x21\r
-#define LEGACY_8259_CONTROL_REGISTER_SLAVE                0xA0\r
-#define LEGACY_8259_MASK_REGISTER_SLAVE                   0xA1\r
-#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER  0x4D0\r
-#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE   0x4D1\r
-\r
-#define LEGACY_8259_EOI                                   0x20\r
-\r
-//\r
-// Protocol Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetVectorBase (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  UINT8                     MasterBase,\r
-  IN  UINT8                     SlaveBase\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This        - TODO: add argument description\r
-  MasterBase  - TODO: add argument description\r
-  SlaveBase   - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetMask (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  OUT UINT16                    *LegacyMask, OPTIONAL\r
-  OUT UINT16                    *LegacyEdgeLevel, OPTIONAL\r
-  OUT UINT16                    *ProtectedMask, OPTIONAL\r
-  OUT UINT16                    *ProtectedEdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - TODO: add argument description\r
-  LegacyMask          - TODO: add argument description\r
-  LegacyEdgeLevel     - TODO: add argument description\r
-  ProtectedMask       - TODO: add argument description\r
-  ProtectedEdgeLevel  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetMask (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  IN  UINT16                    *LegacyMask, OPTIONAL\r
-  IN  UINT16                    *LegacyEdgeLevel, OPTIONAL\r
-  IN  UINT16                    *ProtectedMask, OPTIONAL\r
-  IN  UINT16                    *ProtectedEdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This                - TODO: add argument description\r
-  LegacyMask          - TODO: add argument description\r
-  LegacyEdgeLevel     - TODO: add argument description\r
-  ProtectedMask       - TODO: add argument description\r
-  ProtectedEdgeLevel  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259SetMode (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
-  IN  EFI_8259_MODE             Mode,\r
-  IN  UINT16                    *Mask, OPTIONAL\r
-  IN  UINT16                    *EdgeLevel OPTIONAL\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This      - TODO: add argument description\r
-  Mode      - TODO: add argument description\r
-  Mask      - TODO: add argument description\r
-  EdgeLevel - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetVector (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq,\r
-  OUT UINT8                     *Vector\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This    - TODO: add argument description\r
-  Irq     - TODO: add argument description\r
-  Vector  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259EnableIrq (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq,\r
-  IN  BOOLEAN                   LevelTriggered\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This            - TODO: add argument description\r
-  Irq             - TODO: add argument description\r
-  LevelTriggered  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259DisableIrq (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This  - TODO: add argument description\r
-  Irq   - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259GetInterruptLine (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                PciHandle,\r
-  OUT UINT8                     *Vector\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This      - TODO: add argument description\r
-  PciHandle - TODO: add argument description\r
-  Vector    - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-Interrupt8259EndOfInterrupt (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
-  IN  EFI_8259_IRQ              Irq\r
-  )\r
-/**\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This  - TODO: add argument description\r
-  Irq   - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
-**/\r
-;\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.inf b/IntelFrameworkModulePkg/Universal/Legacy8259Dxe/8259.inf
deleted file mode 100644 (file)
index fbd1277..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#/*++\r
-# \r
-# Copyright (c) 2005, Intel Corporation                                                         \r
-# All rights reserved. This program and the accompanying materials                          \r
-# are licensed and made available under the terms and conditions of the BSD License         \r
-# which accompanies this distribution.  The full text of the license may be found at        \r
-# http://opensource.org/licenses/bsd-license.php                                            \r
-#                                                                                           \r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-#\r
-#  Module Name:\r
-#\r
-#    8259.inf\r
-#\r
-#  Abstract:\r
-#\r
-#--*/\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Legacy8259\r
-  FILE_GUID                      = 79CA4208-BBA1-4a9a-8456-E1E66A81484E\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
-\r
-  ENTRY_POINT                    = Install8259\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  DebugLib\r
-  UefiDriverEntryPoint\r
-  IoLib\r
-\r
-[Sources.common]\r
-  8259.c\r
-  8259.h\r
-\r
-[Protocols]\r
-  gEfiLegacy8259ProtocolGuid\r
-\r
-[Depex]\r
-  TRUE
\ No newline at end of file
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c
new file mode 100644 (file)
index 0000000..4ba196f
--- /dev/null
@@ -0,0 +1,605 @@
+/**@file\r
+  This contains the installation function for the driver.\r
+  \r
+Copyright (c) 2005 - 2008, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "8259.h"\r
+\r
+//\r
+// Global for the Legacy 8259 Protocol that is prodiced by this driver\r
+//\r
+EFI_LEGACY_8259_PROTOCOL  m8259 = {\r
+  Interrupt8259SetVectorBase,\r
+  Interrupt8259GetMask,\r
+  Interrupt8259SetMask,\r
+  Interrupt8259SetMode,\r
+  Interrupt8259GetVector,\r
+  Interrupt8259EnableIrq,\r
+  Interrupt8259DisableIrq,\r
+  Interrupt8259GetInterruptLine,\r
+  Interrupt8259EndOfInterrupt\r
+};\r
+\r
+//\r
+// Global for the handle that the Legacy 8259 Protocol is installed\r
+//\r
+EFI_HANDLE                m8259Handle             = NULL;\r
+\r
+UINT8                     mMasterBase             = 0xff;\r
+UINT8                     mSlaveBase              = 0xff;\r
+EFI_8259_MODE             mMode                   = Efi8259ProtectedMode;\r
+UINT16                    mProtectedModeMask      = 0xffff;\r
+UINT16                    mLegacyModeMask         = 0x06b8;\r
+UINT16                    mProtectedModeEdgeLevel = 0x0000;\r
+UINT16                    mLegacyModeEdgeLevel    = 0x0000;\r
+\r
+//\r
+// Worker Functions\r
+//\r
+VOID\r
+Interrupt8259WriteMask (\r
+  IN UINT16  Mask,\r
+  IN UINT16  EdgeLevel\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Sets the 8250 mask to the valud specified by Mask\r
+\r
+  Arguments:\r
+    Mask       - A 16 bit valute that represents the master and slave mask values\r
+\r
+  Returns:\r
+    None\r
+\r
+**/\r
+// TODO:    EdgeLevel - add argument and description to function comment\r
+{\r
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, (UINT8) Mask);\r
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8) (Mask >> 8));\r
+  IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8) EdgeLevel);\r
+  IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8) (EdgeLevel >> 8));\r
+}\r
+\r
+VOID\r
+Interrupt8259ReadMask (\r
+  IN UINT16  *Mask,\r
+  IN UINT16  *EdgeLevel\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Sets the 8250 mask to the valud specified by Mask\r
+\r
+  Arguments:\r
+    Mask       - A 16 bit valute that represents the master and slave mask values\r
+\r
+  Returns:\r
+    None\r
+\r
+**/\r
+// TODO:    EdgeLevel - add argument and description to function comment\r
+{\r
+  UINT16  MasterValue;\r
+  UINT16  SlaveValue;\r
+\r
+  if (Mask != NULL) {\r
+    MasterValue = IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);\r
+    SlaveValue  = IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);\r
+\r
+    *Mask = (UINT16) (MasterValue | (SlaveValue << 8));\r
+  }\r
+\r
+  if (EdgeLevel != NULL) {\r
+    MasterValue = IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER);\r
+    SlaveValue  = IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE);\r
+\r
+    *EdgeLevel = (UINT16) (MasterValue | (SlaveValue << 8));\r
+  }\r
+}\r
+//\r
+// Legacy 8259 Protocol Interface Function\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetVectorBase (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  UINT8                     MasterBase,\r
+  IN  UINT8                     SlaveBase\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Sets the base vector for the 8250 Master and Slave interrupt controllers\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MasterBase - Base vector of the 8259 Master\r
+    SlaveBase  - Base vector of the 8259 Slave\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 programmed\r
+\r
+**/\r
+{\r
+  UINT8 Mask;\r
+\r
+  if (SlaveBase != mSlaveBase) {\r
+    mSlaveBase = SlaveBase;\r
+\r
+    //\r
+    // Initialize Slave interrupt controller.\r
+    //\r
+    Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);\r
+    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, 0x11);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, mSlaveBase);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x02);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x01);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, Mask);\r
+  }\r
+\r
+  if (MasterBase != mMasterBase) {\r
+    mMasterBase = MasterBase;\r
+\r
+    //\r
+    // Initialize Master interrupt controller.\r
+    //\r
+    Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);\r
+    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, 0x11);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, mMasterBase);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x04);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x01);\r
+    IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, Mask);\r
+  }\r
+\r
+  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, 0x20);\r
+  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, 0x20);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetMask (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  OUT UINT16                    *LegacyMask, OPTIONAL\r
+  OUT UINT16                    *LegacyEdgeLevel, OPTIONAL\r
+  OUT UINT16                    *ProtectedMask, OPTIONAL\r
+  OUT UINT16                    *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Get the 8259 master and slave address that maps IRQ to processor interrupt \r
+    vector number. Get the Context of the device including the state of the\r
+    interrupt mask.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 programmed\r
+    EFI_DEVICE_ERROR  - Error writting to 8259\r
+\r
+**/\r
+// TODO:    LegacyMask - add argument and description to function comment\r
+// TODO:    LegacyEdgeLevel - add argument and description to function comment\r
+// TODO:    ProtectedMask - add argument and description to function comment\r
+// TODO:    ProtectedEdgeLevel - add argument and description to function comment\r
+{\r
+  if (LegacyMask != NULL) {\r
+    *LegacyMask = mLegacyModeMask;\r
+  }\r
+\r
+  if (LegacyEdgeLevel != NULL) {\r
+    *LegacyEdgeLevel = mLegacyModeEdgeLevel;\r
+  }\r
+\r
+  if (ProtectedMask != NULL) {\r
+    *ProtectedMask = mProtectedModeMask;\r
+  }\r
+\r
+  if (ProtectedEdgeLevel != NULL) {\r
+    *ProtectedEdgeLevel = mProtectedModeEdgeLevel;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetMask (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  IN  UINT16                    *LegacyMask, OPTIONAL\r
+  IN  UINT16                    *LegacyEdgeLevel, OPTIONAL\r
+  IN  UINT16                    *ProtectedMask, OPTIONAL\r
+  IN  UINT16                    *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Set the 8259 interrupt and edge/level masks for legacy and/or protected \r
+    mode operation. This routine does not touch the hardware but only the\r
+    RAM copies of the masks.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 masks updated\r
+\r
+**/\r
+// TODO:    LegacyMask - add argument and description to function comment\r
+// TODO:    LegacyEdgeLevel - add argument and description to function comment\r
+// TODO:    ProtectedMask - add argument and description to function comment\r
+// TODO:    ProtectedEdgeLevel - add argument and description to function comment\r
+{\r
+  if (LegacyMask != NULL) {\r
+    mLegacyModeMask = *LegacyMask;\r
+  }\r
+\r
+  if (LegacyEdgeLevel != NULL) {\r
+    mLegacyModeEdgeLevel = *LegacyEdgeLevel;\r
+  }\r
+\r
+  if (ProtectedMask != NULL) {\r
+    mProtectedModeMask = *ProtectedMask;\r
+  }\r
+\r
+  if (ProtectedEdgeLevel != NULL) {\r
+    mProtectedModeEdgeLevel = *ProtectedEdgeLevel;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetMode (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  IN  EFI_8259_MODE             Mode,\r
+  IN  UINT16                    *Mask, OPTIONAL\r
+  IN  UINT16                    *EdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Set the 8259 master and slave address that maps IRQ to processor interrupt \r
+    vector number. Restore the Context of the device, so that the interrupt\r
+    mask is put back in it's previous mode.\r
+\r
+  Arguments:\r
+    This  - Protocol instance pointer.\r
+    Mode  - \r
+    Mask  -\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 programmed\r
+    EFI_DEVICE_ERROR  - Error writting to 8259\r
+\r
+**/\r
+// TODO:    EdgeLevel - add argument and description to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  if (Mode == mMode) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (Mode == Efi8259LegacyMode) {\r
+    //\r
+    // Save the protected mode mask\r
+    //\r
+    Interrupt8259ReadMask (&mProtectedModeMask, &mProtectedModeEdgeLevel);\r
+\r
+    if (Mask != NULL) {\r
+      //\r
+      // Update the Mask for the new mode\r
+      //\r
+      mLegacyModeMask = *Mask;\r
+    }\r
+\r
+    if (EdgeLevel != NULL) {\r
+      //\r
+      // Update the Edge/Level triggered mask for the new mode\r
+      //\r
+      mLegacyModeEdgeLevel = *EdgeLevel;\r
+    }\r
+\r
+    mMode = Mode;\r
+\r
+    //\r
+    // Set 8259 Vector Base\r
+    //\r
+    //\r
+    Interrupt8259SetVectorBase (This, LEGACY_MODE_BASE_VECTOR_MASTER, LEGACY_MODE_BASE_VECTOR_SLAVE);\r
+\r
+    //\r
+    // Enable Interrupts\r
+    //\r
+    Interrupt8259WriteMask (mLegacyModeMask, mLegacyModeEdgeLevel);\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (Mode == Efi8259ProtectedMode) {\r
+    //\r
+    // Save the legacy mode mask\r
+    //\r
+    Interrupt8259ReadMask (&mLegacyModeMask, &mLegacyModeEdgeLevel);\r
+    //\r
+    // Always force Timer to be enabled after return from 16-bit code.\r
+    // This always insures that on next entry, timer is counting.\r
+    //\r
+    mLegacyModeMask &= 0xFFFE;\r
+\r
+    if (Mask != NULL) {\r
+      //\r
+      // Update the Mask for the new mode\r
+      //\r
+      mProtectedModeMask = *Mask;\r
+    }\r
+\r
+    if (EdgeLevel != NULL) {\r
+      //\r
+      // Update the Edge/Level triggered mask for the new mode\r
+      //\r
+      mProtectedModeEdgeLevel = *EdgeLevel;\r
+    }\r
+\r
+    mMode = Mode;\r
+\r
+    //\r
+    // Set 8259 Vector Base\r
+    //\r
+    //\r
+    Interrupt8259SetVectorBase (This, PROTECTED_MODE_BASE_VECTOR_MASTER, PROTECTED_MODE_BASE_VECTOR_SLAVE);\r
+\r
+    //\r
+    // Enable Interrupts\r
+    //\r
+    Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  return EFI_INVALID_PARAMETER;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetVector (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq,\r
+  OUT UINT8                     *Vector\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Convert from IRQ to processor interrupt vector number.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+    Vector  - Processor vector number that matches Irq\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Vector matching Irq is returned\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+**/\r
+{\r
+  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Irq <= Efi8259Irq7) {\r
+    *Vector = (UINT8) (mMasterBase + Irq);\r
+  } else {\r
+    *Vector = (UINT8) (mSlaveBase + (Irq - Efi8259Irq8));\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259EnableIrq (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq,\r
+  IN  BOOLEAN                   LevelTriggered\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Enable Irq by unmasking interrupt in 8259\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Irq enabled on 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+**/\r
+// TODO:    LevelTriggered - add argument and description to function comment\r
+{\r
+  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  mProtectedModeMask = (UINT16) (mProtectedModeMask & ~(1 << Irq));\r
+  if (LevelTriggered) {\r
+    mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel | (1 << Irq));\r
+  } else {\r
+    mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel & ~(1 << Irq));\r
+  }\r
+\r
+  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259DisableIrq (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Disable Irq by masking interrupt in 8259\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Irq disabled on 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+**/\r
+{\r
+  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  mProtectedModeMask      = (UINT16) (mProtectedModeMask | (1 << Irq));\r
+  mProtectedModeEdgeLevel = (UINT16) (mProtectedModeEdgeLevel & ~(1 << Irq));\r
+\r
+  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetInterruptLine (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                PciHandle,\r
+  OUT UINT8                     *Vector\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    PciHandle represents a PCI config space of a PCI function. Vector \r
+    represents Interrupt Pin (from PCI config space) and it is the data\r
+    that is programmed into the Interrupt Line (from the PCI config space)\r
+    register.\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    PciHandle - PCI function to return vector for \r
+    Vector    - Vector for fucntion that matches \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - A valid Vector is returned\r
+    EFI_INVALID_PARAMETER - PciHandle not valid\r
+\r
+**/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259EndOfInterrupt (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq\r
+  )\r
+/**\r
+\r
+  Routine Description:\r
+    Send an EOI to 8259\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - EOI successfully sent to 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+**/\r
+{\r
+  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Irq >= Efi8259Irq8) {\r
+    IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, LEGACY_8259_EOI);\r
+  }\r
+\r
+  IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, LEGACY_8259_EOI);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// Legacy 8259 Driver Entry Point\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+Install8259 (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+  \r
+\r
+Arguments:\r
+\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Legacy 8259  Protocol Installed\r
+\r
+**/\r
+// TODO:    ImageHandle - add argument and description to function comment\r
+// TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS   Status;\r
+  EFI_8259_IRQ Irq;\r
+\r
+  //\r
+  // Clear all pending interrupt\r
+  //\r
+  for (Irq = Efi8259Irq0; Irq <= Efi8259Irq15; Irq++) {\r
+    Interrupt8259EndOfInterrupt (&m8259, Irq);\r
+  }\r
+\r
+  //\r
+  // Set the 8259 Master base to 0x68 and the 8259 Slave base to 0x70\r
+  //\r
+  Status = Interrupt8259SetVectorBase (&m8259, PROTECTED_MODE_BASE_VECTOR_MASTER, PROTECTED_MODE_BASE_VECTOR_SLAVE);\r
+\r
+  //\r
+  // Set all 8259 interrupts to edge triggered and disabled\r
+  //\r
+  Interrupt8259WriteMask (mProtectedModeMask, mProtectedModeEdgeLevel);\r
+\r
+  //\r
+  // Install 8259 Protocol onto a new handle\r
+  //\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &m8259Handle,\r
+                  &gEfiLegacy8259ProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &m8259\r
+                  );\r
+  return Status;\r
+}\r
+\r
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h
new file mode 100644 (file)
index 0000000..f77494c
--- /dev/null
@@ -0,0 +1,293 @@
+/**\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  8259.h\r
+\r
+Abstract:\r
+\r
+  Driver implementing the Tiano Legacy 8259 Protocol\r
+\r
+**/\r
+\r
+#ifndef _8259_H__\r
+#define _8259_H__\r
+\r
+#include <FrameworkDxe.h>\r
+\r
+#include <Protocol/Legacy8259.h>\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+\r
+//\r
+// 8259 Hardware definitions\r
+//\r
+#define LEGACY_MODE_BASE_VECTOR_MASTER                    0x08\r
+#define LEGACY_MODE_BASE_VECTOR_SLAVE                     0x70\r
+\r
+#define PROTECTED_MODE_BASE_VECTOR_MASTER                 0x68\r
+#define PROTECTED_MODE_BASE_VECTOR_SLAVE                  0x70\r
+\r
+#define LEGACY_8259_CONTROL_REGISTER_MASTER               0x20\r
+#define LEGACY_8259_MASK_REGISTER_MASTER                  0x21\r
+#define LEGACY_8259_CONTROL_REGISTER_SLAVE                0xA0\r
+#define LEGACY_8259_MASK_REGISTER_SLAVE                   0xA1\r
+#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER  0x4D0\r
+#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE   0x4D1\r
+\r
+#define LEGACY_8259_EOI                                   0x20\r
+\r
+//\r
+// Protocol Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetVectorBase (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  UINT8                     MasterBase,\r
+  IN  UINT8                     SlaveBase\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  MasterBase  - TODO: add argument description\r
+  SlaveBase   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetMask (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  OUT UINT16                    *LegacyMask, OPTIONAL\r
+  OUT UINT16                    *LegacyEdgeLevel, OPTIONAL\r
+  OUT UINT16                    *ProtectedMask, OPTIONAL\r
+  OUT UINT16                    *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  LegacyMask          - TODO: add argument description\r
+  LegacyEdgeLevel     - TODO: add argument description\r
+  ProtectedMask       - TODO: add argument description\r
+  ProtectedEdgeLevel  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetMask (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  IN  UINT16                    *LegacyMask, OPTIONAL\r
+  IN  UINT16                    *LegacyEdgeLevel, OPTIONAL\r
+  IN  UINT16                    *ProtectedMask, OPTIONAL\r
+  IN  UINT16                    *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  LegacyMask          - TODO: add argument description\r
+  LegacyEdgeLevel     - TODO: add argument description\r
+  ProtectedMask       - TODO: add argument description\r
+  ProtectedEdgeLevel  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259SetMode (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  * This,\r
+  IN  EFI_8259_MODE             Mode,\r
+  IN  UINT16                    *Mask, OPTIONAL\r
+  IN  UINT16                    *EdgeLevel OPTIONAL\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This      - TODO: add argument description\r
+  Mode      - TODO: add argument description\r
+  Mask      - TODO: add argument description\r
+  EdgeLevel - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetVector (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq,\r
+  OUT UINT8                     *Vector\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  Irq     - TODO: add argument description\r
+  Vector  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259EnableIrq (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq,\r
+  IN  BOOLEAN                   LevelTriggered\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This            - TODO: add argument description\r
+  Irq             - TODO: add argument description\r
+  LevelTriggered  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259DisableIrq (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+  Irq   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259GetInterruptLine (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                PciHandle,\r
+  OUT UINT8                     *Vector\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This      - TODO: add argument description\r
+  PciHandle - TODO: add argument description\r
+  Vector    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+Interrupt8259EndOfInterrupt (\r
+  IN  EFI_LEGACY_8259_PROTOCOL  *This,\r
+  IN  EFI_8259_IRQ              Irq\r
+  )\r
+/**\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+  Irq   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+;\r
+\r
+#endif\r
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
new file mode 100644 (file)
index 0000000..fbd1277
--- /dev/null
@@ -0,0 +1,50 @@
+#/*++\r
+# \r
+# Copyright (c) 2005, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#\r
+#  Module Name:\r
+#\r
+#    8259.inf\r
+#\r
+#  Abstract:\r
+#\r
+#--*/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = Legacy8259\r
+  FILE_GUID                      = 79CA4208-BBA1-4a9a-8456-E1E66A81484E\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = Install8259\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  DebugLib\r
+  UefiDriverEntryPoint\r
+  IoLib\r
+\r
+[Sources.common]\r
+  8259.c\r
+  8259.h\r
+\r
+[Protocols]\r
+  gEfiLegacy8259ProtocolGuid\r
+\r
+[Depex]\r
+  TRUE
\ No newline at end of file