and add a psci_version() routine. Signed-off-by: Ralf Ramsauer <[email protected]> --- inmates/lib/arm-common/include/asm/psci_generic.h | 42 +++++++++++++++++ inmates/lib/arm-common/include/psci.h | 39 ++++++++++++++++ inmates/lib/arm-common/psci.c | 8 ++++ inmates/lib/arm/include/asm/psci_call.h | 57 +++++++++++++++++++++++ inmates/lib/arm64/include/asm/psci_call.h | 56 ++++++++++++++++++++++ 5 files changed, 202 insertions(+) create mode 100644 inmates/lib/arm-common/include/asm/psci_generic.h create mode 100644 inmates/lib/arm-common/include/psci.h create mode 100644 inmates/lib/arm/include/asm/psci_call.h create mode 100644 inmates/lib/arm64/include/asm/psci_call.h
diff --git a/inmates/lib/arm-common/include/asm/psci_generic.h b/inmates/lib/arm-common/include/asm/psci_generic.h new file mode 100644 index 00000000..993d1fd2 --- /dev/null +++ b/inmates/lib/arm-common/include/asm/psci_generic.h @@ -0,0 +1,42 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2017 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define PSCI_VERSION 0x84000000 +#define PSCI_CPU_OFF 0x84000002 +#define PSCI_CPU_ON_32 0x84000003 +#define PSCI_CPU_ON_64 0xc4000003 diff --git a/inmates/lib/arm-common/include/psci.h b/inmates/lib/arm-common/include/psci.h new file mode 100644 index 00000000..a367beb4 --- /dev/null +++ b/inmates/lib/arm-common/include/psci.h @@ -0,0 +1,39 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2017 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +unsigned int psci_version(void); diff --git a/inmates/lib/arm-common/psci.c b/inmates/lib/arm-common/psci.c index 622200cc..3470bdf7 100644 --- a/inmates/lib/arm-common/psci.c +++ b/inmates/lib/arm-common/psci.c @@ -36,4 +36,12 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include <psci.h> +#include <asm/psci_call.h> + volatile unsigned int cpus_online; + +unsigned int psci_version(void) +{ + return (unsigned int)psci_call(PSCI_VERSION, 0, 0, 0); +} diff --git a/inmates/lib/arm/include/asm/psci_call.h b/inmates/lib/arm/include/asm/psci_call.h new file mode 100644 index 00000000..0cf6651d --- /dev/null +++ b/inmates/lib/arm/include/asm/psci_call.h @@ -0,0 +1,57 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2017 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <asm/psci_generic.h> + +static inline int psci_call(unsigned int function_id, unsigned int arg0, + unsigned int arg1, unsigned int arg2) +{ + register unsigned int __function_id asm("r0") = function_id; + register unsigned int __par1 asm("r1") = arg0; + register unsigned int __par2 asm("r2") = arg1; + register unsigned int __par3 asm("r3") = arg2; + + asm volatile( + ".arch_extension sec\n\t" + "smc #0\n\t" + : "=r" (__function_id) + : "r"(__function_id), "r"(__par1), "r"(__par2), "r"(__par3) + : "memory"); + + return __function_id; +} diff --git a/inmates/lib/arm64/include/asm/psci_call.h b/inmates/lib/arm64/include/asm/psci_call.h new file mode 100644 index 00000000..ae71da4c --- /dev/null +++ b/inmates/lib/arm64/include/asm/psci_call.h @@ -0,0 +1,56 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2017 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <asm/psci_generic.h> + +static inline int psci_call(unsigned long function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2) +{ + register unsigned long __function_id asm("r0") = function_id; + register unsigned long __par1 asm("x1") = arg0; + register unsigned long __par2 asm("x2") = arg1; + register unsigned long __par3 asm("x3") = arg2; + + asm volatile( + "smc #0\n\t" + : "=r" (__function_id) + : "r"(__function_id), "r"(__par1), "r"(__par2), "r"(__par3) + : "memory"); + + return __function_id; +} -- 2.14.1 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
