diff --git a/bsd-user/e2k/target_arch.h b/bsd-user/e2k/target_arch.h new file mode 100644 index 0000000000..10841c1493 --- /dev/null +++ b/bsd-user/e2k/target_arch.h @@ -0,0 +1,34 @@ +/* + * E2K 32-bit specific prototypes for bsd-user + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_H_ +#define _TARGET_ARCH_H_ + +#include "qemu.h" + +#endif /* !_TARGET_ARCH_H_ */ diff --git a/bsd-user/e2k/target_arch_cpu.c b/bsd-user/e2k/target_arch_cpu.c new file mode 100644 index 0000000000..18c5471b25 --- /dev/null +++ b/bsd-user/e2k/target_arch_cpu.c @@ -0,0 +1,30 @@ +/* + * E2K CPU related code + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 "target_arch.h" + diff --git a/bsd-user/e2k/target_arch_cpu.h b/bsd-user/e2k/target_arch_cpu.h new file mode 100644 index 0000000000..87305275a1 --- /dev/null +++ b/bsd-user/e2k/target_arch_cpu.h @@ -0,0 +1,76 @@ +/* + * E2K cpu init and loop + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_CPU_H_ +#define _TARGET_ARCH_CPU_H_ + +#include "target_arch.h" + +#define TARGET_DEFAULT_CPU_MODEL "e8c" + +static inline void target_cpu_init(CPUE2KState *env, + struct target_pt_regs *regs) +{ + assert(0 && "target_cpu_init not implemented yet"); +} + +static inline void target_cpu_loop(CPUE2KState *env) +{ + CPUState *cs = env_cpu(env); + int trapnr; + + for (;;) { + cpu_exec_start(cs); + trapnr = cpu_exec(cs); + cpu_exec_end(cs); + process_queued_cpu_work(cs); + + switch (trapnr) { + + default: + fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); + cpu_dump_state(cs, stderr, 0); + abort(); + } + process_pending_signals(env); + } +} + +static inline void target_cpu_clone_regs(CPUE2KState *env, target_ulong newsp) +{ + if (newsp) + env->usd.curptr = newsp; +} + +static inline void target_cpu_set_tls(CPUE2KState *env, target_ulong newtls) +{ + assert(0 && "target_cpu_set_tls not implemented yet"); +} + + +#endif /* !_TARGET_ARCH_CPU_H */ diff --git a/bsd-user/e2k/target_arch_elf.h b/bsd-user/e2k/target_arch_elf.h new file mode 100644 index 0000000000..442731ce08 --- /dev/null +++ b/bsd-user/e2k/target_arch_elf.h @@ -0,0 +1,42 @@ +/* + * E2K ELF definitions + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_ELF_H_ +#define _TARGET_ARCH_ELF_H_ + +#define elf_check_arch(x) ( (x) == EM_MCST_ELBRUS ) +#define ELF_START_MMAP 0x80000000 +#define ELF_ET_DYN_LOAD_ADDR 0x100000 +#define ELF_CLASS ELFCLASS64 + +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_MCST_ELBRUS + +#define ELF_HWCAP 0 + +#endif /* _TARGET_ARCH_ELF_H_ */ diff --git a/bsd-user/e2k/target_arch_reg.h b/bsd-user/e2k/target_arch_reg.h new file mode 100644 index 0000000000..3f63375a51 --- /dev/null +++ b/bsd-user/e2k/target_arch_reg.h @@ -0,0 +1,34 @@ +/* + * E2K register structures + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_REG_H_ +#define _TARGET_ARCH_REG_H_ + + + +#endif /* !_TARGET_ARCH_REG_H_ */ diff --git a/bsd-user/e2k/target_arch_signal.h b/bsd-user/e2k/target_arch_signal.h new file mode 100644 index 0000000000..241a03d49d --- /dev/null +++ b/bsd-user/e2k/target_arch_signal.h @@ -0,0 +1,140 @@ +/* + * E2K signal definitions + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_SIGNAL_H_ +#define _TARGET_ARCH_SIGNAL_H_ + +#include "cpu.h" + +#define MAX_TC_SIZE 10 + +#define TIR_NUM 19 +#define DAM_ENTRIES_NUM 32 +#define SBBP_ENTRIES_NUM 32 + +/* from user.h !!! */ +#define MLT_NUM (16 * 3) /* common for E3M and E3S */ + +#define TARGET_MINSIGSTKSZ (512 * 4) /* min sig stack size */ + +#define TARGET_MC_GET_CLEAR_RET 0x0001 + +typedef struct target_mcontext { + abi_ullong cr0_lo; + abi_ullong cr0_hi; + abi_ullong cr1_lo; + abi_ullong cr1_hi; + abi_ullong sbr; /* 21 Stack base register: top of */ + /* local data (user) stack */ + abi_ullong usd_lo; /* 22 Local data (user) stack */ + abi_ullong usd_hi; /* 23 descriptor: base & size */ + abi_ullong psp_lo; /* 24 Procedure stack pointer: */ + abi_ullong psp_hi; /* 25 base & index & size */ + abi_ullong pcsp_lo; /* 26 Procedure chain stack */ + abi_ullong pcsp_hi; /* 27 pointer: base & index & size */ + + /* additional part (for binary compiler) */ + abi_ullong rpr_hi; + abi_ullong rpr_lo; + + abi_ullong nr_TIRs; + abi_ullong tir_lo[TIR_NUM]; + abi_ullong tir_hi[TIR_NUM]; + abi_ullong trap_cell_addr[MAX_TC_SIZE]; + abi_ullong trap_cell_val[MAX_TC_SIZE]; + uint8_t trap_cell_tag[MAX_TC_SIZE]; + abi_ullong trap_cell_info[MAX_TC_SIZE]; + + abi_ullong dam[DAM_ENTRIES_NUM]; + abi_ullong sbbp[SBBP_ENTRIES_NUM]; + abi_ullong mlt[MLT_NUM]; + abi_ullong upsr; +} target_mcontext_t; + +typedef struct target_ucontext { + target_sigset_t uc_sigmask; + target_mcontext_t uc_mcontext; + abi_ulong uc_link; + target_stack_t uc_stack; + int32_t uc_flags; + int32_t __spare__[4]; +} target_ucontext_t; + +struct target_sigframe { + target_siginfo_t sf_si; + union { + target_ucontext_t sf_uc; + // TODO: ucontext_prot + }; + + /* FIXME: move this data to TaskState? */ + E2KAauState aau; + uint64_t lsr; + uint64_t lsr_lcnt; + uint32_t ilcr; + uint64_t ilcr_lcnt; + // FIXME: according to ABI only 16-31 must be saved + E2KReg gregs[16]; + uint8_t gtags[16]; +}; + +static inline abi_long set_sigtramp_args(CPUE2KState *regs, + int sig, struct target_sigframe *frame, abi_ulong frame_addr, + struct target_sigaction *ka) +{ + assert(0 && "set_sigtramp_args not implemented yet"); + /* XXX */ + return -TARGET_EOPNOTSUPP; +} + +static inline abi_long get_mcontext(CPUE2KState *regs, + target_mcontext_t *mcp, int flags) +{ + assert(0 && "get_mcontext not implemented yet"); + /* XXX */ + return -TARGET_EOPNOTSUPP; +} + +static inline abi_long set_mcontext(CPUE2KState *regs, + target_mcontext_t *mcp, int srflag) +{ + assert(0 && "set_mcontext not implemented yet"); + /* XXX */ + return -TARGET_EOPNOTSUPP; +} + +static inline abi_long get_ucontext_sigreturn(CPUE2KState *regs, + abi_ulong target_sf, abi_ulong *target_uc) +{ + /* XXX */ + *target_uc = 0; + assert(0 && "get_ucontext_sigreturn not implemented yet"); + return -TARGET_EOPNOTSUPP; +} + +#endif /* !TARGET_ARCH_SIGNAL_H_ */ diff --git a/bsd-user/e2k/target_arch_sigtramp.h b/bsd-user/e2k/target_arch_sigtramp.h new file mode 100644 index 0000000000..ffb785db23 --- /dev/null +++ b/bsd-user/e2k/target_arch_sigtramp.h @@ -0,0 +1,38 @@ +/* + * E2K sigcode for bsd-user + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_SIGTRAMP_H_ +#define _TARGET_ARCH_SIGTRAMP_H_ + +static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc, + unsigned sys_sigreturn) +{ + assert(0 && "setup_sigtramp is not implemented yet"); + return -TARGET_EOPNOTSUPP; +} +#endif /* _TARGET_ARCH_SIGTRAMP_H_ */ diff --git a/bsd-user/e2k/target_arch_sysarch.h b/bsd-user/e2k/target_arch_sysarch.h new file mode 100644 index 0000000000..3d697ef216 --- /dev/null +++ b/bsd-user/e2k/target_arch_sysarch.h @@ -0,0 +1,49 @@ +/* + * E2K sysarch() system call emulation + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 __ARCH_SYSARCH_H_ +#define __ARCH_SYSARCH_H_ + +#include "target_syscall.h" +#include "target_arch.h" + +static inline abi_long do_freebsd_arch_sysarch(CPUE2KState *env, int op, + abi_ulong parms) +{ + return -TARGET_EINVAL; +} + +static inline void do_freebsd_arch_print_sysarch( + const struct syscallname *name, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) +{ + gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", " + TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4); +} + +#endif /*!__ARCH_SYSARCH_H_ */ diff --git a/bsd-user/e2k/target_arch_thread.h b/bsd-user/e2k/target_arch_thread.h new file mode 100644 index 0000000000..869e1c9149 --- /dev/null +++ b/bsd-user/e2k/target_arch_thread.h @@ -0,0 +1,44 @@ +/* + * E2K thread support + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_THREAD_H_ +#define _TARGET_ARCH_THREAD_H_ + +static inline void target_thread_set_upcall(CPUE2KState *regs, abi_ulong entry, + abi_ulong arg, abi_ulong stack_base, abi_ulong stack_size) +{ + assert(0 && "target_thread_set_upcall is not implemented yet"); +} + +static inline void target_thread_init(struct target_pt_regs *regs, + struct image_info *infop) +{ + assert(0 && "target_thread_init is not implemented yet"); +} + +#endif /* !_TARGET_ARCH_THREAD_H_ */ diff --git a/bsd-user/e2k/target_arch_vmparam.h b/bsd-user/e2k/target_arch_vmparam.h new file mode 100644 index 0000000000..ad27aa18a8 --- /dev/null +++ b/bsd-user/e2k/target_arch_vmparam.h @@ -0,0 +1,56 @@ +/* + * E2K VM parameters definitions + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 _TARGET_ARCH_VMPARAM_H_ +#define _TARGET_ARCH_VMPARAM_H_ + +#include "cpu.h" + +// TODO: find out proper values for these constants +#define TARGET_MAXTSIZ (128UL*1024*1024) /* max text size */ +#define TARGET_DFLDSIZ (32768UL*1024*1024) /* initial data size limit */ +#define TARGET_MAXDSIZ (32768UL*1024*1024) /* max data size */ +#define TARGET_DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ +#define TARGET_MAXSSIZ (512UL*1024*1024) /* max stack size */ +#define TARGET_SGROWSIZ (128UL*1024) /* amount to grow stack */ + +#define TARGET_VM_MAXUSER_ADDRESS (0x00007fffff000000UL) + +#define TARGET_USRSTACK (TARGET_VM_MAXUSER_ADDRESS - TARGET_PAGE_SIZE) + +static inline abi_ulong get_sp_from_cpustate(CPUE2KState *state) +{ + return state->usd.curptr; +} + +static inline void set_second_rval(CPUE2KState *state, abi_ulong retval2) +{ + assert(0 && "set_second_rval not implemented yet"); +} + +#endif /* !_TARGET_ARCH_VMPARAM_H_ */ diff --git a/bsd-user/e2k/target_syscall.h b/bsd-user/e2k/target_syscall.h new file mode 100644 index 0000000000..179fb427a4 --- /dev/null +++ b/bsd-user/e2k/target_syscall.h @@ -0,0 +1,83 @@ +/* + * E2K system call definitions + * + * Copyright (c) 2021 Gleb Popov + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its contributors may + * be used to endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 HOLDER 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 __ARCH_SYSCALL_H_ +#define __ARCH_SYSCALL_H_ + +#define E2K_DEFAULT_PCS_SIZE (TARGET_PAGE_SIZE) +#define E2K_DEFAULT_PS_SIZE (TARGET_PAGE_SIZE * 4) + +struct target_pt_regs { + /* special registers */ + uint64_t wd; // Current window descriptor (WD) + + uint64_t sbr; // User Stack Base Register (USBR/SBR) + // SBR - contains the base (top) virtual address of the current User Stack area. + + // uint64_t tr; // current type register + + E2KPsp pcsp; + E2KPsp psp; + + uint32_t psr; // Processor State Register (PSR) + uint32_t upsr; // User processor status register (UPSR) + uint64_t ip; // instruction pointer + uint64_t nip; // next instruction pointer + + uint64_t ctpr1; // Control Transfer Preparation Register (CTPR) + uint64_t ctpr2; + uint64_t ctpr3; + + uint32_t pfpfr; // Packed Floating Point Flag Register (PFPFR) + uint32_t fpcr; // Floating point control register (FPCR) + uint32_t fpsr; // Floating point state register (FPSR) + + // borrowed from Embox OS + uint64_t lsr; // Loop status register (LSR) + uint64_t ilcr; // Loop counter register (ILCR) + + uint64_t dr0; + + uint64_t cr0_hi; + uint64_t cr1_lo; + uint64_t cr1_hi; + uint64_t pcsp_hi; + uint64_t pcsp_lo; + uint64_t usd_lo; // User data + uint64_t usd_hi; + + uint64_t gbase[32]; + uint16_t gext[32]; +}; + +#define UNAME_MACHINE "e2k" + +#define TARGET_HW_MACHINE "e2k" +#define TARGET_HW_MACHINE_ARCH UNAME_MACHINE + +#endif /* !__ARCH_SYSCALL_H_ */ diff --git a/configs/targets/e2k-bsd-user.mak b/configs/targets/e2k-bsd-user.mak new file mode 100644 index 0000000000..5b5d9a6e48 --- /dev/null +++ b/configs/targets/e2k-bsd-user.mak @@ -0,0 +1,2 @@ +TARGET_ARCH=e2k +TARGET_XML_FILES= gdb-xml/e2k-v1.xml gdb-xml/e2k-v2.xml gdb-xml/e2k-v3.xml gdb-xml/e2k-v5.xml \ No newline at end of file