Platform hook for suspend/resume.

Change-Id: I3c1ae34e3ba8a8437d9d7ebb7684907acbef5307
diff --git a/inc/hf/arch/plat/psci.h b/inc/hf/arch/plat/psci.h
new file mode 100644
index 0000000..a016fba
--- /dev/null
+++ b/inc/hf/arch/plat/psci.h
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "hf/vcpu.h"
+
+/**
+ * Called before the PSCI_CPU_SUSPEND SMC is forwarded. The power state is
+ * provided to allow actions to be taken based on the implementation defined
+ * meaning of this field.
+ */
+void plat_psci_cpu_suspend(uint32_t power_state);
+
+/** Called when a CPU resumes from being off or suspended. */
+void plat_psci_cpu_resume(void);
diff --git a/src/arch/aarch64/args.gni b/src/arch/aarch64/args.gni
index 1582b34..6deb2be 100644
--- a/src/arch/aarch64/args.gni
+++ b/src/arch/aarch64/args.gni
@@ -13,6 +13,9 @@
 # limitations under the License.
 
 declare_args() {
+  # PSCI hooks to be used for the platform, specified as build target.
+  plat_psci = "//src/arch/aarch64/plat/psci:absent"
+
   # SMC hooks to be used for the platform, specified as build target.
-  plat_smc = "//src/arch/aarch64/smc:absent"
+  plat_smc = "//src/arch/aarch64/plat/smc:absent"
 }
diff --git a/src/arch/aarch64/hypervisor/BUILD.gn b/src/arch/aarch64/hypervisor/BUILD.gn
index 6182aaf..d5db714 100644
--- a/src/arch/aarch64/hypervisor/BUILD.gn
+++ b/src/arch/aarch64/hypervisor/BUILD.gn
@@ -47,6 +47,7 @@
     "//src/arch/aarch64:arch",
     "//src/arch/aarch64:entry",
     "//src/arch/aarch64:smc",
+    plat_psci,
     plat_smc,
   ]
 }
diff --git a/src/arch/aarch64/hypervisor/cpu.c b/src/arch/aarch64/hypervisor/cpu.c
index adb5b12..97457c4 100644
--- a/src/arch/aarch64/hypervisor/cpu.c
+++ b/src/arch/aarch64/hypervisor/cpu.c
@@ -20,6 +20,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "hf/arch/plat/psci.h"
+
 #include "hf/addr.h"
 #include "hf/spci.h"
 #include "hf/std.h"
@@ -137,6 +139,8 @@
 
 void arch_cpu_init(void)
 {
+	plat_psci_cpu_resume();
+
 	/*
 	 * Linux expects LORegions to be disabled, hence if the current system
 	 * supports them, Hafnium ensures that they are disabled.
diff --git a/src/arch/aarch64/hypervisor/psci_handler.c b/src/arch/aarch64/hypervisor/psci_handler.c
index 147f9eb..aabe979 100644
--- a/src/arch/aarch64/hypervisor/psci_handler.c
+++ b/src/arch/aarch64/hypervisor/psci_handler.c
@@ -18,6 +18,7 @@
 
 #include <stdint.h>
 
+#include "hf/arch/plat/psci.h"
 #include "hf/arch/types.h"
 
 #include "hf/api.h"
@@ -162,6 +163,7 @@
 		break;
 
 	case PSCI_CPU_SUSPEND: {
+		plat_psci_cpu_suspend(arg0);
 		/*
 		 * Update vCPU state to wake from the provided entry point but
 		 * if suspend returns, for example because it failed or was a
diff --git a/src/arch/aarch64/plat/psci/BUILD.gn b/src/arch/aarch64/plat/psci/BUILD.gn
new file mode 100644
index 0000000..46e5b60
--- /dev/null
+++ b/src/arch/aarch64/plat/psci/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+source_set("absent") {
+  sources = [
+    "absent.c",
+  ]
+}
diff --git a/src/arch/aarch64/plat/psci/absent.c b/src/arch/aarch64/plat/psci/absent.c
new file mode 100644
index 0000000..5b1e998
--- /dev/null
+++ b/src/arch/aarch64/plat/psci/absent.c
@@ -0,0 +1,26 @@
+/*
+ * 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/plat/psci.h"
+
+void plat_psci_cpu_suspend(uint32_t power_state)
+{
+	(void)power_state;
+}
+
+void plat_psci_cpu_resume(void)
+{
+}
diff --git a/src/arch/aarch64/smc/BUILD.gn b/src/arch/aarch64/plat/smc/BUILD.gn
similarity index 100%
rename from src/arch/aarch64/smc/BUILD.gn
rename to src/arch/aarch64/plat/smc/BUILD.gn
diff --git a/src/arch/aarch64/smc/absent.c b/src/arch/aarch64/plat/smc/absent.c
similarity index 100%
rename from src/arch/aarch64/smc/absent.c
rename to src/arch/aarch64/plat/smc/absent.c