r1979 - in trunk/src/host/qemu-neo1973: . hw linux-user linux-user/mips target-i386 target-mips target-sh4

andrew at sita.openmoko.org andrew at sita.openmoko.org
Wed May 16 21:51:06 CEST 2007


Author: andrew
Date: 2007-05-16 21:50:58 +0200 (Wed, 16 May 2007)
New Revision: 1979

Modified:
   trunk/src/host/qemu-neo1973/Makefile.target
   trunk/src/host/qemu-neo1973/configure
   trunk/src/host/qemu-neo1973/cpu-exec.c
   trunk/src/host/qemu-neo1973/exec-all.h
   trunk/src/host/qemu-neo1973/gdbstub.c
   trunk/src/host/qemu-neo1973/hw/vga.c
   trunk/src/host/qemu-neo1973/hw/vga_int.h
   trunk/src/host/qemu-neo1973/hw/vmware_vga.c
   trunk/src/host/qemu-neo1973/linux-user/elfload.c
   trunk/src/host/qemu-neo1973/linux-user/main.c
   trunk/src/host/qemu-neo1973/linux-user/mips/syscall_nr.h
   trunk/src/host/qemu-neo1973/linux-user/signal.c
   trunk/src/host/qemu-neo1973/linux-user/syscall.c
   trunk/src/host/qemu-neo1973/target-i386/helper.c
   trunk/src/host/qemu-neo1973/target-mips/cpu.h
   trunk/src/host/qemu-neo1973/target-mips/exec.h
   trunk/src/host/qemu-neo1973/target-mips/helper.c
   trunk/src/host/qemu-neo1973/target-mips/mips-defs.h
   trunk/src/host/qemu-neo1973/target-mips/op.c
   trunk/src/host/qemu-neo1973/target-mips/op_helper.c
   trunk/src/host/qemu-neo1973/target-mips/translate.c
   trunk/src/host/qemu-neo1973/target-mips/translate_init.c
   trunk/src/host/qemu-neo1973/target-sh4/op.c
   trunk/src/host/qemu-neo1973/target-sh4/translate.c
   trunk/src/host/qemu-neo1973/vl.c
Log:
Pull changes from cvs.savannah.nongnu.org.


Modified: trunk/src/host/qemu-neo1973/Makefile.target
===================================================================
--- trunk/src/host/qemu-neo1973/Makefile.target	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/Makefile.target	2007-05-16 19:50:58 UTC (rev 1979)
@@ -365,6 +365,7 @@
 # must use static linking to avoid leaving stuff in virtual address space
 VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o
 VL_OBJS+=cutils.o
+VL_OBJS+=host-utils.o
 VL_OBJS+=block.o block-raw.o
 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
 VL_OBJS+=irq.o

Modified: trunk/src/host/qemu-neo1973/configure
===================================================================
--- trunk/src/host/qemu-neo1973/configure	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/configure	2007-05-16 19:50:58 UTC (rev 1979)
@@ -158,6 +158,9 @@
             kqemu="yes"
         fi
     fi
+    if test -f /usr/include/sys/soundcard.h ; then
+        oss=yes
+    fi
 ;;
 *)
 oss="yes"
@@ -680,6 +683,7 @@
     fmod_support=""
 fi
 echo "FMOD support      $fmod $fmod_support"
+echo "OSS support       $oss"
 if test -n "$sparc_cpu"; then
     echo "Target Sparc Arch $sparc_cpu"
 fi

Modified: trunk/src/host/qemu-neo1973/cpu-exec.c
===================================================================
--- trunk/src/host/qemu-neo1973/cpu-exec.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/cpu-exec.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -1132,8 +1132,8 @@
     }
     if (ret == 1) {
 #if 0
-        printf("PF exception: NIP=0x%08x error=0x%x %p\n", 
-               env->nip, env->error_code, tb);
+        printf("PF exception: PC=0x" TARGET_FMT_lx " error=0x%x %p\n", 
+               env->PC, env->error_code, tb);
 #endif
     /* we restore the process signal mask as the sigreturn should
        do it (XXX: use sigsetjmp) */

Modified: trunk/src/host/qemu-neo1973/exec-all.h
===================================================================
--- trunk/src/host/qemu-neo1973/exec-all.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/exec-all.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -78,6 +78,9 @@
 extern FILE *logfile;
 extern int loglevel;
 
+void muls64(int64_t *phigh, int64_t *plow, int64_t a, int64_t b);
+void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);
+
 int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
 int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
 void dump_ops(const uint16_t *opc_buf, const uint32_t *opparam_buf);

Modified: trunk/src/host/qemu-neo1973/gdbstub.c
===================================================================
--- trunk/src/host/qemu-neo1973/gdbstub.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/gdbstub.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -657,6 +657,9 @@
       }
 }
 #elif defined (TARGET_SH4)
+
+/* Hint: Use "set architecture sh4" in GDB to see fpu registers */
+
 static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
 {
   uint32_t *ptr = (uint32_t *)mem_buf;
@@ -676,12 +679,14 @@
   SAVE (env->mach);
   SAVE (env->macl);
   SAVE (env->sr);
-  SAVE (0); /* TICKS */
-  SAVE (0); /* STALLS */
-  SAVE (0); /* CYCLES */
-  SAVE (0); /* INSTS */
-  SAVE (0); /* PLR */
-
+  SAVE (env->fpul);
+  SAVE (env->fpscr);
+  for (i = 0; i < 16; i++)
+      SAVE(env->fregs[i + ((env->fpscr & FPSCR_FR) ? 16 : 0)]);
+  SAVE (env->ssr);
+  SAVE (env->spc);
+  for (i = 0; i < 8; i++) SAVE(env->gregs[i]);
+  for (i = 0; i < 8; i++) SAVE(env->gregs[i + 16]);
   return ((uint8_t *)ptr - mem_buf);
 }
 
@@ -704,6 +709,14 @@
   LOAD (env->mach);
   LOAD (env->macl);
   LOAD (env->sr);
+  LOAD (env->fpul);
+  LOAD (env->fpscr);
+  for (i = 0; i < 16; i++)
+      LOAD(env->fregs[i + ((env->fpscr & FPSCR_FR) ? 16 : 0)]);
+  LOAD (env->ssr);
+  LOAD (env->spc);
+  for (i = 0; i < 8; i++) LOAD(env->gregs[i]);
+  for (i = 0; i < 8; i++) LOAD(env->gregs[i + 16]);
 }
 #else
 static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)

Modified: trunk/src/host/qemu-neo1973/hw/vga.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/vga.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/hw/vga.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -2036,8 +2036,8 @@
 {
 }
 
-static int ppm_save(const char *filename, uint8_t *data, 
-                    int w, int h, int linesize)
+int ppm_save(const char *filename, uint8_t *data, 
+             int w, int h, int linesize)
 {
     FILE *f;
     uint8_t *d, *d1;

Modified: trunk/src/host/qemu-neo1973/hw/vga_int.h
===================================================================
--- trunk/src/host/qemu-neo1973/hw/vga_int.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/hw/vga_int.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -166,6 +166,8 @@
 uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
 void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
 void vga_invalidate_scanlines(VGAState *s, int y1, int y2);
+int ppm_save(const char *filename, uint8_t *data, 
+             int w, int h, int linesize);
 
 void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, 
                             int poffset, int w, 

Modified: trunk/src/host/qemu-neo1973/hw/vmware_vga.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/vmware_vga.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/hw/vmware_vga.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -226,18 +226,19 @@
 #ifdef VERBOSE
 # define GUEST_OS_BASE		0x5001
 static const char *vmsvga_guest_id[] = {
-    [0x0] = "Dos",
-    [0x1] = "Windows 3.1",
-    [0x2] = "Windows 95",
-    [0x3] = "Windows 98",
-    [0x4] = "Windows ME",
-    [0x5] = "Windows NT",
-    [0x6] = "Windows 2000",
-    [0x7] = "Linux",
-    [0x8] = "OS/2",
-    [0x9] = "Unknown",
-    [0xa] = "BSD",
-    [0xb] = "Whistler",
+    [0x00 ... 0x15] = "an unknown OS",
+    [0x00] = "Dos",
+    [0x01] = "Windows 3.1",
+    [0x02] = "Windows 95",
+    [0x03] = "Windows 98",
+    [0x04] = "Windows ME",
+    [0x05] = "Windows NT",
+    [0x06] = "Windows 2000",
+    [0x07] = "Linux",
+    [0x08] = "OS/2",
+    [0x0a] = "BSD",
+    [0x0b] = "Whistler",
+    [0x15] = "Windows 2003",
 };
 #endif
 
@@ -459,7 +460,7 @@
 static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s)
 {
     if (!s->config || !s->enable)
-        return 0;
+        return 1;
     return (s->cmd->next_cmd == s->cmd->stop);
 }
 
@@ -619,7 +620,7 @@
         return SVGA_MAX_WIDTH;
 
     case SVGA_REG_MAX_HEIGHT:
-        return SVGA_MAX_WIDTH;
+        return SVGA_MAX_HEIGHT;
 
     case SVGA_REG_DEPTH:
         return s->depth;
@@ -727,7 +728,8 @@
         break;
 
     case SVGA_REG_ENABLE:
-        s->enable = s->config = value & s->config;
+        s->enable = value;
+        s->config &= !!value;
         s->width = -1;
         s->height = -1;
         s->invalidated = 1;
@@ -770,7 +772,7 @@
             if (s->cmd->max < s->cmd->min + 10 * 1024)
                 break;
         }
-        s->config = value;
+        s->config = !!value;
         break;
 
     case SVGA_REG_SYNC:
@@ -902,14 +904,14 @@
         s->wblue  = 0x0000f800;
         break;
     case 24:
-        s->wred   = 0x000000ff;
+        s->wred   = 0x00ff0000;
         s->wgreen = 0x0000ff00;
-        s->wblue  = 0x00ff0000;
+        s->wblue  = 0x000000ff;
         break;
     case 32:
-        s->wred   = 0x000000ff;
+        s->wred   = 0x00ff0000;
         s->wgreen = 0x0000ff00;
-        s->wblue  = 0x00ff0000;
+        s->wblue  = 0x000000ff;
         break;
     }
     s->syncing = 0;
@@ -928,6 +930,8 @@
     s->invalidated = 1;
 }
 
+/* save the vga display in a PPM image even if no display is
+   available */
 static void vmsvga_screen_dump(void *opaque, const char *filename)
 {
     struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
@@ -938,7 +942,9 @@
         return;
     }
 
-    /* TODO */
+    if (s->depth == 32) {
+        ppm_save(filename, s->vram, s->width, s->height, s->ds->linesize);
+    }
 }
 
 #ifdef DIRECT_VRAM

Modified: trunk/src/host/qemu-neo1973/linux-user/elfload.c
===================================================================
--- trunk/src/host/qemu-neo1973/linux-user/elfload.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/linux-user/elfload.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -287,7 +287,11 @@
 
 #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 @@
     regs->regs[29] = infop->start_stack;
 }
 
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE        4096
+
 #endif /* TARGET_MIPS */
 
 #ifdef TARGET_SH4

Modified: trunk/src/host/qemu-neo1973/linux-user/main.c
===================================================================
--- trunk/src/host/qemu-neo1973/linux-user/main.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/linux-user/main.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -1312,9 +1312,41 @@
 	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 @@
 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);
+            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;
                 }
-                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;
-                }
+                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:

Modified: trunk/src/host/qemu-neo1973/linux-user/mips/syscall_nr.h
===================================================================
--- trunk/src/host/qemu-neo1973/linux-user/mips/syscall_nr.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/linux-user/mips/syscall_nr.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -2,45 +2,45 @@
  * Linux o32 style syscalls are in the range from 4000 to 4999.
  */
 #define TARGET_NR_Linux			4000
-#define TARGET_NR_syscall			(TARGET_NR_Linux +   0)
+#define TARGET_NR_syscall		(TARGET_NR_Linux +   0)
 #define TARGET_NR_exit			(TARGET_NR_Linux +   1)
 #define TARGET_NR_fork			(TARGET_NR_Linux +   2)
 #define TARGET_NR_read			(TARGET_NR_Linux +   3)
 #define TARGET_NR_write			(TARGET_NR_Linux +   4)
 #define TARGET_NR_open			(TARGET_NR_Linux +   5)
 #define TARGET_NR_close			(TARGET_NR_Linux +   6)
-#define TARGET_NR_waitpid			(TARGET_NR_Linux +   7)
+#define TARGET_NR_waitpid		(TARGET_NR_Linux +   7)
 #define TARGET_NR_creat			(TARGET_NR_Linux +   8)
 #define TARGET_NR_link			(TARGET_NR_Linux +   9)
-#define TARGET_NR_unlink			(TARGET_NR_Linux +  10)
-#define TARGET_NR_execve			(TARGET_NR_Linux +  11)
+#define TARGET_NR_unlink		(TARGET_NR_Linux +  10)
+#define TARGET_NR_execve		(TARGET_NR_Linux +  11)
 #define TARGET_NR_chdir			(TARGET_NR_Linux +  12)
 #define TARGET_NR_time			(TARGET_NR_Linux +  13)
 #define TARGET_NR_mknod			(TARGET_NR_Linux +  14)
 #define TARGET_NR_chmod			(TARGET_NR_Linux +  15)
-#define TARGET_NR_lchown32			(TARGET_NR_Linux +  16)
+#define TARGET_NR_lchown32		(TARGET_NR_Linux +  16)
 #define TARGET_NR_break			(TARGET_NR_Linux +  17)
-#define TARGET_NR_unused18			(TARGET_NR_Linux +  18)
+#define TARGET_NR_unused18		(TARGET_NR_Linux +  18)
 #define TARGET_NR_lseek			(TARGET_NR_Linux +  19)
-#define TARGET_NR_getpid			(TARGET_NR_Linux +  20)
+#define TARGET_NR_getpid		(TARGET_NR_Linux +  20)
 #define TARGET_NR_mount			(TARGET_NR_Linux +  21)
-#define TARGET_NR_umount			(TARGET_NR_Linux +  22)
-#define TARGET_NR_setuid32			(TARGET_NR_Linux +  23)
-#define TARGET_NR_getuid32			(TARGET_NR_Linux +  24)
+#define TARGET_NR_umount		(TARGET_NR_Linux +  22)
+#define TARGET_NR_setuid32		(TARGET_NR_Linux +  23)
+#define TARGET_NR_getuid32		(TARGET_NR_Linux +  24)
 #define TARGET_NR_stime			(TARGET_NR_Linux +  25)
-#define TARGET_NR_ptrace			(TARGET_NR_Linux +  26)
+#define TARGET_NR_ptrace		(TARGET_NR_Linux +  26)
 #define TARGET_NR_alarm			(TARGET_NR_Linux +  27)
-#define TARGET_NR_unused28			(TARGET_NR_Linux +  28)
+#define TARGET_NR_unused28		(TARGET_NR_Linux +  28)
 #define TARGET_NR_pause			(TARGET_NR_Linux +  29)
 #define TARGET_NR_utime			(TARGET_NR_Linux +  30)
 #define TARGET_NR_stty			(TARGET_NR_Linux +  31)
 #define TARGET_NR_gtty			(TARGET_NR_Linux +  32)
-#define TARGET_NR_access			(TARGET_NR_Linux +  33)
+#define TARGET_NR_access		(TARGET_NR_Linux +  33)
 #define TARGET_NR_nice			(TARGET_NR_Linux +  34)
 #define TARGET_NR_ftime			(TARGET_NR_Linux +  35)
 #define TARGET_NR_sync			(TARGET_NR_Linux +  36)
 #define TARGET_NR_kill			(TARGET_NR_Linux +  37)
-#define TARGET_NR_rename			(TARGET_NR_Linux +  38)
+#define TARGET_NR_rename		(TARGET_NR_Linux +  38)
 #define TARGET_NR_mkdir			(TARGET_NR_Linux +  39)
 #define TARGET_NR_rmdir			(TARGET_NR_Linux +  40)
 #define TARGET_NR_dup			(TARGET_NR_Linux +  41)
@@ -48,241 +48,273 @@
 #define TARGET_NR_times			(TARGET_NR_Linux +  43)
 #define TARGET_NR_prof			(TARGET_NR_Linux +  44)
 #define TARGET_NR_brk			(TARGET_NR_Linux +  45)
-#define TARGET_NR_setgid32			(TARGET_NR_Linux +  46)
-#define TARGET_NR_getgid32			(TARGET_NR_Linux +  47)
-#define TARGET_NR_signal			(TARGET_NR_Linux +  48)
-#define TARGET_NR_geteuid32			(TARGET_NR_Linux +  49)
-#define TARGET_NR_getegid32			(TARGET_NR_Linux +  50)
+#define TARGET_NR_setgid32		(TARGET_NR_Linux +  46)
+#define TARGET_NR_getgid32		(TARGET_NR_Linux +  47)
+#define TARGET_NR_signal		(TARGET_NR_Linux +  48)
+#define TARGET_NR_geteuid32		(TARGET_NR_Linux +  49)
+#define TARGET_NR_getegid32		(TARGET_NR_Linux +  50)
 #define TARGET_NR_acct			(TARGET_NR_Linux +  51)
-#define TARGET_NR_umount2			(TARGET_NR_Linux +  52)
+#define TARGET_NR_umount2		(TARGET_NR_Linux +  52)
 #define TARGET_NR_lock			(TARGET_NR_Linux +  53)
 #define TARGET_NR_ioctl			(TARGET_NR_Linux +  54)
 #define TARGET_NR_fcntl			(TARGET_NR_Linux +  55)
 #define TARGET_NR_mpx			(TARGET_NR_Linux +  56)
-#define TARGET_NR_setpgid			(TARGET_NR_Linux +  57)
-#define TARGET_NR_ulimit			(TARGET_NR_Linux +  58)
-#define TARGET_NR_unused59			(TARGET_NR_Linux +  59)
+#define TARGET_NR_setpgid		(TARGET_NR_Linux +  57)
+#define TARGET_NR_ulimit		(TARGET_NR_Linux +  58)
+#define TARGET_NR_unused59		(TARGET_NR_Linux +  59)
 #define TARGET_NR_umask			(TARGET_NR_Linux +  60)
-#define TARGET_NR_chroot			(TARGET_NR_Linux +  61)
+#define TARGET_NR_chroot		(TARGET_NR_Linux +  61)
 #define TARGET_NR_ustat			(TARGET_NR_Linux +  62)
 #define TARGET_NR_dup2			(TARGET_NR_Linux +  63)
-#define TARGET_NR_getppid			(TARGET_NR_Linux +  64)
-#define TARGET_NR_getpgrp			(TARGET_NR_Linux +  65)
-#define TARGET_NR_setsid			(TARGET_NR_Linux +  66)
-#define TARGET_NR_sigaction			(TARGET_NR_Linux +  67)
-#define TARGET_NR_sgetmask			(TARGET_NR_Linux +  68)
-#define TARGET_NR_ssetmask			(TARGET_NR_Linux +  69)
-#define TARGET_NR_setreuid32			(TARGET_NR_Linux +  70)
-#define TARGET_NR_setregid32			(TARGET_NR_Linux +  71)
-#define TARGET_NR_sigsuspend			(TARGET_NR_Linux +  72)
-#define TARGET_NR_sigpending			(TARGET_NR_Linux +  73)
+#define TARGET_NR_getppid		(TARGET_NR_Linux +  64)
+#define TARGET_NR_getpgrp		(TARGET_NR_Linux +  65)
+#define TARGET_NR_setsid		(TARGET_NR_Linux +  66)
+#define TARGET_NR_sigaction		(TARGET_NR_Linux +  67)
+#define TARGET_NR_sgetmask		(TARGET_NR_Linux +  68)
+#define TARGET_NR_ssetmask		(TARGET_NR_Linux +  69)
+#define TARGET_NR_setreuid32		(TARGET_NR_Linux +  70)
+#define TARGET_NR_setregid32		(TARGET_NR_Linux +  71)
+#define TARGET_NR_sigsuspend		(TARGET_NR_Linux +  72)
+#define TARGET_NR_sigpending		(TARGET_NR_Linux +  73)
 #define TARGET_NR_sethostname		(TARGET_NR_Linux +  74)
-#define TARGET_NR_setrlimit			(TARGET_NR_Linux +  75)
-#define TARGET_NR_getrlimit			(TARGET_NR_Linux +  76)
-#define TARGET_NR_getrusage			(TARGET_NR_Linux +  77)
+#define TARGET_NR_setrlimit		(TARGET_NR_Linux +  75)
+#define TARGET_NR_getrlimit		(TARGET_NR_Linux +  76)
+#define TARGET_NR_getrusage		(TARGET_NR_Linux +  77)
 #define TARGET_NR_gettimeofday		(TARGET_NR_Linux +  78)
 #define TARGET_NR_settimeofday		(TARGET_NR_Linux +  79)
-#define TARGET_NR_getgroups32			(TARGET_NR_Linux +  80)
-#define TARGET_NR_setgroups32			(TARGET_NR_Linux +  81)
-#define TARGET_NR_reserved82			(TARGET_NR_Linux +  82)
-#define TARGET_NR_symlink			(TARGET_NR_Linux +  83)
-#define TARGET_NR_unused84			(TARGET_NR_Linux +  84)
-#define TARGET_NR_readlink			(TARGET_NR_Linux +  85)
-#define TARGET_NR_uselib			(TARGET_NR_Linux +  86)
-#define TARGET_NR_swapon			(TARGET_NR_Linux +  87)
-#define TARGET_NR_reboot			(TARGET_NR_Linux +  88)
-#define TARGET_NR_readdir			(TARGET_NR_Linux +  89)
+#define TARGET_NR_getgroups32		(TARGET_NR_Linux +  80)
+#define TARGET_NR_setgroups32		(TARGET_NR_Linux +  81)
+#define TARGET_NR_reserved82		(TARGET_NR_Linux +  82)
+#define TARGET_NR_symlink		(TARGET_NR_Linux +  83)
+#define TARGET_NR_unused84		(TARGET_NR_Linux +  84)
+#define TARGET_NR_readlink		(TARGET_NR_Linux +  85)
+#define TARGET_NR_uselib		(TARGET_NR_Linux +  86)
+#define TARGET_NR_swapon		(TARGET_NR_Linux +  87)
+#define TARGET_NR_reboot		(TARGET_NR_Linux +  88)
+#define TARGET_NR_readdir		(TARGET_NR_Linux +  89)
 #define TARGET_NR_mmap			(TARGET_NR_Linux +  90)
-#define TARGET_NR_munmap			(TARGET_NR_Linux +  91)
-#define TARGET_NR_truncate			(TARGET_NR_Linux +  92)
-#define TARGET_NR_ftruncate			(TARGET_NR_Linux +  93)
-#define TARGET_NR_fchmod			(TARGET_NR_Linux +  94)
-#define TARGET_NR_fchown32			(TARGET_NR_Linux +  95)
+#define TARGET_NR_munmap		(TARGET_NR_Linux +  91)
+#define TARGET_NR_truncate		(TARGET_NR_Linux +  92)
+#define TARGET_NR_ftruncate		(TARGET_NR_Linux +  93)
+#define TARGET_NR_fchmod		(TARGET_NR_Linux +  94)
+#define TARGET_NR_fchown32		(TARGET_NR_Linux +  95)
 #define TARGET_NR_getpriority		(TARGET_NR_Linux +  96)
 #define TARGET_NR_setpriority		(TARGET_NR_Linux +  97)
-#define TARGET_NR_profil			(TARGET_NR_Linux +  98)
-#define TARGET_NR_statfs			(TARGET_NR_Linux +  99)
-#define TARGET_NR_fstatfs			(TARGET_NR_Linux + 100)
-#define TARGET_NR_ioperm			(TARGET_NR_Linux + 101)
-#define TARGET_NR_socketcall			(TARGET_NR_Linux + 102)
-#define TARGET_NR_syslog			(TARGET_NR_Linux + 103)
-#define TARGET_NR_setitimer			(TARGET_NR_Linux + 104)
-#define TARGET_NR_getitimer			(TARGET_NR_Linux + 105)
+#define TARGET_NR_profil		(TARGET_NR_Linux +  98)
+#define TARGET_NR_statfs		(TARGET_NR_Linux +  99)
+#define TARGET_NR_fstatfs		(TARGET_NR_Linux + 100)
+#define TARGET_NR_ioperm		(TARGET_NR_Linux + 101)
+#define TARGET_NR_socketcall		(TARGET_NR_Linux + 102)
+#define TARGET_NR_syslog		(TARGET_NR_Linux + 103)
+#define TARGET_NR_setitimer		(TARGET_NR_Linux + 104)
+#define TARGET_NR_getitimer		(TARGET_NR_Linux + 105)
 #define TARGET_NR_stat			(TARGET_NR_Linux + 106)
 #define TARGET_NR_lstat			(TARGET_NR_Linux + 107)
 #define TARGET_NR_fstat			(TARGET_NR_Linux + 108)
-#define TARGET_NR_unused109			(TARGET_NR_Linux + 109)
+#define TARGET_NR_unused109		(TARGET_NR_Linux + 109)
 #define TARGET_NR_iopl			(TARGET_NR_Linux + 110)
-#define TARGET_NR_vhangup			(TARGET_NR_Linux + 111)
+#define TARGET_NR_vhangup		(TARGET_NR_Linux + 111)
 #define TARGET_NR_idle			(TARGET_NR_Linux + 112)
 #define TARGET_NR_vm86			(TARGET_NR_Linux + 113)
 #define TARGET_NR_wait4			(TARGET_NR_Linux + 114)
-#define TARGET_NR_swapoff			(TARGET_NR_Linux + 115)
-#define TARGET_NR_sysinfo			(TARGET_NR_Linux + 116)
+#define TARGET_NR_swapoff		(TARGET_NR_Linux + 115)
+#define TARGET_NR_sysinfo		(TARGET_NR_Linux + 116)
 #define TARGET_NR_ipc			(TARGET_NR_Linux + 117)
 #define TARGET_NR_fsync			(TARGET_NR_Linux + 118)
-#define TARGET_NR_sigreturn			(TARGET_NR_Linux + 119)
+#define TARGET_NR_sigreturn		(TARGET_NR_Linux + 119)
 #define TARGET_NR_clone			(TARGET_NR_Linux + 120)
 #define TARGET_NR_setdomainname		(TARGET_NR_Linux + 121)
 #define TARGET_NR_uname			(TARGET_NR_Linux + 122)
-#define TARGET_NR_modify_ldt			(TARGET_NR_Linux + 123)
-#define TARGET_NR_adjtimex			(TARGET_NR_Linux + 124)
-#define TARGET_NR_mprotect			(TARGET_NR_Linux + 125)
+#define TARGET_NR_modify_ldt		(TARGET_NR_Linux + 123)
+#define TARGET_NR_adjtimex		(TARGET_NR_Linux + 124)
+#define TARGET_NR_mprotect		(TARGET_NR_Linux + 125)
 #define TARGET_NR_sigprocmask		(TARGET_NR_Linux + 126)
 #define TARGET_NR_create_module		(TARGET_NR_Linux + 127)
 #define TARGET_NR_init_module		(TARGET_NR_Linux + 128)
 #define TARGET_NR_delete_module		(TARGET_NR_Linux + 129)
-#define TARGET_NR_get_kernel_syms		(TARGET_NR_Linux + 130)
-#define TARGET_NR_quotactl			(TARGET_NR_Linux + 131)
-#define TARGET_NR_getpgid			(TARGET_NR_Linux + 132)
-#define TARGET_NR_fchdir			(TARGET_NR_Linux + 133)
-#define TARGET_NR_bdflush			(TARGET_NR_Linux + 134)
+#define TARGET_NR_get_kernel_syms	(TARGET_NR_Linux + 130)
+#define TARGET_NR_quotactl		(TARGET_NR_Linux + 131)
+#define TARGET_NR_getpgid		(TARGET_NR_Linux + 132)
+#define TARGET_NR_fchdir		(TARGET_NR_Linux + 133)
+#define TARGET_NR_bdflush		(TARGET_NR_Linux + 134)
 #define TARGET_NR_sysfs			(TARGET_NR_Linux + 135)
 #define TARGET_NR_personality		(TARGET_NR_Linux + 136)
 #define TARGET_NR_afs_syscall		(TARGET_NR_Linux + 137) /* Syscall for Andrew File System */
-#define TARGET_NR_setfsuid32			(TARGET_NR_Linux + 138)
-#define TARGET_NR_setfsgid32			(TARGET_NR_Linux + 139)
-#define TARGET_NR__llseek			(TARGET_NR_Linux + 140)
-#define TARGET_NR_getdents			(TARGET_NR_Linux + 141)
-#define TARGET_NR__newselect			(TARGET_NR_Linux + 142)
+#define TARGET_NR_setfsuid32		(TARGET_NR_Linux + 138)
+#define TARGET_NR_setfsgid32		(TARGET_NR_Linux + 139)
+#define TARGET_NR__llseek		(TARGET_NR_Linux + 140)
+#define TARGET_NR_getdents		(TARGET_NR_Linux + 141)
+#define TARGET_NR__newselect		(TARGET_NR_Linux + 142)
 #define TARGET_NR_flock			(TARGET_NR_Linux + 143)
 #define TARGET_NR_msync			(TARGET_NR_Linux + 144)
 #define TARGET_NR_readv			(TARGET_NR_Linux + 145)
-#define TARGET_NR_writev			(TARGET_NR_Linux + 146)
-#define TARGET_NR_cacheflush			(TARGET_NR_Linux + 147)
-#define TARGET_NR_cachectl			(TARGET_NR_Linux + 148)
-#define TARGET_NR_sysmips			(TARGET_NR_Linux + 149)
-#define TARGET_NR_unused150			(TARGET_NR_Linux + 150)
-#define TARGET_NR_getsid			(TARGET_NR_Linux + 151)
-#define TARGET_NR_fdatasync			(TARGET_NR_Linux + 152)
-#define TARGET_NR__sysctl			(TARGET_NR_Linux + 153)
+#define TARGET_NR_writev		(TARGET_NR_Linux + 146)
+#define TARGET_NR_cacheflush		(TARGET_NR_Linux + 147)
+#define TARGET_NR_cachectl		(TARGET_NR_Linux + 148)
+#define TARGET_NR_sysmips		(TARGET_NR_Linux + 149)
+#define TARGET_NR_unused150		(TARGET_NR_Linux + 150)
+#define TARGET_NR_getsid		(TARGET_NR_Linux + 151)
+#define TARGET_NR_fdatasync		(TARGET_NR_Linux + 152)
+#define TARGET_NR__sysctl		(TARGET_NR_Linux + 153)
 #define TARGET_NR_mlock			(TARGET_NR_Linux + 154)
-#define TARGET_NR_munlock			(TARGET_NR_Linux + 155)
-#define TARGET_NR_mlockall			(TARGET_NR_Linux + 156)
-#define TARGET_NR_munlockall			(TARGET_NR_Linux + 157)
-#define TARGET_NR_sched_setparam		(TARGET_NR_Linux + 158)
-#define TARGET_NR_sched_getparam		(TARGET_NR_Linux + 159)
-#define TARGET_NR_sched_setscheduler		(TARGET_NR_Linux + 160)
-#define TARGET_NR_sched_getscheduler		(TARGET_NR_Linux + 161)
+#define TARGET_NR_munlock		(TARGET_NR_Linux + 155)
+#define TARGET_NR_mlockall		(TARGET_NR_Linux + 156)
+#define TARGET_NR_munlockall		(TARGET_NR_Linux + 157)
+#define TARGET_NR_sched_setparam	(TARGET_NR_Linux + 158)
+#define TARGET_NR_sched_getparam	(TARGET_NR_Linux + 159)
+#define TARGET_NR_sched_setscheduler	(TARGET_NR_Linux + 160)
+#define TARGET_NR_sched_getscheduler	(TARGET_NR_Linux + 161)
 #define TARGET_NR_sched_yield		(TARGET_NR_Linux + 162)
 #define TARGET_NR_sched_get_priority_max	(TARGET_NR_Linux + 163)
 #define TARGET_NR_sched_get_priority_min	(TARGET_NR_Linux + 164)
 #define TARGET_NR_sched_rr_get_interval	(TARGET_NR_Linux + 165)
-#define TARGET_NR_nanosleep			(TARGET_NR_Linux + 166)
-#define TARGET_NR_mremap			(TARGET_NR_Linux + 167)
-#define TARGET_NR_accept			(TARGET_NR_Linux + 168)
+#define TARGET_NR_nanosleep		(TARGET_NR_Linux + 166)
+#define TARGET_NR_mremap		(TARGET_NR_Linux + 167)
+#define TARGET_NR_accept		(TARGET_NR_Linux + 168)
 #define TARGET_NR_bind			(TARGET_NR_Linux + 169)
-#define TARGET_NR_connect			(TARGET_NR_Linux + 170)
+#define TARGET_NR_connect		(TARGET_NR_Linux + 170)
 #define TARGET_NR_getpeername		(TARGET_NR_Linux + 171)
 #define TARGET_NR_getsockname		(TARGET_NR_Linux + 172)
-#define TARGET_NR_getsockopt			(TARGET_NR_Linux + 173)
-#define TARGET_NR_listen			(TARGET_NR_Linux + 174)
+#define TARGET_NR_getsockopt		(TARGET_NR_Linux + 173)
+#define TARGET_NR_listen		(TARGET_NR_Linux + 174)
 #define TARGET_NR_recv			(TARGET_NR_Linux + 175)
-#define TARGET_NR_recvfrom			(TARGET_NR_Linux + 176)
-#define TARGET_NR_recvmsg			(TARGET_NR_Linux + 177)
+#define TARGET_NR_recvfrom		(TARGET_NR_Linux + 176)
+#define TARGET_NR_recvmsg		(TARGET_NR_Linux + 177)
 #define TARGET_NR_send			(TARGET_NR_Linux + 178)
-#define TARGET_NR_sendmsg			(TARGET_NR_Linux + 179)
-#define TARGET_NR_sendto			(TARGET_NR_Linux + 180)
-#define TARGET_NR_setsockopt			(TARGET_NR_Linux + 181)
-#define TARGET_NR_shutdown			(TARGET_NR_Linux + 182)
-#define TARGET_NR_socket			(TARGET_NR_Linux + 183)
-#define TARGET_NR_socketpair			(TARGET_NR_Linux + 184)
-#define TARGET_NR_setresuid32			(TARGET_NR_Linux + 185)
-#define TARGET_NR_getresuid32			(TARGET_NR_Linux + 186)
+#define TARGET_NR_sendmsg		(TARGET_NR_Linux + 179)
+#define TARGET_NR_sendto		(TARGET_NR_Linux + 180)
+#define TARGET_NR_setsockopt		(TARGET_NR_Linux + 181)
+#define TARGET_NR_shutdown		(TARGET_NR_Linux + 182)
+#define TARGET_NR_socket		(TARGET_NR_Linux + 183)
+#define TARGET_NR_socketpair		(TARGET_NR_Linux + 184)
+#define TARGET_NR_setresuid32		(TARGET_NR_Linux + 185)
+#define TARGET_NR_getresuid32		(TARGET_NR_Linux + 186)
 #define TARGET_NR_query_module		(TARGET_NR_Linux + 187)
 #define TARGET_NR_poll			(TARGET_NR_Linux + 188)
-#define TARGET_NR_nfsservctl			(TARGET_NR_Linux + 189)
-#define TARGET_NR_setresgid32			(TARGET_NR_Linux + 190)
-#define TARGET_NR_getresgid32			(TARGET_NR_Linux + 191)
+#define TARGET_NR_nfsservctl		(TARGET_NR_Linux + 189)
+#define TARGET_NR_setresgid32		(TARGET_NR_Linux + 190)
+#define TARGET_NR_getresgid32		(TARGET_NR_Linux + 191)
 #define TARGET_NR_prctl			(TARGET_NR_Linux + 192)
 #define TARGET_NR_rt_sigreturn		(TARGET_NR_Linux + 193)
 #define TARGET_NR_rt_sigaction		(TARGET_NR_Linux + 194)
-#define TARGET_NR_rt_sigprocmask		(TARGET_NR_Linux + 195)
+#define TARGET_NR_rt_sigprocmask	(TARGET_NR_Linux + 195)
 #define TARGET_NR_rt_sigpending		(TARGET_NR_Linux + 196)
-#define TARGET_NR_rt_sigtimedwait		(TARGET_NR_Linux + 197)
-#define TARGET_NR_rt_sigqueueinfo		(TARGET_NR_Linux + 198)
+#define TARGET_NR_rt_sigtimedwait	(TARGET_NR_Linux + 197)
+#define TARGET_NR_rt_sigqueueinfo	(TARGET_NR_Linux + 198)
 #define TARGET_NR_rt_sigsuspend		(TARGET_NR_Linux + 199)
-#define TARGET_NR_pread64			(TARGET_NR_Linux + 200)
-#define TARGET_NR_pwrite64			(TARGET_NR_Linux + 201)
-#define TARGET_NR_chown32			(TARGET_NR_Linux + 202)
-#define TARGET_NR_getcwd			(TARGET_NR_Linux + 203)
-#define TARGET_NR_capget			(TARGET_NR_Linux + 204)
-#define TARGET_NR_capset			(TARGET_NR_Linux + 205)
+#define TARGET_NR_pread64		(TARGET_NR_Linux + 200)
+#define TARGET_NR_pwrite64		(TARGET_NR_Linux + 201)
+#define TARGET_NR_chown32		(TARGET_NR_Linux + 202)
+#define TARGET_NR_getcwd		(TARGET_NR_Linux + 203)
+#define TARGET_NR_capget		(TARGET_NR_Linux + 204)
+#define TARGET_NR_capset		(TARGET_NR_Linux + 205)
 #define TARGET_NR_sigaltstack		(TARGET_NR_Linux + 206)
-#define TARGET_NR_sendfile			(TARGET_NR_Linux + 207)
-#define TARGET_NR_getpmsg			(TARGET_NR_Linux + 208)
-#define TARGET_NR_putpmsg			(TARGET_NR_Linux + 209)
+#define TARGET_NR_sendfile		(TARGET_NR_Linux + 207)
+#define TARGET_NR_getpmsg		(TARGET_NR_Linux + 208)
+#define TARGET_NR_putpmsg		(TARGET_NR_Linux + 209)
 #define TARGET_NR_mmap2			(TARGET_NR_Linux + 210)
-#define TARGET_NR_truncate64			(TARGET_NR_Linux + 211)
+#define TARGET_NR_truncate64		(TARGET_NR_Linux + 211)
 #define TARGET_NR_ftruncate64		(TARGET_NR_Linux + 212)
-#define TARGET_NR_stat64			(TARGET_NR_Linux + 213)
-#define TARGET_NR_lstat64			(TARGET_NR_Linux + 214)
-#define TARGET_NR_fstat64			(TARGET_NR_Linux + 215)
-#define TARGET_NR_pivot_root			(TARGET_NR_Linux + 216)
-#define TARGET_NR_mincore			(TARGET_NR_Linux + 217)
-#define TARGET_NR_madvise			(TARGET_NR_Linux + 218)
-#define TARGET_NR_getdents64			(TARGET_NR_Linux + 219)
-#define TARGET_NR_fcntl64			(TARGET_NR_Linux + 220)
+#define TARGET_NR_stat64		(TARGET_NR_Linux + 213)
+#define TARGET_NR_lstat64		(TARGET_NR_Linux + 214)
+#define TARGET_NR_fstat64		(TARGET_NR_Linux + 215)
+#define TARGET_NR_pivot_root		(TARGET_NR_Linux + 216)
+#define TARGET_NR_mincore		(TARGET_NR_Linux + 217)
+#define TARGET_NR_madvise		(TARGET_NR_Linux + 218)
+#define TARGET_NR_getdents64		(TARGET_NR_Linux + 219)
+#define TARGET_NR_fcntl64		(TARGET_NR_Linux + 220)
 #define TARGET_NR_reserved221		(TARGET_NR_Linux + 221)
-#define TARGET_NR_gettid			(TARGET_NR_Linux + 222)
-#define TARGET_NR_readahead			(TARGET_NR_Linux + 223)
-#define TARGET_NR_setxattr			(TARGET_NR_Linux + 224)
-#define TARGET_NR_lsetxattr			(TARGET_NR_Linux + 225)
-#define TARGET_NR_fsetxattr			(TARGET_NR_Linux + 226)
-#define TARGET_NR_getxattr			(TARGET_NR_Linux + 227)
-#define TARGET_NR_lgetxattr			(TARGET_NR_Linux + 228)
-#define TARGET_NR_fgetxattr			(TARGET_NR_Linux + 229)
-#define TARGET_NR_listxattr			(TARGET_NR_Linux + 230)
-#define TARGET_NR_llistxattr			(TARGET_NR_Linux + 231)
-#define TARGET_NR_flistxattr			(TARGET_NR_Linux + 232)
+#define TARGET_NR_gettid		(TARGET_NR_Linux + 222)
+#define TARGET_NR_readahead		(TARGET_NR_Linux + 223)
+#define TARGET_NR_setxattr		(TARGET_NR_Linux + 224)
+#define TARGET_NR_lsetxattr		(TARGET_NR_Linux + 225)
+#define TARGET_NR_fsetxattr		(TARGET_NR_Linux + 226)
+#define TARGET_NR_getxattr		(TARGET_NR_Linux + 227)
+#define TARGET_NR_lgetxattr		(TARGET_NR_Linux + 228)
+#define TARGET_NR_fgetxattr		(TARGET_NR_Linux + 229)
+#define TARGET_NR_listxattr		(TARGET_NR_Linux + 230)
+#define TARGET_NR_llistxattr		(TARGET_NR_Linux + 231)
+#define TARGET_NR_flistxattr		(TARGET_NR_Linux + 232)
 #define TARGET_NR_removexattr		(TARGET_NR_Linux + 233)
 #define TARGET_NR_lremovexattr		(TARGET_NR_Linux + 234)
 #define TARGET_NR_fremovexattr		(TARGET_NR_Linux + 235)
 #define TARGET_NR_tkill			(TARGET_NR_Linux + 236)
-#define TARGET_NR_sendfile64			(TARGET_NR_Linux + 237)
+#define TARGET_NR_sendfile64		(TARGET_NR_Linux + 237)
 #define TARGET_NR_futex			(TARGET_NR_Linux + 238)
-#define TARGET_NR_sched_setaffinity		(TARGET_NR_Linux + 239)
-#define TARGET_NR_sched_getaffinity		(TARGET_NR_Linux + 240)
-#define TARGET_NR_io_setup			(TARGET_NR_Linux + 241)
-#define TARGET_NR_io_destroy			(TARGET_NR_Linux + 242)
+#define TARGET_NR_sched_setaffinity	(TARGET_NR_Linux + 239)
+#define TARGET_NR_sched_getaffinity	(TARGET_NR_Linux + 240)
+#define TARGET_NR_io_setup		(TARGET_NR_Linux + 241)
+#define TARGET_NR_io_destroy		(TARGET_NR_Linux + 242)
 #define TARGET_NR_io_getevents		(TARGET_NR_Linux + 243)
-#define TARGET_NR_io_submit			(TARGET_NR_Linux + 244)
-#define TARGET_NR_io_cancel			(TARGET_NR_Linux + 245)
-#define TARGET_NR_exit_group			(TARGET_NR_Linux + 246)
-#define TARGET_NR_lookup_dcookie		(TARGET_NR_Linux + 247)
+#define TARGET_NR_io_submit		(TARGET_NR_Linux + 244)
+#define TARGET_NR_io_cancel		(TARGET_NR_Linux + 245)
+#define TARGET_NR_exit_group		(TARGET_NR_Linux + 246)
+#define TARGET_NR_lookup_dcookie	(TARGET_NR_Linux + 247)
 #define TARGET_NR_epoll_create		(TARGET_NR_Linux + 248)
-#define TARGET_NR_epoll_ctl			(TARGET_NR_Linux + 249)
-#define TARGET_NR_epoll_wait			(TARGET_NR_Linux + 250)
-#define TARGET_NR_remap_file_pages		(TARGET_NR_Linux + 251)
-#define TARGET_NR_set_tid_address		(TARGET_NR_Linux + 252)
-#define TARGET_NR_restart_syscall		(TARGET_NR_Linux + 253)
-#define TARGET_NR_fadvise64			(TARGET_NR_Linux + 254)
-#define TARGET_NR_statfs64			(TARGET_NR_Linux + 255)
-#define TARGET_NR_fstatfs64			(TARGET_NR_Linux + 256)
+#define TARGET_NR_epoll_ctl		(TARGET_NR_Linux + 249)
+#define TARGET_NR_epoll_wait		(TARGET_NR_Linux + 250)
+#define TARGET_NR_remap_file_pages	(TARGET_NR_Linux + 251)
+#define TARGET_NR_set_tid_address	(TARGET_NR_Linux + 252)
+#define TARGET_NR_restart_syscall	(TARGET_NR_Linux + 253)
+#define TARGET_NR_fadvise64		(TARGET_NR_Linux + 254)
+#define TARGET_NR_statfs64		(TARGET_NR_Linux + 255)
+#define TARGET_NR_fstatfs64		(TARGET_NR_Linux + 256)
 #define TARGET_NR_timer_create		(TARGET_NR_Linux + 257)
 #define TARGET_NR_timer_settime		(TARGET_NR_Linux + 258)
 #define TARGET_NR_timer_gettime		(TARGET_NR_Linux + 259)
-#define TARGET_NR_timer_getoverrun		(TARGET_NR_Linux + 260)
+#define TARGET_NR_timer_getoverrun	(TARGET_NR_Linux + 260)
 #define TARGET_NR_timer_delete		(TARGET_NR_Linux + 261)
 #define TARGET_NR_clock_settime		(TARGET_NR_Linux + 262)
 #define TARGET_NR_clock_gettime		(TARGET_NR_Linux + 263)
 #define TARGET_NR_clock_getres		(TARGET_NR_Linux + 264)
-#define TARGET_NR_clock_nanosleep		(TARGET_NR_Linux + 265)
-#define TARGET_NR_tgkill			(TARGET_NR_Linux + 266)
-#define TARGET_NR_utimes			(TARGET_NR_Linux + 267)
+#define TARGET_NR_clock_nanosleep	(TARGET_NR_Linux + 265)
+#define TARGET_NR_tgkill		(TARGET_NR_Linux + 266)
+#define TARGET_NR_utimes		(TARGET_NR_Linux + 267)
 #define TARGET_NR_mbind			(TARGET_NR_Linux + 268)
 #define TARGET_NR_get_mempolicy		(TARGET_NR_Linux + 269)
 #define TARGET_NR_set_mempolicy		(TARGET_NR_Linux + 270)
-#define TARGET_NR_mq_open			(TARGET_NR_Linux + 271)
-#define TARGET_NR_mq_unlink			(TARGET_NR_Linux + 272)
+#define TARGET_NR_mq_open		(TARGET_NR_Linux + 271)
+#define TARGET_NR_mq_unlink		(TARGET_NR_Linux + 272)
 #define TARGET_NR_mq_timedsend		(TARGET_NR_Linux + 273)
-#define TARGET_NR_mq_timedreceive		(TARGET_NR_Linux + 274)
-#define TARGET_NR_mq_notify			(TARGET_NR_Linux + 275)
+#define TARGET_NR_mq_timedreceive	(TARGET_NR_Linux + 274)
+#define TARGET_NR_mq_notify		(TARGET_NR_Linux + 275)
 #define TARGET_NR_mq_getsetattr		(TARGET_NR_Linux + 276)
-#define TARGET_NR_vserver			(TARGET_NR_Linux + 277)
-#define TARGET_NR_waitid			(TARGET_NR_Linux + 278)
-/* #define TARGET_NR_sys_setaltroot		(TARGET_NR_Linux + 279) */
-#define TARGET_NR_add_key			(TARGET_NR_Linux + 280)
+#define TARGET_NR_vserver		(TARGET_NR_Linux + 277)
+#define TARGET_NR_waitid		(TARGET_NR_Linux + 278)
+/* #define TARGET_NR_sys_setaltroot	(TARGET_NR_Linux + 279) */
+#define TARGET_NR_add_key		(TARGET_NR_Linux + 280)
 #define TARGET_NR_request_key		(TARGET_NR_Linux + 281)
-#define TARGET_NR_keyctl			(TARGET_NR_Linux + 282)
+#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)

Modified: trunk/src/host/qemu-neo1973/linux-user/signal.c
===================================================================
--- trunk/src/host/qemu-neo1973/linux-user/signal.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/linux-user/signal.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -432,17 +432,17 @@
     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 @@
 
     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 @@
     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 @@
 	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 @@
 	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 @@
     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_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 @@
 	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 @@
 	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 @@
 
 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 @@
     if (q != &k->info)
         free_sigqueue(q);
 }
-
-

Modified: trunk/src/host/qemu-neo1973/linux-user/syscall.c
===================================================================
--- trunk/src/host/qemu-neo1973/linux-user/syscall.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/linux-user/syscall.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -1750,7 +1750,9 @@
         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 @@
 #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 @@
                 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 @@
 		old_act->sa_mask.sig[3] = 0;
 		unlock_user_struct(old_act, arg3, 1);
 	    }
-	#endif
+#endif
         }
         break;
 #endif

Modified: trunk/src/host/qemu-neo1973/target-i386/helper.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-i386/helper.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-i386/helper.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -3620,50 +3620,6 @@
     add128(plow, phigh, 1, 0);
 }
 
-static void mul64(uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b)
-{
-    uint32_t a0, a1, b0, b1;
-    uint64_t v;
-
-    a0 = a;
-    a1 = a >> 32;
-
-    b0 = b;
-    b1 = b >> 32;
-    
-    v = (uint64_t)a0 * (uint64_t)b0;
-    *plow = v;
-    *phigh = 0;
-
-    v = (uint64_t)a0 * (uint64_t)b1;
-    add128(plow, phigh, v << 32, v >> 32);
-    
-    v = (uint64_t)a1 * (uint64_t)b0;
-    add128(plow, phigh, v << 32, v >> 32);
-    
-    v = (uint64_t)a1 * (uint64_t)b1;
-    *phigh += v;
-#ifdef DEBUG_MULDIV
-    printf("mul: 0x%016" PRIx64 " * 0x%016" PRIx64 " = 0x%016" PRIx64 "%016" PRIx64 "\n",
-           a, b, *phigh, *plow);
-#endif
-}
-
-static void imul64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b)
-{
-    int sa, sb;
-    sa = (a < 0);
-    if (sa)
-        a = -a;
-    sb = (b < 0);
-    if (sb)
-        b = -b;
-    mul64(plow, phigh, a, b);
-    if (sa ^ sb) {
-        neg128(plow, phigh);
-    }
-}
-
 /* return TRUE if overflow */
 static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
 {
@@ -3731,7 +3687,7 @@
 {
     uint64_t r0, r1;
 
-    mul64(&r0, &r1, EAX, T0);
+    mulu64(&r1, &r0, EAX, T0);
     EAX = r0;
     EDX = r1;
     CC_DST = r0;
@@ -3742,7 +3698,7 @@
 {
     uint64_t r0, r1;
 
-    imul64(&r0, &r1, EAX, T0);
+    muls64(&r1, &r0, EAX, T0);
     EAX = r0;
     EDX = r1;
     CC_DST = r0;
@@ -3753,7 +3709,7 @@
 {
     uint64_t r0, r1;
 
-    imul64(&r0, &r1, T0, T1);
+    muls64(&r1, &r0, T0, T1);
     T0 = r0;
     CC_DST = r0;
     CC_SRC = ((int64_t)r1 != ((int64_t)r0 >> 63));

Modified: trunk/src/host/qemu-neo1973/target-mips/cpu.h
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/cpu.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/cpu.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -33,9 +33,8 @@
 #  define FP_ENDIAN_IDX 0
 #endif
 
-#if defined(MIPS_USES_R4K_TLB)
-typedef struct tlb_t tlb_t;
-struct tlb_t {
+typedef struct r4k_tlb_t r4k_tlb_t;
+struct r4k_tlb_t {
     target_ulong VPN;
     uint32_t PageMask;
     uint_fast8_t ASID;
@@ -48,7 +47,6 @@
     uint_fast16_t D1:1;
     target_ulong PFN[2];
 };
-#endif
 
 typedef struct CPUMIPSState CPUMIPSState;
 struct CPUMIPSState {
@@ -100,11 +98,19 @@
 #define FP_INVALID        16
 #define FP_UNIMPLEMENTED  32
 
-#if defined(MIPS_USES_R4K_TLB)
-    tlb_t tlb[MIPS_TLB_MAX];
+    uint32_t nb_tlb;
     uint32_t tlb_in_use;
-    uint32_t nb_tlb;
-#endif
+    int (*map_address) (CPUMIPSState *env, target_ulong *physical, int *prot, target_ulong address, int rw, int access_type);
+    void (*do_tlbwi) (void);
+    void (*do_tlbwr) (void);
+    void (*do_tlbp) (void);
+    void (*do_tlbr) (void);
+    union {
+        struct {
+            r4k_tlb_t tlb[MIPS_TLB_MAX];
+        } r4k;
+    } mmu;
+
     int32_t CP0_Index;
     int32_t CP0_Random;
     target_ulong CP0_EntryLo0;
@@ -289,6 +295,16 @@
     struct QEMUTimer *timer; /* Internal timer */
 };
 
+int no_mmu_map_address (CPUMIPSState *env, target_ulong *physical, int *prot,
+                        target_ulong address, int rw, int access_type);
+int fixed_mmu_map_address (CPUMIPSState *env, target_ulong *physical, int *prot,
+                           target_ulong address, int rw, int access_type);
+int r4k_map_address (CPUMIPSState *env, target_ulong *physical, int *prot,
+                     target_ulong address, int rw, int access_type);
+void r4k_do_tlbwi (void);
+void r4k_do_tlbwr (void);
+void r4k_do_tlbp (void);
+void r4k_do_tlbr (void);
 typedef struct mips_def_t mips_def_t;
 int mips_find_by_name (const unsigned char *name, mips_def_t **def);
 void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
@@ -356,5 +372,6 @@
 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__) */

Modified: trunk/src/host/qemu-neo1973/target-mips/exec.h
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/exec.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/exec.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -97,18 +97,12 @@
 #if TARGET_LONG_BITS > HOST_LONG_BITS
 void do_ddivu (void);
 #endif
-void do_dmult (void);
-void do_dmultu (void);
 #endif
 void do_mfc0_random(void);
 void do_mfc0_count(void);
 void do_mtc0_entryhi(uint32_t in);
 void do_mtc0_status_debug(uint32_t old, uint32_t val);
 void do_mtc0_status_irqraise_debug(void);
-void do_tlbwi (void);
-void do_tlbwr (void);
-void do_tlbp (void);
-void do_tlbr (void);
 void dump_fpu(CPUState *env);
 void fpu_dump_state(CPUState *env, FILE *f, 
                     int (*fpu_fprintf)(FILE *f, const char *fmt, ...),
@@ -151,7 +145,7 @@
 int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
                                int is_user, int is_softmmu);
 void do_interrupt (CPUState *env);
-void invalidate_tlb (CPUState *env, int idx, int use_extra);
+void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra);
 
 void cpu_loop_exit(void);
 void do_raise_exception_err (uint32_t exception, int error_code);

Modified: trunk/src/host/qemu-neo1973/target-mips/helper.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/helper.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/helper.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -36,30 +36,58 @@
     TLBRET_MATCH = 0
 };
 
-/* MIPS32 4K MMU emulation */
-#ifdef MIPS_USES_R4K_TLB
-static int map_address (CPUState *env, target_ulong *physical, int *prot,
+/* no MMU emulation */
+int no_mmu_map_address (CPUState *env, target_ulong *physical, int *prot,
                         target_ulong address, int rw, int access_type)
 {
+    *physical = address;
+    *prot = PAGE_READ | PAGE_WRITE;
+    return TLBRET_MATCH;
+}
+
+/* fixed mapping MMU emulation */
+int fixed_mmu_map_address (CPUState *env, target_ulong *physical, int *prot,
+                           target_ulong address, int rw, int access_type)
+{
+    if (address <= (int32_t)0x7FFFFFFFUL) {
+        if (!(env->CP0_Status & (1 << CP0St_ERL)))
+            *physical = address + 0x40000000UL;
+        else
+            *physical = address;
+    } else if (address <= (int32_t)0xBFFFFFFFUL)
+        *physical = address & 0x1FFFFFFF;
+    else
+        *physical = address;
+
+    *prot = PAGE_READ | PAGE_WRITE;
+    return TLBRET_MATCH;
+}
+
+/* MIPS32/MIPS64 R4000-style MMU emulation */
+int r4k_map_address (CPUState *env, target_ulong *physical, int *prot,
+                     target_ulong address, int rw, int access_type)
+{
     uint8_t ASID = env->CP0_EntryHi & 0xFF;
     int i;
 
     for (i = 0; i < env->tlb_in_use; i++) {
-        tlb_t *tlb = &env->tlb[i];
+        r4k_tlb_t *tlb = &env->mmu.r4k.tlb[i];
         /* 1k pages are not supported. */
-        target_ulong mask = tlb->PageMask | 0x1FFF;
+        target_ulong mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
         target_ulong tag = address & ~mask;
-        int n;
+        target_ulong VPN = tlb->VPN & ~mask;
+#ifdef TARGET_MIPS64
+        tag &= 0xC00000FFFFFFFFFFULL;
+#endif
 
         /* Check ASID, virtual page number & size */
-        if ((tlb->G == 1 || tlb->ASID == ASID) &&
-            tlb->VPN == tag) {
+        if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {
             /* TLB match */
-            n = !!(address & mask & ~(mask >> 1));
+            int n = !!(address & mask & ~(mask >> 1));
             /* Check access rights */
-           if (!(n ? tlb->V1 : tlb->V0))
+            if (!(n ? tlb->V1 : tlb->V0))
                 return TLBRET_INVALID;
-           if (rw == 0 || (n ? tlb->D1 : tlb->D0)) {
+            if (rw == 0 || (n ? tlb->D1 : tlb->D0)) {
                 *physical = tlb->PFN[n] | (address & (mask >> 1));
                 *prot = PAGE_READ;
                 if (n ? tlb->D1 : tlb->D0)
@@ -71,7 +99,6 @@
     }
     return TLBRET_NOMATCH;
 }
-#endif
 
 static int get_physical_address (CPUState *env, target_ulong *physical,
                                 int *prot, target_ulong address,
@@ -104,14 +131,9 @@
     if (address <= (int32_t)0x7FFFFFFFUL) {
         /* useg */
         if (!(env->CP0_Status & (1 << CP0St_ERL) && user_mode)) {
-#ifdef MIPS_USES_R4K_TLB
-            ret = map_address(env, physical, prot, address, rw, access_type);
-#else
-            *physical = address + 0x40000000UL;
-            *prot = PAGE_READ | PAGE_WRITE;
-#endif
+            ret = env->map_address(env, physical, prot, address, rw, access_type);
         } else {
-            *physical = address;
+            *physical = address & 0xFFFFFFFF;
             *prot = PAGE_READ | PAGE_WRITE;
         }
 #ifdef TARGET_MIPS64
@@ -123,14 +145,14 @@
     } else if (address < 0x3FFFFFFFFFFFFFFFULL) {
         /* xuseg */
 	if (UX && address < 0x000000FFFFFFFFFFULL) {
-            ret = map_address(env, physical, prot, address, rw, access_type);
+            ret = env->map_address(env, physical, prot, address, rw, access_type);
 	} else {
 	    ret = TLBRET_BADADDR;
         }
     } else if (address < 0x7FFFFFFFFFFFFFFFULL) {
         /* xsseg */
 	if (SX && address < 0x400000FFFFFFFFFFULL) {
-            ret = map_address(env, physical, prot, address, rw, access_type);
+            ret = env->map_address(env, physical, prot, address, rw, access_type);
 	} else {
 	    ret = TLBRET_BADADDR;
         }
@@ -148,7 +170,7 @@
         /* xkseg */
         /* XXX: check supervisor mode */
 	if (KX && address < 0xC00000FF7FFFFFFFULL) {
-            ret = map_address(env, physical, prot, address, rw, access_type);
+            ret = env->map_address(env, physical, prot, address, rw, access_type);
 	} else {
 	    ret = TLBRET_BADADDR;
 	}
@@ -165,22 +187,12 @@
         *prot = PAGE_READ | PAGE_WRITE;
     } else if (address < (int32_t)0xE0000000UL) {
         /* kseg2 */
-#ifdef MIPS_USES_R4K_TLB
-        ret = map_address(env, physical, prot, address, rw, access_type);
-#else
-        *physical = address & 0xFFFFFFFF;
-        *prot = PAGE_READ | PAGE_WRITE;
-#endif
+        ret = env->map_address(env, physical, prot, address, rw, access_type);
     } else {
         /* kseg3 */
         /* XXX: check supervisor mode */
         /* XXX: debug segment is not emulated */
-#ifdef MIPS_USES_R4K_TLB
-        ret = map_address(env, physical, prot, address, rw, access_type);
-#else
-        *physical = address & 0xFFFFFFFF;
-        *prot = PAGE_READ | PAGE_WRITE;
-#endif
+        ret = env->map_address(env, physical, prot, address, rw, access_type);
     }
 #if 0
     if (logfile) {
@@ -286,10 +298,16 @@
         }
         /* Raise exception */
         env->CP0_BadVAddr = address;
-        env->CP0_Context = (env->CP0_Context & 0xff800000) |
+        env->CP0_Context = (env->CP0_Context & ~0x007fffff) |
 	                   ((address >> 9) &   0x007ffff0);
         env->CP0_EntryHi =
             (env->CP0_EntryHi & 0xFF) | (address & (TARGET_PAGE_MASK << 1));
+#ifdef TARGET_MIPS64
+        env->CP0_EntryHi &= 0xc00000ffffffffffULL;
+        env->CP0_XContext = (env->CP0_XContext & 0xfffffffe00000000ULL) |
+                            ((address >> 31) & 0x0000000180000000ULL) |
+                            ((address >> 9) & 0x000000007ffffff0ULL);
+#endif
         env->exception_index = exception;
         env->error_code = error_code;
         ret = 1;
@@ -402,8 +420,19 @@
         goto set_EPC;
     case EXCP_TLBL:
         cause = 2;
-        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL)))
-            offset = 0x000;
+        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
+#ifdef TARGET_MIPS64
+            int R = env->CP0_BadVAddr >> 62;
+            int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
+            int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
+            int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
+
+            if ((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX))
+                offset = 0x080;
+            else
+#endif
+                offset = 0x000;
+        }
         goto set_EPC;
     case EXCP_IBE:
         cause = 6;
@@ -439,8 +468,19 @@
         goto set_EPC;
     case EXCP_TLBS:
         cause = 3;
-        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL)))
-            offset = 0x000;
+        if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
+#ifdef TARGET_MIPS64
+            int R = env->CP0_BadVAddr >> 62;
+            int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
+            int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
+            int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
+
+            if ((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX))
+                offset = 0x080;
+            else
+#endif
+                offset = 0x000;
+        }
     set_EPC:
         if (!(env->CP0_Status & (1 << CP0St_EXL))) {
             if (env->hflags & MIPS_HFLAG_BMASK) {
@@ -483,16 +523,16 @@
 }
 #endif /* !defined(CONFIG_USER_ONLY) */
 
-void invalidate_tlb (CPUState *env, int idx, int use_extra)
+void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra)
 {
-    tlb_t *tlb;
+    r4k_tlb_t *tlb;
     target_ulong addr;
     target_ulong end;
     uint8_t ASID = env->CP0_EntryHi & 0xFF;
     target_ulong mask;
 
-    tlb = &env->tlb[idx];
-    /* The qemu TLB is flushed then the ASID changes, so no need to
+    tlb = &env->mmu.r4k.tlb[idx];
+    /* The qemu TLB is flushed when the ASID changes, so no need to
        flush these entries again.  */
     if (tlb->G == 0 && tlb->ASID != ASID) {
         return;
@@ -502,15 +542,20 @@
         /* For tlbwr, we can shadow the discarded entry into
 	   a new (fake) TLB entry, as long as the guest can not
 	   tell that it's there.  */
-        env->tlb[env->tlb_in_use] = *tlb;
+        env->mmu.r4k.tlb[env->tlb_in_use] = *tlb;
         env->tlb_in_use++;
         return;
     }
 
     /* 1k pages are not supported. */
-    mask = tlb->PageMask | 0x1FFF;
+    mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
     if (tlb->V0) {
-        addr = tlb->VPN;
+        addr = tlb->VPN & ~mask;
+#ifdef TARGET_MIPS64
+        if (addr >= 0xC00000FF80000000ULL) {
+            addr |= 0x3FFFFF0000000000ULL;
+        }
+#endif
         end = addr | (mask >> 1);
         while (addr < end) {
             tlb_flush_page (env, addr);
@@ -518,8 +563,12 @@
         }
     }
     if (tlb->V1) {
-        addr = tlb->VPN | ((mask >> 1) + 1);
-        addr = tlb->VPN + TARGET_PAGE_SIZE;
+        addr = (tlb->VPN & ~mask) | ((mask >> 1) + 1);
+#ifdef TARGET_MIPS64
+        if (addr >= 0xC00000FF80000000ULL) {
+            addr |= 0x3FFFFF0000000000ULL;
+        }
+#endif
         end = addr | mask;
         while (addr < end) {
             tlb_flush_page (env, addr);

Modified: trunk/src/host/qemu-neo1973/target-mips/mips-defs.h
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/mips-defs.h	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/mips-defs.h	2007-05-16 19:50:58 UTC (rev 1979)
@@ -6,8 +6,6 @@
 
 /* real pages are variable size... */
 #define TARGET_PAGE_BITS 12
-/* Uses MIPS R4Kc TLB model */
-#define MIPS_USES_R4K_TLB
 #define MIPS_TLB_MAX 128
 
 #ifdef TARGET_MIPS64

Modified: trunk/src/host/qemu-neo1973/target-mips/op.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/op.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/op.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -874,13 +874,13 @@
 #ifdef TARGET_MIPS64
 void op_dmult (void)
 {
-    CALL_FROM_TB0(do_dmult);
+    CALL_FROM_TB4(muls64, &(env->HI), &(env->LO), T0, T1);
     RETURN();
 }
 
 void op_dmultu (void)
 {
-    CALL_FROM_TB0(do_dmultu);
+    CALL_FROM_TB4(mulu64, &(env->HI), &(env->LO), T0, T1);
     RETURN();
 }
 #endif
@@ -938,8 +938,6 @@
 OP_COND(ltz, (int32_t)T0 < 0);
 
 /* Branches */
-//#undef USE_DIRECT_JUMP
-
 void OPPROTO op_goto_tb0(void)
 {
     GOTO_TB(op_goto_tb0, PARAM1, 0);
@@ -1262,7 +1260,7 @@
 {
     /* Large physaddr not implemented */
     /* 1k pages not implemented */
-    env->CP0_EntryLo0 = (int32_t)T0 & 0x3FFFFFFF;
+    env->CP0_EntryLo0 = T0 & 0x3FFFFFFF;
     RETURN();
 }
 
@@ -1270,7 +1268,7 @@
 {
     /* Large physaddr not implemented */
     /* 1k pages not implemented */
-    env->CP0_EntryLo1 = (int32_t)T0 & 0x3FFFFFFF;
+    env->CP0_EntryLo1 = T0 & 0x3FFFFFFF;
     RETURN();
 }
 
@@ -1283,7 +1281,7 @@
 void op_mtc0_pagemask (void)
 {
     /* 1k pages not implemented */
-    env->CP0_PageMask = T0 & 0x1FFFE000;
+    env->CP0_PageMask = T0 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1));
     RETURN();
 }
 
@@ -1319,8 +1317,10 @@
     target_ulong old, val;
 
     /* 1k pages not implemented */
-    /* Ignore MIPS64 TLB for now */
-    val = (target_ulong)(int32_t)T0 & ~(target_ulong)0x1F00;
+    val = T0 & ((TARGET_PAGE_MASK << 1) | 0xFF);
+#ifdef TARGET_MIPS64
+    val = T0 & 0xC00000FFFFFFFFFFULL;
+#endif
     old = env->CP0_EntryHi;
     env->CP0_EntryHi = val;
     /* If the ASID changes, flush qemu's TLB.  */
@@ -1340,9 +1340,9 @@
     uint32_t val, old;
     uint32_t mask = env->Status_rw_bitmask;
 
-    /* No reverse endianness, no MDMX/DSP, no 64bit ops,
-       no 64bit addressing implemented. */
-    val = (int32_t)T0 & mask;
+    /* No reverse endianness, no MDMX/DSP, no 64bit ops
+       implemented. */
+    val = T0 & mask;
     old = env->CP0_Status;
     if (!(val & (1 << CP0St_EXL)) &&
         !(val & (1 << CP0St_ERL)) &&
@@ -1397,7 +1397,7 @@
 
 void op_mtc0_epc (void)
 {
-    env->CP0_EPC = (int32_t)T0;
+    env->CP0_EPC = T0;
     RETURN();
 }
 
@@ -1411,12 +1411,7 @@
 
 void op_mtc0_config0 (void)
 {
-#if defined(MIPS_USES_R4K_TLB)
-     /* Fixed mapping MMU not implemented */
-    env->CP0_Config0 = (env->CP0_Config0 & 0x8017FF88) | (T0 & 0x00000001);
-#else
-    env->CP0_Config0 = (env->CP0_Config0 & 0xFE17FF88) | (T0 & 0x00000001);
-#endif
+    env->CP0_Config0 = (env->CP0_Config0 & 0x81FFFFF8) | (T0 & 0x00000001);
     RETURN();
 }
 
@@ -1431,7 +1426,7 @@
 {
     /* Watch exceptions for instructions, data loads, data stores
        not implemented. */
-    env->CP0_WatchLo = (int32_t)(T0 & ~0x7);
+    env->CP0_WatchLo = (T0 & ~0x7);
     RETURN();
 }
 
@@ -1460,7 +1455,7 @@
 
 void op_mtc0_depc (void)
 {
-    env->CP0_DEPC = (int32_t)T0;
+    env->CP0_DEPC = T0;
     RETURN();
 }
 
@@ -1496,7 +1491,7 @@
 
 void op_mtc0_errorepc (void)
 {
-    env->CP0_ErrorEPC = (int32_t)T0;
+    env->CP0_ErrorEPC = T0;
     RETURN();
 }
 
@@ -1507,6 +1502,12 @@
 }
 
 #ifdef TARGET_MIPS64
+void op_mtc0_xcontext (void)
+{
+    env->CP0_XContext = (env->CP0_XContext & 0x1ffffffffULL) | (T0 & ~0x1ffffffffULL);
+    RETURN();
+}
+
 void op_dmfc0_entrylo0 (void)
 {
     T0 = env->CP0_EntryLo0;
@@ -1572,60 +1573,6 @@
     T0 = env->CP0_ErrorEPC;
     RETURN();
 }
-
-void op_dmtc0_entrylo0 (void)
-{
-    /* Large physaddr not implemented */
-    /* 1k pages not implemented */
-    env->CP0_EntryLo0 = T0 & 0x3FFFFFFF;
-    RETURN();
-}
-
-void op_dmtc0_entrylo1 (void)
-{
-    /* Large physaddr not implemented */
-    /* 1k pages not implemented */
-    env->CP0_EntryLo1 = T0 & 0x3FFFFFFF;
-    RETURN();
-}
-
-void op_dmtc0_context (void)
-{
-    env->CP0_Context = (env->CP0_Context & 0x007FFFFF) | (T0 & ~0x007FFFFF);
-    RETURN();
-}
-
-void op_dmtc0_epc (void)
-{
-    env->CP0_EPC = T0;
-    RETURN();
-}
-
-void op_dmtc0_watchlo0 (void)
-{
-    /* Watch exceptions for instructions, data loads, data stores
-       not implemented. */
-    env->CP0_WatchLo = T0 & ~0x7;
-    RETURN();
-}
-
-void op_dmtc0_xcontext (void)
-{
-    env->CP0_XContext = (env->CP0_XContext & 0xffffffff) | (T0 & ~0xffffffff);
-    RETURN();
-}
-
-void op_dmtc0_depc (void)
-{
-    env->CP0_DEPC = T0;
-    RETURN();
-}
-
-void op_dmtc0_errorepc (void)
-{
-    env->CP0_ErrorEPC = T0;
-    RETURN();
-}
 #endif /* TARGET_MIPS64 */
 
 /* CP1 functions */
@@ -2680,31 +2627,29 @@
     RETURN();
 }
 
-#if defined(MIPS_USES_R4K_TLB)
 void op_tlbwi (void)
 {
-    CALL_FROM_TB0(do_tlbwi);
+    CALL_FROM_TB0(env->do_tlbwi);
     RETURN();
 }
 
 void op_tlbwr (void)
 {
-    CALL_FROM_TB0(do_tlbwr);
+    CALL_FROM_TB0(env->do_tlbwr);
     RETURN();
 }
 
 void op_tlbp (void)
 {
-    CALL_FROM_TB0(do_tlbp);
+    CALL_FROM_TB0(env->do_tlbp);
     RETURN();
 }
 
 void op_tlbr (void)
 {
-    CALL_FROM_TB0(do_tlbr);
+    CALL_FROM_TB0(env->do_tlbr);
     RETURN();
 }
-#endif
 
 /* Specials */
 #if defined (CONFIG_USER_ONLY)

Modified: trunk/src/host/qemu-neo1973/target-mips/op_helper.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/op_helper.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/op_helper.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -228,20 +228,6 @@
 #endif
 
 #ifdef TARGET_MIPS64
-void do_dmult (void)
-{
-    env->LO = (int64_t)T0 * (int64_t)T1;
-    /* XXX */
-    env->HI = (env->LO | (1ULL << 63)) ? ~0ULL : 0ULL;
-}
-
-void do_dmultu (void)
-{
-    env->LO = T0 * T1;
-    /* XXX */
-    env->HI = 0;
-}
-
 void do_ddiv (void)
 {
     if (T1 != 0) {
@@ -298,26 +284,6 @@
     cpu_abort(env, "mtc0 status irqraise debug\n");
 }
 
-void do_tlbwi (void)
-{
-    cpu_abort(env, "tlbwi\n");
-}
-
-void do_tlbwr (void)
-{
-    cpu_abort(env, "tlbwr\n");
-}
-
-void do_tlbp (void)
-{
-    cpu_abort(env, "tlbp\n");
-}
-
-void do_tlbr (void)
-{
-    cpu_abort(env, "tlbr\n");
-}
-
 void cpu_mips_tlb_flush (CPUState *env, int flush_global)
 {
     cpu_abort(env, "mips_tlb_flush\n");
@@ -389,7 +355,6 @@
 }
 
 /* TLB management */
-#if defined(MIPS_USES_R4K_TLB)
 void cpu_mips_tlb_flush (CPUState *env, int flush_global)
 {
     /* Flush qemu's TLB and discard all shadowed entries.  */
@@ -397,21 +362,24 @@
     env->tlb_in_use = env->nb_tlb;
 }
 
-static void mips_tlb_flush_extra (CPUState *env, int first)
+static void r4k_mips_tlb_flush_extra (CPUState *env, int first)
 {
     /* Discard entries from env->tlb[first] onwards.  */
     while (env->tlb_in_use > first) {
-        invalidate_tlb(env, --env->tlb_in_use, 0);
+        r4k_invalidate_tlb(env, --env->tlb_in_use, 0);
     }
 }
 
-static void fill_tlb (int idx)
+static void r4k_fill_tlb (int idx)
 {
-    tlb_t *tlb;
+    r4k_tlb_t *tlb;
 
     /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
-    tlb = &env->tlb[idx];
-    tlb->VPN = env->CP0_EntryHi & ~(target_ulong)0x1FFF;
+    tlb = &env->mmu.r4k.tlb[idx];
+    tlb->VPN = env->CP0_EntryHi & (TARGET_PAGE_MASK << 1);
+#ifdef TARGET_MIPS64
+    tlb->VPN &= 0xC00000FFFFFFFFFFULL;
+#endif
     tlb->ASID = env->CP0_EntryHi & 0xFF;
     tlb->PageMask = env->CP0_PageMask;
     tlb->G = env->CP0_EntryLo0 & env->CP0_EntryLo1 & 1;
@@ -425,38 +393,43 @@
     tlb->PFN[1] = (env->CP0_EntryLo1 >> 6) << 12;
 }
 
-void do_tlbwi (void)
+void r4k_do_tlbwi (void)
 {
     /* Discard cached TLB entries.  We could avoid doing this if the
        tlbwi is just upgrading access permissions on the current entry;
        that might be a further win.  */
-    mips_tlb_flush_extra (env, env->nb_tlb);
+    r4k_mips_tlb_flush_extra (env, env->nb_tlb);
 
-    invalidate_tlb(env, env->CP0_Index % env->nb_tlb, 0);
-    fill_tlb(env->CP0_Index % env->nb_tlb);
+    r4k_invalidate_tlb(env, env->CP0_Index % env->nb_tlb, 0);
+    r4k_fill_tlb(env->CP0_Index % env->nb_tlb);
 }
 
-void do_tlbwr (void)
+void r4k_do_tlbwr (void)
 {
     int r = cpu_mips_get_random(env);
 
-    invalidate_tlb(env, r, 1);
-    fill_tlb(r);
+    r4k_invalidate_tlb(env, r, 1);
+    r4k_fill_tlb(r);
 }
 
-void do_tlbp (void)
+void r4k_do_tlbp (void)
 {
-    tlb_t *tlb;
+    r4k_tlb_t *tlb;
+    target_ulong mask;
     target_ulong tag;
+    target_ulong VPN;
     uint8_t ASID;
     int i;
 
-    tag = env->CP0_EntryHi & (int32_t)0xFFFFE000;
     ASID = env->CP0_EntryHi & 0xFF;
     for (i = 0; i < env->nb_tlb; i++) {
-        tlb = &env->tlb[i];
+        tlb = &env->mmu.r4k.tlb[i];
+        /* 1k pages are not supported. */
+        mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
+        tag = env->CP0_EntryHi & ~mask;
+        VPN = tlb->VPN & ~mask;
         /* Check ASID, virtual page number & size */
-        if ((tlb->G == 1 || tlb->ASID == ASID) && tlb->VPN == tag) {
+        if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {
             /* TLB match */
             env->CP0_Index = i;
             break;
@@ -465,11 +438,14 @@
     if (i == env->nb_tlb) {
         /* No match.  Discard any shadow entries, if any of them match.  */
         for (i = env->nb_tlb; i < env->tlb_in_use; i++) {
-	    tlb = &env->tlb[i];
-
+	    tlb = &env->mmu.r4k.tlb[i];
+	    /* 1k pages are not supported. */
+	    mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
+	    tag = env->CP0_EntryHi & ~mask;
+	    VPN = tlb->VPN & ~mask;
 	    /* Check ASID, virtual page number & size */
-	    if ((tlb->G == 1 || tlb->ASID == ASID) && tlb->VPN == tag) {
-                mips_tlb_flush_extra (env, i);
+	    if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {
+                r4k_mips_tlb_flush_extra (env, i);
 	        break;
 	    }
 	}
@@ -478,19 +454,19 @@
     }
 }
 
-void do_tlbr (void)
+void r4k_do_tlbr (void)
 {
-    tlb_t *tlb;
+    r4k_tlb_t *tlb;
     uint8_t ASID;
 
     ASID = env->CP0_EntryHi & 0xFF;
-    tlb = &env->tlb[env->CP0_Index % env->nb_tlb];
+    tlb = &env->mmu.r4k.tlb[env->CP0_Index % env->nb_tlb];
 
     /* If this will change the current ASID, flush qemu's TLB.  */
     if (ASID != tlb->ASID)
         cpu_mips_tlb_flush (env, 1);
 
-    mips_tlb_flush_extra(env, env->nb_tlb);
+    r4k_mips_tlb_flush_extra(env, env->nb_tlb);
 
     env->CP0_EntryHi = tlb->VPN | tlb->ASID;
     env->CP0_PageMask = tlb->PageMask;
@@ -499,7 +475,6 @@
     env->CP0_EntryLo1 = tlb->G | (tlb->V1 << 1) | (tlb->D1 << 2) |
                         (tlb->C1 << 3) | (tlb->PFN[1] >> 6);
 }
-#endif
 
 #endif /* !CONFIG_USER_ONLY */
 

Modified: trunk/src/host/qemu-neo1973/target-mips/translate.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/translate.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/translate.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -2190,10 +2190,11 @@
     case 20:
         switch (sel) {
         case 0:
-            /* 64 bit MMU only */
+#ifdef TARGET_MIPS64
             gen_op_mfc0_xcontext();
             rn = "XContext";
             break;
+#endif
         default:
             goto die;
         }
@@ -2788,10 +2789,11 @@
     case 20:
         switch (sel) {
         case 0:
-            /* 64 bit MMU only */
-            /* Nothing writable in lower 32 bits */
+#ifdef TARGET_MIPS64
+            gen_op_mtc0_xcontext();
             rn = "XContext";
             break;
+#endif
         default:
             goto die;
         }
@@ -3377,10 +3379,11 @@
     case 20:
         switch (sel) {
         case 0:
-            /* 64 bit MMU only */
+#ifdef TARGET_MIPS64
             gen_op_dmfc0_xcontext();
             rn = "XContext";
             break;
+#endif
         default:
             goto die;
         }
@@ -3580,15 +3583,15 @@
             rn = "Index";
             break;
         case 1:
-//            gen_op_dmtc0_mvpcontrol(); /* MT ASE */
+//            gen_op_mtc0_mvpcontrol(); /* MT ASE */
             rn = "MVPControl";
 //            break;
         case 2:
-//            gen_op_dmtc0_mvpconf0(); /* MT ASE */
+//            gen_op_mtc0_mvpconf0(); /* MT ASE */
             rn = "MVPConf0";
 //            break;
         case 3:
-//            gen_op_dmtc0_mvpconf1(); /* MT ASE */
+//            gen_op_mtc0_mvpconf1(); /* MT ASE */
             rn = "MVPConf1";
 //            break;
         default:
@@ -3602,31 +3605,31 @@
             rn = "Random";
             break;
         case 1:
-//            gen_op_dmtc0_vpecontrol(); /* MT ASE */
+//            gen_op_mtc0_vpecontrol(); /* MT ASE */
             rn = "VPEControl";
 //            break;
         case 2:
-//            gen_op_dmtc0_vpeconf0(); /* MT ASE */
+//            gen_op_mtc0_vpeconf0(); /* MT ASE */
             rn = "VPEConf0";
 //            break;
         case 3:
-//            gen_op_dmtc0_vpeconf1(); /* MT ASE */
+//            gen_op_mtc0_vpeconf1(); /* MT ASE */
             rn = "VPEConf1";
 //            break;
         case 4:
-//            gen_op_dmtc0_YQMask(); /* MT ASE */
+//            gen_op_mtc0_YQMask(); /* MT ASE */
             rn = "YQMask";
 //            break;
         case 5:
-//            gen_op_dmtc0_vpeschedule(); /* MT ASE */
+//            gen_op_mtc0_vpeschedule(); /* MT ASE */
             rn = "VPESchedule";
 //            break;
         case 6:
-//            gen_op_dmtc0_vpeschefback(); /* MT ASE */
+//            gen_op_mtc0_vpeschefback(); /* MT ASE */
             rn = "VPEScheFBack";
 //            break;
         case 7:
-//            gen_op_dmtc0_vpeopt(); /* MT ASE */
+//            gen_op_mtc0_vpeopt(); /* MT ASE */
             rn = "VPEOpt";
 //            break;
         default:
@@ -3636,35 +3639,35 @@
     case 2:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_entrylo0();
+            gen_op_mtc0_entrylo0();
             rn = "EntryLo0";
             break;
         case 1:
-//            gen_op_dmtc0_tcstatus(); /* MT ASE */
+//            gen_op_mtc0_tcstatus(); /* MT ASE */
             rn = "TCStatus";
 //            break;
         case 2:
-//            gen_op_dmtc0_tcbind(); /* MT ASE */
+//            gen_op_mtc0_tcbind(); /* MT ASE */
             rn = "TCBind";
 //            break;
         case 3:
-//            gen_op_dmtc0_tcrestart(); /* MT ASE */
+//            gen_op_mtc0_tcrestart(); /* MT ASE */
             rn = "TCRestart";
 //            break;
         case 4:
-//            gen_op_dmtc0_tchalt(); /* MT ASE */
+//            gen_op_mtc0_tchalt(); /* MT ASE */
             rn = "TCHalt";
 //            break;
         case 5:
-//            gen_op_dmtc0_tccontext(); /* MT ASE */
+//            gen_op_mtc0_tccontext(); /* MT ASE */
             rn = "TCContext";
 //            break;
         case 6:
-//            gen_op_dmtc0_tcschedule(); /* MT ASE */
+//            gen_op_mtc0_tcschedule(); /* MT ASE */
             rn = "TCSchedule";
 //            break;
         case 7:
-//            gen_op_dmtc0_tcschefback(); /* MT ASE */
+//            gen_op_mtc0_tcschefback(); /* MT ASE */
             rn = "TCScheFBack";
 //            break;
         default:
@@ -3674,7 +3677,7 @@
     case 3:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_entrylo1();
+            gen_op_mtc0_entrylo1();
             rn = "EntryLo1";
             break;
         default:
@@ -3684,11 +3687,11 @@
     case 4:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_context();
+            gen_op_mtc0_context();
             rn = "Context";
             break;
         case 1:
-//           gen_op_dmtc0_contextconfig(); /* SmartMIPS ASE */
+//           gen_op_mtc0_contextconfig(); /* SmartMIPS ASE */
             rn = "ContextConfig";
 //           break;
         default:
@@ -3716,23 +3719,23 @@
             rn = "Wired";
             break;
         case 1:
-//            gen_op_dmtc0_srsconf0(); /* shadow registers */
+//            gen_op_mtc0_srsconf0(); /* shadow registers */
             rn = "SRSConf0";
 //            break;
         case 2:
-//            gen_op_dmtc0_srsconf1(); /* shadow registers */
+//            gen_op_mtc0_srsconf1(); /* shadow registers */
             rn = "SRSConf1";
 //            break;
         case 3:
-//            gen_op_dmtc0_srsconf2(); /* shadow registers */
+//            gen_op_mtc0_srsconf2(); /* shadow registers */
             rn = "SRSConf2";
 //            break;
         case 4:
-//            gen_op_dmtc0_srsconf3(); /* shadow registers */
+//            gen_op_mtc0_srsconf3(); /* shadow registers */
             rn = "SRSConf3";
 //            break;
         case 5:
-//            gen_op_dmtc0_srsconf4(); /* shadow registers */
+//            gen_op_mtc0_srsconf4(); /* shadow registers */
             rn = "SRSConf4";
 //            break;
         default:
@@ -3828,7 +3831,7 @@
     case 14:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_epc();
+            gen_op_mtc0_epc();
             rn = "EPC";
             break;
         default:
@@ -3890,35 +3893,35 @@
     case 18:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_watchlo0();
+            gen_op_mtc0_watchlo0();
             rn = "WatchLo";
             break;
         case 1:
-//            gen_op_dmtc0_watchlo1();
+//            gen_op_mtc0_watchlo1();
             rn = "WatchLo1";
 //            break;
         case 2:
-//            gen_op_dmtc0_watchlo2();
+//            gen_op_mtc0_watchlo2();
             rn = "WatchLo2";
 //            break;
         case 3:
-//            gen_op_dmtc0_watchlo3();
+//            gen_op_mtc0_watchlo3();
             rn = "WatchLo3";
 //            break;
         case 4:
-//            gen_op_dmtc0_watchlo4();
+//            gen_op_mtc0_watchlo4();
             rn = "WatchLo4";
 //            break;
         case 5:
-//            gen_op_dmtc0_watchlo5();
+//            gen_op_mtc0_watchlo5();
             rn = "WatchLo5";
 //            break;
         case 6:
-//            gen_op_dmtc0_watchlo6();
+//            gen_op_mtc0_watchlo6();
             rn = "WatchLo6";
 //            break;
         case 7:
-//            gen_op_dmtc0_watchlo7();
+//            gen_op_mtc0_watchlo7();
             rn = "WatchLo7";
 //            break;
         default:
@@ -3932,31 +3935,31 @@
             rn = "WatchHi";
             break;
         case 1:
-//            gen_op_dmtc0_watchhi1();
+//            gen_op_mtc0_watchhi1();
             rn = "WatchHi1";
 //            break;
         case 2:
-//            gen_op_dmtc0_watchhi2();
+//            gen_op_mtc0_watchhi2();
             rn = "WatchHi2";
 //            break;
         case 3:
-//            gen_op_dmtc0_watchhi3();
+//            gen_op_mtc0_watchhi3();
             rn = "WatchHi3";
 //            break;
         case 4:
-//            gen_op_dmtc0_watchhi4();
+//            gen_op_mtc0_watchhi4();
             rn = "WatchHi4";
 //            break;
         case 5:
-//            gen_op_dmtc0_watchhi5();
+//            gen_op_mtc0_watchhi5();
             rn = "WatchHi5";
 //            break;
         case 6:
-//            gen_op_dmtc0_watchhi6();
+//            gen_op_mtc0_watchhi6();
             rn = "WatchHi6";
 //            break;
         case 7:
-//            gen_op_dmtc0_watchhi7();
+//            gen_op_mtc0_watchhi7();
             rn = "WatchHi7";
 //            break;
         default:
@@ -3966,10 +3969,11 @@
     case 20:
         switch (sel) {
         case 0:
-            /* 64 bit MMU only */
-            gen_op_dmtc0_xcontext();
+#ifdef TARGET_MIPS64
+            gen_op_mtc0_xcontext();
             rn = "XContext";
             break;
+#endif
         default:
             goto die;
         }
@@ -3996,19 +4000,19 @@
             rn = "Debug";
             break;
         case 1:
-//            gen_op_dmtc0_tracecontrol(); /* PDtrace support */
+//            gen_op_mtc0_tracecontrol(); /* PDtrace support */
             rn = "TraceControl";
 //            break;
         case 2:
-//            gen_op_dmtc0_tracecontrol2(); /* PDtrace support */
+//            gen_op_mtc0_tracecontrol2(); /* PDtrace support */
             rn = "TraceControl2";
 //            break;
         case 3:
-//            gen_op_dmtc0_usertracedata(); /* PDtrace support */
+//            gen_op_mtc0_usertracedata(); /* PDtrace support */
             rn = "UserTraceData";
 //            break;
         case 4:
-//            gen_op_dmtc0_debug(); /* PDtrace support */
+//            gen_op_mtc0_debug(); /* PDtrace support */
             rn = "TraceBPC";
 //            break;
         default:
@@ -4020,7 +4024,7 @@
     case 24:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_depc(); /* EJTAG support */
+            gen_op_mtc0_depc(); /* EJTAG support */
             rn = "DEPC";
             break;
         default:
@@ -4034,31 +4038,31 @@
             rn = "Performance0";
             break;
         case 1:
-//            gen_op_dmtc0_performance1();
+//            gen_op_mtc0_performance1();
             rn = "Performance1";
 //            break;
         case 2:
-//            gen_op_dmtc0_performance2();
+//            gen_op_mtc0_performance2();
             rn = "Performance2";
 //            break;
         case 3:
-//            gen_op_dmtc0_performance3();
+//            gen_op_mtc0_performance3();
             rn = "Performance3";
 //            break;
         case 4:
-//            gen_op_dmtc0_performance4();
+//            gen_op_mtc0_performance4();
             rn = "Performance4";
 //            break;
         case 5:
-//            gen_op_dmtc0_performance5();
+//            gen_op_mtc0_performance5();
             rn = "Performance5";
 //            break;
         case 6:
-//            gen_op_dmtc0_performance6();
+//            gen_op_mtc0_performance6();
             rn = "Performance6";
 //            break;
         case 7:
-//            gen_op_dmtc0_performance7();
+//            gen_op_mtc0_performance7();
             rn = "Performance7";
 //            break;
         default:
@@ -4123,7 +4127,7 @@
     case 30:
         switch (sel) {
         case 0:
-            gen_op_dmtc0_errorepc();
+            gen_op_mtc0_errorepc();
             rn = "ErrorEPC";
             break;
         default:
@@ -4164,7 +4168,7 @@
 }
 #endif /* TARGET_MIPS64 */
 
-static void gen_cp0 (DisasContext *ctx, uint32_t opc, int rt, int rd)
+static void gen_cp0 (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int rd)
 {
     const char *opn = "ldst";
 
@@ -4199,24 +4203,30 @@
         opn = "dmtc0";
         break;
 #endif
-#if defined(MIPS_USES_R4K_TLB)
     case OPC_TLBWI:
+        opn = "tlbwi";
+        if (!env->do_tlbwi)
+            goto die;
         gen_op_tlbwi();
-        opn = "tlbwi";
         break;
     case OPC_TLBWR:
+        opn = "tlbwr";
+        if (!env->do_tlbwr)
+            goto die;
         gen_op_tlbwr();
-        opn = "tlbwr";
         break;
     case OPC_TLBP:
+        opn = "tlbp";
+        if (!env->do_tlbp)
+            goto die;
         gen_op_tlbp();
-        opn = "tlbp";
         break;
     case OPC_TLBR:
+        opn = "tlbr";
+        if (!env->do_tlbr)
+            goto die;
         gen_op_tlbr();
-        opn = "tlbr";
         break;
-#endif
     case OPC_ERET:
         opn = "eret";
         save_cpu_state(ctx, 0);
@@ -4244,6 +4254,7 @@
         ctx->bstate = BS_EXCP;
         break;
     default:
+ die:
         MIPS_INVAL(opn);
         generate_exception(ctx, EXCP_RI);
         return;
@@ -5576,10 +5587,10 @@
         case OPC_DMFC0:
         case OPC_DMTC0:
 #endif
-            gen_cp0(ctx, op1, rt, rd);
+            gen_cp0(env, ctx, op1, rt, rd);
             break;
         case OPC_C0_FIRST ... OPC_C0_LAST:
-            gen_cp0(ctx, MASK_C0(ctx->opcode), rt, rd);
+            gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd);
             break;
         case OPC_MFMC0:
             op2 = MASK_MFMC0(ctx->opcode);

Modified: trunk/src/host/qemu-neo1973/target-mips/translate_init.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-mips/translate_init.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-mips/translate_init.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -148,7 +148,7 @@
         .Status_rw_bitmask = 0x3678FFFF,
         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
                     (1 << FCR0_D) | (1 << FCR0_S) |
-                    (0x4 << FCR0_PRID) | (0x0 << FCR0_REV),
+                    (0x5 << FCR0_PRID) | (0x0 << FCR0_REV),
     },
 #endif
 };
@@ -180,6 +180,30 @@
     }
 }
 
+#ifndef CONFIG_USER_ONLY
+static void no_mmu_init (CPUMIPSState *env, mips_def_t *def)
+{
+    env->nb_tlb = 1;
+    env->map_address = &no_mmu_map_address;
+}
+
+static void fixed_mmu_init (CPUMIPSState *env, mips_def_t *def)
+{
+    env->nb_tlb = 1;
+    env->map_address = &fixed_mmu_map_address;
+}
+
+static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def)
+{
+    env->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
+    env->map_address = &r4k_map_address;
+    env->do_tlbwi = r4k_do_tlbwi;
+    env->do_tlbwr = r4k_do_tlbwr;
+    env->do_tlbp = r4k_do_tlbp;
+    env->do_tlbr = r4k_do_tlbr;
+}
+#endif /* CONFIG_USER_ONLY */
+
 int cpu_mips_register (CPUMIPSState *env, mips_def_t *def)
 {
     if (!def)
@@ -199,10 +223,23 @@
     env->CCRes = def->CCRes;
     env->Status_rw_bitmask = def->Status_rw_bitmask;
     env->fcr0 = def->CP1_fcr0;
-#if defined (MIPS_USES_R4K_TLB)
-    env->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
+#ifndef CONFIG_USER_ONLY
+    switch ((env->CP0_Config0 >> CP0C0_MT) & 3) {
+        case 0:
+            no_mmu_init(env, def);
+            break;
+        case 1:
+            r4k_mmu_init(env, def);
+            break;
+        case 3:
+            fixed_mmu_init(env, def);
+            break;
+        default:
+            /* Older CPUs like the R3000 may need nonstandard handling here. */
+            cpu_abort(env, "MMU type not supported\n");
+    }
     env->CP0_Random = env->nb_tlb - 1;
     env->tlb_in_use = env->nb_tlb;
-#endif
+#endif /* CONFIG_USER_ONLY */
     return 0;
 }

Modified: trunk/src/host/qemu-neo1973/target-sh4/op.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-sh4/op.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-sh4/op.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -561,14 +561,14 @@
 void OPPROTO op_shar_Rn(void)
 {
     cond_t(env->gregs[PARAM1] & 1);
-    *(int32_t *) & env->gregs[PARAM1] >>= 1;
+    env->gregs[PARAM1] >>= 1;
     RETURN();
 }
 
 void OPPROTO op_shlr_Rn(void)
 {
     cond_t(env->gregs[PARAM1] & 1);
-    *(uint32_t *) & env->gregs[PARAM1] >>= 1;
+    env->gregs[PARAM1] >>= 1;
     RETURN();
 }
 
@@ -592,19 +592,19 @@
 
 void OPPROTO op_shlr2_Rn(void)
 {
-    *(uint32_t *) & env->gregs[PARAM1] >>= 2;
+    env->gregs[PARAM1] >>= 2;
     RETURN();
 }
 
 void OPPROTO op_shlr8_Rn(void)
 {
-    *(uint32_t *) & env->gregs[PARAM1] >>= 8;
+    env->gregs[PARAM1] >>= 8;
     RETURN();
 }
 
 void OPPROTO op_shlr16_Rn(void)
 {
-    *(uint32_t *) & env->gregs[PARAM1] >>= 16;
+    env->gregs[PARAM1] >>= 16;
     RETURN();
 }
 

Modified: trunk/src/host/qemu-neo1973/target-sh4/translate.c
===================================================================
--- trunk/src/host/qemu-neo1973/target-sh4/translate.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/target-sh4/translate.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -236,7 +236,7 @@
 		? (x) + 16 : (x))
 
 #define FREG(x) (ctx->fpscr & FPSCR_FR ? (x) ^ 0x10 : (x))
-#define XHACK(x) (((x) & 1 ) << 4 | ((x) & 0xe ) << 1)
+#define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe))
 #define XREG(x) (ctx->fpscr & FPSCR_FR ? XHACK(x) ^ 0x10 : XHACK(x))
 
 #define CHECK_NOT_DELAY_SLOT \
@@ -685,7 +685,7 @@
 	} else {
 	    gen_op_movl_rN_T0(REG(B7_4));
 	    gen_op_ldfl_T0_FT0(ctx);
-	    gen_op_fmov_FT0_frN(XREG(B11_8));
+	    gen_op_fmov_FT0_frN(FREG(B11_8));
 	}
 	return;
     case 0xf009:		/* fmov @Rm+,{F,D,X}Rn */
@@ -704,7 +704,7 @@
 	} else {
 	    gen_op_movl_rN_T0(REG(B7_4));
 	    gen_op_ldfl_T0_FT0(ctx);
-	    gen_op_fmov_FT0_frN(XREG(B11_8));
+	    gen_op_fmov_FT0_frN(FREG(B11_8));
 	    gen_op_inc4_rN(REG(B7_4));
 	}
 	return;
@@ -745,7 +745,7 @@
 	    gen_op_movl_rN_T0(REG(B7_4));
 	    gen_op_add_rN_T0(REG(0));
 	    gen_op_ldfl_T0_FT0(ctx);
-	    gen_op_fmov_FT0_frN(XREG(B11_8));
+	    gen_op_fmov_FT0_frN(FREG(B11_8));
 	}
 	return;
     case 0xf007:		/* fmov {F,D,X}Rn,@(R0,Rn) */

Modified: trunk/src/host/qemu-neo1973/vl.c
===================================================================
--- trunk/src/host/qemu-neo1973/vl.c	2007-05-16 19:50:55 UTC (rev 1978)
+++ trunk/src/host/qemu-neo1973/vl.c	2007-05-16 19:50:58 UTC (rev 1979)
@@ -2420,7 +2420,12 @@
     qemu_chr_reset(chr);
     return chr;
 }
-    
+
+static CharDriverState *qemu_chr_open_win_con(const char *filename)
+{
+    return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE));
+}
+
 static CharDriverState *qemu_chr_open_win_file_out(const char *file_out)
 {
     HANDLE fd_out;
@@ -2962,6 +2967,9 @@
     if (strstart(filename, "pipe:", &p)) {
         return qemu_chr_open_win_pipe(p);
     } else
+    if (strstart(filename, "con:", NULL)) {
+        return qemu_chr_open_win_con(filename);
+    } else
     if (strstart(filename, "file:", &p)) {
         return qemu_chr_open_win_file_out(p);
     }





More information about the commitlog mailing list