From ba7651fba54199e5dedbbd08157687291b9dbae3 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Wed, 25 Jan 2017 10:54:11 -0800 Subject: target/xtensa: add linux-user support Import list of syscalls from the kernel source. Conditionalize code/data that is only used with softmmu. Implement exception handlers. Implement signal hander (only the core registers for now, no coprocessors or TIE). Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov --- linux-user/elfload.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'linux-user/elfload.c') diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5fc130cc20..fe7a5bc566 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1341,6 +1341,64 @@ static inline void init_thread(struct target_pt_regs *regs, #endif /* TARGET_HPPA */ +#ifdef TARGET_XTENSA + +#define ELF_START_MMAP 0x20000000 + +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_XTENSA + +static inline void init_thread(struct target_pt_regs *regs, + struct image_info *infop) +{ + regs->windowbase = 0; + regs->windowstart = 1; + regs->areg[1] = infop->start_stack; + regs->pc = infop->entry; +} + +/* See linux kernel: arch/xtensa/include/asm/elf.h. */ +#define ELF_NREG 128 +typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG]; + +enum { + TARGET_REG_PC, + TARGET_REG_PS, + TARGET_REG_LBEG, + TARGET_REG_LEND, + TARGET_REG_LCOUNT, + TARGET_REG_SAR, + TARGET_REG_WINDOWSTART, + TARGET_REG_WINDOWBASE, + TARGET_REG_THREADPTR, + TARGET_REG_AR0 = 64, +}; + +static void elf_core_copy_regs(target_elf_gregset_t *regs, + const CPUXtensaState *env) +{ + unsigned i; + + (*regs)[TARGET_REG_PC] = tswapreg(env->pc); + (*regs)[TARGET_REG_PS] = tswapreg(env->sregs[PS] & ~PS_EXCM); + (*regs)[TARGET_REG_LBEG] = tswapreg(env->sregs[LBEG]); + (*regs)[TARGET_REG_LEND] = tswapreg(env->sregs[LEND]); + (*regs)[TARGET_REG_LCOUNT] = tswapreg(env->sregs[LCOUNT]); + (*regs)[TARGET_REG_SAR] = tswapreg(env->sregs[SAR]); + (*regs)[TARGET_REG_WINDOWSTART] = tswapreg(env->sregs[WINDOW_START]); + (*regs)[TARGET_REG_WINDOWBASE] = tswapreg(env->sregs[WINDOW_BASE]); + (*regs)[TARGET_REG_THREADPTR] = tswapreg(env->uregs[THREADPTR]); + xtensa_sync_phys_from_window((CPUXtensaState *)env); + for (i = 0; i < env->config->nareg; ++i) { + (*regs)[TARGET_REG_AR0 + i] = tswapreg(env->phys_regs[i]); + } +} + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#endif /* TARGET_XTENSA */ + #ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL) #endif -- cgit v1.2.1