Implement the Xen BSP for Xen on ARM. --- bsps/arm/xen/config/{no_bsp.cfg => xen.inc} | 7 +- bsps/arm/xen/config/xen_virtual.cfg | 1 + bsps/arm/xen/console/console.c | 260 ++++---------------- bsps/arm/xen/headers.am | 6 +- bsps/arm/xen/include/bsp.h | 77 ++++-- bsps/arm/xen/include/bsp/irq.h | 63 ++++- bsps/arm/xen/include/tm27.h | 39 ++- bsps/arm/xen/start/bsp_specs | 12 +- bsps/arm/xen/start/bspstart.c | 55 ++++- bsps/arm/xen/start/bspstarthooks.c | 44 ++++ bsps/arm/xen/start/bspstartmmu.c | 73 ++++++ bsps/arm/xen/start/linkcmds.in | 115 ++++----- c/src/lib/libbsp/arm/acinclude.m4 | 2 + c/src/lib/libbsp/arm/xen/Makefile.am | 42 ++-- c/src/lib/libbsp/arm/xen/configure.ac | 43 +++- 15 files changed, 503 insertions(+), 336 deletions(-) rename bsps/arm/xen/config/{no_bsp.cfg => xen.inc} (56%) create mode 100644 bsps/arm/xen/config/xen_virtual.cfg create mode 100644 bsps/arm/xen/start/bspstarthooks.c create mode 100644 bsps/arm/xen/start/bspstartmmu.c
diff --git a/bsps/arm/xen/config/no_bsp.cfg b/bsps/arm/xen/config/xen.inc similarity index 56% rename from bsps/arm/xen/config/no_bsp.cfg rename to bsps/arm/xen/config/xen.inc index 15e2f29bff..2ec17435a9 100644 --- a/bsps/arm/xen/config/no_bsp.cfg +++ b/bsps/arm/xen/config/xen.inc @@ -1,12 +1,13 @@ # -# Configuration file for the "no_bsp" board +# Configuration file for the "xen" board # include $(RTEMS_ROOT)/make/custom/default.cfg -RTEMS_CPU=no_cpu +RTEMS_CPU = arm + +CPU_CFLAGS = -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -# Miscellaneous additions go here. Typical options usually look like CFLAGS_OPTIMIZE_V += -O2 -g CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections diff --git a/bsps/arm/xen/config/xen_virtual.cfg b/bsps/arm/xen/config/xen_virtual.cfg new file mode 100644 index 0000000000..10b1db231e --- /dev/null +++ b/bsps/arm/xen/config/xen_virtual.cfg @@ -0,0 +1 @@ +include $(RTEMS_ROOT)/make/custom/xen.inc diff --git a/bsps/arm/xen/console/console.c b/bsps/arm/xen/console/console.c index 41c17c29ef..786b98f3ba 100644 --- a/bsps/arm/xen/console/console.c +++ b/bsps/arm/xen/console/console.c @@ -1,217 +1,63 @@ /* - * This file contains the template for a console IO package. - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#define NO_BSP_INIT + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> + * + * 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 OWNER 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 <rtems/bspIo.h> #include <bsp.h> -#include <rtems/libio.h> - -/* console_initialize - * - * This routine initializes the console IO driver. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: - */ - -rtems_device_driver console_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -) -{ - rtems_status_code status; - - status = rtems_io_register_name( - "/dev/console", - major, - (rtems_device_minor_number) 0 - ); - - if (status != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred(status); - - return RTEMS_SUCCESSFUL; -} - -/* is_character_ready - * - * This routine returns TRUE if a character is available. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: - */ - -bool is_character_ready( - char *ch -) -{ - *ch = '\0'; /* return NULL for no particular reason */ - return true; -} - -/* inbyte - * - * This routine reads a character from the SOURCE. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: - * character read from SOURCE - */ - -char inbyte( void ) -{ - /* - * If polling, wait until a character is available. - */ - - return '\0'; -} - -/* outbyte - * - * This routine transmits a character out the SOURCE. It may support - * XON/XOFF flow control. - * - * Input parameters: - * ch - character to be transmitted - * - * Output parameters: NONE - */ - -void outbyte( - char ch -) -{ - /* - * If polling, wait for the transmitter to be ready. - * Check for flow control requests and process. - * Then output the character. - */ - - /* - * Carriage Return/New line translation. - */ - - if ( ch == '\n' ) - outbyte( '\r' ); -} - -/* - * Open entry point - */ - -rtems_device_driver console_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - return RTEMS_SUCCESSFUL; -} - -/* - * Close entry point - */ - -rtems_device_driver console_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - return RTEMS_SUCCESSFUL; -} - -/* - * read bytes from the serial port. We only have stdin. - */ - -rtems_device_driver console_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - rtems_libio_rw_args_t *rw_args; - char *buffer; - int maximum; - int count = 0; - - rw_args = (rtems_libio_rw_args_t *) arg; - - buffer = rw_args->buffer; - maximum = rw_args->count; - - for (count = 0; count < maximum; count++) { - buffer[ count ] = inbyte(); - if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { - buffer[ count++ ] = '\n'; - break; - } +#include <bsp/arm-pl011.h> +#include <bsp/console-termios.h> +#include <bsp/irq-generic.h> + +#include <bspopts.h> + +arm_pl011_context xen_vpl011_context = { + .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"), + .regs = (volatile pl011 *) BSP_XEN_VPL011_BASE, + .irq = GUEST_VPL011_SPI, + .initial_baud = 115200 +}; + +const console_device console_device_table[] = { + { + .device_file = "/dev/ttyS0", + .probe = console_device_probe_default, + .handler = &arm_pl011_fns, + .context = &xen_vpl011_context.base } +}; - rw_args->bytes_moved = count; - return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; -} - -/* - * write bytes to the serial port. Stdout and stderr are the same. - */ +const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table); -rtems_device_driver console_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) +static void output_char( char c ) { - int count; - int maximum; - rtems_libio_rw_args_t *rw_args; - char *buffer; - - rw_args = (rtems_libio_rw_args_t *) arg; - - buffer = rw_args->buffer; - maximum = rw_args->count; - - for (count = 0; count < maximum; count++) { - if ( buffer[ count ] == '\n') { - outbyte('\r'); - } - outbyte( buffer[ count ] ); - } - - rw_args->bytes_moved = maximum; - return 0; + arm_pl011_write_polled(&xen_vpl011_context.base, c); } -/* - * IO Control entry point - */ +BSP_output_char_function_type BSP_output_char = output_char; -rtems_device_driver console_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -) -{ - return RTEMS_SUCCESSFUL; -} +BSP_polling_getchar_function_type BSP_poll_char = NULL; diff --git a/bsps/arm/xen/headers.am b/bsps/arm/xen/headers.am index fe2f157349..952fa37670 100644 --- a/bsps/arm/xen/headers.am +++ b/bsps/arm/xen/headers.am @@ -1,10 +1,10 @@ ## This file was generated by "./boostrap -H". include_HEADERS = -include_HEADERS += ../../../../../../bsps/no_cpu/no_bsp/include/bsp.h +include_HEADERS += ../../../../../../bsps/arm/xen/include/bsp.h include_HEADERS += include/bspopts.h -include_HEADERS += ../../../../../../bsps/no_cpu/no_bsp/include/tm27.h +include_HEADERS += ../../../../../../bsps/arm/xen/include/tm27.h include_bspdir = $(includedir)/bsp include_bsp_HEADERS = -include_bsp_HEADERS += ../../../../../../bsps/no_cpu/no_bsp/include/bsp/irq.h +include_bsp_HEADERS += ../../../../../../bsps/arm/xen/include/bsp/irq.h diff --git a/bsps/arm/xen/include/bsp.h b/bsps/arm/xen/include/bsp.h index 46a20fc831..e5b23a902e 100644 --- a/bsps/arm/xen/include/bsp.h +++ b/bsps/arm/xen/include/bsp.h @@ -1,57 +1,86 @@ /** * @file * - * @ingroup RTEMSBSPsNoCPUNoBsp + * @ingroup RTEMSBSPsARMxen * * @brief Global BSP definitions. */ -/* bsp.h +/* + * SPDX-License-Identifier: BSD-2-Clause * - * This include file contains all board IO definitions. + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> * - * XXX : put yours in here - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 OWNER 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 LIBBSP_NO_CPU_NO_BSP_BSP_H -#define LIBBSP_NO_CPU_NO_BSP_BSP_H +#ifndef LIBBSP_ARM_XEN_BSP_H +#define LIBBSP_ARM_XEN_BSP_H /** - * @addtogroup RTEMSBSPsNoCPU + * @addtogroup RTEMSBSPsARM * * @{ */ #include <bspopts.h> + +#define BSP_FEATURE_IRQ_EXTENSION + +#ifndef ASM + #include <bsp/default-initial-extension.h> +#include <bsp/start.h> #include <rtems.h> #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ -/* functions */ +#define BSP_ARM_GIC_CPUIF_BASE 0x03002000 +#define BSP_ARM_GIC_CPUIF_LENGTH 0x1000 -rtems_isr_entry set_vector( /* returns old vector */ - rtems_isr_entry handler, /* isr routine */ - rtems_vector_number vector, /* vector number */ - int type /* RTEMS or RAW intr */ -); +#define BSP_ARM_GIC_DIST_BASE 0x03001000 +#define BSP_ARM_GIC_DIST_LENGTH 0x1000 + +#define BSP_ARM_A9MPCORE_SCU_BASE 0 + +#define BSP_ARM_A9MPCORE_GT_BASE 0 + +#define BSP_XEN_VPL011_BASE 0x22000000 +#define BSP_XEN_VPL011_LENGTH 0x1000 + +void arm_generic_timer_get_config(uint32_t *frequency, uint32_t *irq); + +BSP_START_TEXT_SECTION void bsp_xen_setup_mmu_and_cache(void); #ifdef __cplusplus } -#endif +#endif /* __cplusplus */ + +#endif /* ASM */ /** @} */ -#endif +#endif /* LIBBSP_ARM_XEN_BSP_H */ diff --git a/bsps/arm/xen/include/bsp/irq.h b/bsps/arm/xen/include/bsp/irq.h index 8a97d7a1b0..dc09e52373 100644 --- a/bsps/arm/xen/include/bsp/irq.h +++ b/bsps/arm/xen/include/bsp/irq.h @@ -1 +1,62 @@ -#include <bsp/irq-default.h> +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> + * + * 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 OWNER 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 LIBBSP_ARM_XEN_IRQ_H +#define LIBBSP_ARM_XEN_IRQ_H + +#ifndef ASM + +#include <rtems/irq.h> +#include <rtems/irq-extension.h> + +#include <bsp/arm-gic-irq.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define BSP_INTERRUPT_VECTOR_MIN 0 +#define BSP_INTERRUPT_VECTOR_MAX 1023 + +/* Xen guest interrupts */ +#define GUEST_TIMER_VIRT_PPI 27 +#define GUEST_TIMER_PHYS_S_PPI 29 +#define GUEST_TIMER_PHYS_NS_PPI 30 +#define GUEST_EVTCHN_PPI 31 + +#define GUEST_VPL011_SPI 32 + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ASM */ + +#endif /* LIBBSP_ARM_XEN_IRQ_H */ diff --git a/bsps/arm/xen/include/tm27.h b/bsps/arm/xen/include/tm27.h index 0dfa7bf628..2fc4afa4f2 100644 --- a/bsps/arm/xen/include/tm27.h +++ b/bsps/arm/xen/include/tm27.h @@ -1 +1,38 @@ -#include <rtems/tm27-default.h> +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> + * + * 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 OWNER 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 _RTEMS_TMTEST27 +#error "This is an RTEMS internal file you must not include directly." +#endif + +#ifndef __tm27_h +#define __tm27_h + +#include <bsp/arm-gic-tm27.h> + +#endif /* __tm27_h */ diff --git a/bsps/arm/xen/start/bsp_specs b/bsps/arm/xen/start/bsp_specs index 140802f2c0..47dd31d46b 100644 --- a/bsps/arm/xen/start/bsp_specs +++ b/bsps/arm/xen/start/bsp_specs @@ -1,7 +1,9 @@ -%rename lib old_lib +%rename endfile old_endfile +%rename startfile old_startfile -*lib: -%{!qrtems: %(old_lib)} \ -%{!nostdlib: %{qrtems: --start-group -lrtemsbsp -lrtemscpu -lc -lgcc --end-group \ -%{!qnolinkcmds: -T linkcmds%s}}} +*startfile: +%{!qrtems: %(old_startfile)} \ +%{!nostdlib: %{qrtems: crti.o%s crtbegin.o%s}} +*endfile: +%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s} diff --git a/bsps/arm/xen/start/bspstart.c b/bsps/arm/xen/start/bspstart.c index b77b971ca1..6b826fc917 100644 --- a/bsps/arm/xen/start/bspstart.c +++ b/bsps/arm/xen/start/bspstart.c @@ -1,20 +1,48 @@ /* - * This routine starts the application. It includes application, - * board, and monitor specific initialization and configuration. - * The generic CPU dependent initialization has been performed - * before this routine is invoked. + * SPDX-License-Identifier: BSD-2-Clause * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/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 OWNER 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 <string.h> - #include <bsp.h> +#include <bsp/bootcard.h> +#include <bsp/irq-generic.h> +#include <bsp/linker-symbols.h> + +#include <libcpu/arm-cp15.h> + +void arm_generic_timer_get_config( uint32_t *frequency, uint32_t *irq ) +{ + *frequency = arm_cp15_get_counter_frequency(); + +#ifdef ARM_GENERIC_TIMER_USE_VIRTUAL + *irq = GUEST_TIMER_VIRT_PPI; +#else + *irq = GUEST_TIMER_PHYS_NS_PPI; +#endif +} /* * bsp_start @@ -24,4 +52,9 @@ void bsp_start( void ) { + bsp_interrupt_initialize(); + rtems_cache_coherent_add_area( + bsp_section_nocacheheap_begin, + (uintptr_t) bsp_section_nocacheheap_size + ); } diff --git a/bsps/arm/xen/start/bspstarthooks.c b/bsps/arm/xen/start/bspstarthooks.c new file mode 100644 index 0000000000..120535c60f --- /dev/null +++ b/bsps/arm/xen/start/bspstarthooks.c @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> + * + * 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 OWNER 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 <bsp.h> +#include <bsp/start.h> +#include <bsp/arm-a9mpcore-start.h> + +BSP_START_TEXT_SECTION void bsp_start_hook_0(void) +{ + /* Do nothing */ +} + +BSP_START_TEXT_SECTION void bsp_start_hook_1(void) +{ + arm_a9mpcore_start_set_vector_base(); + bsp_start_copy_sections(); + bsp_xen_setup_mmu_and_cache(); + bsp_start_clear_bss(); +} diff --git a/bsps/arm/xen/start/bspstartmmu.c b/bsps/arm/xen/start/bspstartmmu.c new file mode 100644 index 0000000000..b24af89d41 --- /dev/null +++ b/bsps/arm/xen/start/bspstartmmu.c @@ -0,0 +1,73 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> + * + * 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 OWNER 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 ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION + +#include <bsp.h> +#include <bsp/start.h> +#include <bsp/arm-cp15-start.h> +#include <bsp/arm-a9mpcore-start.h> + +BSP_START_DATA_SECTION static const arm_cp15_start_section_config +xen_bsp_mmu_config_table[] = { + ARMV7_CP15_START_DEFAULT_SECTIONS, + { + .begin = BSP_ARM_GIC_DIST_BASE, + .end = BSP_ARM_GIC_DIST_BASE + BSP_ARM_GIC_DIST_LENGTH, + .flags = ARMV7_MMU_DEVICE + }, { + .begin = BSP_ARM_GIC_CPUIF_BASE, + .end = BSP_ARM_GIC_CPUIF_BASE + BSP_ARM_GIC_CPUIF_LENGTH, + .flags = ARMV7_MMU_DEVICE + }, { + .begin = BSP_XEN_VPL011_BASE, + .end = BSP_XEN_VPL011_BASE + BSP_XEN_VPL011_LENGTH, + .flags = ARMV7_MMU_DEVICE + } +}; + +/* + * Make weak and let the user override. + */ +BSP_START_TEXT_SECTION void bsp_xen_setup_mmu_and_cache(void) __attribute__ ((weak)); + +BSP_START_TEXT_SECTION void bsp_xen_setup_mmu_and_cache(void) +{ + uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache( + ARM_CP15_CTRL_TRE | ARM_CP15_CTRL_A, + ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z + ); + + arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache( + ctrl, + (uint32_t *) bsp_translation_table_base, + ARM_MMU_DEFAULT_CLIENT_DOMAIN, + &xen_bsp_mmu_config_table[0], + RTEMS_ARRAY_SIZE(xen_bsp_mmu_config_table) + ); +} diff --git a/bsps/arm/xen/start/linkcmds.in b/bsps/arm/xen/start/linkcmds.in index 6f2fda7b41..944687679b 100644 --- a/bsps/arm/xen/start/linkcmds.in +++ b/bsps/arm/xen/start/linkcmds.in @@ -1,71 +1,62 @@ /* - * This file contains directives for the GNU linker which are specific - * to the NO_CPU NO_BSP BOARD. + * SPDX-License-Identifier: BSD-2-Clause * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2019 DornerWorks + * Written by Jeff Kubascik <jeff.kubas...@dornerworks.com> * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/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 OWNER 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. */ -MEMORY - { - ram : org = 0x0, l = 1M - } +MEMORY { + RAM_MMU : ORIGIN = @GUEST_RAM_BASE@, LENGTH = @GUEST_RAM_MMU_LENGTH@ + RAM : ORIGIN = @GUEST_RAM_BASE@ + @GUEST_LOAD_OFFSET@, LENGTH = @GUEST_RAM_LENGTH@ - @GUEST_LOAD_OFFSET@ - @GUEST_RAM_NOCACHE_LENGTH@ + NOCACHE : ORIGIN = @GUEST_RAM_BASE@ + @GUEST_RAM_LENGTH@ - @GUEST_RAM_NOCACHE_LENGTH@, LENGTH = @GUEST_RAM_NOCACHE_LENGTH@ +} -SECTIONS -{ - .text 0x0 : - { - text_start = . ; - _text_start = . ; - *(.text) - . = ALIGN (16); +REGION_ALIAS ("REGION_START", RAM); +REGION_ALIAS ("REGION_VECTOR", RAM); +REGION_ALIAS ("REGION_TEXT", RAM); +REGION_ALIAS ("REGION_TEXT_LOAD", RAM); +REGION_ALIAS ("REGION_RODATA", RAM); +REGION_ALIAS ("REGION_RODATA_LOAD", RAM); +REGION_ALIAS ("REGION_DATA", RAM); +REGION_ALIAS ("REGION_DATA_LOAD", RAM); +REGION_ALIAS ("REGION_FAST_TEXT", RAM); +REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM); +REGION_ALIAS ("REGION_FAST_DATA", RAM); +REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM); +REGION_ALIAS ("REGION_BSS", RAM); +REGION_ALIAS ("REGION_WORK", RAM); +REGION_ALIAS ("REGION_STACK", RAM); +REGION_ALIAS ("REGION_NOCACHE", NOCACHE); +REGION_ALIAS ("REGION_NOCACHE_LOAD", NOCACHE); - /* - * Special FreeBSD sysctl sections. - */ - . = ALIGN (16); - __start_set_sysctl_set = .; - *(set_sysctl_*); - __stop_set_sysctl_set = ABSOLUTE(.); - *(set_domain_*); - *(set_pseudo_*); +bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024; - *(.eh_fram) - . = ALIGN (16); +bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1M; - /* - * C++ constructors - */ - __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) - *(.ctors) - LONG(0) - __CTOR_END__ = .; - __DTOR_LIST__ = .; - LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) - *(.dtors) - LONG(0) - __DTOR_END__ = .; - _etext = ALIGN( 0x10 ) ; - } - .data ADDR( .text ) + SIZEOF( .text ): - { - data_start = . ; - _data_start = . ; - *(.data) - _edata = ALIGN( 0x10 ) ; - } - .bss ADDR( .data ) + SIZEOF( .data ): - { - bss_start = . ; - _bss_start = . ; - *(.bss) - *(COMMON) - end = . ; - __end = . ; - } -} +bsp_vector_table_in_start_section = 1; + +bsp_translation_table_base = ORIGIN (RAM_MMU); +bsp_translation_table_end = ORIGIN (RAM_MMU) + LENGTH (RAM_MMU); + +INCLUDE linkcmds.armv4 diff --git a/c/src/lib/libbsp/arm/acinclude.m4 b/c/src/lib/libbsp/arm/acinclude.m4 index 04557a6d69..4d50477eb3 100644 --- a/c/src/lib/libbsp/arm/acinclude.m4 +++ b/c/src/lib/libbsp/arm/acinclude.m4 @@ -40,6 +40,8 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR], AC_CONFIG_SUBDIRS([stm32f4]);; tms570 ) AC_CONFIG_SUBDIRS([tms570]);; + xen ) + AC_CONFIG_SUBDIRS([xen]);; xilinx-zynq ) AC_CONFIG_SUBDIRS([xilinx-zynq]);; xilinx-zynqmp ) diff --git a/c/src/lib/libbsp/arm/xen/Makefile.am b/c/src/lib/libbsp/arm/xen/Makefile.am index 9f9b6426bd..fecb665af4 100644 --- a/c/src/lib/libbsp/arm/xen/Makefile.am +++ b/c/src/lib/libbsp/arm/xen/Makefile.am @@ -3,11 +3,15 @@ ACLOCAL_AMFLAGS = -I ../../../../aclocal include $(top_srcdir)/../../../../automake/compile.am include $(top_srcdir)/../../bsp.am -dist_project_lib_DATA = ../../../../../../bsps/no_cpu/no_bsp/start/bsp_specs +dist_project_lib_DATA = ../../../../../../bsps/arm/xen/start/bsp_specs noinst_PROGRAMS = -project_lib_DATA = linkcmds +start.$(OBJEXT): ../../../../../../bsps/arm/shared/start/start.S + $(CPPASCOMPILE) -o $@ -c $< +project_lib_DATA = start.$(OBJEXT) + +project_lib_DATA += linkcmds project_lib_LIBRARIES = librtemsbsp.a librtemsbsp_a_SOURCES = @@ -15,24 +19,30 @@ librtemsbsp_a_SOURCES = # startup librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspfatal-default.c librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-default.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/start/bspstart.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/xen/start/bspstart.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/xen/start/bspstarthooks.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/xen/start/bspstartmmu.c librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/getentropy/getentropy-cpucounter.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/start/setvec.c librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspreset-empty.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/start/bsp-start-memcpy.S +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/cp15/arm-cp15-set-exception-handler.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c # clock -librtemsbsp_a_SOURCES +=../../../../../../bsps/no_cpu/no_bsp/clock/ckinit.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/clock/clock-generic-timer.c +# cache +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/cache/cache-cp15.c +# irq +librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/irq/irq-gic.c # console -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/console/console.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/xen/console/console.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/console-termios.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/console-termios-init.c +librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/shared/serial/arm-pl011.c # timer -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/btimer/btimer.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/btimer/timerisr.c -# shmsupp -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/mpci/addrconv.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/mpci/getcfg.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/mpci/lock.c -librtemsbsp_a_SOURCES += ../../../../../../bsps/no_cpu/no_bsp/mpci/mpisr.c - -include $(srcdir)/../../../../../../bsps/shared/irq-default-sources.am +librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/btimer/btimer-stub.c + +include $(srcdir)/../../../../../../bsps/shared/irq-sources.am include $(srcdir)/../../../../../../bsps/shared/shared-sources.am -include $(srcdir)/../../../../../../bsps/no_cpu/no_bsp/headers.am +include $(srcdir)/../../../../../../bsps/arm/xen/headers.am diff --git a/c/src/lib/libbsp/arm/xen/configure.ac b/c/src/lib/libbsp/arm/xen/configure.ac index 3e54ec9f34..1e887df8fc 100644 --- a/c/src/lib/libbsp/arm/xen/configure.ac +++ b/c/src/lib/libbsp/arm/xen/configure.ac @@ -1,19 +1,56 @@ ## Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([rtems-c-src-lib-libbsp-no_cpu-no_bsp],[_RTEMS_VERSION],[https://devel.rtems.org/newticket]) +AC_INIT([rtems-c-src-lib-libbsp-arm-xen],[_RTEMS_VERSION],[https://devel.rtems.org/newticket]) RTEMS_TOP(../../../../../..) RTEMS_SOURCE_TOP RTEMS_BUILD_TOP -RTEMS_BSP_LINKCMDS RTEMS_CANONICAL_TARGET_CPU AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2]) RTEMS_BSP_CONFIGURE + +RTEMS_BSPOPTS_SET([BSP_DATA_CACHE_ENABLED],[*qemu],[]) +RTEMS_BSPOPTS_SET([BSP_DATA_CACHE_ENABLED],[*],[1]) +RTEMS_BSPOPTS_HELP([BSP_DATA_CACHE_ENABLED],[enable data cache]) + +RTEMS_BSPOPTS_SET([BSP_INSTRUCTION_CACHE_ENABLED],[*qemu],[]) +RTEMS_BSPOPTS_SET([BSP_INSTRUCTION_CACHE_ENABLED],[*],[1]) +RTEMS_BSPOPTS_HELP([BSP_INSTRUCTION_CACHE_ENABLED],[enable instruction cache]) + +RTEMS_BSPOPTS_SET([ARM_GENERIC_TIMER_USE_VIRTUAL],[*],[1]) +RTEMS_BSPOPTS_HELP([ARM_GENERIC_TIMER_USE_VIRTUAL],[Use virtual ARM generic timer]) + +RTEMS_BSPOPTS_SET([BSP_START_ZIMAGE_HEADER],[*],[1]) +RTEMS_BSPOPTS_HELP([BSP_START_ZIMAGE_HEADER],[include zImage boot header]) + +RTEMS_BSPOPTS_SET([BSP_XEN_RAM_LENGTH],[*],[8M]) +RTEMS_BSPOPTS_HELP([BSP_XEN_RAM_LENGTH],[override a BSP's default RAM length]) + +RTEMS_BSPOPTS_SET([BSP_XEN_NOCACHE_LENGTH],[*],[1M]) +RTEMS_BSPOPTS_HELP([BSP_XEN_NOCACHE_LENGTH],[length of nocache RAM region]) + +GUEST_RAM_BASE="0x40000000" +GUEST_LOAD_OFFSET="0x8000" +GUEST_RAM_MMU_LENGTH="16k" + +AC_DEFUN([XEN_LINKCMD],[ +AC_ARG_VAR([$1],[$2; default $3])dnl +[$1]=[$]{[$1]:-[$3]} +]) + +XEN_LINKCMD([GUEST_RAM_BASE],[normal RAM region origin],[${GUEST_RAM_BASE}]) +XEN_LINKCMD([GUEST_RAM_LENGTH],[normal RAM region length],[${BSP_XEN_RAM_LENGTH}]) +XEN_LINKCMD([GUEST_LOAD_OFFSET],[entry point of guest],[${GUEST_LOAD_OFFSET}]) +XEN_LINKCMD([GUEST_RAM_MMU_LENGTH],[MMU region length],[${GUEST_RAM_MMU_LENGTH}]) +XEN_LINKCMD([GUEST_RAM_NOCACHE_LENGTH],[length of nocache RAM region],[${BSP_XEN_NOCACHE_LENGTH}]) + RTEMS_BSP_CLEANUP_OPTIONS # Explicitly list all Makefiles here -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([ +Makefile +linkcmds:../../../../../../bsps/arm/xen/start/linkcmds.in]) AC_OUTPUT -- 2.17.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel