提交 388bb21a 编写于 作者: T ths

MIPS linux-user update.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2810 c046a42c-6fe2-441c-8c8c-71466251a162
上级 29929e34
......@@ -287,7 +287,11 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
#define elf_check_arch(x) ( (x) == EM_MIPS )
#ifdef TARGET_MIPS64
#define ELF_CLASS ELFCLASS64
#else
#define ELF_CLASS ELFCLASS32
#endif
#ifdef TARGET_WORDS_BIGENDIAN
#define ELF_DATA ELFDATA2MSB
#else
......@@ -302,6 +306,9 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
regs->regs[29] = infop->start_stack;
}
#define USE_ELF_CORE_DUMP
#define ELF_EXEC_PAGESIZE 4096
#endif /* TARGET_MIPS */
#ifdef TARGET_SH4
......
......@@ -1312,9 +1312,41 @@ static const uint8_t mips_syscall_args[] = {
MIPS_SYS(sys_waitid , 4)
MIPS_SYS(sys_ni_syscall , 0) /* available, was setaltroot */
MIPS_SYS(sys_add_key , 5)
MIPS_SYS(sys_request_key , 4)
MIPS_SYS(sys_request_key, 4)
MIPS_SYS(sys_keyctl , 5)
MIPS_SYS(sys_set_thread_area, 1)
MIPS_SYS(sys_inotify_init, 0)
MIPS_SYS(sys_inotify_add_watch, 3) /* 4285 */
MIPS_SYS(sys_inotify_rm_watch, 2)
MIPS_SYS(sys_migrate_pages, 4)
MIPS_SYS(sys_openat, 4)
MIPS_SYS(sys_mkdirat, 3)
MIPS_SYS(sys_mknodat, 4) /* 4290 */
MIPS_SYS(sys_fchownat, 5)
MIPS_SYS(sys_futimesat, 3)
MIPS_SYS(sys_fstatat64, 4)
MIPS_SYS(sys_unlinkat, 3)
MIPS_SYS(sys_renameat, 4) /* 4295 */
MIPS_SYS(sys_linkat, 5)
MIPS_SYS(sys_symlinkat, 3)
MIPS_SYS(sys_readlinkat, 4)
MIPS_SYS(sys_fchmodat, 3)
MIPS_SYS(sys_faccessat, 3) /* 4300 */
MIPS_SYS(sys_pselect6, 6)
MIPS_SYS(sys_ppoll, 5)
MIPS_SYS(sys_unshare, 1)
MIPS_SYS(sys_splice, 4)
MIPS_SYS(sys_sync_file_range, 7) /* 4305 */
MIPS_SYS(sys_tee, 4)
MIPS_SYS(sys_vmsplice, 4)
MIPS_SYS(sys_move_pages, 6)
MIPS_SYS(sys_set_robust_list, 2)
MIPS_SYS(sys_get_robust_list, 3) /* 4310 */
MIPS_SYS(sys_kexec_load, 4)
MIPS_SYS(sys_getcpu, 3)
MIPS_SYS(sys_epoll_pwait, 6)
MIPS_SYS(sys_ioprio_set, 3)
MIPS_SYS(sys_ioprio_get, 2)
};
#undef MIPS_SYS
......@@ -1322,53 +1354,45 @@ static const uint8_t mips_syscall_args[] = {
void cpu_loop(CPUMIPSState *env)
{
target_siginfo_t info;
int trapnr, ret, nb_args;
int trapnr, ret;
unsigned int syscall_num;
target_ulong arg5, arg6, sp_reg;
for(;;) {
trapnr = cpu_mips_exec(env);
switch(trapnr) {
case EXCP_SYSCALL:
{
syscall_num = env->gpr[2] - 4000;
env->PC += 4;
if (syscall_num >= sizeof(mips_syscall_args)) {
ret = -ENOSYS;
} else {
nb_args = mips_syscall_args[syscall_num];
if (nb_args >= 5) {
sp_reg = env->gpr[29];
/* these arguments are taken from the stack */
arg5 = tgetl(sp_reg + 16);
if (nb_args >= 6) {
arg6 = tgetl(sp_reg + 20);
} else {
arg6 = 0;
}
} else {
arg5 = 0;
arg6 = 0;
}
ret = do_syscall(env,
env->gpr[2],
env->gpr[4],
env->gpr[5],
env->gpr[6],
env->gpr[7],
arg5,
arg6);
}
if ((unsigned int)ret >= (unsigned int)(-1133)) {
env->gpr[7] = 1; /* error flag */
ret = -ret;
env->gpr[0] = ret;
env->gpr[2] = ret;
} else {
env->gpr[7] = 0; /* error flag */
env->gpr[2] = ret;
syscall_num = env->gpr[2] - 4000;
env->PC += 4;
if (syscall_num >= sizeof(mips_syscall_args)) {
ret = -ENOSYS;
} else {
int nb_args;
target_ulong sp_reg;
target_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
nb_args = mips_syscall_args[syscall_num];
sp_reg = env->gpr[29];
switch (nb_args) {
/* these arguments are taken from the stack */
case 8: arg8 = tgetl(sp_reg + 28);
case 7: arg7 = tgetl(sp_reg + 24);
case 6: arg6 = tgetl(sp_reg + 20);
case 5: arg5 = tgetl(sp_reg + 16);
default:
break;
}
ret = do_syscall(env, env->gpr[2],
env->gpr[4], env->gpr[5],
env->gpr[6], env->gpr[7],
arg5, arg6/*, arg7, arg8*/);
}
if ((unsigned int)ret >= (unsigned int)(-1133)) {
env->gpr[7] = 1; /* error flag */
ret = -ret;
} else {
env->gpr[7] = 0; /* error flag */
}
env->gpr[2] = ret;
break;
case EXCP_TLBL:
case EXCP_TLBS:
......
此差异已折叠。
......@@ -432,17 +432,17 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (oact) {
oact->_sa_handler = tswapl(k->sa._sa_handler);
oact->sa_flags = tswapl(k->sa.sa_flags);
#if !defined(TARGET_MIPS)
oact->sa_restorer = tswapl(k->sa.sa_restorer);
#endif
#if !defined(TARGET_MIPS)
oact->sa_restorer = tswapl(k->sa.sa_restorer);
#endif
oact->sa_mask = k->sa.sa_mask;
}
if (act) {
k->sa._sa_handler = tswapl(act->_sa_handler);
k->sa.sa_flags = tswapl(act->sa_flags);
#if !defined(TARGET_MIPS)
k->sa.sa_restorer = tswapl(act->sa_restorer);
#endif
#if !defined(TARGET_MIPS)
k->sa.sa_restorer = tswapl(act->sa_restorer);
#endif
k->sa.sa_mask = act->sa_mask;
/* we update the host linux signal state */
......@@ -1684,8 +1684,8 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __put_user(regs->PC, &sc->sc_pc);
#define save_gp_reg(i) do { \
err |= __put_user(regs->gpr[i], &sc->sc_regs[i]); \
#define save_gp_reg(i) do { \
err |= __put_user(regs->gpr[i], &sc->sc_regs[i]); \
} while(0)
__put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
......@@ -1696,7 +1696,7 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
save_gp_reg(31);
#undef save_gp_reg
#undef save_gp_reg
err |= __put_user(regs->HI, &sc->sc_mdhi);
err |= __put_user(regs->LO, &sc->sc_mdlo);
......@@ -1713,7 +1713,7 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
}
/* same with 64 bit */
#ifdef CONFIG_64BIT
#ifdef CONFIG_64BIT
err |= __put_user(regs->hi, &sc->sc_hi[0]);
err |= __put_user(regs->lo, &sc->sc_lo[0]);
if (cpu_has_dsp) {
......@@ -1725,13 +1725,10 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __put_user(mflo3(), &sc->sc_lo[3]);
err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
}
#endif
#endif
#endif
#endif
#if 0
#if 0
err |= __put_user(!!used_math(), &sc->sc_used_math);
if (!used_math())
......@@ -1765,7 +1762,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __get_user(regs->HI, &sc->sc_mdhi);
err |= __get_user(regs->LO, &sc->sc_mdlo);
#define restore_gp_reg(i) do { \
#define restore_gp_reg(i) do { \
err |= __get_user(regs->gpr[i], &sc->sc_regs[i]); \
} while(0)
restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
......@@ -1779,7 +1776,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
restore_gp_reg(31);
#undef restore_gp_reg
#undef restore_gp_reg
#if 0
if (cpu_has_dsp) {
......@@ -1791,7 +1788,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
}
#ifdef CONFIG_64BIT
#ifdef CONFIG_64BIT
err |= __get_user(regs->hi, &sc->sc_hi[0]);
err |= __get_user(regs->lo, &sc->sc_lo[0]);
if (cpu_has_dsp) {
......@@ -1803,7 +1800,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __get_user(treg, &sc->sc_lo[3]); mthi3(treg);
err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
}
#endif
#endif
err |= __get_user(used_math, &sc->sc_used_math);
conditional_used_math(used_math);
......@@ -1898,51 +1895,50 @@ give_sigsegv:
long do_sigreturn(CPUState *regs)
{
struct sigframe *frame;
sigset_t blocked;
target_sigset_t target_set;
int i;
struct sigframe *frame;
sigset_t blocked;
target_sigset_t target_set;
int i;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_sigreturn\n");
fprintf(stderr, "do_sigreturn\n");
#endif
frame = (struct sigframe *) regs->gpr[29];
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
frame = (struct sigframe *) regs->gpr[29];
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
goto badframe;
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if(__get_user(target_set.sig[i], &frame->sf_mask.sig[i]))
goto badframe;
}
}
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
if (restore_sigcontext(regs, &frame->sf_sc))
if (restore_sigcontext(regs, &frame->sf_sc))
goto badframe;
#if 0
/*
* Don't let your children do this ...
*/
__asm__ __volatile__(
/*
* Don't let your children do this ...
*/
__asm__ __volatile__(
"move\t$29, %0\n\t"
"j\tsyscall_exit"
:/* no outputs */
:"r" (&regs));
/* Unreached */
/* Unreached */
#endif
regs->PC = regs->CP0_EPC;
/* I am not sure this is right, but it seems to work
/* I am not sure this is right, but it seems to work
* maybe a problem with nested signals ? */
regs->CP0_EPC = 0;
return 0;
badframe:
force_sig(TARGET_SIGSEGV/*, current*/);
return 0;
force_sig(TARGET_SIGSEGV/*, current*/);
return 0;
}
static void setup_rt_frame(int sig, struct emulated_sigaction *ka,
......@@ -2070,5 +2066,3 @@ void process_pending_signals(void *cpu_env)
if (q != &k->info)
free_sigqueue(q);
}
......@@ -1750,7 +1750,9 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp)
new_env->dregs[0] = 0;
/* ??? is this sufficient? */
#elif defined(TARGET_MIPS)
printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
if (!newsp)
newsp = env->gpr[29];
new_env->gpr[29] = newsp;
#elif defined(TARGET_PPC)
if (!newsp)
newsp = env->gpr[1];
......@@ -2429,7 +2431,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
#if !defined(TARGET_MIPS)
#if !defined(TARGET_MIPS)
struct target_old_sigaction *old_act;
struct target_sigaction act, oact, *pact;
if (arg2) {
......@@ -2452,7 +2454,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
old_act->sa_restorer = oact.sa_restorer;
unlock_user_struct(old_act, arg3, 1);
}
#else
#else
struct target_sigaction act, oact, *pact, *old_act;
if (arg2) {
......@@ -2478,7 +2480,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
old_act->sa_mask.sig[3] = 0;
unlock_user_struct(old_act, arg3, 1);
}
#endif
#endif
}
break;
#endif
......
......@@ -372,5 +372,6 @@ enum {
int cpu_mips_exec(CPUMIPSState *s);
CPUMIPSState *cpu_mips_init(void);
uint32_t cpu_mips_get_clock (void);
int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
#endif /* !defined (__MIPS_CPU_H__) */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册