From 708b1ec4b48b27f0c1f9bbda80ee4810e2b5f0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Wed, 24 Sep 2014 15:19:26 +0200 Subject: [PATCH] initial s390 support --- build/Jamfile.v2 | 42 +++++++++++++++ build/architecture.jam | 4 ++ config/s390.cpp | 11 ++++ include/boost/context/detail/fcontext_s390.hpp | 73 ++++++++++++++++++++++++++ src/asm/jump_s390_sysv_elf_gas.S | 0 src/asm/jump_s390x_sysv_elf_gas.S | 37 +++++++++++++ src/asm/make_s390_sysv_elf_gas.S | 0 src/asm/make_s390x_sysv_elf_gas.S | 0 8 files changed, 167 insertions(+) create mode 100644 config/s390.cpp create mode 100644 include/boost/context/detail/fcontext_s390.hpp create mode 100644 src/asm/jump_s390_sysv_elf_gas.S create mode 100644 src/asm/jump_s390x_sysv_elf_gas.S create mode 100644 src/asm/make_s390_sysv_elf_gas.S create mode 100644 src/asm/make_s390x_sysv_elf_gas.S diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 112e979..733fb39 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -479,6 +479,48 @@ alias asm_context_sources mach-o ; +# S390 +# S390/SYSV/ELF +alias asm_context_sources + : [ make asm/make_s390_sysv_elf_gas.o : asm/make_s390_sysv_elf_gas.S : @gas ] + [ make asm/jump_s390_sysv_elf_gas.o : asm/jump_s390_sysv_elf_gas.S : @gas ] + : sysv + 32 + s390 + elf + ; + +alias asm_context_sources + : asm/make_s390_sysv_elf_gas.S + asm/jump_s390_sysv_elf_gas.S + : sysv + 32 + s390 + elf + gcc + ; + +# S390 +# S390X/SYSV/ELF +alias asm_context_sources + : [ make asm/make_s390x_sysv_elf_gas.o : asm/make_s390x_sysv_elf_gas.S : @gas ] + [ make asm/jump_s390x_sysv_elf_gas.o : asm/jump_s390x_sysv_elf_gas.S : @gas ] + : sysv + 64 + s390 + elf + ; + +alias asm_context_sources + : asm/make_s390x_sysv_elf_gas.S + asm/jump_s390x_sysv_elf_gas.S + : sysv + 64 + s390 + elf + gcc + ; + # SPARC # SPARC/SYSV/ELF alias asm_context_sources diff --git a/build/architecture.jam b/build/architecture.jam index 81dcb49..103bb25 100644 --- a/build/architecture.jam +++ b/build/architecture.jam @@ -63,6 +63,10 @@ rule deduce-architecture ( properties * ) { return power ; } + else if [ configure.builds /boost/architecture//s390 : $(properties) : s390 ] + { + return s390 ; + } else if [ configure.builds /boost/architecture//sparc : $(properties) : sparc ] { return sparc ; diff --git a/config/s390.cpp b/config/s390.cpp new file mode 100644 index 0000000..cb518cc --- /dev/null +++ b/config/s390.cpp @@ -0,0 +1,11 @@ +// s390.cpp +// +// Copyright (c) 2012 Dan Horák +// +// Distributed under the Boost Software License Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(__s390__) +#error "Not S390" +#endif diff --git a/include/boost/context/detail/fcontext_s390.hpp b/include/boost/context/detail/fcontext_s390.hpp new file mode 100644 index 0000000..cc99cb9 --- /dev/null +++ b/include/boost/context/detail/fcontext_s390.hpp @@ -0,0 +1,73 @@ + +// Copyright Dan Horák 2014. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_S390_H +#define BOOST_CONTEXT_DETAIL_FCONTEXT_S390_H + +#include + +#include +#include + +#include + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { +namespace context { + +extern "C" { + +#define BOOST_CONTEXT_CALLDECL + +struct stack_t +{ + void * sp; + std::size_t size; + + stack_t() : + sp( 0), size( 0) + {} +}; + +struct fp_t +{ + boost::uint64_t fc_freg[8]; + boost::uint32_t fc_fpc; + + fp_t() : + fc_freg() + {} +}; + +struct fcontext_t +{ +# if defined(__s390x__) + boost::uint64_t fc_greg[16]; +# else + boost::uint32_t fc_greg[16]; +# endif + stack_t fc_stack; + fp_t fc_fp; + + fcontext_t() : + fc_greg(), + fc_stack(), + fc_fp() + {} +}; + +} + +}} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_S390_H diff --git a/src/asm/jump_s390_sysv_elf_gas.S b/src/asm/jump_s390_sysv_elf_gas.S new file mode 100644 index 0000000..e69de29 diff --git a/src/asm/jump_s390x_sysv_elf_gas.S b/src/asm/jump_s390x_sysv_elf_gas.S new file mode 100644 index 0000000..8f5d5c1 --- /dev/null +++ b/src/asm/jump_s390x_sysv_elf_gas.S @@ -0,0 +1,37 @@ +.globl jump_fcontext +.type jump_fcontext,@function + + # reserve space on stack + aghi 15,-100 + + # save gregs + stmg 6,13,0(15) + + # save fregs if requested + + bnz 1f + std 0,0(15) + std 1,0(15) + + stfpc 0(15) + +1: + stg 15,0(2) + lgr 3,15 + + # restore fregs if requested + + bnz 1f + ld 0,0(15) + ld 1,0(15) + + lfpc 0(15) + +1: + # restore gregs + lmg 6,13,0(15) + +.size .jump_fcontext, .-.jump_fcontext + +/* Mark that we don't need executable stack. */ +.section .note.GNU-stack,"",%progbits diff --git a/src/asm/make_s390_sysv_elf_gas.S b/src/asm/make_s390_sysv_elf_gas.S new file mode 100644 index 0000000..e69de29 diff --git a/src/asm/make_s390x_sysv_elf_gas.S b/src/asm/make_s390x_sysv_elf_gas.S new file mode 100644 index 0000000..e69de29 -- 1.9.3