1#
2#  Copyright (c) 2014, ARM Limited. All rights reserved.
3#
4#  SPDX-License-Identifier: BSD-2-Clause-Patent
5#
6#
7
8#include <AsmMacroIoLibV8.h>
9
10#if !defined(__clang__)
11
12//
13// Clang versions before v3.6 do not support the GNU extension that allows
14// system registers outside of the IMPLEMENTATION DEFINED range to be specified
15// using the generic notation below. However, clang knows these registers by
16// their architectural names, so it has no need for these aliases anyway.
17//
18#define ICC_SRE_EL1             S3_0_C12_C12_5
19#define ICC_SRE_EL2             S3_4_C12_C9_5
20#define ICC_SRE_EL3             S3_6_C12_C12_5
21#define ICC_IGRPEN1_EL1         S3_0_C12_C12_7
22#define ICC_EOIR1_EL1           S3_0_C12_C12_1
23#define ICC_IAR1_EL1            S3_0_C12_C12_0
24#define ICC_PMR_EL1             S3_0_C4_C6_0
25#define ICC_BPR1_EL1            S3_0_C12_C12_3
26
27#endif
28
29//UINT32
30//EFIAPI
31//ArmGicV3GetControlSystemRegisterEnable (
32//  VOID
33//  );
34ASM_FUNC(ArmGicV3GetControlSystemRegisterEnable)
35        EL1_OR_EL2_OR_EL3(x1)
361:  mrs x0, ICC_SRE_EL1
37        b       4f
382:  mrs x0, ICC_SRE_EL2
39        b       4f
403:  mrs x0, ICC_SRE_EL3
414:  ret
42
43//VOID
44//EFIAPI
45//ArmGicV3SetControlSystemRegisterEnable (
46//  IN UINT32         ControlSystemRegisterEnable
47//  );
48ASM_FUNC(ArmGicV3SetControlSystemRegisterEnable)
49        EL1_OR_EL2_OR_EL3(x1)
501:  msr ICC_SRE_EL1, x0
51        b       4f
522:  msr ICC_SRE_EL2, x0
53        b       4f
543:  msr ICC_SRE_EL3, x0
554:  isb
56        ret
57
58//VOID
59//ArmGicV3EnableInterruptInterface (
60//  VOID
61//  );
62ASM_FUNC(ArmGicV3EnableInterruptInterface)
63        mov     x0, #1
64        msr     ICC_IGRPEN1_EL1, x0
65        ret
66
67//VOID
68//ArmGicV3DisableInterruptInterface (
69//  VOID
70//  );
71ASM_FUNC(ArmGicV3DisableInterruptInterface)
72        mov     x0, #0
73        msr     ICC_IGRPEN1_EL1, x0
74        ret
75
76//VOID
77//ArmGicV3EndOfInterrupt (
78//  IN UINTN          InterruptId
79//  );
80ASM_FUNC(ArmGicV3EndOfInterrupt)
81        msr     ICC_EOIR1_EL1, x0
82        ret
83
84//UINTN
85//ArmGicV3AcknowledgeInterrupt (
86//  VOID
87//  );
88ASM_FUNC(ArmGicV3AcknowledgeInterrupt)
89        mrs     x0, ICC_IAR1_EL1
90        ret
91
92//VOID
93//ArmGicV3SetPriorityMask (
94//  IN UINTN          Priority
95//  );
96ASM_FUNC(ArmGicV3SetPriorityMask)
97        msr     ICC_PMR_EL1, x0
98        ret
99
100//VOID
101//ArmGicV3SetBinaryPointer (
102//  IN UINTN          BinaryPoint
103//  );
104ASM_FUNC(ArmGicV3SetBinaryPointer)
105        msr     ICC_BPR1_EL1, x0
106        ret
107