diff --git a/configs/targets/e2k32-linux-user.mak b/configs/targets/e2k32-linux-user.mak new file mode 100644 index 0000000000..934f1cc2f8 --- /dev/null +++ b/configs/targets/e2k32-linux-user.mak @@ -0,0 +1,3 @@ +TARGET_ARCH=e2k32 +TARGET_BASE_ARCH=e2k +TARGET_ABI32=y diff --git a/linux-user/e2k32/cpu_loop.c b/linux-user/e2k32/cpu_loop.c new file mode 100644 index 0000000000..fd8c4a664b --- /dev/null +++ b/linux-user/e2k32/cpu_loop.c @@ -0,0 +1 @@ +#include "../e2k/cpu_loop.c" diff --git a/linux-user/e2k32/signal.c b/linux-user/e2k32/signal.c new file mode 100644 index 0000000000..f06d49bc16 --- /dev/null +++ b/linux-user/e2k32/signal.c @@ -0,0 +1 @@ +#include "../e2k/signal.c" diff --git a/linux-user/e2k32/sockbits.h b/linux-user/e2k32/sockbits.h new file mode 100644 index 0000000000..0e4c8f012d --- /dev/null +++ b/linux-user/e2k32/sockbits.h @@ -0,0 +1 @@ +#include "../generic/sockbits.h" diff --git a/linux-user/e2k32/syscall_nr.h b/linux-user/e2k32/syscall_nr.h new file mode 100644 index 0000000000..a25176dbc2 --- /dev/null +++ b/linux-user/e2k32/syscall_nr.h @@ -0,0 +1 @@ +#include "../e2k/syscall_nr.h" diff --git a/linux-user/e2k32/target_cpu.h b/linux-user/e2k32/target_cpu.h new file mode 100644 index 0000000000..e37ffec954 --- /dev/null +++ b/linux-user/e2k32/target_cpu.h @@ -0,0 +1 @@ +#include "../e2k/target_cpu.h" diff --git a/linux-user/e2k32/target_elf.h b/linux-user/e2k32/target_elf.h new file mode 100644 index 0000000000..e9b0bbd2a2 --- /dev/null +++ b/linux-user/e2k32/target_elf.h @@ -0,0 +1 @@ +#include "../e2k/target_elf.h" diff --git a/linux-user/e2k32/target_fcntl.h b/linux-user/e2k32/target_fcntl.h new file mode 100644 index 0000000000..599506db00 --- /dev/null +++ b/linux-user/e2k32/target_fcntl.h @@ -0,0 +1,4 @@ +#ifndef E2K32_TARGET_FCNTL_H +#define E2K32_TARGET_FCNTL_H +#include "../generic/fcntl.h" +#endif diff --git a/linux-user/e2k32/target_signal.h b/linux-user/e2k32/target_signal.h new file mode 100644 index 0000000000..691e0cc12f --- /dev/null +++ b/linux-user/e2k32/target_signal.h @@ -0,0 +1,26 @@ +#ifndef E2K32_TARGET_SIGNAL_H +#define E2K32_TARGET_SIGNAL_H + +/* + * sigaltstack controls + */ +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 4096 +#define TARGET_SIGSTKSZ 8192 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 + +#define TARGET_ARCH_HAS_SETUP_FRAME + +typedef struct target_sigaltstack { + abi_ulong ss_sp; + abi_int ss_flags; + abi_ulong ss_size; +} target_stack_t; + +#include "../generic/signal.h" + +#endif /* E2K32_TARGET_SIGNAL_H */ diff --git a/linux-user/e2k32/target_structs.h b/linux-user/e2k32/target_structs.h new file mode 100644 index 0000000000..75538c02e7 --- /dev/null +++ b/linux-user/e2k32/target_structs.h @@ -0,0 +1 @@ +#include "../e2k/target_structs.h" diff --git a/linux-user/e2k32/target_syscall.h b/linux-user/e2k32/target_syscall.h new file mode 100644 index 0000000000..b7cfe9eb24 --- /dev/null +++ b/linux-user/e2k32/target_syscall.h @@ -0,0 +1 @@ +#include "../e2k/target_syscall.h" diff --git a/linux-user/e2k32/termbits.h b/linux-user/e2k32/termbits.h new file mode 100644 index 0000000000..67ae5a5620 --- /dev/null +++ b/linux-user/e2k32/termbits.h @@ -0,0 +1,6 @@ +#ifndef _E2K_TERMBITS_H_ +#define _E2K_TERMBITS_H_ + +#include "../generic/termbits.h" + +#endif /* _E2K_TERMBITS_H_ */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5860ceb35b..db77746926 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7089,6 +7089,47 @@ static abi_long do_e2k_longjmp2(CPUE2KState *env, struct target_jmp_info *jmp_in return 0; } + +static abi_long do_e2k_access_hw_stacks(CPUState *cpu, abi_ulong arg2, + abi_ulong arg3, abi_ulong arg4, abi_ulong arg5, abi_ulong arg6) +{ + E2KCPU *e2k_cpu = E2K_CPU(cpu); + CPUE2KState *env = &e2k_cpu->env; + int ret = 0; + abi_ulong mode = arg2; + abi_ulong frame_addr = arg3; // __user (abi_ullong *) +// abi_ulong buf_addr = arg4; // __user (char *) +// abi_ulong buf_size = arg5; + abi_ulong size_addr = arg6; // __user (void *) + + switch (mode) { + case GET_PROCEDURE_STACK_SIZE: + ret = put_user(env->psp.index, size_addr, target_ulong); + break; + case GET_CHAIN_STACK_SIZE: + ret = put_user(env->pcsp.index, size_addr, target_ulong); + break; + case GET_CHAIN_STACK_OFFSET: + ret = -TARGET_ENOSYS; + break; + case READ_CHAIN_STACK_EX: + { + abi_ullong frame = 0; + copy_user(); + + break; + } + case READ_CHAIN_STACK: + case READ_PROCEDURE_STACK: + case WRITE_PROCEDURE_STACK: + case READ_PROCEDURE_STACK_EX: + case WRITE_PROCEDURE_STACK_EX: + case WRITE_CHAIN_STACK_EX: + return -TARGET_ENOSYS; + } + return ret; +} + #endif /* end of TARGET_E2K */ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) @@ -11999,24 +12040,16 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, if (ret) { break; } - do_e2k_longjmp2(env, &ji); + ret = do_e2k_longjmp2(env, &ji); + if (ret) { + break; + } return arg2; } #endif #ifdef TARGET_NR_access_hw_stacks case TARGET_NR_access_hw_stacks: - { -#if 0 - abi_ulong mode = arg2; - abi_ulong frame_ptr = arg3; // __user (abi_ullong *) - abi_ulong buf = arg4; // __user (char *) - abi_ulong buf_size = arg5; - abi_ulong real_size = arg6; // __user (void *) -#endif - - // TODO: e2k_sys_access_hw_stacks - return -TARGET_ENOSYS; - } + return do_e2k_access_hw_stacks(cpu, arg1, arg2, arg3, arg4, arg5); #endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr diff --git a/target/e2k/helper-tcg.h b/target/e2k/helper-tcg.h new file mode 100644 index 0000000000..913a99e7aa --- /dev/null +++ b/target/e2k/helper-tcg.h @@ -0,0 +1,37 @@ +/* + * e2k TCG specific prototypes for helpers + * + * Copyright (c) 2020-2021 Denis Drakhnya, Alibek Omarov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef E2K_HELPER_TCG_H +#define E2K_HELPER_TCG_H + +#include "qemu/osdep.h" +#include "cpu.h" +#include "exec/exec-all.h" + +/* helper.c */ +void G_NORETURN raise_exception(CPUE2KState *env, int exception_index); +void G_NORETURN raise_exception_ra(CPUE2KState *env, int exception_index, + uintptr_t retaddr); + +#endif /* E2K_HELPER_TCG_H */