diff options
Diffstat (limited to 'sys/arm/qemu')
-rw-r--r-- | sys/arm/qemu/files.qemu | 6 | ||||
-rw-r--r-- | sys/arm/qemu/std.virt | 9 | ||||
-rw-r--r-- | sys/arm/qemu/virt_machdep.c | 81 | ||||
-rw-r--r-- | sys/arm/qemu/virt_mp.c | 71 | ||||
-rw-r--r-- | sys/arm/qemu/virt_mp.h | 33 |
5 files changed, 200 insertions, 0 deletions
diff --git a/sys/arm/qemu/files.qemu b/sys/arm/qemu/files.qemu new file mode 100644 index 000000000000..8db5abb8568f --- /dev/null +++ b/sys/arm/qemu/files.qemu @@ -0,0 +1,6 @@ + +# +# Standard qemu virt devices and support. +# +arm/qemu/virt_machdep.c standard +arm/qemu/virt_mp.c optional smp diff --git a/sys/arm/qemu/std.virt b/sys/arm/qemu/std.virt new file mode 100644 index 000000000000..9f0ae0f8e3a5 --- /dev/null +++ b/sys/arm/qemu/std.virt @@ -0,0 +1,9 @@ +machine arm armv7 +cpu CPU_CORTEXA +makeoptions CONF_CFLAGS="-march=armv7a" + +options KERNVIRTADDR = 0xc1000000 +makeoptions KERNVIRTADDR = 0xc1000000 + +files "../qemu/files.qemu" + diff --git a/sys/arm/qemu/virt_machdep.c b/sys/arm/qemu/virt_machdep.c new file mode 100644 index 000000000000..72f426084e17 --- /dev/null +++ b/sys/arm/qemu/virt_machdep.c @@ -0,0 +1,81 @@ +/*- + * Copyright (c) 2015 Andrew Turner + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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 "opt_platform.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/devmap.h> + +#include <vm/vm.h> + +#include <machine/bus.h> +#include <machine/platform.h> +#include <machine/platformvar.h> + +#include <arm/qemu/virt_mp.h> + +#include "platform_if.h" + +/* + * Set up static device mappings. + */ +static int +virt_devmap_init(platform_t plat) +{ + + devmap_add_entry(0x09000000, 0x100000); /* Uart */ + return (0); +} + +static platform_method_t virt_methods[] = { + PLATFORMMETHOD(platform_devmap_init, virt_devmap_init), + +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, virt_mp_start_ap), +#endif + + PLATFORMMETHOD_END, +}; + +FDT_PLATFORM_DEF(virt, "virt", 0, "linux,dummy-virt", 1); + +static int +gem5_devmap_init(platform_t plat) +{ + + devmap_add_entry(0x1c090000, 0x100000); /* Uart */ + return (0); +} + +static platform_method_t gem5_methods[] = { + PLATFORMMETHOD(platform_devmap_init, gem5_devmap_init), + + PLATFORMMETHOD_END, +}; + +FDT_PLATFORM_DEF(gem5, "gem5", 0, "arm,vexpress", 1); diff --git a/sys/arm/qemu/virt_mp.c b/sys/arm/qemu/virt_mp.c new file mode 100644 index 000000000000..a3471b1eb764 --- /dev/null +++ b/sys/arm/qemu/virt_mp.c @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2015 Andrew Turner + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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 <sys/param.h> +#include <sys/systm.h> +#include <sys/bus.h> +#include <sys/pcpu.h> +#include <sys/smp.h> + +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <machine/intr.h> +#include <machine/platformvar.h> +#include <machine/smp.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_cpu.h> +#include <dev/psci/psci.h> + +#include <arm/qemu/virt_mp.h> + +static int running_cpus; + +static bool +virt_start_ap(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg) +{ + int err; + + if (running_cpus >= mp_ncpus) + return (false); + running_cpus++; + + err = psci_cpu_on(*reg, pmap_kextract((vm_offset_t)mpentry), id); + + if (err != PSCI_RETVAL_SUCCESS) + return (false); + + return (true); +} + +void +virt_mp_start_ap(platform_t plat) +{ + + ofw_cpu_early_foreach(virt_start_ap, true); +} diff --git a/sys/arm/qemu/virt_mp.h b/sys/arm/qemu/virt_mp.h new file mode 100644 index 000000000000..f8d42897ebbd --- /dev/null +++ b/sys/arm/qemu/virt_mp.h @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2016 Andrew Turner + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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. + */ + +#ifndef _QEMU_VIRT_MP_H_ +#define _QEMU_VIRT_MP_H_ + +void virt_mp_start_ap(platform_t plat); +void virt_mp_setmaxid(platform_t plat); + +#endif /* _QEMU_VIRT_MP_H_ */ |