Signed-off-by: Andrew Jones <drjo...@redhat.com>
---
 config/config-arm-common.mak |  1 +
 lib/arm/asm/psci.h           | 13 +++++++++++++
 lib/arm/psci.c               | 30 ++++++++++++++++++++++++++++++
 lib/arm64/asm/psci.h         | 13 +++++++++++++
 4 files changed, 57 insertions(+)
 create mode 100644 lib/arm/asm/psci.h
 create mode 100644 lib/arm/psci.c
 create mode 100644 lib/arm64/asm/psci.h

diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
index 94eac8967e234..13f5338a35a02 100644
--- a/config/config-arm-common.mak
+++ b/config/config-arm-common.mak
@@ -35,6 +35,7 @@ cflatobjs += lib/arm/io.o
 cflatobjs += lib/arm/setup.o
 cflatobjs += lib/arm/mmu.o
 cflatobjs += lib/arm/bitops.o
+cflatobjs += lib/arm/psci.o
 
 libeabi = lib/arm/libeabi.a
 eabiobjs = lib/arm/eabi_compat.o
diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
new file mode 100644
index 0000000000000..e2e66b47de480
--- /dev/null
+++ b/lib/arm/asm/psci.h
@@ -0,0 +1,13 @@
+#ifndef _ASMARM_PSCI_H_
+#define _ASMARM_PSCI_H_
+#include <libcflat.h>
+#include <asm/uapi-psci.h>
+
+#define PSCI_INVOKE_ARG_TYPE   u32
+#define PSCI_FN_CPU_ON         PSCI_0_2_FN_CPU_ON
+
+extern int psci_invoke(u32 function_id, u32 arg0, u32 arg1, u32 arg2);
+extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
+extern void psci_sys_reset(void);
+
+#endif /* _ASMARM_PSCI_H_ */
diff --git a/lib/arm/psci.c b/lib/arm/psci.c
new file mode 100644
index 0000000000000..027c4f66f1815
--- /dev/null
+++ b/lib/arm/psci.c
@@ -0,0 +1,30 @@
+/*
+ * PSCI API
+ * From arch/arm[64]/kernel/psci.c
+ *
+ * Copyright (C) 2015, Red Hat Inc, Andrew Jones <drjo...@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <asm/psci.h>
+
+#define T PSCI_INVOKE_ARG_TYPE
+__attribute__((noinline))
+int psci_invoke(T function_id, T arg0, T arg1, T arg2)
+{
+       asm volatile(
+               "hvc #0"
+       : "+r" (function_id)
+       : "r" (arg0), "r" (arg1), "r" (arg2));
+       return function_id;
+}
+
+int psci_cpu_on(unsigned long cpuid, unsigned long entry_point)
+{
+       return psci_invoke(PSCI_FN_CPU_ON, cpuid, entry_point, 0);
+}
+
+void psci_sys_reset(void)
+{
+       psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+}
diff --git a/lib/arm64/asm/psci.h b/lib/arm64/asm/psci.h
new file mode 100644
index 0000000000000..c481be4bd6bab
--- /dev/null
+++ b/lib/arm64/asm/psci.h
@@ -0,0 +1,13 @@
+#ifndef _ASMARM64_PSCI_H_
+#define _ASMARM64_PSCI_H_
+#include <libcflat.h>
+#include <asm/uapi-psci.h>
+
+#define PSCI_INVOKE_ARG_TYPE   u64
+#define PSCI_FN_CPU_ON         PSCI_0_2_FN64_CPU_ON
+
+extern int psci_invoke(u64 function_id, u64 arg0, u64 arg1, u64 arg2);
+extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
+extern void psci_sys_reset(void);
+
+#endif /* _ASMARM64_PSCI_H_ */
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to