From: kub Date: Wed, 21 Aug 2019 16:27:26 +0000 (+0200) Subject: configuration changes and README X-Git-Tag: v2.00~839 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f7a30ede33ee915cc0e7dc86d9d9ee4b22f051c;p=picodrive.git configuration changes and README --- diff --git a/Makefile b/Makefile index 96ccb6ca..c3bd6899 100644 --- a/Makefile +++ b/Makefile @@ -238,8 +238,8 @@ pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing ifeq (1,$(use_sh2drc)) ifneq (,$(findstring -flto,$(CFLAGS))) -# if using the DRC, memory and sh2soc use a global register variable to avoid -# saving and reloading the SH2 SR. However, this collides with the use of LTO. +# if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR +# to avoid saving and reloading it. However, this collides with the use of LTO. pico/32x/memory.o: CFLAGS += -fno-lto pico/32x/sh2soc.o: CFLAGS += -fno-lto endif diff --git a/README.md b/README.md new file mode 100644 index 00000000..d0d7259f --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +This is my foray into dynamic recompilation using PicoDrive, a +Megadrive / Genesis / Sega CD / Mega CD / 32X / SMS emulator. + +I added support for MIPS (mips32r1) and ARM64 (aarch64) to the recompiler, as +well as spent much effort to optimize the code generated by the DRC. +I also optimized SH2 memory access inside the emulator, and did some work on +M68K/SH2 CPU synchronization to fix some problems and speed up the emulator. + +It got a bit out of hand. I ended up doing fixes and optimzations all over the +place, mainly for 32X and CD, 32X graphics handling, and probably some more, +see the commit history. + +### compiling + +I mainly worked with standalone PicoDrive versions as created by configure/make. +A list of platforms for which this is possible can be obtained with + +> configure --help + +If you want to build an executable for a unixoid platform not listed in the +platform list, just use + +> configure --platform=generic + +If DRC is available for the platform, it should be enabled automatically. + +For other platforms using a cross-compiling toolchain I used this, +assuming $TC points to the appropriate cross compile toolchain directory: + +platform|toolchain|configure command +--------|---------|----------------- +gp2x,wiz,caanoo|open2x|CROSS_COMPILE=arm-open2x-linux- CFLAGS="-I$TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include -fno-stack-protector -fno-common -finline-limit=42" LDFLAGS="--sysroot $TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux -L$TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib" ./configure --platform=gp2x +gp2x,wiz,caanoo|open2x with ubuntu arm gcc 4.7|CROSS_COMPILE=arm-linux-gnueabi- CFLAGS="-I$TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include -fno-stack-protector -fno-common -finline-limit=42 -fipa-pta" LDFLAGS="-B$TC/gcc-4.1.1-glibc-2.3.6/lib/gcc/arm-open2x-linux/4.1.1 -B$TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib -L$TC/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib" ./configure --platform=gp2x +opendingux|opendingux|CROSS_COMPILE=mipsel-linux- CFLAGS="-I$TC/usr/include -I$TC/usr/include/SDL -fno-stack-protector -fno-common -finline-limit=42 -fipa-pta" LDFLAGS="--sysroot $TC -L$TC/lib" ./configure --platform=opendingux +opendingux|opendingux with ubuntu mips gcc 5.4|CROSS_COMPILE=mipsel-linux-gnu- CFLAGS="-I$TC/usr/include -I$TC/usr/include/SDL -fno-stack-protector -fno-common -finline-limit=42 -fipa-pta" LDFLAGS="-B$TC/usr/lib -B$TC/lib -Wl,-rpath-link=$TC/usr/lib -Wl,-rpath-link=$TC/lib" ./configure --platform=opendingux +gcw0|gcw0|CROSS_COMPILE=mipsel-gcw0-linux-uclibc- CFLAGS="-I$TC/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include -I$TC/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL -fno-stack-protector -fno-common -finline-limit=42 -fipa-pta" LDFLAGS="--sysroot $TC/usr/mipsel-gcw0-linux-uclibc/sysroot" ./configure --platform=gcw0 + +For gp2x, wiz, and caanoo you may need to compile libpng first, and additionally +this patch may need to be applied to the cpu/cyclone submodule: +> diff --git a/OpArith.cpp b/OpArith.cpp +> index 96c7e0d..09517b8 100644 +> --- a/OpArith.cpp +> +++ b/OpArith.cpp +> @@ -425,7 +425,7 @@ int OpAbcd(int op) +> ot(" add r1,r1,r0\n"); +> ot(" add r1,r1,r6\n"); +> ot(" mov r12,r1\n"); +> - ot(" addhi r12,#6 ;@ Decimal adjust units\n"); +> + ot(" addhi r12,r12,#6 ;@ Decimal adjust units\n"); +> ot(" tst r1,#0x80\n"); +> ot(" orreq r10,r10,#0x10000000 ;@ Undefined V behavior\n"); +> ot(" cmp r12,#0x9f\n"); +> @@ -452,7 +452,7 @@ int OpAbcd(int op) +> ot(" cmp r1,r12\n"); +> ot(" orrlt r10,r10,#0x20000000 ;@ C\n"); +> ot(" cmp r1,#0xff\n"); +> - ot(" addhi r1,#0xa0\n"); +> + ot(" addhi r1,r1,#0xa0\n"); +> ot(" sub r12,r1,r12\n"); +> ot(" movs r0,r12,lsl #24\n"); +> ot(" bicmi r10,r10,#0x10000000 ;@ Undefined V behavior part II\n"); +> diff --git a/OpLogic.cpp b/OpLogic.cpp +> index 012e35a..d40d814 100644 +> --- a/OpLogic.cpp +> +++ b/OpLogic.cpp +> @@ -74,12 +74,12 @@ const char *TestCond(int m68k_cc, int invert) +> break; +> case 0x0e: // gt +> ot(" eor r0,r10,r10,lsl #3 ;@ gt: !Z && N == V\n"); +> - ot(" orrs r0,r10,lsl #1\n"); +> + ot(" orrs r0,r0,r10,lsl #1\n"); +> cond="pl", icond="mi"; +> break; +> case 0x0f: // le +> ot(" eor r0,r10,r10,lsl #3 ;@ le: Z || N != V\n"); +> - ot(" orrs r0,r10,lsl #1\n"); +> + ot(" orrs r0,r0,r10,lsl #1\n"); +> cond="mi", icond="pl"; +> break; +> default: + +After configure, compile with + +> make opk # for opendingux and gcw0 +> +> make # for anything else + +### helix MP3 decoder + +For 32 bit ARM platforms, there is the possibility to compile the helix MP3 +decoder into a shared library to be able to use MP3 audio files with CD games. +The helix source files aren't supplied because of licensing issues. However, if +you have obtained the sources, put them into the platform/common/helix +directory, set CROSS to your cross compiler prefix (e.g. arm-linux-gnueabi-) +and LIBGCC to your cross compiler's libgcc.a +(e.g. /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/libgcc.a), and compile with + +> make -C platform/common/helix CROSS=$CROSS LIBGCC=$LIBGCC + +Copy the resulting ${CROSS}helix_mp3.so as libhelix.so to the directory where +the PicoDrive binary is. + +### installing + +You need to install the resulting binary onto your device manually. +For opendingux and gcw0, copy the opk to your SD card. +For gp2x, wiz and caanoo, the easiest way is to unpack +[PicoDrive_191.zip](http://notaz.gp2x.de/releases/PicoDrive/PicoDrive_191.zip) +on you SD card and replace the PicoDrive binary. + +Send bug reports, fixes etc to +Kai-Uwe Bloem diff --git a/config.dingux b/config.dingux index d1ec7fe5..b981bd3f 100644 --- a/config.dingux +++ b/config.dingux @@ -1,5 +1,5 @@ # Automatically generated by configure -# Configured with: './configure' '--platform=generic' +# Configured with: './configure' '--platform=opendingux' CC = mipsel-linux-gcc CXX = mipsel-linux-g++ AS = mipsel-linux-as diff --git a/config.dingux54 b/config.dingux54 index 423cbd17..a232d952 100644 --- a/config.dingux54 +++ b/config.dingux54 @@ -1,5 +1,5 @@ # Automatically generated by configure -# Configured with: './configure' '--platform=generic' +# Configured with: './configure' '--platform=opendingux' CC = mipsel-linux-gnu-gcc CXX = mipsel-linux-gnu-g++ AS = mipsel-linux-gnu-as diff --git a/config.gcw0 b/config.gcw0 index 78f7c3a4..cebe79a1 100644 --- a/config.gcw0 +++ b/config.gcw0 @@ -1,5 +1,5 @@ # Automatically generated by configure -# Configured with: './configure' '--platform=generic' +# Configured with: './configure' '--platform=gcw0' CC = mipsel-gcw0-linux-uclibc-gcc CXX = mipsel-gcw0-linux-uclibc-g++ AS = mipsel-gcw0-linux-uclibc-as diff --git a/config.gp2x b/config.gp2x index 84d2f93d..cf99bd77 100644 --- a/config.gp2x +++ b/config.gp2x @@ -4,8 +4,8 @@ CC = arm-open2x-linux-gcc CXX = arm-open2x-linux-g++ AS = arm-open2x-linux-as STRIP = arm-open2x-linux-strip -CFLAGS += -I${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include -I${HOME}/src/gp2x/armroot/include -D__GP2X__ -Wno-unused-result -CFLAGS += -msoft-float -mcpu=arm920t -mtune=arm920t +CFLAGS += -I${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include -I${HOME}/src/gp2x/armroot/include -D__GP2X__ +CFLAGS += -mfloat-abi=soft -mcpu=arm920t -mtune=arm920t -mno-thumb-interwork -fno-stack-protector -fno-common CFLAGS += -finline-limit=42 -fipa-cp -fno-ipa-pure-const ASFLAGS += -mcpu=arm920t -mfloat-abi=soft LDFLAGS += --sysroot ${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux -L${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib -L${HOME}/src/gp2x/armroot/lib -static diff --git a/config.gp2x47 b/config.gp2x47 index 7ce3d9a9..8a86e850 100644 --- a/config.gp2x47 +++ b/config.gp2x47 @@ -5,8 +5,7 @@ CXX = arm-linux-gnueabi-g++ AS = arm-linux-gnueabi-as STRIP = arm-linux-gnueabi-strip CFLAGS += -I${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/include -I${HOME}/src/gp2x/armroot/include -D__GP2X__ -Wno-unused-result -CFLAGS += -mabi=apcs-gnu -mfloat-abi=soft -mfpu=fpa -mcpu=arm920t -mtune=arm920t -CFLAGS += -mno-thumb-interwork -fno-stack-protector -fno-common +CFLAGS += -mabi=apcs-gnu -mfloat-abi=soft -mfpu=fpa -mcpu=arm920t -mtune=arm920t -mno-thumb-interwork -fno-stack-protector -fno-common CFLAGS += -finline-limit=42 -fipa-pta -fno-ipa-sra -fno-ipa-pure-const ASFLAGS += -mabi=apcs-gnu -mfloat-abi=soft -mfpu=fpa -mcpu=arm920t LDFLAGS += -mabi=apcs-gnu -mfpu=fpa -B${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/gcc/arm-open2x-linux/4.1.1 -B${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib -L${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/usr/lib -L${HOME}/src/gp2x/armroot/lib -static diff --git a/configure b/configure index 1310ab2c..c82fe205 100755 --- a/configure +++ b/configure @@ -22,6 +22,13 @@ compile_binary() $c >> config.log 2>&1 } +check_option() +{ + echo 'void test(void) { }' >$TMPC + compile_object $1 || return 1 + return 0 +} + check_define() { $CC -E -dD $CFLAGS pico/arm_features.h | grep -q $1 || return 1 @@ -31,17 +38,18 @@ check_define() # setting options to "yes" or "no" will make that choice default, # "" means "autodetect". -platform_list="generic pandora gp2x opendingux rpi1 rpi2" +platform_list="generic pandora gp2x wiz caanoo opendingux gcw0 rpi1 rpi2" platform="generic" sound_driver_list="oss alsa sdl" sound_drivers="" have_armv5="" have_armv6="" have_armv7="" +have_arm_oabi="" have_arm_neon="" have_libavcodec="" need_sdl="no" -need_xlib="no" +need_zlib="no" # these are for known platforms optimize_cortexa8="no" optimize_cortexa7="no" @@ -54,7 +62,7 @@ CC="${CC-${CROSS_COMPILE}gcc}" CXX="${CXX-${CROSS_COMPILE}g++}" AS="${AS-${CROSS_COMPILE}as}" STRIP="${STRIP-${CROSS_COMPILE}strip}" -test -n "$SDL_CONFIG" || SDL_CONFIG="`$CC --print-sysroot 2> /dev/null || true`/usr/bin/sdl-config" +test -n "$SDL_CONFIG" || SDL_CONFIG="`$CC $CFLAGS $LDFLAGS --print-sysroot 2> /dev/null || true`/usr/bin/sdl-config" MAIN_LDLIBS="$LDLIBS -lm" config_mak="config.mak" @@ -78,23 +86,27 @@ set_platform() ;; generic) ;; - opendingux) + opendingux | gcw0) sound_drivers="sdl" + # both are really an opendingux + platform="opendingux" ;; pandora) sound_drivers="oss alsa" optimize_cortexa8="yes" have_arm_neon="yes" ;; - gp2x) + gp2x | wiz | caanoo) sound_drivers="oss" optimize_arm920="yes" + # compile for OABI if toolchain provides it (faster code on caanoo) + have_arm_oabi="yes" + # always use static linking, since caanoo doesn't have OABI libs. Moreover, + # dynamic linking slows Wiz 1-10%, and libm on F100 isn't compatible + LDFLAGS="$LDFLAGS -static" + # unified binary for all of them CFLAGS="$CFLAGS -D__GP2X__" - if [ "$CROSS_COMPILE" = "arm-linux-" ]; then - # still using static, dynamic linking slows Wiz 1-10% - # also libm on F100 is not compatible - MAIN_LDLIBS="$MAIN_LDLIBS -static" - fi + platform="gp2x" ;; *) fail "unsupported platform: $platform" @@ -147,18 +159,11 @@ fi # fi #fi -# basic compiler test -cat > $TMPC < $TMPC < $TMPC <> $config_mak if [ "$have_libavcodec" = "yes" ]; then echo "HAVE_LIBAVCODEC = 1" >> $config_mak fi +if [ "$need_zlib" = "yes" ]; then + echo "PLATFORM_ZLIB = 1" >> $config_mak +fi # GP2X toolchains are too old for UAL asm, # so add this here to not litter main Makefile -if [ "$platform" = "g1p2x" ]; then - echo >> $config_mak - echo "%.o: %.S" >> $config_mak - echo " $(CC) $(CFLAGS) -E -c $^ -o /tmp/$(notdir $@).s" >> $config_mak - echo " $(AS) $(ASFLAGS) /tmp/$(notdir $@).s -o $@" >> $config_mak -fi +#if [ "$platform" = "gp2x" ]; then +# echo >> $config_mak +# echo '%.o: %.S' >> $config_mak +# echo ' $(CC) $(CFLAGS) -E -c $^ -o /tmp/$(notdir $@).s' >> $config_mak +# echo ' $(AS) $(ASFLAGS) /tmp/$(notdir $@).s -o $@' >> $config_mak +#fi # use pandora's skin (for now) test -e skin || ln -s platform/pandora/skin skin diff --git a/cpu/drc/emit_arm.c b/cpu/drc/emit_arm.c index a4aa2ec6..1d70866c 100644 --- a/cpu/drc/emit_arm.c +++ b/cpu/drc/emit_arm.c @@ -1,6 +1,7 @@ /* * Basic macros to emit ARM instructions and some utils * Copyright (C) 2008,2009,2010 notaz + * Copyright (C) 2019 kub * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. diff --git a/cpu/drc/emit_x86.c b/cpu/drc/emit_x86.c index 2177541c..62288ff5 100644 --- a/cpu/drc/emit_x86.c +++ b/cpu/drc/emit_x86.c @@ -1,6 +1,7 @@ /* * Basic macros to emit x86 instructions and some utils * Copyright (C) 2008,2009,2010 notaz + * Copyright (C) 2019 kuv * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. diff --git a/platform/common/helix/Makefile b/platform/common/helix/Makefile index 0021ea8e..9fa4c1cc 100644 --- a/platform/common/helix/Makefile +++ b/platform/common/helix/Makefile @@ -4,6 +4,7 @@ CC = $(CROSS)gcc AS = $(CROSS)as AR = $(CROSS)ar TOOLCHAIN = $(notdir $(CROSS)) +LIBGCC ?= ${HOME}/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/gcc/arm-open2x-linux/4.1.1/libgcc.a CFLAGS += -Ipub -O2 -Wall -fstrict-aliasing -ffast-math ifneq ($(findstring arm-,$(TOOLCHAIN)),) @@ -34,7 +35,7 @@ real/arm/asmpoly_gcc.o: real/arm/asmpoly_gcc.s $(LIB) : $(OBJS) $(AR) r $@ $^ -$(SHLIB) : $(OBJS) /home/build/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/gcc/arm-open2x-linux/4.1.1/libgcc.a +$(SHLIB) : $(OBJS) $(LIBGCC) $(CC) -o $@ -nostdlib -shared $(CFLAGS) $^ clean: