Merge branch 'elbrus' into e2k-bsd-user
This commit is contained in:
commit
30d478ff6f
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* E2K 32-bit specific prototypes for bsd-user
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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_ */
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* E2K CPU related code
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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"
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* E2K cpu init and loop
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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"
|
||||
#include "target_arch_elf.h"
|
||||
|
||||
#define TARGET_DEFAULT_CPU_MODEL "e8c"
|
||||
|
||||
// linux-user/e2k/cpu_loop.c:target_cpu_copy_regs
|
||||
static inline void target_cpu_init(CPUE2KState *env,
|
||||
struct target_pt_regs *regs)
|
||||
{
|
||||
CPUState *cpu = env_cpu(env);
|
||||
TaskState *ts = cpu->opaque;
|
||||
struct image_info *info = ts->info;
|
||||
uint32_t eflags = info->elf_flags;
|
||||
|
||||
env->psr = PSR_NMIE | PSR_SGE | PSR_IE;
|
||||
env->upsr = UPSR_NMIE | UPSR_IE | UPSR_FE;
|
||||
env->ip = regs->ip;
|
||||
env->pcsp = regs->pcsp;
|
||||
env->psp = regs->psp;
|
||||
env->usd.lo = regs->usd_lo;
|
||||
env->usd.hi = regs->usd_hi;
|
||||
env->sbr = regs->sbr;
|
||||
env->elf_flags = info->elf_flags;
|
||||
|
||||
// Save initial frame for gdb.
|
||||
env->is_bp = true;
|
||||
e2k_proc_call(env, env->wd.size, env->ip, true);
|
||||
|
||||
// TODO: set a chain info to return to kernel
|
||||
|
||||
if (eflags & E2K_ELF_PM) {
|
||||
fprintf(stderr, "Protected mode is unsupported\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (eflags & E2K_ELF_X86APP) {
|
||||
fprintf(stderr, "x86 recompiler is unsupported\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
static void gen_signal(CPUE2KState *env, int signo, int code, abi_ulong addr)
|
||||
{
|
||||
target_siginfo_t info = {
|
||||
.si_signo = signo,
|
||||
.si_code = code,
|
||||
.si_addr = addr,
|
||||
// TODO: ._sifields._sigfault._trapno = trapnr
|
||||
};
|
||||
|
||||
queue_signal(env, signo, &info);
|
||||
}
|
||||
|
||||
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) {
|
||||
case EXCP_SYSCALL: {
|
||||
abi_ullong args[E2K_SYSCALL_MAX_ARGS] = { 0 };
|
||||
int i, psize = MIN(E2K_SYSCALL_MAX_ARGS, env->wd.size);
|
||||
abi_ulong ret;
|
||||
|
||||
// TODO: check what happens if env->wd.size is zero
|
||||
for (i = 0; i < psize; i++) {
|
||||
args[i] = env->regs[i].lo;
|
||||
}
|
||||
|
||||
ret = do_freebsd_syscall(env, args[0], args[1], args[2], args[3],
|
||||
args[4], args[5], args[6], args[7], args[8]);
|
||||
|
||||
if (ret == -TARGET_ERESTARTSYS) {
|
||||
/* do not set sysret address and syscall will be restarted */
|
||||
// TODO: Was it correct to replace TARGET_QEMU_ESIGRETURN with TARGET_EJUSTRETURN ?
|
||||
//} else if (ret != -TARGET_QEMU_ESIGRETURN && env->wd.psize > 0) {
|
||||
} else if (ret != -TARGET_EJUSTRETURN && env->wd.psize > 0) {
|
||||
memset(env->tags, E2K_TAG_NON_NUMBER64,
|
||||
psize * sizeof(env->tags[0]));
|
||||
|
||||
env->regs[0].lo = ret;
|
||||
env->tags[0] = E2K_TAG_NUMBER64;
|
||||
env->ip = E2K_SYSRET_ADDR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EXCP_DATA_PAGE:
|
||||
gen_signal(env, TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->ip);
|
||||
break;
|
||||
|
||||
case EXCP_INTERRUPT:
|
||||
/* just indicate that signals should be handled asap */
|
||||
break;
|
||||
|
||||
case EXCP_DEBUG:
|
||||
env->is_bp = true;
|
||||
e2k_proc_call(env, env->wd.size, env->ip, true);
|
||||
gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, 0);
|
||||
break;
|
||||
|
||||
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)
|
||||
{
|
||||
assert(0 && "target_cpu_clone_regs not implemented yet");
|
||||
}
|
||||
|
||||
static inline void target_cpu_set_tls(CPUE2KState *env, target_ulong newtls)
|
||||
{
|
||||
// According to docs, g13 register is used for TLS pointer
|
||||
assert(0 && "target_cpu_set_tls not implemented yet");
|
||||
}
|
||||
|
||||
|
||||
#endif /* !_TARGET_ARCH_CPU_H */
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* E2K ELF definitions
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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 || (x) == EM_E2K_OLD)
|
||||
#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
|
||||
|
||||
#define E2K_ELF_IPD_MASK ((1U << 1)|(1U << 0))
|
||||
#define E2K_ELF_X86APP (1U << 2)
|
||||
#define E2K_ELF_4MB_PAGES (1U << 3)
|
||||
#define E2K_ELF_INCOMPAT (1U << 4)
|
||||
#define E2K_ELF_PM (1U << 5)
|
||||
|
||||
#endif /* _TARGET_ARCH_ELF_H_ */
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* E2K register structures
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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_ */
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* E2K signal definitions
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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 */
|
||||
|
||||
/* TODO: Size of the signal trampolin code placed on the stack. */
|
||||
#define TARGET_SZSIGCODE 0
|
||||
|
||||
#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_ */
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* E2K sigcode for bsd-user
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* _TARGET_ARCH_SIGTRAMP_H_ */
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* E2K sysarch() system call emulation
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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_ */
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* E2K thread support
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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 abi_ulong e2k_mmap(abi_ulong size)
|
||||
{
|
||||
abi_ulong addr;
|
||||
abi_ulong guard = TARGET_PAGE_SIZE;
|
||||
|
||||
if (size < TARGET_PAGE_SIZE) {
|
||||
size = TARGET_PAGE_SIZE;
|
||||
}
|
||||
if (guard < qemu_real_host_page_size) {
|
||||
guard = qemu_real_host_page_size;
|
||||
}
|
||||
|
||||
addr = target_mmap(0, size + guard, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (addr == -1) {
|
||||
perror("mmap e2k stack");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
target_mprotect(addr + size, guard, PROT_NONE);
|
||||
return addr;
|
||||
}
|
||||
|
||||
// compare to linux-user/elfload.c:init_thread for e2k
|
||||
static inline void target_thread_init(struct target_pt_regs *regs,
|
||||
struct image_info *infop)
|
||||
{
|
||||
abi_ulong start_stack = infop->start_stack & ~0xf;
|
||||
|
||||
regs->ip = infop->entry;
|
||||
|
||||
// FIXME: set real start stack address
|
||||
// regs->sbr = infop->arg_strings & ~0xf;
|
||||
regs->sbr = 0;
|
||||
regs->usd_lo = (0x1800UL << 48) | start_stack;
|
||||
regs->usd_hi = (regs->sbr - start_stack) << 32;
|
||||
|
||||
e2k_psp_new(®s->pcsp, E2K_DEFAULT_PCS_SIZE, false);
|
||||
e2k_psp_new(®s->psp, E2K_DEFAULT_PS_SIZE, true);
|
||||
}
|
||||
|
||||
#endif /* !_TARGET_ARCH_THREAD_H_ */
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* E2K VM parameters definitions
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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)
|
||||
|
||||
// see linux-user/e2k/target_cpu.h:get_sp_from_cpustate
|
||||
static inline abi_ulong get_sp_from_cpustate(CPUE2KState *state)
|
||||
{
|
||||
return state->usd.base;
|
||||
}
|
||||
|
||||
static inline void set_second_rval(CPUE2KState *state, abi_ulong retval2)
|
||||
{
|
||||
assert(0 && "set_second_rval not implemented yet");
|
||||
}
|
||||
|
||||
#endif /* !_TARGET_ARCH_VMPARAM_H_ */
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* E2K system call definitions
|
||||
*
|
||||
* Copyright (c) 2021 Gleb Popov <arrowd@freebsd.org>
|
||||
*
|
||||
* 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_ */
|
|
@ -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
|
Loading…
Reference in New Issue