]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/8259InterruptControllerDxe/8259.c
PcAtChipsetPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / PcAtChipsetPkg / 8259InterruptControllerDxe / 8259.c
index ac0642750cbcc2ab9d68b25e5a01d8332addd225..1c2ac1039d403389a00962b903b7b9d375e95724 100644 (file)
@@ -1,14 +1,8 @@
-/**@file\r
+/** @file\r
   This contains the installation function for the driver.\r
-  \r
-Copyright (c) 2005 - 2009, 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
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -17,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // Global for the Legacy 8259 Protocol that is produced by this driver\r
 //\r
-EFI_LEGACY_8259_PROTOCOL  m8259 = {\r
+EFI_LEGACY_8259_PROTOCOL  mInterrupt8259 = {\r
   Interrupt8259SetVectorBase,\r
   Interrupt8259GetMask,\r
   Interrupt8259SetMask,\r
@@ -38,9 +32,9 @@ UINT8                     mMasterBase             = 0xff;
 UINT8                     mSlaveBase              = 0xff;\r
 EFI_8259_MODE             mMode                   = Efi8259ProtectedMode;\r
 UINT16                    mProtectedModeMask      = 0xffff;\r
-UINT16                    mLegacyModeMask         = 0x06b8;\r
+UINT16                    mLegacyModeMask;\r
 UINT16                    mProtectedModeEdgeLevel = 0x0000;\r
-UINT16                    mLegacyModeEdgeLevel    = 0x0000;\r
+UINT16                    mLegacyModeEdgeLevel;\r
 \r
 //\r
 // Worker Functions\r
@@ -123,8 +117,10 @@ Interrupt8259SetVectorBase (
   IN UINT8                     SlaveBase\r
   )\r
 {\r
-  UINT8 Mask;\r
+  UINT8   Mask;\r
+  EFI_TPL OriginalTpl;\r
 \r
+  OriginalTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
   //\r
   // Set vector base for slave PIC\r
   //\r
@@ -137,7 +133,7 @@ Interrupt8259SetVectorBase (
 \r
     //\r
     // Preserve interrtup mask register before initialization sequence\r
-    // because it will be cleared during intialization\r
+    // because it will be cleared during initialization\r
     //\r
     Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);\r
 \r
@@ -179,7 +175,7 @@ Interrupt8259SetVectorBase (
 \r
     //\r
     // Preserve interrtup mask register before initialization sequence\r
-    // because it will be cleared during intialization\r
+    // because it will be cleared during initialization\r
     //\r
     Mask = IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);\r
 \r
@@ -212,6 +208,8 @@ Interrupt8259SetVectorBase (
   IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, LEGACY_8259_EOI);\r
   IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, LEGACY_8259_EOI);\r
 \r
+  gBS->RestoreTPL (OriginalTpl);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -413,7 +411,7 @@ Interrupt8259GetVector (
   OUT UINT8                     *Vector\r
   )\r
 {\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+  if ((UINT32)Irq > Efi8259Irq15) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -445,7 +443,7 @@ Interrupt8259EnableIrq (
   IN BOOLEAN                   LevelTriggered\r
   )\r
 {\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+  if ((UINT32)Irq > Efi8259Irq15) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -478,7 +476,7 @@ Interrupt8259DisableIrq (
   IN EFI_8259_IRQ              Irq\r
   )\r
 {\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+  if ((UINT32)Irq > Efi8259Irq15) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -555,7 +553,7 @@ Interrupt8259EndOfInterrupt (
   IN EFI_8259_IRQ              Irq\r
   )\r
 {\r
-  if (Irq < Efi8259Irq0 || Irq > Efi8259Irq15) {\r
+  if ((UINT32)Irq > Efi8259Irq15) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -588,17 +586,23 @@ Install8259 (
   EFI_STATUS   Status;\r
   EFI_8259_IRQ Irq;\r
 \r
+  //\r
+  // Initialze mask values from PCDs\r
+  //\r
+  mLegacyModeMask      = PcdGet16 (Pcd8259LegacyModeMask);\r
+  mLegacyModeEdgeLevel = PcdGet16 (Pcd8259LegacyModeEdgeLevel);\r
+\r
   //\r
   // Clear all pending interrupt\r
   //\r
   for (Irq = Efi8259Irq0; Irq <= Efi8259Irq15; Irq++) {\r
-    Interrupt8259EndOfInterrupt (&m8259, Irq);\r
+    Interrupt8259EndOfInterrupt (&mInterrupt8259, 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
+  Status = Interrupt8259SetVectorBase (&mInterrupt8259, PROTECTED_MODE_BASE_VECTOR_MASTER, PROTECTED_MODE_BASE_VECTOR_SLAVE);\r
 \r
   //\r
   // Set all 8259 interrupts to edge triggered and disabled\r
@@ -612,8 +616,7 @@ Install8259 (
                   &m8259Handle,\r
                   &gEfiLegacy8259ProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
-                  &m8259\r
+                  &mInterrupt8259\r
                   );\r
   return Status;\r
 }\r
-\r