xref: /kvm-unit-tests/lib/arm/psci.c (revision f0705d4ceb944a286e8d1b5a9645366a8db4cead)
1 /*
2  * PSCI API
3  * From arch/arm[64]/kernel/psci.c
4  *
5  * Copyright (C) 2015, Red Hat Inc, Andrew Jones <drjones@redhat.com>
6  *
7  * This work is licensed under the terms of the GNU LGPL, version 2.
8  */
9 #include <asm/psci.h>
10 
11 #define T PSCI_INVOKE_ARG_TYPE
12 __attribute__((noinline))
13 int psci_invoke(T function_id, T arg0, T arg1, T arg2)
14 {
15 	asm volatile(
16 		"hvc #0"
17 	: "+r" (function_id)
18 	: "r" (arg0), "r" (arg1), "r" (arg2));
19 	return function_id;
20 }
21 
22 int psci_cpu_on(unsigned long cpuid, unsigned long entry_point)
23 {
24 	return psci_invoke(PSCI_FN_CPU_ON, cpuid, entry_point, 0);
25 }
26 
27 void psci_sys_reset(void)
28 {
29 	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
30 }
31