Search
lxdream.org :: lxdream :: r1125:9dd5dee45db9
lxdream 0.9.1
released Jun 29
Download Now
changeset1125:9dd5dee45db9
parent1124:aacaae9812ea
child1126:1f2c7cdee73e
authornkeynes
dateMon Sep 13 10:13:42 2010 +1000 (9 years ago)
Implement shadow-execution 'core' to run translator + interpreter side by
side (for testing)
src/Makefile.am
src/Makefile.in
src/main.c
src/sh4/sh4.c
src/sh4/sh4.h
src/sh4/sh4core.in
src/sh4/sh4trans.c
src/sh4/sh4trans.h
src/sh4/sh4x86.in
src/xlat/x86/amd64abi.h
src/xlat/x86/ia32abi.h
1.1 --- a/src/Makefile.am Sat Sep 11 09:58:22 2010 +1000
1.2 +++ b/src/Makefile.am Mon Sep 13 10:13:42 2010 +1000
1.3 @@ -52,7 +52,7 @@
1.4 sh4/mmu.c sh4/sh4core.c sh4/sh4core.h sh4/sh4dasm.c sh4/sh4dasm.h \
1.5 sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c sh4/sh4stat.c sh4/sh4stat.h \
1.6 xlat/xltcache.c xlat/xltcache.h sh4/sh4.h sh4/dmac.h sh4/pmm.c \
1.7 - sh4/cache.c sh4/mmu.h \
1.8 + sh4/cache.c sh4/mmu.h sh4/shadow.c \
1.9 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armdasm.h aica/armmem.c \
1.10 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
1.11 pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c pvr2/pvr2mmio.h \
2.1 --- a/src/Makefile.in Sat Sep 11 09:58:22 2010 +1000
2.2 +++ b/src/Makefile.in Mon Sep 13 10:13:42 2010 +1000
2.3 @@ -152,13 +152,13 @@
2.4 sh4/sh4core.h sh4/sh4dasm.c sh4/sh4dasm.h sh4/sh4mmio.c \
2.5 sh4/sh4mmio.h sh4/scif.c sh4/sh4stat.c sh4/sh4stat.h \
2.6 xlat/xltcache.c xlat/xltcache.h sh4/sh4.h sh4/dmac.h sh4/pmm.c \
2.7 - sh4/cache.c sh4/mmu.h aica/armcore.c aica/armcore.h \
2.8 - aica/armdasm.c aica/armdasm.h aica/armmem.c aica/aica.c \
2.9 - aica/aica.h aica/audio.c aica/audio.h pvr2/pvr2.c pvr2/pvr2.h \
2.10 - pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c \
2.11 - pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
2.12 - pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.13 - pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.14 + sh4/cache.c sh4/mmu.h sh4/shadow.c aica/armcore.c \
2.15 + aica/armcore.h aica/armdasm.c aica/armdasm.h aica/armmem.c \
2.16 + aica/aica.c aica/aica.h aica/audio.c aica/audio.h pvr2/pvr2.c \
2.17 + pvr2/pvr2.h pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c \
2.18 + pvr2/rendsort.c pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
2.19 + pvr2/scene.c pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c \
2.20 + pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.21 pvr2/fragment.glsl maple/maple.c maple/maple.h \
2.22 maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c \
2.23 maple/vmu.c loader.c loader.h elf.h bootstrap.c bootstrap.h \
2.24 @@ -257,35 +257,35 @@
2.25 lxdream-sh4mmio.$(OBJEXT) lxdream-scif.$(OBJEXT) \
2.26 lxdream-sh4stat.$(OBJEXT) lxdream-xltcache.$(OBJEXT) \
2.27 lxdream-pmm.$(OBJEXT) lxdream-cache.$(OBJEXT) \
2.28 - lxdream-armcore.$(OBJEXT) lxdream-armdasm.$(OBJEXT) \
2.29 - lxdream-armmem.$(OBJEXT) lxdream-aica.$(OBJEXT) \
2.30 - lxdream-audio.$(OBJEXT) lxdream-pvr2.$(OBJEXT) \
2.31 - lxdream-pvr2mem.$(OBJEXT) lxdream-tacore.$(OBJEXT) \
2.32 - lxdream-rendsort.$(OBJEXT) lxdream-texcache.$(OBJEXT) \
2.33 - lxdream-yuv.$(OBJEXT) lxdream-rendsave.$(OBJEXT) \
2.34 - lxdream-scene.$(OBJEXT) lxdream-gl_sl.$(OBJEXT) \
2.35 - lxdream-gl_slsrc.$(OBJEXT) lxdream-glutil.$(OBJEXT) \
2.36 - lxdream-glrender.$(OBJEXT) lxdream-maple.$(OBJEXT) \
2.37 - lxdream-controller.$(OBJEXT) lxdream-kbd.$(OBJEXT) \
2.38 - lxdream-mouse.$(OBJEXT) lxdream-lightgun.$(OBJEXT) \
2.39 - lxdream-vmu.$(OBJEXT) lxdream-loader.$(OBJEXT) \
2.40 - lxdream-bootstrap.$(OBJEXT) lxdream-util.$(OBJEXT) \
2.41 - lxdream-gdlist.$(OBJEXT) lxdream-vmuvol.$(OBJEXT) \
2.42 - lxdream-vmulist.$(OBJEXT) lxdream-display.$(OBJEXT) \
2.43 - lxdream-audio_null.$(OBJEXT) lxdream-video_null.$(OBJEXT) \
2.44 - lxdream-video_gl.$(OBJEXT) lxdream-gl_fbo.$(OBJEXT) \
2.45 - lxdream-serial_unix.$(OBJEXT) lxdream-cdrom.$(OBJEXT) \
2.46 - lxdream-sector.$(OBJEXT) lxdream-cd_nrg.$(OBJEXT) \
2.47 - lxdream-cd_cdi.$(OBJEXT) lxdream-cd_gdi.$(OBJEXT) \
2.48 - lxdream-edc_ecc.$(OBJEXT) lxdream-drive.$(OBJEXT) \
2.49 - lxdream-cd_mmc.$(OBJEXT) lxdream-isofs.$(OBJEXT) \
2.50 - lxdream-hotkeys.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
2.51 - $(am__objects_3) $(am__objects_4) $(am__objects_5) \
2.52 - $(am__objects_6) $(am__objects_7) $(am__objects_8) \
2.53 - $(am__objects_9) $(am__objects_10) $(am__objects_11) \
2.54 - $(am__objects_12) $(am__objects_13) $(am__objects_14) \
2.55 - $(am__objects_15) $(am__objects_16) $(am__objects_17) \
2.56 - $(am__objects_18)
2.57 + lxdream-shadow.$(OBJEXT) lxdream-armcore.$(OBJEXT) \
2.58 + lxdream-armdasm.$(OBJEXT) lxdream-armmem.$(OBJEXT) \
2.59 + lxdream-aica.$(OBJEXT) lxdream-audio.$(OBJEXT) \
2.60 + lxdream-pvr2.$(OBJEXT) lxdream-pvr2mem.$(OBJEXT) \
2.61 + lxdream-tacore.$(OBJEXT) lxdream-rendsort.$(OBJEXT) \
2.62 + lxdream-texcache.$(OBJEXT) lxdream-yuv.$(OBJEXT) \
2.63 + lxdream-rendsave.$(OBJEXT) lxdream-scene.$(OBJEXT) \
2.64 + lxdream-gl_sl.$(OBJEXT) lxdream-gl_slsrc.$(OBJEXT) \
2.65 + lxdream-glutil.$(OBJEXT) lxdream-glrender.$(OBJEXT) \
2.66 + lxdream-maple.$(OBJEXT) lxdream-controller.$(OBJEXT) \
2.67 + lxdream-kbd.$(OBJEXT) lxdream-mouse.$(OBJEXT) \
2.68 + lxdream-lightgun.$(OBJEXT) lxdream-vmu.$(OBJEXT) \
2.69 + lxdream-loader.$(OBJEXT) lxdream-bootstrap.$(OBJEXT) \
2.70 + lxdream-util.$(OBJEXT) lxdream-gdlist.$(OBJEXT) \
2.71 + lxdream-vmuvol.$(OBJEXT) lxdream-vmulist.$(OBJEXT) \
2.72 + lxdream-display.$(OBJEXT) lxdream-audio_null.$(OBJEXT) \
2.73 + lxdream-video_null.$(OBJEXT) lxdream-video_gl.$(OBJEXT) \
2.74 + lxdream-gl_fbo.$(OBJEXT) lxdream-serial_unix.$(OBJEXT) \
2.75 + lxdream-cdrom.$(OBJEXT) lxdream-sector.$(OBJEXT) \
2.76 + lxdream-cd_nrg.$(OBJEXT) lxdream-cd_cdi.$(OBJEXT) \
2.77 + lxdream-cd_gdi.$(OBJEXT) lxdream-edc_ecc.$(OBJEXT) \
2.78 + lxdream-drive.$(OBJEXT) lxdream-cd_mmc.$(OBJEXT) \
2.79 + lxdream-isofs.$(OBJEXT) lxdream-hotkeys.$(OBJEXT) \
2.80 + $(am__objects_1) $(am__objects_2) $(am__objects_3) \
2.81 + $(am__objects_4) $(am__objects_5) $(am__objects_6) \
2.82 + $(am__objects_7) $(am__objects_8) $(am__objects_9) \
2.83 + $(am__objects_10) $(am__objects_11) $(am__objects_12) \
2.84 + $(am__objects_13) $(am__objects_14) $(am__objects_15) \
2.85 + $(am__objects_16) $(am__objects_17) $(am__objects_18)
2.86 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
2.87 lxdream_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.88 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.89 @@ -571,37 +571,37 @@
2.90 sh4/sh4dasm.h sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c \
2.91 sh4/sh4stat.c sh4/sh4stat.h xlat/xltcache.c xlat/xltcache.h \
2.92 sh4/sh4.h sh4/dmac.h sh4/pmm.c sh4/cache.c sh4/mmu.h \
2.93 - aica/armcore.c aica/armcore.h aica/armdasm.c aica/armdasm.h \
2.94 - aica/armmem.c aica/aica.c aica/aica.h aica/audio.c \
2.95 - aica/audio.h pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c \
2.96 - pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c pvr2/texcache.c \
2.97 - pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c pvr2/scene.h \
2.98 - pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c pvr2/glutil.h \
2.99 - pvr2/glrender.c pvr2/vertex.glsl pvr2/fragment.glsl \
2.100 - maple/maple.c maple/maple.h maple/controller.c maple/kbd.c \
2.101 - maple/mouse.c maple/lightgun.c maple/vmu.c loader.c loader.h \
2.102 - elf.h bootstrap.c bootstrap.h util.c gdlist.c gdlist.h \
2.103 - vmu/vmuvol.c vmu/vmuvol.h vmu/vmulist.c vmu/vmulist.h \
2.104 - display.c display.h dckeysyms.h drivers/audio_null.c \
2.105 - drivers/video_null.c drivers/video_gl.c drivers/video_gl.h \
2.106 - drivers/gl_fbo.c drivers/serial_unix.c drivers/cdrom/cdrom.h \
2.107 - drivers/cdrom/cdrom.c drivers/cdrom/drive.h \
2.108 - drivers/cdrom/sector.h drivers/cdrom/sector.c \
2.109 - drivers/cdrom/defs.h drivers/cdrom/cd_nrg.c \
2.110 - drivers/cdrom/cd_cdi.c drivers/cdrom/cd_gdi.c \
2.111 - drivers/cdrom/edc_ecc.c drivers/cdrom/ecc.h \
2.112 - drivers/cdrom/drive.c drivers/cdrom/edc_crctable.h \
2.113 - drivers/cdrom/edc_encoder.h drivers/cdrom/edc_l2sq.h \
2.114 - drivers/cdrom/edc_scramble.h drivers/cdrom/cd_mmc.c \
2.115 - drivers/cdrom/isofs.h drivers/cdrom/isofs.c sh4/sh4.def \
2.116 - sh4/sh4core.in sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in \
2.117 - hotkeys.c hotkeys.h $(am__append_1) $(am__append_2) \
2.118 - $(am__append_4) $(am__append_5) $(am__append_6) \
2.119 - $(am__append_7) $(am__append_8) $(am__append_9) \
2.120 - $(am__append_10) $(am__append_17) $(am__append_19) \
2.121 - $(am__append_21) $(am__append_23) $(am__append_25) \
2.122 - $(am__append_27) $(am__append_28) $(am__append_29) \
2.123 - $(am__append_30)
2.124 + sh4/shadow.c aica/armcore.c aica/armcore.h aica/armdasm.c \
2.125 + aica/armdasm.h aica/armmem.c aica/aica.c aica/aica.h \
2.126 + aica/audio.c aica/audio.h pvr2/pvr2.c pvr2/pvr2.h \
2.127 + pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c \
2.128 + pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
2.129 + pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.130 + pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.131 + pvr2/fragment.glsl maple/maple.c maple/maple.h \
2.132 + maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c \
2.133 + maple/vmu.c loader.c loader.h elf.h bootstrap.c bootstrap.h \
2.134 + util.c gdlist.c gdlist.h vmu/vmuvol.c vmu/vmuvol.h \
2.135 + vmu/vmulist.c vmu/vmulist.h display.c display.h dckeysyms.h \
2.136 + drivers/audio_null.c drivers/video_null.c drivers/video_gl.c \
2.137 + drivers/video_gl.h drivers/gl_fbo.c drivers/serial_unix.c \
2.138 + drivers/cdrom/cdrom.h drivers/cdrom/cdrom.c \
2.139 + drivers/cdrom/drive.h drivers/cdrom/sector.h \
2.140 + drivers/cdrom/sector.c drivers/cdrom/defs.h \
2.141 + drivers/cdrom/cd_nrg.c drivers/cdrom/cd_cdi.c \
2.142 + drivers/cdrom/cd_gdi.c drivers/cdrom/edc_ecc.c \
2.143 + drivers/cdrom/ecc.h drivers/cdrom/drive.c \
2.144 + drivers/cdrom/edc_crctable.h drivers/cdrom/edc_encoder.h \
2.145 + drivers/cdrom/edc_l2sq.h drivers/cdrom/edc_scramble.h \
2.146 + drivers/cdrom/cd_mmc.c drivers/cdrom/isofs.h \
2.147 + drivers/cdrom/isofs.c sh4/sh4.def sh4/sh4core.in sh4/sh4x86.in \
2.148 + sh4/sh4dasm.in sh4/sh4stat.in hotkeys.c hotkeys.h \
2.149 + $(am__append_1) $(am__append_2) $(am__append_4) \
2.150 + $(am__append_5) $(am__append_6) $(am__append_7) \
2.151 + $(am__append_8) $(am__append_9) $(am__append_10) \
2.152 + $(am__append_17) $(am__append_19) $(am__append_21) \
2.153 + $(am__append_23) $(am__append_25) $(am__append_27) \
2.154 + $(am__append_28) $(am__append_29) $(am__append_30)
2.155 lxdream_CPPFLAGS = @LXDREAMCPPFLAGS@
2.156 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @LXDREAM_LIBS@ @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@
2.157 @BUILD_SH4X86_TRUE@test_testsh4x86_CPPFLAGS = @LXDREAMCPPFLAGS@
2.158 @@ -870,6 +870,7 @@
2.159 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-sh4stat.Po@am__quote@
2.160 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-sh4trans.Po@am__quote@
2.161 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-sh4x86.Po@am__quote@
2.162 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-shadow.Po@am__quote@
2.163 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-syscall.Po@am__quote@
2.164 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-tacore.Po@am__quote@
2.165 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-texcache.Po@am__quote@
2.166 @@ -1452,6 +1453,20 @@
2.167 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.168 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-cache.obj `if test -f 'sh4/cache.c'; then $(CYGPATH_W) 'sh4/cache.c'; else $(CYGPATH_W) '$(srcdir)/sh4/cache.c'; fi`
2.169
2.170 +lxdream-shadow.o: sh4/shadow.c
2.171 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-shadow.o -MD -MP -MF "$(DEPDIR)/lxdream-shadow.Tpo" -c -o lxdream-shadow.o `test -f 'sh4/shadow.c' || echo '$(srcdir)/'`sh4/shadow.c; \
2.172 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-shadow.Tpo" "$(DEPDIR)/lxdream-shadow.Po"; else rm -f "$(DEPDIR)/lxdream-shadow.Tpo"; exit 1; fi
2.173 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sh4/shadow.c' object='lxdream-shadow.o' libtool=no @AMDEPBACKSLASH@
2.174 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.175 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-shadow.o `test -f 'sh4/shadow.c' || echo '$(srcdir)/'`sh4/shadow.c
2.176 +
2.177 +lxdream-shadow.obj: sh4/shadow.c
2.178 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-shadow.obj -MD -MP -MF "$(DEPDIR)/lxdream-shadow.Tpo" -c -o lxdream-shadow.obj `if test -f 'sh4/shadow.c'; then $(CYGPATH_W) 'sh4/shadow.c'; else $(CYGPATH_W) '$(srcdir)/sh4/shadow.c'; fi`; \
2.179 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-shadow.Tpo" "$(DEPDIR)/lxdream-shadow.Po"; else rm -f "$(DEPDIR)/lxdream-shadow.Tpo"; exit 1; fi
2.180 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sh4/shadow.c' object='lxdream-shadow.obj' libtool=no @AMDEPBACKSLASH@
2.181 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.182 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-shadow.obj `if test -f 'sh4/shadow.c'; then $(CYGPATH_W) 'sh4/shadow.c'; else $(CYGPATH_W) '$(srcdir)/sh4/shadow.c'; fi`
2.183 +
2.184 lxdream-armcore.o: aica/armcore.c
2.185 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-armcore.o -MD -MP -MF "$(DEPDIR)/lxdream-armcore.Tpo" -c -o lxdream-armcore.o `test -f 'aica/armcore.c' || echo '$(srcdir)/'`aica/armcore.c; \
2.186 @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-armcore.Tpo" "$(DEPDIR)/lxdream-armcore.Po"; else rm -f "$(DEPDIR)/lxdream-armcore.Tpo"; exit 1; fi
3.1 --- a/src/main.c Sat Sep 11 09:58:22 2010 +1000
3.2 +++ b/src/main.c Mon Sep 13 10:13:42 2010 +1000
3.3 @@ -42,7 +42,7 @@
3.4 #include "hotkeys.h"
3.5 #include "plugin.h"
3.6
3.7 -char *option_list = "a:A:bc:e:dfg:G:hHl:m:npt:T:uvV:x?";
3.8 +char *option_list = "a:A:bc:e:dfg:G:hHl:m:npt:T:uvV:xX?";
3.9 struct option longopts[] = {
3.10 { "aica", required_argument, NULL, 'a' },
3.11 { "audio", required_argument, NULL, 'A' },
3.12 @@ -58,6 +58,7 @@
3.13 { "log", required_argument, NULL,'l' },
3.14 { "multiplier", required_argument, NULL, 'm' },
3.15 { "run-time", required_argument, NULL, 't' },
3.16 + { "shadow", no_argument, NULL, 'X' },
3.17 { "trace", required_argument, NULL, 'T' },
3.18 { "unsafe", no_argument, NULL, 'u' },
3.19 { "video", no_argument, NULL, 'V' },
3.20 @@ -72,7 +73,7 @@
3.21 gboolean start_immediately = FALSE;
3.22 gboolean no_start = FALSE;
3.23 gboolean headless = FALSE;
3.24 -gboolean use_xlat = TRUE;
3.25 +sh4core_t sh4_core = SH4_TRANSLATE;
3.26 gboolean show_debugger = FALSE;
3.27 gboolean show_fullscreen = FALSE;
3.28 gboolean use_bootrom = TRUE;
3.29 @@ -110,6 +111,7 @@
3.30 printf( " -v, --version %s\n", _("Print the lxdream version string") );
3.31 printf( " -V, --video=DRIVER %s\n", _("Use the specified video driver (? to list)") );
3.32 printf( " -x %s\n", _("Disable the SH4 translator") );
3.33 + printf( " -X %s\n", _("Run both SH4 interpreter and translator") );
3.34 }
3.35
3.36 static void bind_gettext_domain()
3.37 @@ -207,7 +209,10 @@
3.38 display_driver_name = optarg;
3.39 break;
3.40 case 'x': /* Disable translator */
3.41 - use_xlat = FALSE;
3.42 + sh4_core = SH4_INTERPRET;
3.43 + break;
3.44 + case 'X': /* Shadow translator */
3.45 + sh4_core = SH4_SHADOW;
3.46 break;
3.47 }
3.48 }
3.49 @@ -321,7 +326,7 @@
3.50 }
3.51 }
3.52
3.53 - sh4_translate_set_enabled( use_xlat );
3.54 + sh4_set_core( sh4_core );
3.55
3.56 /* If requested, start the gdb server immediately before we go into the main
3.57 * loop.
4.1 --- a/src/sh4/sh4.c Sat Sep 11 09:58:22 2010 +1000
4.2 +++ b/src/sh4/sh4.c Mon Sep 13 10:13:42 2010 +1000
4.3 @@ -160,14 +160,19 @@
4.4 {
4.5 }
4.6
4.7 -void sh4_translate_set_enabled( gboolean use )
4.8 +void sh4_set_core( sh4core_t core )
4.9 {
4.10 // No-op if the translator was not built
4.11 #ifdef SH4_TRANSLATOR
4.12 - if( use ) {
4.13 + if( core != SH4_INTERPRET ) {
4.14 sh4_translate_init();
4.15 + sh4_use_translator = TRUE;
4.16 + if( core == SH4_SHADOW ) {
4.17 + sh4_shadow_init();
4.18 + }
4.19 + } else {
4.20 + sh4_use_translator = FALSE;
4.21 }
4.22 - sh4_use_translator = use;
4.23 #endif
4.24 }
4.25
5.1 --- a/src/sh4/sh4.h Sat Sep 11 09:58:22 2010 +1000
5.2 +++ b/src/sh4/sh4.h Mon Sep 13 10:13:42 2010 +1000
5.3 @@ -97,6 +97,12 @@
5.4
5.5 extern const struct cpu_desc_struct sh4_cpu_desc;
5.6
5.7 +typedef enum {
5.8 + SH4_INTERPRET,
5.9 + SH4_TRANSLATE,
5.10 + SH4_SHADOW
5.11 +} sh4core_t;
5.12 +
5.13 /**
5.14 * Switch between translation and emulation execution modes. Note that this
5.15 * should only be used while the system is stopped. If the system was built
5.16 @@ -104,7 +110,7 @@
5.17 *
5.18 * @param use TRUE for translation mode, FALSE for emulation mode.
5.19 */
5.20 -void sh4_translate_set_enabled( gboolean use );
5.21 +void sh4_set_core( sh4core_t core );
5.22
5.23 /**
5.24 * Test if system is currently using the translation engine.
6.1 --- a/src/sh4/sh4core.in Sat Sep 11 09:58:22 2010 +1000
6.2 +++ b/src/sh4/sh4core.in Mon Sep 13 10:13:42 2010 +1000
6.3 @@ -178,6 +178,7 @@
6.4 static FASTCALL __attribute__((noinline)) void *__first_arg(void *a, void *b) { return a; }
6.5 #define INIT_EXCEPTIONS(label) goto *__first_arg(&&fnstart,&&label); fnstart:
6.6 #define MEM_READ_BYTE( addr, val ) val = ((mem_read_exc_fn_t)ADDRSPACE[(addr)>>12]->read_byte)((addr), &&except)
6.7 +#define MEM_READ_BYTE_FOR_WRITE( addr, val ) val = ((mem_read_exc_fn_t)ADDRSPACE[(addr)>>12]->read_byte_for_write)((addr), &&except)
6.8 #define MEM_READ_WORD( addr, val ) val = ((mem_read_exc_fn_t)ADDRSPACE[(addr)>>12]->read_word)((addr), &&except)
6.9 #define MEM_READ_LONG( addr, val ) val = ((mem_read_exc_fn_t)ADDRSPACE[(addr)>>12]->read_long)((addr), &&except)
6.10 #define MEM_WRITE_BYTE( addr, val ) ((mem_write_exc_fn_t)ADDRSPACE[(addr)>>12]->write_byte)((addr), (val), &&except)
6.11 @@ -187,6 +188,7 @@
6.12 #else
6.13 #define INIT_EXCEPTIONS(label)
6.14 #define MEM_READ_BYTE( addr, val ) val = ADDRSPACE[(addr)>>12]->read_byte(addr)
6.15 +#define MEM_READ_BYTE_FOR_WRITE( addr, val ) val = ADDRSPACE[(addr)>>12]->read_byte_for_write(addr)
6.16 #define MEM_READ_WORD( addr, val ) val = ADDRSPACE[(addr)>>12]->read_word(addr)
6.17 #define MEM_READ_LONG( addr, val ) val = ADDRSPACE[(addr)>>12]->read_long(addr)
6.18 #define MEM_WRITE_BYTE( addr, val ) ADDRSPACE[(addr)>>12]->write_byte(addr, val)
6.19 @@ -406,13 +408,13 @@
6.20 %%
6.21 AND Rm, Rn {: sh4r.r[Rn] &= sh4r.r[Rm]; :}
6.22 AND #imm, R0 {: R0 &= imm; :}
6.23 - AND.B #imm, @(R0, GBR) {: MEM_READ_BYTE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm & tmp ); :}
6.24 + AND.B #imm, @(R0, GBR) {: MEM_READ_BYTE_FOR_WRITE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm & tmp ); :}
6.25 NOT Rm, Rn {: sh4r.r[Rn] = ~sh4r.r[Rm]; :}
6.26 OR Rm, Rn {: sh4r.r[Rn] |= sh4r.r[Rm]; :}
6.27 OR #imm, R0 {: R0 |= imm; :}
6.28 - OR.B #imm, @(R0, GBR) {: MEM_READ_BYTE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm | tmp ); :}
6.29 + OR.B #imm, @(R0, GBR) {: MEM_READ_BYTE_FOR_WRITE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm | tmp ); :}
6.30 TAS.B @Rn {:
6.31 - MEM_READ_BYTE( sh4r.r[Rn], tmp );
6.32 + MEM_READ_BYTE_FOR_WRITE( sh4r.r[Rn], tmp );
6.33 sh4r.t = ( tmp == 0 ? 1 : 0 );
6.34 MEM_WRITE_BYTE( sh4r.r[Rn], tmp | 0x80 );
6.35 :}
6.36 @@ -421,7 +423,7 @@
6.37 TST.B #imm, @(R0, GBR) {: MEM_READ_BYTE(R0+sh4r.gbr, tmp); sh4r.t = ( tmp & imm ? 0 : 1 ); :}
6.38 XOR Rm, Rn {: sh4r.r[Rn] ^= sh4r.r[Rm]; :}
6.39 XOR #imm, R0 {: R0 ^= imm; :}
6.40 - XOR.B #imm, @(R0, GBR) {: MEM_READ_BYTE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm ^ tmp ); :}
6.41 + XOR.B #imm, @(R0, GBR) {: MEM_READ_BYTE_FOR_WRITE(R0+sh4r.gbr, tmp); MEM_WRITE_BYTE( R0 + sh4r.gbr, imm ^ tmp ); :}
6.42 XTRCT Rm, Rn {: sh4r.r[Rn] = (sh4r.r[Rn]>>16) | (sh4r.r[Rm]<<16); :}
6.43
6.44 ROTL Rn {:
7.1 --- a/src/sh4/sh4trans.c Sat Sep 11 09:58:22 2010 +1000
7.2 +++ b/src/sh4/sh4trans.c Mon Sep 13 10:13:42 2010 +1000
7.3 @@ -27,6 +27,8 @@
7.4 #include "sh4/mmu.h"
7.5 #include "xlat/xltcache.h"
7.6
7.7 +//#define SINGLESTEP 1
7.8 +
7.9 /**
7.10 * Execute a timeslice using translated code only (ie translate/execute loop)
7.11 */
7.12 @@ -113,6 +115,9 @@
7.13 if ( pc >= lastpc ) {
7.14 done = 2;
7.15 }
7.16 +#ifdef SINGLESTEP
7.17 + if( !done ) done = 2;
7.18 +#endif
7.19 } while( !done );
7.20 pc += (done - 2);
7.21
8.1 --- a/src/sh4/sh4trans.h Sat Sep 11 09:58:22 2010 +1000
8.2 +++ b/src/sh4/sh4trans.h Mon Sep 13 10:13:42 2010 +1000
8.3 @@ -41,6 +41,9 @@
8.4 */
8.5 #define MAX_RECOVERY_SIZE 2049
8.6
8.7 +typedef void (*xlat_block_begin_callback_t)();
8.8 +typedef void (*xlat_block_end_callback_t)();
8.9 +
8.10 /**
8.11 */
8.12 uint32_t sh4_translate_run_slice( uint32_t nanosecs );
8.13 @@ -63,6 +66,11 @@
8.14 */
8.15 void sh4_translate_add_recovery( uint32_t icount );
8.16
8.17 +/**
8.18 + * Initialize shadow execution mode
8.19 + */
8.20 +void sh4_shadow_init( void );
8.21 +
8.22 extern uint8_t *xlat_output;
8.23 extern struct xlat_recovery_record xlat_recovery[MAX_RECOVERY_SIZE];
8.24 extern xlat_cache_block_t xlat_current_block;
8.25 @@ -85,6 +93,21 @@
8.26 typedef void (*unwind_thunk_t)(void);
8.27
8.28 /**
8.29 + * Set instrumentation callbacks
8.30 + */
8.31 +void sh4_translate_set_callbacks( xlat_block_begin_callback_t begin, xlat_block_end_callback_t end );
8.32 +
8.33 +/**
8.34 + * Enable/disable memory optimizations that bypass the mmu
8.35 + */
8.36 +void sh4_translate_set_fastmem( gboolean flag );
8.37 +
8.38 +/**
8.39 + * Set the address spaces for the translated code.
8.40 + */
8.41 +void sh4_translate_set_address_space( struct mem_region_fn **priv, struct mem_region_fn **user );
8.42 +
8.43 +/**
8.44 * From within the translator, (typically called from MMU exception handling routines)
8.45 * immediately exit the current translation block (performing cleanup as necessary) and
8.46 * return to sh4_translate_run_slice(). Effectively a fast longjmp w/ xlat recovery.
9.1 --- a/src/sh4/sh4x86.in Sat Sep 11 09:58:22 2010 +1000
9.2 +++ b/src/sh4/sh4x86.in Mon Sep 13 10:13:42 2010 +1000
9.3 @@ -97,9 +97,16 @@
9.4 uint32_t sh4_mode; /* Mirror of sh4r.xlat_sh4_mode */
9.5 int tstate;
9.6
9.7 - /* mode flags */
9.8 + /* mode settings */
9.9 gboolean tlb_on; /* True if tlb translation is active */
9.10 + struct mem_region_fn **priv_address_space;
9.11 + struct mem_region_fn **user_address_space;
9.12
9.13 + /* Instrumentation */
9.14 + xlat_block_begin_callback_t begin_callback;
9.15 + xlat_block_end_callback_t end_callback;
9.16 + gboolean fastmem;
9.17 +
9.18 /* Allocated memory for the (block-wide) back-patch list */
9.19 struct backpatch_record *backpatch_list;
9.20 uint32_t backpatch_posn;
9.21 @@ -117,8 +124,8 @@
9.22 { "sh4r+128", ((char *)&sh4r)+128 },
9.23 { "sh4_cpu_period", &sh4_cpu_period },
9.24 { "sh4_address_space", NULL },
9.25 + { "sh4_user_address_space", NULL },
9.26 { "sh4_translate_breakpoint_hit", sh4_translate_breakpoint_hit },
9.27 - { "sh4_user_address_space", NULL },
9.28 { "sh4_write_fpscr", sh4_write_fpscr },
9.29 { "sh4_write_sr", sh4_write_sr },
9.30 { "sh4_read_sr", sh4_read_sr },
9.31 @@ -143,17 +150,38 @@
9.32 return (features & 1) ? TRUE : FALSE;
9.33 }
9.34
9.35 +void sh4_translate_set_address_space( struct mem_region_fn **priv, struct mem_region_fn **user )
9.36 +{
9.37 + sh4_x86.priv_address_space = priv;
9.38 + sh4_x86.user_address_space = user;
9.39 + x86_symbol_table[2].ptr = priv;
9.40 + x86_symbol_table[3].ptr = user;
9.41 +}
9.42 +
9.43 void sh4_translate_init(void)
9.44 {
9.45 sh4_x86.backpatch_list = malloc(DEFAULT_BACKPATCH_SIZE);
9.46 sh4_x86.backpatch_size = DEFAULT_BACKPATCH_SIZE / sizeof(struct backpatch_record);
9.47 + sh4_x86.begin_callback = NULL;
9.48 + sh4_x86.end_callback = NULL;
9.49 + sh4_translate_set_address_space( sh4_address_space, sh4_user_address_space );
9.50 + sh4_x86.fastmem = TRUE;
9.51 sh4_x86.sse3_enabled = is_sse3_supported();
9.52 - x86_symbol_table[2].ptr = sh4_address_space;
9.53 - x86_symbol_table[3].ptr = sh4_user_address_space;
9.54 x86_disasm_init();
9.55 x86_set_symtab( x86_symbol_table, sizeof(x86_symbol_table)/sizeof(struct x86_symbol) );
9.56 }
9.57
9.58 +void sh4_translate_set_callbacks( xlat_block_begin_callback_t begin, xlat_block_end_callback_t end )
9.59 +{
9.60 + sh4_x86.begin_callback = begin;
9.61 + sh4_x86.end_callback = end;
9.62 +}
9.63 +
9.64 +void sh4_translate_set_fastmem( gboolean flag )
9.65 +{
9.66 + sh4_x86.fastmem = flag;
9.67 +}
9.68 +
9.69 /**
9.70 * Disassemble the given translated code block, and it's source SH4 code block
9.71 * side-by-side. The current native pc will be marked if non-null.
9.72 @@ -371,7 +399,7 @@
9.73 TESTL_imms_r32( 0x00000007, x86reg ); \
9.74 JNE_exc(EXC_DATA_ADDR_WRITE);
9.75
9.76 -#define address_space() ((sh4_x86.sh4_mode&SR_MD) ? (uintptr_t)sh4_address_space : (uintptr_t)sh4_user_address_space)
9.77 +#define address_space() ((sh4_x86.sh4_mode&SR_MD) ? (uintptr_t)sh4_x86.priv_address_space : (uintptr_t)sh4_x86.user_address_space)
9.78
9.79 #define UNDEF(ir)
9.80 /* Note: For SR.MD == 1 && MMUCR.AT == 0, there are no memory exceptions, so
9.81 @@ -461,7 +489,10 @@
9.82 sh4_x86.double_prec = sh4r.fpscr & FPSCR_PR;
9.83 sh4_x86.double_size = sh4r.fpscr & FPSCR_SZ;
9.84 sh4_x86.sh4_mode = sh4r.xlat_sh4_mode;
9.85 - enter_block();
9.86 + emit_prologue();
9.87 + if( sh4_x86.begin_callback ) {
9.88 + CALL_ptr( sh4_x86.begin_callback );
9.89 + }
9.90 }
9.91
9.92
9.93 @@ -508,10 +539,30 @@
9.94 }
9.95 JNE_label(wrongmode);
9.96 LEAP_rptrdisp_rptr(REG_EAX, PROLOGUE_SIZE,REG_EAX);
9.97 - JMP_rptr(REG_EAX);
9.98 + if( sh4_x86.end_callback ) {
9.99 + /* Note this does leave the stack out of alignment, but doesn't matter
9.100 + * for what we're currently using it for.
9.101 + */
9.102 + PUSH_r32(REG_EAX);
9.103 + MOVP_immptr_rptr(sh4_x86.end_callback, REG_ECX);
9.104 + JMP_rptr(REG_ECX);
9.105 + } else {
9.106 + JMP_rptr(REG_EAX);
9.107 + }
9.108 JMP_TARGET(nocode); JMP_TARGET(wrongmode);
9.109 }
9.110
9.111 +static void exit_block()
9.112 +{
9.113 + emit_epilogue();
9.114 + if( sh4_x86.end_callback ) {
9.115 + MOVP_immptr_rptr(sh4_x86.end_callback, REG_ECX);
9.116 + JMP_rptr(REG_ECX);
9.117 + } else {
9.118 + RET();
9.119 + }
9.120 +}
9.121 +
9.122 /**
9.123 * Exit the block with sh4r.pc already written
9.124 */
9.125 @@ -1616,7 +1667,7 @@
9.126 SLOTILLEGAL();
9.127 } else {
9.128 uint32_t target = (pc & 0xFFFFFFFC) + disp + 4;
9.129 - if( IS_IN_ICACHE(target) ) {
9.130 + if( sh4_x86.fastmem && IS_IN_ICACHE(target) ) {
9.131 // If the target address is in the same page as the code, it's
9.132 // pretty safe to just ref it directly and circumvent the whole
9.133 // memory subsystem. (this is a big performance win)
9.134 @@ -1738,7 +1789,7 @@
9.135 } else {
9.136 // See comments for MOV.L @(disp, PC), Rn
9.137 uint32_t target = pc + disp + 4;
9.138 - if( IS_IN_ICACHE(target) ) {
9.139 + if( sh4_x86.fastmem && IS_IN_ICACHE(target) ) {
9.140 sh4ptr_t ptr = GET_ICACHE_PTR(target);
9.141 MOVL_moffptr_eax( ptr );
9.142 MOVSXL_r16_r32( REG_EAX, REG_EAX );
10.1 --- a/src/xlat/x86/amd64abi.h Sat Sep 11 09:58:22 2010 +1000
10.2 +++ b/src/xlat/x86/amd64abi.h Mon Sep 13 10:13:42 2010 +1000
10.3 @@ -100,16 +100,15 @@
10.4 * Emit the 'start of block' assembly. Sets up the stack frame and save
10.5 * SI/DI as required
10.6 */
10.7 -static inline void enter_block( )
10.8 +static inline void emit_prologue( )
10.9 {
10.10 PUSH_r32(REG_RBP);
10.11 SUBQ_imms_r64( 16, REG_RSP );
10.12 MOVP_immptr_rptr( ((uint8_t *)&sh4r) + 128, REG_EBP );
10.13 }
10.14
10.15 -static inline void exit_block( )
10.16 +static inline void emit_epilogue( )
10.17 {
10.18 ADDQ_imms_r64( 16, REG_RSP );
10.19 POP_r32(REG_RBP);
10.20 - RET();
10.21 }
11.1 --- a/src/xlat/x86/ia32abi.h Sat Sep 11 09:58:22 2010 +1000
11.2 +++ b/src/xlat/x86/ia32abi.h Mon Sep 13 10:13:42 2010 +1000
11.3 @@ -140,16 +140,16 @@
11.4 * Allocates 8 bytes for local variables, which also has the convenient
11.5 * side-effect of aligning the stack.
11.6 */
11.7 -static inline void enter_block( )
11.8 +static inline void emit_prologue( )
11.9 {
11.10 PUSH_r32(REG_EBP);
11.11 SUBL_imms_r32( 8, REG_ESP );
11.12 MOVP_immptr_rptr( ((uint8_t *)&sh4r) + 128, REG_EBP );
11.13 }
11.14
11.15 -static inline void exit_block( )
11.16 +static inline void emit_epilogue( )
11.17 {
11.18 ADDL_imms_r32( 8, REG_ESP );
11.19 POP_r32(REG_EBP);
11.20 - RET();
11.21 }
11.22 +
.