From 24115e44926b33c763f81026690f20efd913daf2 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Fri, 17 Sep 2010 10:42:10 +0000 Subject: RefRefine soma code to make code run safely. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10885 6f19259b-4bc3-4df7-8a09-765794883524 --- PcAtChipsetPkg/8259InterruptControllerDxe/8259.c | 8 +- PcAtChipsetPkg/8259InterruptControllerDxe/8259.h | 100 +++++++++++++++++++++++ 2 files changed, 104 insertions(+), 4 deletions(-) (limited to 'PcAtChipsetPkg/8259InterruptControllerDxe') diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c index 7b9067f89a..3defe0ed08 100644 --- a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c +++ b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c @@ -17,7 +17,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, @@ -592,13 +592,13 @@ Install8259 ( // 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,7 +612,7 @@ Install8259 ( &m8259Handle, &gEfiLegacy8259ProtocolGuid, EFI_NATIVE_INTERFACE, - &m8259 + &mInterrupt8259 ); return Status; } diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h index fff068a0df..0d4c1e8223 100644 --- a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h +++ b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h @@ -47,7 +47,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // Protocol Function Prototypes +/** + Sets the base address for the 8259 master and slave PICs. + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] MasterBase Interrupt vectors for IRQ0-IRQ7. + @param[in] SlaveBase Interrupt vectors for IRQ8-IRQ15. + + @retval EFI_SUCCESS The 8259 PIC was programmed successfully. + @retval EFI_DEVICE_ERROR There was an error while writing to the 8259 PIC. + +**/ EFI_STATUS EFIAPI Interrupt8259SetVectorBase ( @@ -56,6 +66,19 @@ Interrupt8259SetVectorBase ( IN UINT8 SlaveBase ); +/** + Gets the current 16-bit real mode and 32-bit protected-mode IRQ masks. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[out] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15. + @param[out] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15. + @param[out] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15. + @param[out] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15. + + @retval EFI_SUCCESS The 8259 PIC was programmed successfully. + @retval EFI_DEVICE_ERROR There was an error while reading the 8259 PIC. + +**/ EFI_STATUS EFIAPI Interrupt8259GetMask ( @@ -66,6 +89,19 @@ Interrupt8259GetMask ( OUT UINT16 *ProtectedEdgeLevel OPTIONAL ); +/** + Sets the current 16-bit real mode and 32-bit protected-mode IRQ masks. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15. + @param[in] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15. + @param[in] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15. + @param[in] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15. + + @retval EFI_SUCCESS The 8259 PIC was programmed successfully. + @retval EFI_DEVICE_ERROR There was an error while writing the 8259 PIC. + +**/ EFI_STATUS EFIAPI Interrupt8259SetMask ( @@ -76,6 +112,18 @@ Interrupt8259SetMask ( IN UINT16 *ProtectedEdgeLevel OPTIONAL ); +/** + Sets the mode of the PICs. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] Mode 16-bit real or 32-bit protected mode. + @param[in] Mask The value with which to set the interrupt mask. + @param[in] EdgeLevel The value with which to set the edge/level mask. + + @retval EFI_SUCCESS The mode was set successfully. + @retval EFI_INVALID_PARAMETER The mode was not set. + +**/ EFI_STATUS EFIAPI Interrupt8259SetMode ( @@ -85,6 +133,17 @@ Interrupt8259SetMode ( IN UINT16 *EdgeLevel OPTIONAL ); +/** + Translates the IRQ into a vector. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] Irq IRQ0-IRQ15. + @param[out] Vector The vector that is assigned to the IRQ. + + @retval EFI_SUCCESS The Vector that matches Irq was returned. + @retval EFI_INVALID_PARAMETER Irq is not valid. + +**/ EFI_STATUS EFIAPI Interrupt8259GetVector ( @@ -93,6 +152,17 @@ Interrupt8259GetVector ( OUT UINT8 *Vector ); +/** + Enables the specified IRQ. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] Irq IRQ0-IRQ15. + @param[in] LevelTriggered 0 = Edge triggered; 1 = Level triggered. + + @retval EFI_SUCCESS The Irq was enabled on the 8259 PIC. + @retval EFI_INVALID_PARAMETER The Irq is not valid. + +**/ EFI_STATUS EFIAPI Interrupt8259EnableIrq ( @@ -101,6 +171,16 @@ Interrupt8259EnableIrq ( IN BOOLEAN LevelTriggered ); +/** + Disables the specified IRQ. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] Irq IRQ0-IRQ15. + + @retval EFI_SUCCESS The Irq was disabled on the 8259 PIC. + @retval EFI_INVALID_PARAMETER The Irq is not valid. + +**/ EFI_STATUS EFIAPI Interrupt8259DisableIrq ( @@ -108,6 +188,16 @@ Interrupt8259DisableIrq ( IN EFI_8259_IRQ Irq ); +/** + Reads the PCI configuration space to get the interrupt number that is assigned to the card. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] PciHandle PCI function for which to return the vector. + @param[out] Vector IRQ number that corresponds to the interrupt line. + + @retval EFI_SUCCESS The interrupt line value was read successfully. + +**/ EFI_STATUS EFIAPI Interrupt8259GetInterruptLine ( @@ -116,6 +206,16 @@ Interrupt8259GetInterruptLine ( OUT UINT8 *Vector ); +/** + Issues the End of Interrupt (EOI) commands to PICs. + + @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance. + @param[in] Irq The interrupt for which to issue the EOI command. + + @retval EFI_SUCCESS The EOI command was issued. + @retval EFI_INVALID_PARAMETER The Irq is not valid. + +**/ EFI_STATUS EFIAPI Interrupt8259EndOfInterrupt ( -- cgit v1.2.3