Split arch cpu.c into hypervisor and shared parts.

Change-Id: I502a2ac44a6f0b66c51f54c102bd6696e7a8f336
diff --git a/inc/hf/arch/cpu.h b/inc/hf/arch/cpu.h
index c26cb8c..2b35f02 100644
--- a/inc/hf/arch/cpu.h
+++ b/inc/hf/arch/cpu.h
@@ -27,16 +27,6 @@
 #include "vmapi/hf/spci.h"
 
 /**
- * Disables interrupts.
- */
-void arch_irq_disable(void);
-
-/**
- * Enables interrupts.
- */
-void arch_irq_enable(void);
-
-/**
  * Reset the register values other than the PC and argument which are set with
  * `arch_regs_set_pc_arg()`.
  */
diff --git a/inc/hf/arch/irq.h b/inc/hf/arch/irq.h
new file mode 100644
index 0000000..c1ee943
--- /dev/null
+++ b/inc/hf/arch/irq.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2019 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+/**
+ * Disables interrupts.
+ */
+void arch_irq_disable(void);
+
+/**
+ * Enables interrupts.
+ */
+void arch_irq_enable(void);
diff --git a/src/arch/aarch64/BUILD.gn b/src/arch/aarch64/BUILD.gn
index f9cbc5a..93569ac 100644
--- a/src/arch/aarch64/BUILD.gn
+++ b/src/arch/aarch64/BUILD.gn
@@ -19,7 +19,7 @@
 # Implementation of the arch interface for aarch64.
 source_set("arch") {
   sources = [
-    "cpu.c",
+    "irq.c",
     "mm.c",
     "timer.c",
   ]
diff --git a/src/arch/aarch64/hypervisor/BUILD.gn b/src/arch/aarch64/hypervisor/BUILD.gn
index 0972dde..db2cca5 100644
--- a/src/arch/aarch64/hypervisor/BUILD.gn
+++ b/src/arch/aarch64/hypervisor/BUILD.gn
@@ -31,6 +31,7 @@
   ]
 
   sources += [
+    "cpu.c",
     "debug_el1.c",
     "handler.c",
     "perfmon.c",
diff --git a/src/arch/aarch64/cpu.c b/src/arch/aarch64/hypervisor/cpu.c
similarity index 94%
rename from src/arch/aarch64/cpu.c
rename to src/arch/aarch64/hypervisor/cpu.c
index a8ff2bc..c0886fe 100644
--- a/src/arch/aarch64/cpu.c
+++ b/src/arch/aarch64/hypervisor/cpu.c
@@ -24,25 +24,15 @@
 #include "hf/spci.h"
 #include "hf/std.h"
 
-#include "hypervisor/perfmon.h"
-#include "hypervisor/sysregs.h"
 #include "msr.h"
+#include "perfmon.h"
+#include "sysregs.h"
 
 /**
  * The LO field indicates whether LORegions are supported.
  */
 #define ID_AA64MMFR1_EL1_LO (UINT64_C(1) << 16)
 
-void arch_irq_disable(void)
-{
-	__asm__ volatile("msr DAIFSet, #0xf");
-}
-
-void arch_irq_enable(void)
-{
-	__asm__ volatile("msr DAIFClr, #0xf");
-}
-
 static void lor_disable(void)
 {
 	/*
diff --git a/src/arch/aarch64/irq.c b/src/arch/aarch64/irq.c
new file mode 100644
index 0000000..4114d76
--- /dev/null
+++ b/src/arch/aarch64/irq.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hf/arch/irq.h"
+
+#include "msr.h"
+
+void arch_irq_disable(void)
+{
+	__asm__ volatile("msr DAIFSet, #0xf");
+}
+
+void arch_irq_enable(void)
+{
+	__asm__ volatile("msr DAIFClr, #0xf");
+}
diff --git a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
index db57638..2c1a7be 100644
--- a/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/busy_secondary.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/arch/aarch64/gicv3/gicv3.c b/test/vmapi/arch/aarch64/gicv3/gicv3.c
index c3f2734..b2bf118 100644
--- a/test/vmapi/arch/aarch64/gicv3/gicv3.c
+++ b/test/vmapi/arch/aarch64/gicv3/gicv3.c
@@ -16,7 +16,7 @@
 
 #include "gicv3.h"
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 
diff --git a/test/vmapi/arch/aarch64/gicv3/interrupts.c b/test/vmapi/arch/aarch64/gicv3/interrupts.c
index c6c07f9..1b42ee3 100644
--- a/test/vmapi/arch/aarch64/gicv3/interrupts.c
+++ b/test/vmapi/arch/aarch64/gicv3/interrupts.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/arch/aarch64/gicv3/services/busy.c b/test/vmapi/arch/aarch64/gicv3/services/busy.c
index 3ee2f84..e8f63e5 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/busy.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/busy.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/arch/aarch64/gicv3/services/systemreg.c b/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
index 7535167..6538c84 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/systemreg.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
 #include "hf/arch/vm/events.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 #include "hf/arch/vm/timer.h"
diff --git a/test/vmapi/arch/aarch64/gicv3/services/timer.c b/test/vmapi/arch/aarch64/gicv3/services/timer.c
index 2dd7e76..cdd3d53 100644
--- a/test/vmapi/arch/aarch64/gicv3/services/timer.c
+++ b/test/vmapi/arch/aarch64/gicv3/services/timer.c
@@ -16,7 +16,7 @@
 
 #include "hf/arch/vm/timer.h"
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/events.h"
 #include "hf/arch/vm/interrupts.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
diff --git a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
index 12ff038..7151273 100644
--- a/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
+++ b/test/vmapi/arch/aarch64/gicv3/timer_secondary.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts_gicv3.h"
 
 #include "hf/abi.h"
diff --git a/test/vmapi/primary_with_secondaries/services/echo_with_notification.c b/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
index be8f1d0..e62ae58 100644
--- a/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
+++ b/test/vmapi/primary_with_secondaries/services/echo_with_notification.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 
 #include "hf/spci.h"
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible.c b/test/vmapi/primary_with_secondaries/services/interruptible.c
index 0e1df08..2afef68 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
index 8300665..e90c1a5 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible_echo.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/primary_with_secondaries/services/receive_block.c b/test/vmapi/primary_with_secondaries/services/receive_block.c
index 50543be..0ca2181 100644
--- a/test/vmapi/primary_with_secondaries/services/receive_block.c
+++ b/test/vmapi/primary_with_secondaries/services/receive_block.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/primary_with_secondaries/services/smp.c b/test/vmapi/primary_with_secondaries/services/smp.c
index cd8fe9e..1644ae4 100644
--- a/test/vmapi/primary_with_secondaries/services/smp.c
+++ b/test/vmapi/primary_with_secondaries/services/smp.c
@@ -17,7 +17,6 @@
 #include <stdalign.h>
 #include <stdint.h>
 
-#include "hf/arch/cpu.h"
 #include "hf/arch/vm/power_mgmt.h"
 
 #include "hf/dlog.h"
diff --git a/test/vmapi/primary_with_secondaries/services/wfi.c b/test/vmapi/primary_with_secondaries/services/wfi.c
index 59baa51..f31a27b 100644
--- a/test/vmapi/primary_with_secondaries/services/wfi.c
+++ b/test/vmapi/primary_with_secondaries/services/wfi.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "hf/arch/cpu.h"
+#include "hf/arch/irq.h"
 #include "hf/arch/vm/interrupts.h"
 
 #include "hf/dlog.h"