[PATCH 2/2] bsps/sparc: Add XtratuM BSP.
Gedare Bloom
gedare at rtems.org
Tue May 20 14:58:18 UTC 2014
On Tue, May 20, 2014 at 5:16 AM, Christian Mauderer
<christian.mauderer at embedded-brains.de> wrote:
> From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
>
> ---
> c/src/lib/libbsp/shared/include/fatal.h | 6 +-
> c/src/lib/libbsp/sparc/acinclude.m4 | 2 +
> c/src/lib/libbsp/sparc/shared/irq_asm.S | 97 ++++++++++++++++
> c/src/lib/libbsp/sparc/shared/start/start.S | 58 +++++++++-
> .../lib/libbsp/sparc/shared/startup/linkcmds.base | 19 ++++
> c/src/lib/libbsp/sparc/xtratum/Makefile.am | 119 ++++++++++++++++++++
> c/src/lib/libbsp/sparc/xtratum/README | 8 ++
> c/src/lib/libbsp/sparc/xtratum/bsp_specs | 17 +++
> .../sparc/xtratum/clock/clock-xtratum-exec.c | 23 ++++
> .../libbsp/sparc/xtratum/clock/clock-xtratum-hw.c | 21 ++++
> .../lib/libbsp/sparc/xtratum/clock/clock-xtratum.h | 103 +++++++++++++++++
> c/src/lib/libbsp/sparc/xtratum/configure.ac | 33 ++++++
> .../libbsp/sparc/xtratum/console/console-config.c | 27 +++++
> .../libbsp/sparc/xtratum/console/printk-support.c | 28 +++++
> .../sparc/xtratum/console/xtratum-hyper-console.c | 71 ++++++++++++
> c/src/lib/libbsp/sparc/xtratum/include/bsp.h | 52 +++++++++
> c/src/lib/libbsp/sparc/xtratum/include/cache_.h | 113 +++++++++++++++++++
> .../sparc/xtratum/include/clock-xtratum-exec.h | 26 +++++
> c/src/lib/libbsp/sparc/xtratum/include/irq.h | 2 +
> c/src/lib/libbsp/sparc/xtratum/include/tm27.h | 30 +++++
> .../sparc/xtratum/include/xtratum-hyper-console.h | 30 +++++
> c/src/lib/libbsp/sparc/xtratum/include/xtratum.h | 87 +++++++++++++++
> c/src/lib/libbsp/sparc/xtratum/irq/irq.c | 77 +++++++++++++
> .../libbsp/sparc/xtratum/make/custom/xtratum.cfg | 55 +++++++++
> c/src/lib/libbsp/sparc/xtratum/preinstall.am | 123 +++++++++++++++++++++
> .../libbsp/sparc/xtratum/startup/bsppredriver.c | 7 ++
> c/src/lib/libbsp/sparc/xtratum/startup/bspreset.c | 52 +++++++++
> c/src/lib/libbsp/sparc/xtratum/startup/bspsmp.c | 104 +++++++++++++++++
> c/src/lib/libbsp/sparc/xtratum/startup/bspstart.c | 22 ++++
> .../libbsp/sparc/xtratum/startup/example_xm_cf.xml | 66 +++++++++++
> .../lib/libbsp/sparc/xtratum/startup/isr-en-dis.S | 50 +++++++++
> .../libbsp/sparc/xtratum/startup/linkcmds.xtratum | 20 ++++
> c/src/lib/libbsp/sparc/xtratum/startup/psr.c | 26 +++++
> c/src/lib/libbsp/sparc/xtratum/startup/setvec.c | 61 ++++++++++
> c/src/lib/libbsp/sparc/xtratum/startup/spurious.c | 35 ++++++
> c/src/lib/libbsp/sparc/xtratum/startup/tbr.c | 30 +++++
> c/src/lib/libbsp/sparc/xtratum/xm/xmhdr.c | 36 ++++++
> cpukit/score/cpu/sparc/rtems/score/cpu.h | 11 +-
> testsuites/smptests/smpfatal08/init.c | 3 +-
> 39 files changed, 1735 insertions(+), 15 deletions(-)
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/Makefile.am
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/README
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/bsp_specs
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-exec.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-hw.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/configure.ac
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/console/console-config.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/console/printk-support.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/console/xtratum-hyper-console.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/bsp.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/cache_.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/clock-xtratum-exec.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/irq.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/tm27.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/xtratum-hyper-console.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/include/xtratum.h
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/irq/irq.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/make/custom/xtratum.cfg
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/preinstall.am
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/bsppredriver.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/bspreset.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/bspsmp.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/bspstart.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/example_xm_cf.xml
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/isr-en-dis.S
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/linkcmds.xtratum
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/psr.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/setvec.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/spurious.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/startup/tbr.c
> create mode 100644 c/src/lib/libbsp/sparc/xtratum/xm/xmhdr.c
>
> diff --git a/c/src/lib/libbsp/shared/include/fatal.h b/c/src/lib/libbsp/shared/include/fatal.h
> index e928bba..8ca90bb 100644
> --- a/c/src/lib/libbsp/shared/include/fatal.h
> +++ b/c/src/lib/libbsp/shared/include/fatal.h
> @@ -101,7 +101,11 @@ typedef enum {
> PPC_FATAL_EXCEPTION_INITIALIZATION = BSP_FATAL_CODE_BLOCK(7),
>
> /* Libchip fatal codes */
> - DWMAC_FATAL_TOO_MANY_RBUFS_CONFIGURED = BSP_FATAL_CODE_BLOCK(8)
> + DWMAC_FATAL_TOO_MANY_RBUFS_CONFIGURED = BSP_FATAL_CODE_BLOCK(8),
> +
> + /* XtratuM fatal codes */
> + XTRATUM_FATAL_CLOCK_IRQ_INSTALL = BSP_FATAL_CODE_BLOCK(9),
> + XTRATUM_FATAL_CPU_SMP_INITIALIZE
> } bsp_fatal_code;
>
> RTEMS_COMPILER_NO_RETURN_ATTRIBUTE static inline void
> diff --git a/c/src/lib/libbsp/sparc/acinclude.m4 b/c/src/lib/libbsp/sparc/acinclude.m4
> index 4d40305..0e053fa 100644
> --- a/c/src/lib/libbsp/sparc/acinclude.m4
> +++ b/c/src/lib/libbsp/sparc/acinclude.m4
> @@ -8,6 +8,8 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
> AC_CONFIG_SUBDIRS([leon2]);;
> leon3 )
> AC_CONFIG_SUBDIRS([leon3]);;
> + xtratum )
> + AC_CONFIG_SUBDIRS([xtratum]);;
> *)
> AC_MSG_ERROR([Invalid BSP]);;
> esac
> diff --git a/c/src/lib/libbsp/sparc/shared/irq_asm.S b/c/src/lib/libbsp/sparc/shared/irq_asm.S
> index bf2dca9..69522a2 100644
> --- a/c/src/lib/libbsp/sparc/shared/irq_asm.S
> +++ b/c/src/lib/libbsp/sparc/shared/irq_asm.S
> @@ -23,6 +23,10 @@
> #include <rtems/score/percpu.h>
> #include <bspopts.h>
>
> +#ifdef RTEMS_PARAVIRT_XTRATUM
> +#include <xm.h>
What is this header file? I don't see it in the commit, is it part of
the installed XtratuM?
> +#endif /* RTEMS_PARAVIRT_XTRATUM */
> +
> /*
> * void _CPU_Context_switch(
> * Context_Control *run,
> @@ -54,7 +58,15 @@ SYM(_CPU_Context_switch):
> ld [%g6 + SPARC_PER_CPU_ISR_DISPATCH_DISABLE], %o4
> ! save it a bit later so we do not waste a couple of cycles
>
> +#ifdef RTEMS_PARAVIRT_XTRATUM
> + mov %o0, %l6
> + mov sparc_get_psr_nr, %o0
> + __XM_AHC
I'm guessing these symbols are defined in xm.h?
> + mov %o0, %o2
> + mov %l6, %o0
> +#else /* RTEMS_PARAVIRT_XTRATUM */
> rd %psr, %o2
> +#endif /* RTEMS_PARAVIRT_XTRATUM */
It would be cleaner code if you can write this get_psr as an assembler
macro, e.g.
.macro GET_PSR REG, TMP0
#ifdef RTEMS_PARAVIRT_XTRATUM
mov %o0, \TMP
mov sparc_get_psr_nr, %o0
__XM_AHC
mov %o0, \REG
mov \TMP, %o0
#else
rd %psr, \REG
#endif
Same for some of the other functions that get used multiple times in
this file, such as set_psr, set_pil, and clear_pil. Putting these in a
header file would make them useful in start.S also.
[...]
> diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
> index 65dd559..158883a 100644
> --- a/c/src/lib/libbsp/sparc/shared/start/start.S
> +++ b/c/src/lib/libbsp/sparc/shared/start/start.S
[...]
> @@ -354,12 +397,19 @@ zerobss:
> bleu,a zerobss
> nop
>
> +#ifdef RTEMS_PARAVIRT_XTRATUM
> + mov %g7, %o0
> + call init_libxm ! initialize libxm
Where is this function?
> diff --git a/c/src/lib/libbsp/sparc/xtratum/include/irq.h b/c/src/lib/libbsp/sparc/xtratum/include/irq.h
> new file mode 100644
> index 0000000..afa99c0
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/include/irq.h
> @@ -0,0 +1,2 @@
> +#define BSP_INTERRUPT_VECTOR_MIN 0
> +#define BSP_INTERRUPT_VECTOR_MAX (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
> diff --git a/c/src/lib/libbsp/sparc/xtratum/include/tm27.h b/c/src/lib/libbsp/sparc/xtratum/include/tm27.h
> new file mode 100644
> index 0000000..85c4963
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/include/tm27.h
> @@ -0,0 +1,30 @@
> +/*
> + * tm27.h
> + *
> + * 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.
> + */
> +
> +#ifndef _RTEMS_TMTEST27
> +#error "This is an RTEMS internal file you must not include directly."
> +#endif
> +
> +#ifndef __tm27_h
> +#define __tm27_h
> +
> +#define TEST_VECTOR SPARC_SYNCHRONOUS_TRAP( 0x90 )
> +
> +#define MUST_WAIT_FOR_INTERRUPT 1
> +
> +#define Install_tm27_vector( handler ) \
> + set_vector( (handler), TEST_VECTOR, 1 );
> +
> +#define Cause_tm27_intr() \
> + __asm__ volatile( "ta 0x10; nop " );
> +
I guess this won't actually work?
> diff --git a/c/src/lib/libbsp/sparc/xtratum/irq/irq.c b/c/src/lib/libbsp/sparc/xtratum/irq/irq.c
> new file mode 100644
> index 0000000..c061f9c
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/irq/irq.c
> @@ -0,0 +1,77 @@
File needs copyright/license header.
> diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/bsppredriver.c b/c/src/lib/libbsp/sparc/xtratum/startup/bsppredriver.c
> new file mode 100644
> index 0000000..f99c528
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/startup/bsppredriver.c
> @@ -0,0 +1,7 @@
File needs copyright/license header, although I'm not sure why this
file is included anyway since the hook is empty.
> diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/bspreset.c b/c/src/lib/libbsp/sparc/xtratum/startup/bspreset.c
> new file mode 100644
> index 0000000..ec80be4
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/startup/bspreset.c
> @@ -0,0 +1,52 @@
> +/*
> + * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
> + *
> + * embedded brains GmbH
> + * Dornierstr. 4
> + * 82178 Puchheim
> + * Germany
> + * <info at embedded-brains.de>
> + *
> + * 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.
> + */
> +
> +#include <xm.h>
> +#include <bsp/bootcard.h>
> +
> +#ifdef RTEMS_SMP
> +void bsp_reset(void)
> +{
> + uint32_t self_cpu = rtems_get_current_processor();
> +
> + if (self_cpu == 0) {
> + /* Value should give us roughly something in the range of a few
> + * milliseconds. */
> + uint32_t max_wait = 1234567;
> + uint32_t cpu_count = rtems_get_processor_count();
> + uint32_t cpus_halted = 0;
> +
> + /* Wait some time for secondary processors to halt */
> + do {
> + xmVirtualCpuStatus_t status;
> + cpus_halted = 0;
> + uint32_t i;
> +
> + for (i=1; i<cpu_count; ++i) {
> + XM_get_vcpu_status(i, &status);
> + if (status.state == XM_STATUS_HALTED) {
> + ++cpus_halted;
> + }
> + }
> + --max_wait;
> + } while (cpus_halted < cpu_count - 1 && max_wait > 0);
> +
> + XM_halt_partition(XM_PARTITION_SELF);
> + } else {
> + XM_halt_vcpu(XM_VCPU_SELF);
> + }
> +
> + while (1);
> +}
> +#endif
What if it is not RTEMS_SMP?
> diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/spurious.c b/c/src/lib/libbsp/sparc/xtratum/startup/spurious.c
> new file mode 100644
> index 0000000..2d4428a
> --- /dev/null
> +++ b/c/src/lib/libbsp/sparc/xtratum/startup/spurious.c
> @@ -0,0 +1,35 @@
> +/*
> + * LEON Spurious Trap Handler
> + *
> + * This is just enough of a trap handler to let us know what
> + * the likely source of the trap was.
> + *
> + * Developed as part of the port of RTEMS to the LEON implementation
> + * of the SPARC by On-Line Applications Research Corporation (OAR)
> + * under contract to the European Space Agency (ESA).
> + *
> + * COPYRIGHT (c) 1995. European Space Agency.
> + *
> + * Modified for LEON3 BSP.
> + * COPYRIGHT (c) 2004.
> + * Gaisler Research.
> + *
> + * This terms of the RTEMS license apply to this file.
> + */
> +
> +#include <bsp.h>
> +#include <rtems/bspIo.h>
> +
> +void _BSP_Exception_frame_print( const CPU_Exception_frame *frame )
> +{
> + uint32_t trap;
> + uint32_t real_trap;
> + const CPU_Interrupt_frame *isf;
> +
> + trap = frame->trap;
> + real_trap = SPARC_REAL_TRAP_NUMBER(trap);
> + isf = frame->isf;
> +
> + printk( "Unexpected trap (0x%02x) at address 0x%08x\n", real_trap, isf->tpc);
> +}
> +
I don't think this code will get called ever?
> diff --git a/cpukit/score/cpu/sparc/rtems/score/cpu.h b/cpukit/score/cpu/sparc/rtems/score/cpu.h
> index 216fc59..18a8c96 100644
> --- a/cpukit/score/cpu/sparc/rtems/score/cpu.h
> +++ b/cpukit/score/cpu/sparc/rtems/score/cpu.h
> @@ -975,15 +975,8 @@ extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
> * actually provides. Currently, interrupt levels which do not
> * map onto the CPU in a straight fashion are undefined.
> */
> -#ifdef RTEMS_PARAVIRT
> - #define _CPU_ISR_Set_level( _newlevel ) \
> - _SPARC_ISR_Set_level( _newlevel << 8)
> -
> -void _SPARC_ISR_Set_level( uint32_t pil );
> -#else
> - #define _CPU_ISR_Set_level( _newlevel ) \
> - sparc_enable_interrupts( _newlevel << 8)
> -#endif
> +#define _CPU_ISR_Set_level( _newlevel ) \
> + sparc_enable_interrupts( _newlevel << 8)
>
> /**
> * @brief Obtain the current interrupt disable level.
I don't think this revert is intended?
More information about the devel
mailing list