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>
21 ArmGicGetInterfaceIdentification (
22 IN INTN GicInterruptInterfaceBase
25 // Read the GIC Identification Register
26 return MmioRead32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCIIDR
);
31 ArmGicGetMaxNumInterrupts (
32 IN INTN GicDistributorBase
35 return 32 * ((MmioRead32 (GicDistributorBase
+ ARM_GIC_ICDICTR
) & 0x1F) + 1);
41 IN INTN GicDistributorBase
,
42 IN INTN TargetListFilter
,
43 IN INTN CPUTargetList
,
47 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDSGIR
, ((TargetListFilter
& 0x3) << 24) | ((CPUTargetList
& 0xFF) << 16) | SgiId
);
52 ArmGicAcknowledgeInterrupt (
53 IN UINTN GicInterruptInterfaceBase
56 // Read the Interrupt Acknowledge Register
57 return MmioRead32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCIAR
);
62 ArmGicEndOfInterrupt (
63 IN UINTN GicInterruptInterfaceBase
,
67 MmioWrite32 (GicInterruptInterfaceBase
+ ARM_GIC_ICCEIOR
, Source
);
72 ArmGicEnableInterrupt (
73 IN UINTN GicDistributorBase
,
80 // Calculate enable register offset and bit position
81 RegOffset
= Source
/ 32;
82 RegShift
= Source
% 32;
84 // Write set-enable register
85 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDISER
+ (4 * RegOffset
), 1 << RegShift
);
90 ArmGicDisableInterrupt (
91 IN UINTN GicDistributorBase
,
98 // Calculate enable register offset and bit position
99 RegOffset
= Source
/ 32;
100 RegShift
= Source
% 32;
102 // Write clear-enable register
103 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDICER
+ (4 * RegOffset
), 1 << RegShift
);
108 ArmGicIsInterruptEnabled (
109 IN UINTN GicDistributorBase
,
116 // Calculate enable register offset and bit position
117 RegOffset
= Source
/ 32;
118 RegShift
= Source
% 32;
120 return ((MmioRead32 (GicDistributorBase
+ ARM_GIC_ICDISER
+ (4 * RegOffset
)) & (1 << RegShift
)) != 0);
125 ArmGicDisableDistributor (
126 IN INTN GicDistributorBase
129 // Disable Gic Distributor
130 MmioWrite32 (GicDistributorBase
+ ARM_GIC_ICDDCR
, 0x0);