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/ArmGicLib.h>
17 #include <Library/IoLib.h>
19 #include "GicV2/ArmGicV2Lib.h"
23 ArmGicGetInterfaceIdentification (
24 IN INTN GicInterruptInterfaceBase
27 // Read the GIC Identification Register
28 return MmioRead32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCIIDR
);
33 ArmGicGetMaxNumInterrupts (
34 IN INTN GicDistributorBase
37 return 32 * ((MmioRead32 (GicDistributorBase
+ ARM_GIC_ICDICTR
) & 0x1F) + 1);
43 IN INTN GicDistributorBase
,
44 IN INTN TargetListFilter
,
45 IN INTN CPUTargetList
,
49 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDSGIR
, ((TargetListFilter
& 0x3) << 24) | ((CPUTargetList
& 0xFF) << 16) | SgiId
);
54 ArmGicAcknowledgeInterrupt (
55 IN UINTN GicInterruptInterfaceBase
58 return ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase
);
63 ArmGicEndOfInterrupt (
64 IN UINTN GicInterruptInterfaceBase
,
68 ArmGicV2EndOfInterrupt (GicInterruptInterfaceBase
, 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);
126 ArmGicDisableDistributor (
127 IN INTN GicDistributorBase
130 // Disable Gic Distributor
131 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDDCR
, 0x0);
136 ArmGicEnableInterruptInterface (
137 IN INTN GicInterruptInterfaceBase
140 return ArmGicV2EnableInterruptInterface (GicInterruptInterfaceBase
);
145 ArmGicDisableInterruptInterface (
146 IN INTN GicInterruptInterfaceBase
149 return ArmGicV2DisableInterruptInterface (GicInterruptInterfaceBase
);