MIPS linux-user update.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2810 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
ths 2007-05-13 13:58:00 +00:00
parent 29929e3490
commit 388bb21af6
6 changed files with 321 additions and 261 deletions

View File

@ -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

View File

@ -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 {
int nb_args;
target_ulong sp_reg;
target_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
nb_args = mips_syscall_args[syscall_num];
if (nb_args >= 5) {
sp_reg = env->gpr[29];
switch (nb_args) {
/* these arguments are taken from the stack */
arg5 = tgetl(sp_reg + 16);
if (nb_args >= 6) {
arg6 = tgetl(sp_reg + 20);
} else {
arg6 = 0;
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;
}
} 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);
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;
env->gpr[0] = ret;
env->gpr[2] = ret;
} else {
env->gpr[7] = 0; /* error flag */
}
env->gpr[2] = ret;
}
}
break;
case EXCP_TLBL:
case EXCP_TLBS:

View File

@ -286,3 +286,35 @@
#define TARGET_NR_request_key (TARGET_NR_Linux + 281)
#define TARGET_NR_keyctl (TARGET_NR_Linux + 282)
#define TARGET_NR_set_thread_area (TARGET_NR_Linux + 283)
#define TARGET_NR_inotify_init (TARGET_NR_Linux + 284)
#define TARGET_NR_inotify_add_watch (TARGET_NR_Linux + 285)
#define TARGET_NR_inotify_rm_watch (TARGET_NR_Linux + 286)
#define TARGET_NR_migrate_pages (TARGET_NR_Linux + 287)
#define TARGET_NR_openat (TARGET_NR_Linux + 288)
#define TARGET_NR_mkdirat (TARGET_NR_Linux + 289)
#define TARGET_NR_mknodat (TARGET_NR_Linux + 290)
#define TARGET_NR_fchownat (TARGET_NR_Linux + 291)
#define TARGET_NR_futimesat (TARGET_NR_Linux + 292)
#define TARGET_NR_fstatat64 (TARGET_NR_Linux + 293)
#define TARGET_NR_unlinkat (TARGET_NR_Linux + 294)
#define TARGET_NR_renameat (TARGET_NR_Linux + 295)
#define TARGET_NR_linkat (TARGET_NR_Linux + 296)
#define TARGET_NR_symlinkat (TARGET_NR_Linux + 297)
#define TARGET_NR_readlinkat (TARGET_NR_Linux + 298)
#define TARGET_NR_fchmodat (TARGET_NR_Linux + 299)
#define TARGET_NR_faccessat (TARGET_NR_Linux + 300)
#define TARGET_NR_pselect6 (TARGET_NR_Linux + 301)
#define TARGET_NR_ppoll (TARGET_NR_Linux + 302)
#define TARGET_NR_unshare (TARGET_NR_Linux + 303)
#define TARGET_NR_splice (TARGET_NR_Linux + 304)
#define TARGET_NR_sync_file_range (TARGET_NR_Linux + 305)
#define TARGET_NR_tee (TARGET_NR_Linux + 306)
#define TARGET_NR_vmsplice (TARGET_NR_Linux + 307)
#define TARGET_NR_move_pages (TARGET_NR_Linux + 308)
#define TARGET_NR_set_robust_list (TARGET_NR_Linux + 309)
#define TARGET_NR_get_robust_list (TARGET_NR_Linux + 310)
#define TARGET_NR_kexec_load (TARGET_NR_Linux + 311)
#define TARGET_NR_getcpu (TARGET_NR_Linux + 312)
#define TARGET_NR_epoll_pwait (TARGET_NR_Linux + 313)
#define TARGET_NR_ioprio_set (TARGET_NR_Linux + 314)
#define TARGET_NR_ioprio_get (TARGET_NR_Linux + 315)

View File

@ -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)
#if !defined(TARGET_MIPS)
oact->sa_restorer = tswapl(k->sa.sa_restorer);
#endif
#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)
#if !defined(TARGET_MIPS)
k->sa.sa_restorer = tswapl(act->sa_restorer);
#endif
#endif
k->sa.sa_mask = act->sa_mask;
/* we update the host linux signal state */
@ -1684,7 +1684,7 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
err |= __put_user(regs->PC, &sc->sc_pc);
#define save_gp_reg(i) do { \
#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);
@ -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);
@ -1942,7 +1939,6 @@ long do_sigreturn(CPUState *regs)
badframe:
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);
}

View File

@ -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

View File

@ -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__) */