aarch64: introduce platform interrupts module

The interrupts module is the platform specific implementation for the
interrupt controller. The Hypervisor codebase is interrupt controller
agnostic. Though for the SPMC there is some control of the GIC needed.

First helpers added are GIC priority mask register adjustement, needed
later by the managed exit scenario.

Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I12b7465096c7198810c4398ceaa9dd08681d6071
diff --git a/src/arch/aarch64/args.gni b/src/arch/aarch64/args.gni
index 521715e..36b505f 100644
--- a/src/arch/aarch64/args.gni
+++ b/src/arch/aarch64/args.gni
@@ -11,5 +11,7 @@
   # SMC hooks to be used for the platform, specified as build target.
   plat_smc = "//src/arch/aarch64/plat/smc:absent"
 
+  plat_interrupts = "//src/arch/aarch64/plat/interrupts:absent"
+
   secure_world = "0"
 }
diff --git a/src/arch/aarch64/hypervisor/BUILD.gn b/src/arch/aarch64/hypervisor/BUILD.gn
index 8f57598..096026f 100644
--- a/src/arch/aarch64/hypervisor/BUILD.gn
+++ b/src/arch/aarch64/hypervisor/BUILD.gn
@@ -52,6 +52,7 @@
     "//src/arch/aarch64:arch",
     "//src/arch/aarch64:entry",
     "//src/arch/aarch64:smc",
+    plat_interrupts,
     plat_psci,
     plat_smc,
   ]
diff --git a/src/arch/aarch64/irq.c b/src/arch/aarch64/irq.c
index f5db690..9964988 100644
--- a/src/arch/aarch64/irq.c
+++ b/src/arch/aarch64/irq.c
@@ -8,8 +8,6 @@
 
 #include "hf/arch/irq.h"
 
-#include "msr.h"
-
 void arch_irq_disable(void)
 {
 	__asm__ volatile("msr DAIFSet, #0xf");
diff --git a/src/arch/aarch64/plat/interrupts/BUILD.gn b/src/arch/aarch64/plat/interrupts/BUILD.gn
new file mode 100644
index 0000000..e3beb44
--- /dev/null
+++ b/src/arch/aarch64/plat/interrupts/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright 2021 The Hafnium Authors.
+#
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/BSD-3-Clause.
+
+import("//build/toolchain/platform.gni")
+
+source_set("absent") {
+  sources = [
+    "absent.c",
+  ]
+}
+
+source_set("gicv3") {
+  public_configs = [ "//src/arch/${plat_arch}:config" ]
+  sources = [
+    "gicv3.c",
+  ]
+}
diff --git a/src/arch/aarch64/plat/interrupts/absent.c b/src/arch/aarch64/plat/interrupts/absent.c
new file mode 100644
index 0000000..241dc7a
--- /dev/null
+++ b/src/arch/aarch64/plat/interrupts/absent.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright 2021 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+#include "hf/types.h"
+
+void plat_interrupts_set_priority_mask(uint8_t min_priority)
+{
+	(void)min_priority;
+}
diff --git a/src/arch/aarch64/plat/interrupts/gicv3.c b/src/arch/aarch64/plat/interrupts/gicv3.c
new file mode 100644
index 0000000..940cd18
--- /dev/null
+++ b/src/arch/aarch64/plat/interrupts/gicv3.c
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2021 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+#include "hf/types.h"
+
+#include "msr.h"
+
+void plat_interrupts_set_priority_mask(uint8_t min_priority)
+{
+	write_msr(ICC_PMR_EL1, min_priority);
+}
diff --git a/src/arch/fake/hypervisor/cpu.c b/src/arch/fake/hypervisor/cpu.c
index e00f71f..2ef9f32 100644
--- a/src/arch/fake/hypervisor/cpu.c
+++ b/src/arch/fake/hypervisor/cpu.c
@@ -21,6 +21,11 @@
 	/* TODO */
 }
 
+void plat_interrupts_set_priority_mask(uint8_t min_priority)
+{
+	(void)min_priority;
+}
+
 void arch_regs_reset(struct vcpu *vcpu)
 {
 	/* TODO */