[PATCH 2/2] bsps/sparc: Add XtratuM BSP.
Christian Mauderer
christian.mauderer at embedded-brains.de
Tue May 20 09:16:01 UTC 2014
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>
+#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
+ mov %o0, %o2
+ mov %l6, %o0
+#else /* RTEMS_PARAVIRT_XTRATUM */
rd %psr, %o2
+#endif /* RTEMS_PARAVIRT_XTRATUM */
st %o2, [%o0 + PSR_OFFSET] ! save status register
! Now actually save ISR stack nesting prevention flag
@@ -110,6 +122,23 @@ SYM(_CPU_Context_restore_heir):
! g1 = psr w/o cwp
andn %g1, SPARC_PSR_ET_MASK | SPARC_PSR_CWP_MASK, %g1
or %g1, %g3, %g1 ! g1 = heirs psr
+
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov %o0, %g2
+
+ mov %o1, %g5
+ mov sparc_flush_regwin_nr, %o0
+ __XM_AHC
+
+ or %g1, SPARC_PSR_ET_MASK, %g1
+ mov sparc_set_psr_nr, %o0
+ mov %g1, %o1
+ __XM_AHC
+
+ mov %g2, %o0
+ mov %g5, %o1
+
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov %g1, %psr ! restore status register and
! **** DISABLE TRAPS ****
mov %wim, %g2 ! g2 = wim
@@ -163,6 +192,8 @@ done_flushing:
nop
nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
+
#if defined(RTEMS_SMP)
! The executing context no longer executes on this processor
stb %g0, [%o0 + SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
@@ -216,7 +247,14 @@ done_flushing:
PUBLIC(_CPU_Context_restore)
SYM(_CPU_Context_restore):
save %sp, -CPU_MINIMUM_STACK_FRAME_SIZE, %sp
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_get_psr_nr, %o0
+ __XM_AHC
+ mov %o0, %o2
+#else /* RTEMS_PARAVIRT_XTRATUM */
rd %psr, %o2
+#endif /* RTEMS_PARAVIRT_XTRATUM */
+
#if defined(RTEMS_SMP)
! On SPARC the restore path needs also a valid executing context on SMP
! to update the is executing indicator.
@@ -268,6 +306,7 @@ win_ovflow:
mov %g4, %l4 ! save the globals this block uses
mov %g5, %l5
+#ifndef RTEMS_PARAVIRT_XTRATUM
/*
* When at a "window overflow" trap, (wim == (1 << cwp)).
* If we get here like that, then process a window overflow.
@@ -324,6 +363,7 @@ win_ovflow:
restore
nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
dont_do_the_window:
/*
@@ -432,7 +472,14 @@ dont_switch_stacks:
dont_fix_pil:
or %g5, SPARC_PSR_PIL_MASK, %g5
pil_fixed:
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_set_psr_nr, %o0
+ mov %g5, %o1
+ or %o1, SPARC_PSR_ET_MASK, %o1
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
wr %g5, SPARC_PSR_ET_MASK, %psr ! **** ENABLE TRAPS ****
+#endif /* RTEMS_PARAVIRT_XTRATUM */
dont_fix_pil2:
/*
@@ -476,8 +523,14 @@ profiling_not_outer_most_exit:
* NOTE: %l0 has the PSR which was in place when we took the trap.
*/
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_set_psr_nr, %o0
+ mov %l0, %o1
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov %l0, %psr ! **** DISABLE TRAPS ****
nop; nop; nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
/*
* Decrement ISR nest level and Thread dispatch disable level.
@@ -538,10 +591,16 @@ profiling_not_outer_most_exit:
sub %fp, CPU_MINIMUM_STACK_FRAME_SIZE, %sp
or %l0, SPARC_PSR_ET_MASK, %l7 ! l7 = PSR with ET=1
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_set_psr_nr, %o0
+ mov %l7, %o1
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov %l7, %psr ! **** ENABLE TRAPS ****
nop
nop
nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
isr_dispatch:
call SYM(_Thread_Dispatch), 0
nop
@@ -554,8 +613,15 @@ isr_dispatch:
* with the register windowing. In particular, the CWP in the PSR
* is fragile during this period. (See PR578.)
*/
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov %o0, %g1
+ set sparc_set_pil_nr, %o0
+ __XM_AHC
+ mov %g1, %o0
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov 2,%g1 ! syscall (disable interrupts)
ta 0 ! syscall (disable interrupts)
+#endif /* RTEMS_PARAVIRT_XTRATUM */
/*
* While we had ISR dispatching disabled in this thread,
@@ -571,8 +637,15 @@ isr_dispatch:
! Yes, then invoke the dispatcher
dispatchAgain:
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov %o0, %g1
+ set sparc_clear_pil_nr, %o0
+ __XM_AHC
+ mov %g1, %o0
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov 3,%g1 ! syscall (enable interrupts)
ta 0 ! syscall (enable interrupts)
+#endif /* RTEMS_PARAVIRT_XTRATUM */
ba isr_dispatch
nop
@@ -596,12 +669,23 @@ simple_return:
ldd [%fp + ISF_PSR_OFFSET], %l0 ! restore psr, PC
ld [%fp + ISF_NPC_OFFSET], %l2 ! restore nPC
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_get_psr_nr, %o0
+ __XM_AHC
+ mov %o0, %l3
+#else /* RTEMS_PARAVIRT_XTRATUM */
rd %psr, %l3
+#endif /* RTEMS_PARAVIRT_XTRATUM */
and %l3, SPARC_PSR_CWP_MASK, %l3 ! want "current" CWP
andn %l0, SPARC_PSR_CWP_MASK, %l0 ! want rest from task
or %l3, %l0, %l0 ! install it later...
andn %l0, SPARC_PSR_ET_MASK, %l0
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_ctrl_winflow_nr, %o0
+ __XM_AHC
+#endif /* RTEMS_PARAVIRT_XTRATUM */
+
/*
* Restore tasks global and out registers
*/
@@ -618,6 +702,7 @@ simple_return:
ldd [%fp + ISF_I4_OFFSET], %i4 ! restore i4, i5
ldd [%fp + ISF_I6_FP_OFFSET], %i6 ! restore i6/fp, i7
+#ifndef RTEMS_PARAVIRT_XTRATUM
/*
* Registers:
*
@@ -680,14 +765,26 @@ simple_return:
ldd [%g1 + CPU_STACK_FRAME_I6_FP_OFFSET], %i6
! reload of sp clobbers ISF
save ! Back to ISR dispatch window
+#endif /* RTEMS_PARAVIRT_XTRATUM */
good_task_window:
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov %l0, %o1
+ mov sparc_set_psr_nr, %o0
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
mov %l0, %psr ! **** DISABLE TRAPS ****
nop; nop; nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
! and restore condition codes.
ld [%g1 + ISF_G1_OFFSET], %g1 ! restore g1
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov sparc_iret_nr, %o0
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
jmp %l1 ! transfer control and
rett %l2 ! go back to tasks window
+#endif /* RTEMS_PARAVIRT_XTRATUM */
/* end of file */
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
@@ -19,8 +19,13 @@
#include <rtems/score/percpu.h>
#include <bspopts.h>
-#if defined(RTEMS_SMP) && defined(BSP_LEON3_SMP)
- #define START_LEON3_ENABLE_SMP
+#ifdef RTEMS_PARAVIRT_XTRATUM
+#include <xm.h>
+#endif
+
+#if defined(RTEMS_SMP) && \
+ (defined(BSP_LEON3_SMP) || defined(RTEMS_PARAVIRT_XTRATUM))
+ #define START_ON_SECONDARY_PROCESSOR
#endif
/*
@@ -63,8 +68,13 @@ SYM(trap_table):
BAD_TRAP; ! 02 illegal instruction
BAD_TRAP; ! 03 privileged instruction
BAD_TRAP; ! 04 fp disabled
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ BAD_TRAP; ! 05 window overflow
+ BAD_TRAP; ! 06 window underflow
+#else /* RTEMS_PARAVIRT_XTRATUM */
TRAP( 5, SYM(window_overflow_trap_handler) ); ! 05 window overflow
TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
+#endif /* RTEMS_PARAVIRT_XTRATUM */
BAD_TRAP; ! 07 memory address not aligned
BAD_TRAP; ! 08 fp exception
BAD_TRAP; ! 09 data access exception
@@ -156,9 +166,17 @@ SYM(CLOCK_SPEED):
* installed before.
*/
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ SOFT_TRAP;
+#else /* RTEMS_PARAVIRT_XTRATUM */
TRAP( 0x80, SYM(syscall) ); ! 80 syscall SW trap
+#endif /* RTEMS_PARAVIRT_XTRATUM */
SOFT_TRAP; SOFT_TRAP; ! 81 - 82
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ SOFT_TRAP;
+#else /* RTEMS_PARAVIRT_XTRATUM */
TRAP( 0x83, SYM(window_flush_trap_handler) ); ! 83 flush windows SW trap
+#endif /* RTEMS_PARAVIRT_XTRATUM */
SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 84 - 87
SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 88 - 8B
@@ -205,6 +223,25 @@ SYM(hard_reset):
/* Common initialisation */
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ /* Set up a valid stack */
+ set SYM(_RAM_START), %l1
+ set SYM(_RAM_SIZE), %l2
+ add %l1, %l2, %sp
+ mov %g1, %g7
+
+ /* Initialize TBR */
+ set sparc_write_tbr_nr, %o0
+ set trap_table, %o1
+ __XM_HC
+
+ /* Enable traps */
+ mov sparc_get_psr_nr, %o0
+ __XM_AHC
+ or %o0, SPARC_PSR_ET_MASK, %o1
+ mov sparc_set_psr_nr, %o0
+ __XM_AHC
+#else /* RTEMS_PARAVIRT_XTRATUM */
set SYM(trap_table), %g1 ! Initialize TBR
mov %g1, %tbr
@@ -221,13 +258,19 @@ SYM(hard_reset):
nop
nop
nop
+#endif /* RTEMS_PARAVIRT_XTRATUM */
sethi %hi(_Per_CPU_Information), %g6 ! get per-CPU control
add %g6, %lo(_Per_CPU_Information), %g6
-#if defined(START_LEON3_ENABLE_SMP)
+#if defined(START_ON_SECONDARY_PROCESSOR)
+#if defined(RTEMS_PARAVIRT_XTRATUM)
+ set get_vcpuid_nr, %o0 ! get virtual CPU identifier
+ __XM_HC
+#else
rd %asr17, %o0 ! get CPU identifier
srl %o0, LEON3_ASR17_PROCESSOR_INDEX_SHIFT, %o0
+#endif
cmp %o0, 0
beq cpu0
@@ -354,12 +397,19 @@ zerobss:
bleu,a zerobss
nop
+#ifdef RTEMS_PARAVIRT_XTRATUM
+ mov %g7, %o0
+ call init_libxm ! initialize libxm
+ sub %sp, 0x60, %sp
+ add %sp, 0x60, %sp
+#endif /* RTEMS_PARAVIRT_XTRATUM */
+
mov %0, %o0 ! command line
call SYM(boot_card)
sub %sp, 0x60, %sp ! room for boot_card to save args
nop
-#if !defined(START_LEON3_ENABLE_SMP)
+#if !defined(START_ON_SECONDARY_PROCESSOR)
PUBLIC(BSP_fatal_return)
PUBLIC(bsp_reset)
SYM(BSP_fatal_return):
diff --git a/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base b/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base
index 1df9f14..be09012 100644
--- a/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base
+++ b/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base
@@ -106,6 +106,15 @@ SECTIONS
*(.shdata)
. = ALIGN (16);
} > ram
+
+ /*
+ * Special section for XtratuM hypervisor. It must have exactly this name and
+ * content.
+ */
+ .xmImageHdr : {
+ KEEP (*(.xmImageHdr))
+ } > ram
+
.tdata : {
_TLS_Data_begin = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
@@ -178,6 +187,16 @@ SECTIONS
{
*(.shbss)
} > ram
+
+ /*
+ * Special section for read-write data which will be not zero initialized by
+ * the BSS loop.
+ */
+ .rwextra :
+ {
+ *(.bsp_rwextra)
+ } > ram
+
.bss :
{
__bss_start = ALIGN(0x8);
diff --git a/c/src/lib/libbsp/sparc/xtratum/Makefile.am b/c/src/lib/libbsp/sparc/xtratum/Makefile.am
new file mode 100644
index 0000000..e4934d8
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/Makefile.am
@@ -0,0 +1,119 @@
+ACLOCAL_AMFLAGS = -I ../../../../aclocal
+
+include $(top_srcdir)/../../../../automake/compile.am
+
+include_bspdir = $(includedir)/bsp
+
+dist_project_lib_DATA = bsp_specs
+
+include_HEADERS = include/bsp.h
+include_HEADERS += include/tm27.h
+include_HEADERS += ../../sparc/shared/include/debug_defs.h
+
+include_bsp_HEADERS =
+
+nodist_include_HEADERS = include/bspopts.h
+nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
+DISTCLEANFILES = include/bspopts.h
+
+noinst_PROGRAMS =
+
+include_HEADERS += include/xtratum.h
+include_HEADERS += ../../shared/include/coverhd.h
+
+noinst_LIBRARIES = libbspstart.a
+CPPFLAGS += -I$(XTRATUM_PATH)/include -D"__XM_INCFLD(_fld)=<xm_inc/_fld>"
+libbspstart_a_SOURCES = ../../sparc/shared/start/start.S
+project_lib_DATA = start.$(OBJEXT)
+
+dist_project_lib_DATA += ../shared/startup/linkcmds.base
+dist_project_lib_DATA += startup/linkcmds
+dist_project_lib_DATA += startup/linkcmds.xtratum
+
+dist_project_lib_DATA += startup/example_xm_cf.xml
+
+noinst_LIBRARIES += libbsp.a
+libbsp_a_SOURCES =
+libbsp_a_LIBADD =
+libbsp_a_CPPFLAGS =
+
+libbsp_a_CPPFLAGS += -I$(XTRATUM_PATH)/include -D"__XM_INCFLD(_fld)=<xm_inc/_fld>"
+
+# XtratuM header
+libbsp_a_SOURCES += xm/xmhdr.c
+
+# startup
+libbsp_a_SOURCES += ../../shared/bspclean.c
+libbsp_a_SOURCES += ../../shared/bsplibc.c
+libbsp_a_SOURCES += ../../shared/bsppost.c
+libbsp_a_SOURCES += ../../shared/bootcard.c
+libbsp_a_SOURCES += startup/bspstart.c
+libbsp_a_SOURCES += ../../sparc/shared/startup/bspgetworkarea.c
+libbsp_a_SOURCES += ../../shared/sbrk.c
+libbsp_a_SOURCES += ../../shared/bspinit.c
+libbsp_a_SOURCES += startup/isr-en-dis.S
+libbsp_a_SOURCES += startup/bsppredriver.c
+libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
+libbsp_a_SOURCES += startup/psr.c
+libbsp_a_SOURCES += startup/tbr.c
+libbsp_a_SOURCES += startup/setvec.c
+libbsp_a_SOURCES += startup/spurious.c
+libbsp_a_SOURCES += ../../shared/timerstub.c
+libbsp_a_SOURCES += startup/bspreset.c
+#libbsp_a_SOURCES += startup/cpucounter.c
+
+if HAS_SMP
+libbsp_a_SOURCES += startup/bspsmp.c
+endif
+
+# ISR Handler
+libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
+
+# AMBA bus
+include_HEADERS += ../../sparc/shared/include/ambapp.h
+include_HEADERS += ../../sparc/shared/include/ambapp_ids.h
+include_HEADERS += ../../sparc/shared/include/grlib.h
+
+# Console
+include_bsp_HEADERS += include/xtratum-hyper-console.h
+libbsp_a_SOURCES += console/printk-support.c
+libbsp_a_SOURCES += ../../shared/console.c
+libbsp_a_SOURCES += ../../shared/console_control.c
+libbsp_a_SOURCES += ../../shared/console_read.c
+libbsp_a_SOURCES += ../../shared/console_select.c
+libbsp_a_SOURCES += ../../shared/console_write.c
+libbsp_a_SOURCES += ../../shared/console-output-char.c
+libbsp_a_SOURCES += console/console-config.c
+libbsp_a_SOURCES += console/xtratum-hyper-console.c
+
+# Clock
+include_bsp_HEADERS += include/clock-xtratum-exec.h
+libbsp_a_SOURCES += clock/clock-xtratum-hw.c
+libbsp_a_SOURCES += clock/clock-xtratum-exec.c
+
+# IRQ
+include_bsp_HEADERS += ../../shared/include/irq-generic.h
+include_bsp_HEADERS += ../../shared/include/irq-info.h
+include_bsp_HEADERS += include/irq.h
+
+libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
+libbsp_a_SOURCES += ../../shared/src/irq-generic.c
+libbsp_a_SOURCES += ../../shared/src/irq-info.c
+libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
+libbsp_a_SOURCES += ../../shared/src/irq-server.c
+libbsp_a_SOURCES += ../../shared/src/irq-shell.c
+libbsp_a_SOURCES += irq/irq.c
+
+# UART
+include_HEADERS += ../../sparc/shared/include/apbuart.h
+#libbsp_a_SOURCES += ../../sparc/shared/uart/apbuart.c
+
+# Cache
+libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
+libbsp_a_SOURCES += include/cache_.h
+libbsp_a_CPPFLAGS += -I$(srcdir)/../../shared/include
+
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/access.rel
+
+include $(srcdir)/preinstall.am
+include $(top_srcdir)/../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/xtratum/README b/c/src/lib/libbsp/sparc/xtratum/README
new file mode 100644
index 0000000..989cf86
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/README
@@ -0,0 +1,8 @@
+BSP for use with XtratuM 4 hypervisor on a LEON4-N2X board.
+
+It is necessary that the environment variable XTRATUM_PATH is set to the XtratuM
+installation path. I.e. XTRATUM_PATH='/opt/xtratum/xm'.
+
+By default the example_xm_cf.xml will be used for building the tests. It can be
+overwritten with setting the XTRATUM_CONFIG environment variable to another xml
+file. I.e. XTRATUM_CONFIG="/some/path/to/rtems_xm_cf.xml"
diff --git a/c/src/lib/libbsp/sparc/xtratum/bsp_specs b/c/src/lib/libbsp/sparc/xtratum/bsp_specs
new file mode 100644
index 0000000..93d6e75
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/bsp_specs
@@ -0,0 +1,17 @@
+%rename endfile old_endfile
+%rename startfile old_startfile
+%rename link old_link
+%rename lib old_lib
+
+*endfile:
+crtend.o%s crtn.o%s
+
+*startfile:
+%{!qrtems: %(old_startfile)} \
+%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s}}
+
+*link:
+%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
+
+*lib:
+%(old_lib) -lxm
diff --git a/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-exec.c b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-exec.c
new file mode 100644
index 0000000..a30dfec
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-exec.c
@@ -0,0 +1,23 @@
+/*
+ * 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 <bsp/clock-xtratum-exec.h>
+
+#define XTRATUM_CLOCK XM_EXEC_CLOCK
+#define CLOCK_EXT_TRAP_NUMBER \
+ XTRATUM_TRAP_FROM_XM_EXT_IRQ( XM_VT_EXT_EXEC_TIMER )
+
+#define XTRATUM_CLOCK_INITIALIZE xtratum_clock_exec_initialize
+
+#include "clock-xtratum.h"
diff --git a/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-hw.c b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-hw.c
new file mode 100644
index 0000000..48a7efa
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum-hw.c
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+#define XTRATUM_CLOCK XM_HW_CLOCK
+#define CLOCK_EXT_TRAP_NUMBER \
+ XTRATUM_TRAP_FROM_XM_EXT_IRQ( XM_VT_EXT_HW_TIMER )
+
+#define XTRATUM_CLOCK_INITIALIZE Clock_initialize
+
+#include "clock-xtratum.h"
diff --git a/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum.h b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum.h
new file mode 100644
index 0000000..ed8a9bb
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/clock/clock-xtratum.h
@@ -0,0 +1,103 @@
+/*
+ * 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 <rtems/counter.h>
+
+#include <bsp.h>
+#include <bsp/irq.h>
+#include <xm.h>
+#include <rtems/clockdrv.h>
+#include <assert.h>
+#include <fatal.h>
+
+static uint32_t lasttime = 0;
+
+static uint32_t xtratum_clock_nanoseconds_since_last_tick(void)
+{
+ xmTime_t clocktime;
+ uint32_t now;
+ xm_s32_t rv;
+
+ rv = XM_get_time( XTRATUM_CLOCK, &clocktime );
+ assert (rv == XM_OK );
+
+ now = clocktime;
+
+ return (now - lasttime) * 1000;
+}
+
+static void xtratum_clock_handler(void)
+{
+ xmTime_t clocktime;
+ uint32_t now;
+ uint32_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
+ xm_s32_t rv;
+
+ bsp_clear_interrupt( CLOCK_EXT_TRAP_NUMBER );
+
+ rv = XM_get_time( XTRATUM_CLOCK, &clocktime );
+ assert (rv == XM_OK );
+
+ now = clocktime;
+
+ while (lasttime + us_per_tick <= now) {
+ lasttime += us_per_tick;
+ rtems_clock_tick();
+ }
+}
+
+static void xtratum_clock_handler_install(void)
+{
+ rtems_status_code sc;
+
+ sc = rtems_interrupt_handler_install(
+ CLOCK_EXT_TRAP_NUMBER,
+ "Clock",
+ RTEMS_INTERRUPT_UNIQUE,
+ (rtems_interrupt_handler) xtratum_clock_handler,
+ NULL
+ );
+ if (sc != RTEMS_SUCCESSFUL) {
+ bsp_fatal( XTRATUM_FATAL_CLOCK_IRQ_INSTALL );
+ }
+}
+
+rtems_device_driver XTRATUM_CLOCK_INITIALIZE(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp
+)
+{
+ xmTime_t clocktime;
+ xm_s32_t rv;
+
+ rv = XM_get_time( XTRATUM_CLOCK, &clocktime );
+ assert( rv == XM_OK );
+
+ lasttime = clocktime;
+
+ xtratum_clock_handler_install();
+
+ rtems_clock_set_nanoseconds_extension(
+ xtratum_clock_nanoseconds_since_last_tick
+ );
+
+ XM_set_timer(
+ XTRATUM_CLOCK,
+ clocktime + rtems_configuration_get_microseconds_per_tick(),
+ rtems_configuration_get_microseconds_per_tick()
+ );
+
+ return RTEMS_SUCCESSFUL;
+}
diff --git a/c/src/lib/libbsp/sparc/xtratum/configure.ac b/c/src/lib/libbsp/sparc/xtratum/configure.ac
new file mode 100644
index 0000000..7dde9ac
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/configure.ac
@@ -0,0 +1,33 @@
+## Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([rtems-c-src-lib-libbsp-sparc-xtratum],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
+AC_CONFIG_SRCDIR([bsp_specs])
+RTEMS_TOP(../../../../../..)
+
+RTEMS_CANONICAL_TARGET_CPU
+AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
+RTEMS_BSP_CONFIGURE
+
+RTEMS_PROG_CC_FOR_TARGET
+RTEMS_CANONICALIZE_TOOLS
+RTEMS_PROG_CCAS
+
+RTEMS_CHECK_NETWORKING
+RTEMS_CHECK_SMP
+
+AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
+AM_CONDITIONAL(HAS_SMP,[test "$rtems_cv_HAS_SMP" = "yes"])
+
+RTEMS_BSPOPTS_SET([RTEMS_PARAVIRT_XTRATUM],[*],[1])
+RTEMS_BSPOPTS_HELP([RTEMS_PARAVIRT_XTRATUM],[Should be defined, if it is an XtratuM BSP.])
+
+RTEMS_BSPOPTS_SET([XTRATUM_SIZE_PAGE_TABLE],[*],[256])
+RTEMS_BSPOPTS_HELP([XTRATUM_SIZE_PAGE_TABLE],[Size of the XtratuM page table in pages.])
+
+RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
+RTEMS_BSP_LINKCMDS
+
+# Explicitly list all Makefiles here
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/c/src/lib/libbsp/sparc/xtratum/console/console-config.c b/c/src/lib/libbsp/sparc/xtratum/console/console-config.c
new file mode 100644
index 0000000..366422f
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/console/console-config.c
@@ -0,0 +1,27 @@
+/*
+ * 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 <libchip/serial.h>
+#include <bsp/xtratum-hyper-console.h>
+
+console_tbl Console_Configuration_Ports[] = {
+ {
+ .sDeviceName = "/dev/ttyS0",
+ .deviceType = SERIAL_CUSTOM,
+ .pDeviceFns = &xtratum_hyper_console_fns,
+ }
+};
+
+unsigned long Console_Configuration_Count =
+ RTEMS_ARRAY_SIZE(Console_Configuration_Ports);
diff --git a/c/src/lib/libbsp/sparc/xtratum/console/printk-support.c b/c/src/lib/libbsp/sparc/xtratum/console/printk-support.c
new file mode 100644
index 0000000..9049f18
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/console/printk-support.c
@@ -0,0 +1,28 @@
+/*
+ * 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 <rtems/bspIo.h>
+#include <xm.h>
+
+static void console_output(char c)
+{
+ if (c == '\n') {
+ char r = '\r';
+ XM_write_console(&r, sizeof(r));
+ }
+
+ XM_write_console(&c, sizeof(c));
+}
+
+BSP_output_char_function_type BSP_output_char = console_output;
diff --git a/c/src/lib/libbsp/sparc/xtratum/console/xtratum-hyper-console.c b/c/src/lib/libbsp/sparc/xtratum/console/xtratum-hyper-console.c
new file mode 100644
index 0000000..1dd348b
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/console/xtratum-hyper-console.c
@@ -0,0 +1,71 @@
+/*
+ * 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 <bsp/xtratum-hyper-console.h>
+#include <libchip/sersupp.h>
+#include <xm.h>
+
+static void xtratum_hyper_console_initialize(int minor)
+{
+}
+
+static int xtratum_hyper_console_first_open(int major, int minor, void *arg)
+{
+ return 0;
+}
+
+static int xtratum_hyper_console_last_close(int major, int minor, void *arg)
+{
+ return 0;
+}
+
+static int xtratum_hyper_console_read_polled(int minor)
+{
+ return -1;
+}
+
+static void xtratum_hyper_console_write_polled(int minor, char c)
+{
+ XM_write_console(&c, sizeof(c));
+}
+
+static ssize_t xtratum_hyper_console_write_support_polled(
+ int minor,
+ const char *s,
+ size_t n
+)
+{
+ XM_write_console(s, n);
+ return n;
+}
+
+static int xtratum_hyper_console_set_attribues(
+ int minor,
+ const struct termios *term
+)
+{
+ return -1;
+}
+
+const console_fns xtratum_hyper_console_fns = {
+ .deviceProbe = libchip_serial_default_probe,
+ .deviceFirstOpen = xtratum_hyper_console_first_open,
+ .deviceLastClose = xtratum_hyper_console_last_close,
+ .deviceRead = xtratum_hyper_console_read_polled,
+ .deviceWrite = xtratum_hyper_console_write_support_polled,
+ .deviceInitialize = xtratum_hyper_console_initialize,
+ .deviceWritePolled = xtratum_hyper_console_write_polled,
+ .deviceSetAttributes = xtratum_hyper_console_set_attribues,
+ .deviceOutputUsesInterrupts = false
+};
diff --git a/c/src/lib/libbsp/sparc/xtratum/include/bsp.h b/c/src/lib/libbsp/sparc/xtratum/include/bsp.h
new file mode 100644
index 0000000..6bfddec
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/include/bsp.h
@@ -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.
+ */
+
+#ifndef LIBBSP_SPARC_XTRATUM_BSP_H
+#define LIBBSP_SPARC_XTRATUM_BSP_H
+
+#include <bspopts.h>
+
+#ifndef ASM
+
+#include <rtems.h>
+#include <xtratum.h>
+#include <rtems/console.h>
+#include <rtems/clockdrv.h>
+#include <rtems/irq-extension.h>
+
+#include <bsp/default-initial-extension.h>
+
+#define BSP_FEATURE_IRQ_EXTENSION
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern int end;
+
+rtems_isr_entry set_vector(
+ rtems_isr_entry handler,
+ rtems_vector_number vector,
+ int type
+);
+
+void bsp_spurious_initialize(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ASM */
+
+#endif /* LIBBSP_SPARC_XTRATUM_BSP_H */
diff --git a/c/src/lib/libbsp/sparc/xtratum/include/cache_.h b/c/src/lib/libbsp/sparc/xtratum/include/cache_.h
new file mode 100644
index 0000000..94025d6
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/include/cache_.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems 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.
+ */
+
+#ifndef XTRATUM_CACHE_H
+#define XTRATUM_CACHE_H
+
+#include <xtratum.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS
+
+#define CPU_INSTRUCTION_CACHE_ALIGNMENT 64
+
+#define CPU_DATA_CACHE_ALIGNMENT 64
+
+static inline void _CPU_cache_flush_data_range(
+ const void *d_addr,
+ size_t n_bytes
+)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_invalidate_data_range(
+ const void *d_addr,
+ size_t n_bytes
+)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_freeze_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_unfreeze_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_invalidate_entire_instruction(void)
+{
+ __asm__ volatile ("flush");
+}
+
+static inline void _CPU_cache_invalidate_instruction_range(
+ const void *i_addr,
+ size_t n_bytes
+)
+{
+ _CPU_cache_invalidate_entire_instruction();
+}
+
+static inline void _CPU_cache_freeze_instruction(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_unfreeze_instruction(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_flush_entire_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_invalidate_entire_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_enable_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_disable_data(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_enable_instruction(void)
+{
+ /* TODO */
+}
+
+static inline void _CPU_cache_disable_instruction(void)
+{
+ /* TODO */
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XTRATUM_CACHE_H */
diff --git a/c/src/lib/libbsp/sparc/xtratum/include/clock-xtratum-exec.h b/c/src/lib/libbsp/sparc/xtratum/include/clock-xtratum-exec.h
new file mode 100644
index 0000000..f564abc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/include/clock-xtratum-exec.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+#ifndef _CLOCK_XTRATUM_EXEC_H
+#define _CLOCK_XTRATUM_EXEC_H
+
+#include <rtems/clockdrv.h>
+
+rtems_device_driver xtratum_clock_exec_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp
+);
+
+#endif /* _CLOCK_XTRATUM_EXEC_H */
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 " );
+
+#define Clear_tm27_intr() /* empty */
+
+#define Lower_tm27_intr() /* empty */
+
+#endif /* __tm27_h */
diff --git a/c/src/lib/libbsp/sparc/xtratum/include/xtratum-hyper-console.h b/c/src/lib/libbsp/sparc/xtratum/include/xtratum-hyper-console.h
new file mode 100644
index 0000000..73b7c17
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/include/xtratum-hyper-console.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef LIBBSP_XTRATUM_HYPER_CONSOLE_H
+#define LIBBSP_XTRATUM_HYPER_CONSOLE_H
+
+#include <libchip/serial.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern const console_fns xtratum_hyper_console_fns;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_XTRATUM_HYPER_CONSOLE_H */
diff --git a/c/src/lib/libbsp/sparc/xtratum/include/xtratum.h b/c/src/lib/libbsp/sparc/xtratum/include/xtratum.h
new file mode 100644
index 0000000..659b804
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/include/xtratum.h
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#ifndef _INCLUDE_XTRATUM_H
+#define _INCLUDE_XTRATUM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef ASM
+
+/* XtratuM defines traps for the hardware interrupts as well as some XtratuM
+ * Extended interrupts.
+ * TRAP[0x11..0x1F] <=> Hardware interrupts
+ * TRAP[0x20..0x2F] <=> Reserved for future architectures
+ * TRAP[0xE0..0xFF] <=> XtratuM Extended interrupts
+ */
+
+#define XTRATUM_TRAP_HW_OFFSET 0x10
+#define XTRATUM_TRAP_HW_FIRST (XTRATUM_TRAP_HW_OFFSET + 0x01)
+#define XTRATUM_TRAP_HW_LAST (XTRATUM_TRAP_HW_OFFSET + 0x0F)
+
+#define XTRATUM_TRAP_EXT_OFFSET 0xE0
+#define XTRATUM_TRAP_EXT_FIRST (XTRATUM_TRAP_EXT_OFFSET)
+#define XTRATUM_TRAP_EXT_LAST (XTRATUM_TRAP_EXT_OFFSET + 0x1F)
+
+/* Converter macros for the irq-numbers defined by XtratuM */
+#define XTRATUM_TRAP_FROM_XM_HW_IRQ( xm_vt_hw ) \
+ ((xm_vt_hw) + XTRATUM_TRAP_HW_OFFSET )
+
+#define XTRATUM_TRAP_FROM_XM_EXT_IRQ( xm_vt_ext ) \
+ ((xm_vt_ext) + XTRATUM_TRAP_EXT_OFFSET )
+
+/* Check for the trap number type */
+#define XTRATUM_TRAP_IS_HW( trap ) \
+ ((trap) >= XTRATUM_TRAP_HW_FIRST && (trap) <= XTRATUM_TRAP_HW_LAST)
+
+#define XTRATUM_TRAP_IS_EXT( trap ) \
+ ((trap) >= XTRATUM_TRAP_EXT_FIRST && (trap) <= XTRATUM_TRAP_EXT_LAST)
+
+#define XTRATUM_TRAP_IS_INTERRUPT( trap ) \
+ (XTRATUM_TRAP_IS_HW( trap ) || XTRATUM_TRAP_IS_EXT( trap ))
+
+/* get masks from trap number */
+static inline uint32_t xtratum_hw_mask( rtems_vector_number vector )
+{
+ uint32_t hw_mask = 0;
+ if ( XTRATUM_TRAP_IS_HW( vector ) ) {
+ hw_mask = 1 << (vector - XTRATUM_TRAP_HW_OFFSET);
+ }
+ return hw_mask;
+}
+
+static inline uint32_t xtratum_ext_mask( rtems_vector_number vector )
+{
+ uint32_t ext_mask = 0;
+ if ( XTRATUM_TRAP_IS_EXT( vector ) ) {
+ ext_mask = 1 << (vector - XTRATUM_TRAP_EXT_OFFSET);
+ }
+ return ext_mask;
+}
+
+#endif /* ASM */
+
+void bsp_clear_interrupt( rtems_vector_number vector );
+void bsp_unmask_interrupt( rtems_vector_number vector );
+void bsp_mask_interrupt( rtems_vector_number vector );
+void xtratum_interrupt_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INCLUDE_XTRATUM_H */
+
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 @@
+#include <rtems.h>
+#include <bsp.h>
+#include <bsp/irq-generic.h>
+#include <xm.h>
+
+static void bsp_isr_handler(rtems_vector_number vector)
+{
+ bsp_interrupt_handler_dispatch(vector);
+}
+
+void xtratum_interrupt_init(void)
+{
+ rtems_vector_number vector;
+ rtems_isr_entry previous_isr;
+
+ for (
+ vector = XTRATUM_TRAP_HW_FIRST;
+ vector <= XTRATUM_TRAP_HW_LAST;
+ vector++
+ ) {
+ rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);
+ }
+
+ for (
+ vector = XTRATUM_TRAP_EXT_FIRST;
+ vector <= XTRATUM_TRAP_EXT_LAST;
+ vector++
+ ) {
+ rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);
+ }
+
+ bsp_interrupt_initialize();
+}
+
+rtems_status_code bsp_interrupt_facility_initialize(void)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
+{
+ bsp_unmask_interrupt(vector);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
+{
+ bsp_mask_interrupt(vector);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+void bsp_clear_interrupt( rtems_vector_number vector )
+{
+ uint32_t hw_mask = xtratum_hw_mask( vector );
+ uint32_t ext_mask = xtratum_ext_mask( vector );
+
+ XM_clear_irqpend( hw_mask, ext_mask );
+}
+
+void bsp_unmask_interrupt( rtems_vector_number vector )
+{
+ uint32_t hw_mask = xtratum_hw_mask( vector );
+ uint32_t ext_mask = xtratum_ext_mask( vector );
+
+ XM_clear_irqmask( hw_mask, ext_mask );
+}
+
+void bsp_mask_interrupt( rtems_vector_number vector )
+{
+ uint32_t hw_mask = xtratum_hw_mask( vector );
+ uint32_t ext_mask = xtratum_ext_mask( vector );
+
+ XM_set_irqmask( hw_mask, ext_mask );
+}
+
diff --git a/c/src/lib/libbsp/sparc/xtratum/make/custom/xtratum.cfg b/c/src/lib/libbsp/sparc/xtratum/make/custom/xtratum.cfg
new file mode 100644
index 0000000..1c0abbd
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/make/custom/xtratum.cfg
@@ -0,0 +1,55 @@
+#
+# Config file for the XtratuM Hypervisor on LEON3.
+#
+
+include $(RTEMS_ROOT)/make/custom/default.cfg
+
+RTEMS_CPU=sparc
+RTEMS_CPU_MODEL=leon3
+
+# This contains the compiler options necessary to select the CPU model
+# and (hopefully) optimize for it.
+CPU_CFLAGS = -mcpu=leon3 -msoft-float
+
+# optimize flag: typically -O2
+CFLAGS_OPTIMIZE_V = -O2 -g
+CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections
+
+LDFLAGS = -Wl,--gc-sections
+LDFLAGS += -L"$(XTRATUM_PATH)/lib"
+LDFLAGS += -u xmImageHdr
+
+# Variables for building XtratuM executable
+XMRSWBUILD = $(XTRATUM_PATH)/bin/rswbuild
+XMPACK = $(XTRATUM_PATH)/bin/xmpack
+XMEFORMAT = $(XTRATUM_PATH)/bin/xmeformat
+XMCPARSER = $(XTRATUM_PATH)/bin/xmcparser
+XMCORE = $(XTRATUM_PATH)/lib/xm_core.xef
+
+ifeq ($(XTRATUM_CONFIG),)
+ XTRATUM_CONFIG = $(PROJECT_LIB)/example_xm_cf.xml
+endif
+
+XM_BASENAME = $(basename $@)
+XM_INPUT = $(XM_BASENAME).exe
+XM_XEF = $(XM_BASENAME).xef
+XM_BIN_XMC = $(XM_BASENAME).xm_cf.bin.xmc
+XM_XEF_XMC = $(XM_BASENAME).xm_cf.bin.xmc
+XM_CONTAINER_BIN = $(XM_BASENAME).bin
+XM_EXECUTABLE = $(XM_BASENAME).ralf
+XMPACK_ARGS = -h $(XMCORE):$(XM_XEF_XMC) -p 0:$(XM_XEF)
+
+define bsp-post-link
+ $(default-bsp-post-link)
+
+ $(XMEFORMAT) build $(XM_INPUT) -o $(XM_XEF)
+
+ $(XMCPARSER) -o $(XM_BIN_XMC) $(XTRATUM_CONFIG)
+
+ $(XMEFORMAT) build -m $(XM_BIN_XMC) -c -o $(XM_XEF_XMC)
+
+ $(XMPACK) check $(XM_XEF_XMC) $(XMPACK_ARGS)
+ $(XMPACK) build $(XMPACK_ARGS) $(XM_CONTAINER_BIN)
+
+ $(XMRSWBUILD) $(XM_CONTAINER_BIN) $(XM_EXECUTABLE)
+endef
diff --git a/c/src/lib/libbsp/sparc/xtratum/preinstall.am b/c/src/lib/libbsp/sparc/xtratum/preinstall.am
new file mode 100644
index 0000000..f99307c
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/preinstall.am
@@ -0,0 +1,123 @@
+## Automatically generated by ampolish3 - Do not edit
+
+if AMPOLISH3
+$(srcdir)/preinstall.am: Makefile.am
+ $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
+endif
+
+all-am: $(PREINSTALL_FILES)
+
+PREINSTALL_FILES =
+CLEANFILES = $(PREINSTALL_FILES)
+
+PREINSTALL_DIRS =
+DISTCLEANFILES += $(PREINSTALL_DIRS)
+
+all-local: $(TMPINSTALL_FILES)
+
+TMPINSTALL_FILES =
+CLEANFILES += $(TMPINSTALL_FILES)
+
+$(PROJECT_LIB)/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_LIB)
+ @: > $(PROJECT_LIB)/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
+
+$(PROJECT_INCLUDE)/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)
+ @: > $(PROJECT_INCLUDE)/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
+
+$(PROJECT_INCLUDE)/bsp/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
+ @: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+
+$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
+PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
+
+$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
+
+$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
+
+$(PROJECT_INCLUDE)/debug_defs.h: ../../sparc/shared/include/debug_defs.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/debug_defs.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/debug_defs.h
+
+$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
+
+$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
+
+$(PROJECT_INCLUDE)/xtratum.h: include/xtratum.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/xtratum.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/xtratum.h
+
+$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
+
+$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
+TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
+
+$(PROJECT_LIB)/linkcmds.base: ../shared/startup/linkcmds.base $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.base
+PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.base
+
+$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
+PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
+
+$(PROJECT_LIB)/linkcmds.xtratum: startup/linkcmds.xtratum $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.xtratum
+PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.xtratum
+
+$(PROJECT_LIB)/example_xm_cf.xml: startup/example_xm_cf.xml $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/example_xm_cf.xml
+PREINSTALL_FILES += $(PROJECT_LIB)/example_xm_cf.xml
+
+$(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h
+
+$(PROJECT_INCLUDE)/ambapp_ids.h: ../../sparc/shared/include/ambapp_ids.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp_ids.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp_ids.h
+
+$(PROJECT_INCLUDE)/grlib.h: ../../sparc/shared/include/grlib.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/grlib.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/grlib.h
+
+$(PROJECT_INCLUDE)/bsp/xtratum-hyper-console.h: include/xtratum-hyper-console.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/xtratum-hyper-console.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/xtratum-hyper-console.h
+
+$(PROJECT_INCLUDE)/bsp/clock-xtratum-exec.h: include/clock-xtratum-exec.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/clock-xtratum-exec.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/clock-xtratum-exec.h
+
+$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
+
+$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
+
+$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
+
+$(PROJECT_INCLUDE)/apbuart.h: ../../sparc/shared/include/apbuart.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/apbuart.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/apbuart.h
+
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 @@
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#include <bsp/irq-generic.h>
+
+void bsp_predriver_hook( void )
+{
+}
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
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/bspsmp.c b/c/src/lib/libbsp/sparc/xtratum/startup/bspsmp.c
new file mode 100644
index 0000000..46ac420
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/bspsmp.c
@@ -0,0 +1,104 @@
+/*
+ * 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 <bsp.h>
+#include <xm.h>
+#include <rtems/score/smpimpl.h>
+#include <fatal.h>
+
+#define IPVI_NR( idx ) (XM_VT_EXT_IPVI0 + idx)
+#define IPVI_TRAP_NR( idx ) XTRATUM_TRAP_FROM_XM_EXT_IRQ( IPVI_NR( idx ) )
+
+void start(void);
+void bsp_start_on_secondary_processor(uint32_t cpu_index);
+extern struct xmImageHdr xmImageHdr;
+
+uint32_t _CPU_SMP_Get_current_processor(void)
+{
+ return XM_get_vcpuid();
+}
+
+static rtems_isr bsp_inter_processor_interrupt(
+ rtems_vector_number vector
+)
+{
+ _SMP_Inter_processor_interrupt_handler();
+}
+
+void bsp_start_on_secondary_processor(uint32_t cpu_index)
+{
+ rtems_vector_number vector = IPVI_TRAP_NR(cpu_index);
+ bsp_unmask_interrupt(vector);
+
+ _SMP_Start_multitasking_on_secondary_processor();
+}
+
+static void install_vector_without_unmask(
+ rtems_isr_entry new_isr_handler,
+ rtems_vector_number vector
+) {
+ rtems_isr_entry previous_isr;
+
+ rtems_interrupt_catch(
+ new_isr_handler,
+ vector,
+ &previous_isr
+ );
+
+ bsp_clear_interrupt( vector );
+
+ rtems_cache_invalidate_entire_instruction();
+}
+
+uint32_t _CPU_SMP_Initialize(void)
+{
+ uint32_t cpu_index_self = XM_get_vcpuid();
+ rtems_vector_number vector = IPVI_TRAP_NR(cpu_index_self);
+
+ if (cpu_index_self != 0) {
+ bsp_fatal(XTRATUM_FATAL_CPU_SMP_INITIALIZE);
+ }
+
+ if (rtems_configuration_get_maximum_processors() > 1) {
+ install_vector_without_unmask(bsp_inter_processor_interrupt, vector);
+ bsp_unmask_interrupt(vector);
+ }
+
+ return XM_get_number_vcpus();
+}
+
+bool _CPU_SMP_Start_processor(uint32_t cpu_index)
+{
+ int32_t rv;
+ rtems_vector_number vector = IPVI_TRAP_NR(cpu_index);
+
+ install_vector_without_unmask(bsp_inter_processor_interrupt, vector);
+
+ rv = XM_reset_vcpu(cpu_index, xmImageHdr.pageTable, (xm_s32_t) start, 0);
+ assert(rv == XM_OK);
+
+ return true;
+}
+
+void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
+{
+ (void) cpu_count;
+
+ /* Nothing to do */
+}
+
+void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
+{
+ XM_raise_ipvi(IPVI_NR(target_processor_index));
+}
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/bspstart.c b/c/src/lib/libbsp/sparc/xtratum/startup/bspstart.c
new file mode 100644
index 0000000..c3697dc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/bspstart.c
@@ -0,0 +1,22 @@
+/*
+ * 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 <bsp.h>
+#include <bsp/irq.h>
+#include <bsp/bootcard.h>
+
+void bsp_start(void)
+{
+ xtratum_interrupt_init();
+}
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/example_xm_cf.xml b/c/src/lib/libbsp/sparc/xtratum/startup/example_xm_cf.xml
new file mode 100644
index 0000000..b07b7be
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/example_xm_cf.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<SystemDescription xmlns="http://www.xtratum.org/xm-3.x" version="1.0.0" name="hello_world">
+ <HwDescription>
+ <MemoryLayout>
+ <Region type="sdram" start="0x0" size="256MB"/>
+ <!-- UART1 -->
+ <Region type="sdram" start="0xFF901000" size="4096B"/>
+ <!-- GPTIMER4 -->
+ <Region type="sdram" start="0xFF90C000" size="4096B"/>
+ </MemoryLayout>
+ <ProcessorTable>
+ <Processor id="0" frequency="150Mhz">
+ <CyclicPlanTable>
+ <Plan id="0" majorFrame="1000ms">
+ <Slot id="0" start="0ms" duration="900ms" partitionId="0" vCpuId="0"/>
+ </Plan>
+ </CyclicPlanTable>
+ </Processor>
+ <Processor id="1" frequency="150Mhz">
+ <CyclicPlanTable>
+ <Plan id="0" majorFrame="1000ms">
+ <Slot id="0" start="0ms" duration="900ms" partitionId="0" vCpuId="1"/>
+ </Plan>
+ </CyclicPlanTable>
+ </Processor>
+ <Processor id="2" frequency="150Mhz">
+ <CyclicPlanTable>
+ <Plan id="0" majorFrame="1000ms">
+ <Slot id="0" start="0ms" duration="900ms" partitionId="0" vCpuId="2"/>
+ </Plan>
+ </CyclicPlanTable>
+ </Processor>
+ <Processor id="3" frequency="150Mhz">
+ <CyclicPlanTable>
+ <Plan id="0" majorFrame="1000ms">
+ <Slot id="0" start="0ms" duration="900ms" partitionId="0" vCpuId="3"/>
+ </Plan>
+ </CyclicPlanTable>
+ </Processor>
+ </ProcessorTable>
+ <Devices>
+ <Uart id="0" baudRate="115200" name="Uart"/>
+ </Devices>
+ </HwDescription>
+ <XMHypervisor console="Uart">
+ <PhysicalMemoryArea size="16MB"/>
+ </XMHypervisor>
+ <PartitionTable>
+ <Partition id="0" name="Partition1" flags="system" console="Uart" noVCpus="4">
+ <PhysicalMemoryAreas>
+ <Area start="0x02000000" size="16MB"/>
+ <Area start="0xFF901000" size="4096B" mappedAt="0x40901000"/>
+ <Area start="0xFF90C000" size="4096B" mappedAt="0x4090C000"/>
+ </PhysicalMemoryAreas>
+ <HwResources>
+ <Interrupts lines="9"/>
+ </HwResources>
+ </Partition>
+ </PartitionTable>
+ <Channels>
+ <Ipvi id="0" sourceId="0" destinationId="0"/>
+ <Ipvi id="1" sourceId="0" destinationId="0"/>
+ <Ipvi id="2" sourceId="0" destinationId="0"/>
+ <Ipvi id="3" sourceId="0" destinationId="0"/>
+ </Channels>
+</SystemDescription>
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/isr-en-dis.S b/c/src/lib/libbsp/sparc/xtratum/startup/isr-en-dis.S
new file mode 100644
index 0000000..c427df7
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/isr-en-dis.S
@@ -0,0 +1,50 @@
+/*
+ * irq_en_dis.S
+ *
+ * Disabling or enabling the IRQ.
+ *
+ * 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.
+ *
+ * COPYRIGHT (c) 1995. European Space Agency.
+ * COPYRIGHT (c) 2011 UPV (Universidad Politécnica de Valencia)
+ *
+ * This terms of the RTEMS license apply to this file.
+ */
+
+#include <rtems/asm.h>
+#include <xm.h>
+
+ .seg "text"
+
+ PUBLIC(sparc_disable_interrupts)
+
+SYM(sparc_disable_interrupts):
+
+ set sparc_get_psr_nr, %o0
+ __XM_AHC
+ ! psr is now in %o0
+ mov %o0, %g1
+ set sparc_set_pil_nr, %o0
+ __XM_AHC
+ retl
+ mov %g1, %o0
+
+ PUBLIC(sparc_enable_interrupts)
+
+SYM(sparc_enable_interrupts):
+
+ mov %o0, %g1
+ set sparc_get_psr_nr, %o0
+ __XM_AHC
+ ! psr is now in %o0, old one in %g1
+ and %g1, SPARC_PSR_PIL_MASK, %g1
+ andn %o0, SPARC_PSR_PIL_MASK, %o0
+ or %o0, %g1, %o1
+ set sparc_set_psr_nr, %o0
+ __XM_AHC
+ retl
+ nop
+
+/* end of file */
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/linkcmds.xtratum b/c/src/lib/libbsp/sparc/xtratum/startup/linkcmds.xtratum
new file mode 100644
index 0000000..2dea399
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/linkcmds.xtratum
@@ -0,0 +1,20 @@
+/* linkcmds
+ */
+
+/* Default values, can be overridden */
+
+_PROM_SIZE = DEFINED (_PROM_SIZE) ? _PROM_SIZE : 0;
+_PROM_START = DEFINED (_PROM_START) ? _PROM_START : 0x00000000;
+
+_RAM_SIZE = DEFINED (_RAM_SIZE) ? _RAM_SIZE : 16M;
+_RAM_START = DEFINED (_RAM_START) ? _RAM_START : 0x02000000;
+
+/* these are the maximum values */
+
+MEMORY
+{
+ rom : ORIGIN = 0x00000000, LENGTH = 0
+ ram : ORIGIN = 0x02000000, LENGTH = 16M
+}
+
+INCLUDE linkcmds.base
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/psr.c b/c/src/lib/libbsp/sparc/xtratum/startup/psr.c
new file mode 100644
index 0000000..21a84e7
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/psr.c
@@ -0,0 +1,26 @@
+/*
+ * 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 <rtems/score/sparc.h>
+#include <xm.h>
+
+uint32_t _SPARC_Get_PSR( void )
+{
+ return XM_sparc_get_psr();
+}
+
+void _SPARC_Set_PSR( uint32_t new_psr )
+{
+ XM_sparc_set_psr( new_psr );
+}
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/setvec.c b/c/src/lib/libbsp/sparc/xtratum/startup/setvec.c
new file mode 100644
index 0000000..c370bc9
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/setvec.c
@@ -0,0 +1,61 @@
+/**
+ * @file
+ * @ingroup sparc_xtratum
+ * @brief Install an interrupt vector on SPARC
+ */
+
+/* This routine installs an interrupt vector on the SPARC simulator.
+ *
+ * INPUT PARAMETERS:
+ * handler - interrupt handler entry point
+ * vector - vector number
+ * type - 0 indicates raw hardware connect
+ * 1 indicates RTEMS interrupt connect
+ *
+ * OUTPUT PARAMETERS: NONE
+ *
+ * RETURNS:
+ * address of previous interrupt handler
+ */
+
+/* COPYRIGHT (c) 1989-1998.
+ * 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.
+ *
+ * Ported to LEON implementation of the SPARC by On-Line Applications
+ * Research Corporation (OAR) under contract to the European Space
+ * Agency (ESA).
+ *
+ * LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
+ * European Space Agency.
+ */
+
+#include <bsp.h>
+#include <xm.h>
+
+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 */
+)
+{
+ rtems_isr_entry previous_isr;
+ uint32_t real_trap;
+
+ if ( type )
+ rtems_interrupt_catch( handler, vector, &previous_isr );
+ else
+ _CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr );
+
+ real_trap = SPARC_REAL_TRAP_NUMBER( vector );
+
+ if ( XTRATUM_TRAP_IS_INTERRUPT( real_trap ) ) {
+ bsp_clear_interrupt( real_trap );
+ bsp_unmask_interrupt( real_trap );
+ }
+
+ return previous_isr;
+}
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);
+}
+
diff --git a/c/src/lib/libbsp/sparc/xtratum/startup/tbr.c b/c/src/lib/libbsp/sparc/xtratum/startup/tbr.c
new file mode 100644
index 0000000..54de476
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/startup/tbr.c
@@ -0,0 +1,30 @@
+/*
+ * 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 <rtems/score/sparc.h>
+#include <xm.h>
+#include <rtems/fatal.h>
+
+uint32_t _SPARC_Get_TBR( void )
+{
+ partitionControlTable_t * pct = XM_get_PCT();
+ xmAddress_t tbr = pct->arch.tbr;
+ return tbr;
+}
+
+void _SPARC_Set_TBR( uint32_t new_tbr )
+{
+ /* TODO: implement */
+ rtems_fatal( RTEMS_FATAL_SOURCE_BSP, 0xf51fbdc1 );
+}
diff --git a/c/src/lib/libbsp/sparc/xtratum/xm/xmhdr.c b/c/src/lib/libbsp/sparc/xtratum/xm/xmhdr.c
new file mode 100644
index 0000000..d20da6b
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/xtratum/xm/xmhdr.c
@@ -0,0 +1,36 @@
+/*
+ * xmhdr.c
+ *
+ * Partition header definition
+ *
+ * Created for RTEMS/XM3 by Javier Coronel (jacopa at ai2.upv.es)
+ * $Id: xmhdr.c, 2011/06/08
+ *
+ * Porting of RTEMS to XM3.
+ * It has been performed under IMA-SP project.
+ * COPYRIGHT (c) 2011
+ * UPV (Universidad Politécnica de Valencia)
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#include <xm.h>
+#include <xm_inc/arch/paging.h>
+#include <bsp.h>
+
+static xm_u8_t _pageTable[PAGE_SIZE*XTRATUM_SIZE_PAGE_TABLE] __attribute__((aligned(PAGE_SIZE))) __attribute__ ((section(".bsp_rwextra")));
+
+struct xmImageHdr xmImageHdr __XMIHDR = {
+ .sSignature=XMEF_PARTITION_MAGIC,
+ .compilationXmAbiVersion=XM_SET_VERSION(XM_ABI_VERSION, XM_ABI_SUBVERSION, XM_ABI_REVISION),
+ .compilationXmApiVersion=XM_SET_VERSION(XM_API_VERSION, XM_API_SUBVERSION, XM_API_REVISION),
+ .pageTable=(xmAddress_t)_pageTable,
+ .pageTableSize=XTRATUM_SIZE_PAGE_TABLE*PAGE_SIZE,
+ .noCustomFiles=0,
+ .eSignature=XMEF_PARTITION_MAGIC,
+};
+
+
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.
diff --git a/testsuites/smptests/smpfatal08/init.c b/testsuites/smptests/smpfatal08/init.c
index b005443..7387d23 100644
--- a/testsuites/smptests/smpfatal08/init.c
+++ b/testsuites/smptests/smpfatal08/init.c
@@ -56,7 +56,8 @@ void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
assert(0);
}
-#if !defined(__leon__) && !defined(__PPC__) && !defined(__arm__)
+#if (!defined(__leon__) && !defined(__PPC__) && !defined(__arm__)) \
+ || defined(RTEMS_PARAVIRT)
uint32_t _CPU_SMP_Get_current_processor(void)
{
return 0;
--
1.8.4.5
More information about the devel
mailing list