Add PSCI implementation of hftest_device driver
The hftest_device driver contains board-specific implementation of basic
functionality like rebooting. Now that this is needed for the RPi4
target, add a default, PSCI-based implementation.
Change-Id: Iaf233adcb4cbb4f88a3e720e4c49a94059f8019d
diff --git a/project/reference b/project/reference
index c702a03..b38816f 160000
--- a/project/reference
+++ b/project/reference
@@ -1 +1 @@
-Subproject commit c702a035abf38c1d4916dd015071bd942d3429f5
+Subproject commit b38816f04b97fcd3ce9eb688ff8154b156d9fb38
diff --git a/src/arch/aarch64/hftest/power_mgmt.c b/src/arch/aarch64/hftest/power_mgmt.c
index cfa3e08..5412fd1 100644
--- a/src/arch/aarch64/hftest/power_mgmt.c
+++ b/src/arch/aarch64/hftest/power_mgmt.c
@@ -91,3 +91,14 @@
/* This should never be reached. */
}
}
+
+/**
+ * Restarts the system.
+ */
+noreturn void arch_reboot(void)
+{
+ smc32(PSCI_SYSTEM_RESET, 0, 0, 0, 0, 0, 0, SMCCC_CALLER_HYPERVISOR);
+ for (;;) {
+ /* This should never be reached. */
+ }
+}
diff --git a/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h b/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
index 41ebe49..ca67454 100644
--- a/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
+++ b/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
@@ -47,3 +47,4 @@
enum power_status arch_cpu_status(cpu_id_t cpu_id);
noreturn void arch_power_off(void);
+noreturn void arch_reboot(void);
diff --git a/test/hftest/BUILD.gn b/test/hftest/BUILD.gn
index db97cef..80936f7 100644
--- a/test/hftest/BUILD.gn
+++ b/test/hftest/BUILD.gn
@@ -16,7 +16,7 @@
declare_args() {
hftest_ctrl = ":ctrl_fdt"
- hftest_device = ""
+ hftest_device = ":device_psci"
}
config("hftest_config") {
@@ -127,6 +127,20 @@
]
}
+source_set("device_psci") {
+ testonly = true
+
+ public_configs = [ ":hftest_config" ]
+
+ sources = [
+ "device_psci.c",
+ ]
+
+ deps = [
+ "//src/arch/${plat_arch}/hftest:power_mgmt",
+ ]
+}
+
source_set("mm") {
testonly = true
@@ -187,10 +201,7 @@
deps = [
"//src:dlog",
"//src:memiter",
+ hftest_device,
plat_console,
]
-
- if (hftest_device != "") {
- deps += [ hftest_device ]
- }
}
diff --git a/test/hftest/device_psci.c b/test/hftest/device_psci.c
new file mode 100644
index 0000000..fd9a8c5
--- /dev/null
+++ b/test/hftest/device_psci.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2020 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/vm/power_mgmt.h"
+
+#include "test/hftest.h"
+
+noreturn void hftest_device_reboot(void)
+{
+ arch_reboot();
+}