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