3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/IoLib.h>
17 #include <Library/ArmGicLib.h>
18 #include <Library/PcdLib.h>
22 ArmGicGetInterfaceIdentification (
23 IN INTN GicInterruptInterfaceBase
26 // Read the GIC Identification Register
27 return MmioRead32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCIIDR
);
32 ArmGicGetMaxNumInterrupts (
33 IN INTN GicDistributorBase
36 return 32 * ((MmioRead32 (GicDistributorBase
+ ARM_GIC_ICDICTR
) & 0x1F) + 1);
42 IN INTN GicDistributorBase
,
43 IN INTN TargetListFilter
,
44 IN INTN CPUTargetList
,
48 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDSGIR
, ((TargetListFilter
& 0x3) << 24) | ((CPUTargetList
& 0xFF) << 16) | SgiId
);
53 ArmGicAcknowledgeInterrupt (
54 IN UINTN GicInterruptInterfaceBase
57 // Read the Interrupt Acknowledge Register
58 return MmioRead32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCIAR
);
63 ArmGicEndOfInterrupt (
64 IN UINTN GicInterruptInterfaceBase
,
68 MmioWrite32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCEIOR
, Source
);
73 ArmGicEnableInterrupt (
74 IN UINTN GicDistributorBase
,
81 // Calculate enable register offset and bit position
82 RegOffset
= Source
/ 32;
83 RegShift
= Source
% 32;
85 // Write set-enable register
86 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDISER
+ (4 * RegOffset
), 1 << RegShift
);
91 ArmGicDisableInterrupt (
92 IN UINTN GicDistributorBase
,
99 // Calculate enable register offset and bit position
100 RegOffset
= Source
/ 32;
101 RegShift
= Source
% 32;
103 // Write clear-enable register
104 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDICER
+ (4 * RegOffset
), 1 << RegShift
);
109 ArmGicIsInterruptEnabled (
110 IN UINTN GicDistributorBase
,
117 // Calculate enable register offset and bit position
118 RegOffset
= Source
/ 32;
119 RegShift
= Source
% 32;
121 return ((MmioRead32 (GicDistributorBase
+ ARM_GIC_ICDISER
+ (4 * RegOffset
)) & (1 << RegShift
)) != 0);