From 1eb704b6332072581bf7c3bc411babc66f8bda8a Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 22 Oct 2009 09:57:36 +0000 Subject: [PATCH] SH2 drc, dummy soc for GP2X git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@823 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/common_arm.mak | 21 ++++----- gp2x/Makefile | 37 ++++++++++----- gp2x/plat.c | 8 +++- gp2x/soc.c | 6 ++- gp2x/soc.h | 3 ++ gp2x/soc_dummy.c | 102 ++++++++++++++++++++++++++++++++++++++++++ gp2x/soc_mmsp2.c | 8 ++-- linux/Makefile | 2 +- linux/host_dasm.c | 4 -- linux/plat.c | 4 +- 10 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 gp2x/soc_dummy.c diff --git a/common/common_arm.mak b/common/common_arm.mak index 397e713..6f8eb9a 100644 --- a/common/common_arm.mak +++ b/common/common_arm.mak @@ -1,38 +1,38 @@ # asm stuff ifeq "$(asm_render)" "1" -DEFINC += -D_ASM_DRAW_C +DEFINES += _ASM_DRAW_C OBJS += pico/draw_arm.o pico/draw2_arm.o endif ifeq "$(asm_memory)" "1" -DEFINC += -D_ASM_MEMORY_C +DEFINES += _ASM_MEMORY_C OBJS += pico/memory_arm.o endif ifeq "$(asm_ym2612)" "1" -DEFINC += -D_ASM_YM2612_C +DEFINES += _ASM_YM2612_C OBJS += pico/sound/ym2612_arm.o endif ifeq "$(asm_misc)" "1" -DEFINC += -D_ASM_MISC_C +DEFINES += _ASM_MISC_C OBJS += pico/misc_arm.o OBJS += pico/cd/misc_arm.o endif ifeq "$(asm_cdpico)" "1" -DEFINC += -D_ASM_CD_PICO_C +DEFINES += _ASM_CD_PICO_C OBJS += pico/cd/pico_arm.o endif ifeq "$(asm_cdmemory)" "1" -DEFINC += -D_ASM_CD_MEMORY_C +DEFINES += _ASM_CD_MEMORY_C OBJS += pico/cd/memory_arm.o endif .c.o: @echo ">>>" $< - $(CC) $(CFLAGS) $(DEFINC) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ .S.o: @echo ">>>" $< - $(CC) $(SFLAGS) $(DEFINC) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ ../../tools/textfilter: ../../tools/textfilter.c @@ -45,8 +45,9 @@ clean_prof: mkdirs: mkdir -p $(DIRS) -# deps -pico/carthw/svp/compiler.o : ../../pico/carthw/svp/ssp16.o ../../pico/carthw/svp/gen_arm.c +# some deps +pico/carthw/svp/compiler.o : ../../pico/carthw/svp/ssp16.o ../../cpu/drc/emit_arm.c +cpu/sh2/compiler.o : ../../cpu/drc/emit_arm.c pico/pico.o pico/cd/pico.o : ../../pico/pico_cmn.c ../../pico/pico_int.h pico/memory.o pico/cd/memory.o : ../../pico/pico_int.h ../../pico/memory.h diff --git a/gp2x/Makefile b/gp2x/Makefile index 0fc42c3..bcaa1d0 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -12,8 +12,8 @@ asm_cdmemory = 1 amalgamate = 0 #profile = 1 #use_musashi = 1 -use_sh2mame = 1 -#up = 1 +use_sh2drc = 1 +drc_debug = 1 ifeq "$(debug_cyclone)" "1" @@ -28,8 +28,8 @@ else use_cyclone = 1 endif -DEFINC = -I../.. -I. -DARM -D__GP2X__ -DIN_GP2X -DIN_EVDEV # -DBENCHMARK -CFLAGS += -Wall -Winline +DEFINES += ARM __GP2X__ IN_GP2X IN_EVDEV # BENCHMARK +CFLAGS += -Wall -Winline -I../.. -I. ifeq ($(DEBUG),) CFLAGS += -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math else @@ -42,8 +42,9 @@ ifeq "$(profile)" "2" CFLAGS += -fprofile-use endif CFLAGS += -mcpu=arm920t -mtune=arm920t -SFLAGS = $(CFLAGS) ASFLAGS = -mcpu=arm920t -mfloat-abi=soft +LDFLAGS += -lm -lpng + CC = $(CROSS)gcc STRIP = $(CROSS)strip AS = $(CROSS)as @@ -51,7 +52,7 @@ LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy # frontend -OBJS += plat.o warm.o pollux_set.o soc.o soc_mmsp2.o soc_pollux.o emu.o in_gp2x.o +OBJS += plat.o warm.o pollux_set.o soc.o soc_mmsp2.o soc_pollux.o soc_dummy.o emu.o in_gp2x.o # 940 core control OBJS += 940ctl.o @@ -98,27 +99,39 @@ OBJS += pico/DebugCPU.o cpu/musashi/m68kdasm.o endif # CPU cores ifeq "$(use_musashi)" "1" -DEFINC += -DEMU_M68K +DEFINES += EMU_M68K OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o endif ifeq "$(use_cyclone)" "1" -DEFINC += -DEMU_C68K +DEFINES += EMU_C68K OBJS += pico/m68kif_cyclone.o cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o endif ifeq "$(mz80)" "1" -DEFINC += -D_USE_MZ80 +DEFINES += _USE_MZ80 OBJS += cpu/mz80/mz80.o else -DEFINC += -D_USE_DRZ80 +DEFINES += _USE_DRZ80 OBJS += cpu/DrZ80/drz80.o endif OBJS += cpu/sh2/sh2.o -ifeq "$(use_sh2mame)" "1" +ifeq "$(use_sh2drc)" "1" +DEFINES += DRC_SH2 DRC_TMP OBJS += cpu/sh2/mame/sh2pico.o +OBJS += cpu/sh2/compiler.o +OBJS += cpu/sh2/stub_arm.o +ifeq "$(drc_debug)" "1" +DEFINES += DRC_DEBUG=1 +OBJS += cpu/sh2/mame/sh2dasm.o +OBJS += platform/linux/host_dasm.o +LDFLAGS += -lbfd -lopcodes -liberty +endif else +OBJS += cpu/sh2/mame/sh2pico.o endif OBJS += cpu/drc/cmn.o +CFLAGS += $(addprefix -D,$(DEFINES)) + vpath %.c = ../.. vpath %.s = ../.. vpath %.S = ../.. @@ -141,7 +154,7 @@ PicoDrive.o : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a # also libm on F100 is not compatible PicoDrive : PicoDrive.o @echo ">>>" $@ - $(CC) -static -o $@ $(CFLAGS) $^ -lm -lpng -Wl,-Map=$@.map + $(CC) -static -o $@ $(CFLAGS) $^ $(LDFLAGS) -Wl,-Map=$@.map ifeq ($(DEBUG),) $(STRIP) $@ endif diff --git a/gp2x/plat.c b/gp2x/plat.c index fe7b6fa..075937e 100644 --- a/gp2x/plat.c +++ b/gp2x/plat.c @@ -146,8 +146,8 @@ void plat_early_init(void) default_cpu_clock = 533; break; default: - fprintf(stderr, "could not recognize SoC, bailing out.\n"); - exit(1); + printf("could not recognize SoC, running in dummy mode.\n"); + break; } } @@ -167,6 +167,7 @@ void plat_init(void) menu_plat_setup(1); break; default: + dummy_init(); break; } @@ -193,6 +194,9 @@ void plat_finish(void) case SOCID_POLLUX: pollux_finish(); break; + default: + dummy_finish(); + break; } sndout_oss_exit(); diff --git a/gp2x/soc.c b/gp2x/soc.c index ee421df..5de0d23 100644 --- a/gp2x/soc.c +++ b/gp2x/soc.c @@ -33,13 +33,13 @@ gp2x_soc_t soc_detect(void) { volatile unsigned short *memregs; volatile unsigned int *memregl; - static gp2x_soc_t ret = -1; + static gp2x_soc_t ret = -2; int pollux_chipname[0x30/4 + 1]; char *pollux_chipname_c = (char *)pollux_chipname; int memdev; int i; - if (ret != -1) + if (ret != -2) /* already detected */ return ret; @@ -47,6 +47,7 @@ gp2x_soc_t soc_detect(void) if (memdev == -1) { perror("open(/dev/mem)"); + ret = -1; return -1; } @@ -55,6 +56,7 @@ gp2x_soc_t soc_detect(void) { perror("mmap(memregs)"); close(memdev); + ret = -1; return -1; } memregl = (volatile void *)memregs; diff --git a/gp2x/soc.h b/gp2x/soc.h index b645e8b..9686148 100644 --- a/gp2x/soc.h +++ b/gp2x/soc.h @@ -11,6 +11,9 @@ void mmsp2_finish(void); void pollux_init(void); void pollux_finish(void); +void dummy_init(void); +void dummy_finish(void); + /* SoC specific functions */ extern void (*gp2x_video_flip)(void); extern void (*gp2x_video_flip2)(void); diff --git a/gp2x/soc_dummy.c b/gp2x/soc_dummy.c new file mode 100644 index 0000000..ad01ab7 --- /dev/null +++ b/gp2x/soc_dummy.c @@ -0,0 +1,102 @@ +/* dummy code for qemu testing, etc */ +#include + +#include "soc.h" +#include "../common/emu.h" + +extern void *gp2x_screens[4]; + +extern unsigned int plat_get_ticks_ms_good(void); +extern unsigned int plat_get_ticks_us_good(void); + +/* video stuff */ +static void gp2x_video_flip_(void) +{ +} + +/* doulblebuffered flip */ +static void gp2x_video_flip2_(void) +{ +} + +static void gp2x_video_changemode_ll_(int bpp) +{ +} + +static void gp2x_video_setpalette_(int *pal, int len) +{ +} + +static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H) +{ +} + +static void gp2x_video_wait_vsync_(void) +{ +} + +/* CPU clock */ +static void gp2x_set_cpuclk_(unsigned int mhz) +{ +} + +/* RAM timings */ +static void set_ram_timings_(void) +{ +} + +static void unset_ram_timings_(void) +{ +} + +/* LCD refresh */ +static void set_lcd_custom_rate_(int is_pal) +{ +} + +static void unset_lcd_custom_rate_(void) +{ +} + +static void set_lcd_gamma_(int g100, int A_SNs_curve) +{ +} + +static int gp2x_read_battery_(void) +{ + return 0; +} + +void dummy_init(void) +{ + int i; + g_screen_ptr = malloc(320 * 240 * 2); + for (i = 0; i < array_size(gp2x_screens); i++) + gp2x_screens[i] = g_screen_ptr; + + gp2x_video_flip = gp2x_video_flip_; + gp2x_video_flip2 = gp2x_video_flip2_; + gp2x_video_changemode_ll = gp2x_video_changemode_ll_; + gp2x_video_setpalette = gp2x_video_setpalette_; + gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_; + gp2x_video_wait_vsync = gp2x_video_wait_vsync_; + + gp2x_set_cpuclk = gp2x_set_cpuclk_; + + set_lcd_custom_rate = set_lcd_custom_rate_; + unset_lcd_custom_rate = unset_lcd_custom_rate_; + set_lcd_gamma = set_lcd_gamma_; + + set_ram_timings = set_ram_timings_; + unset_ram_timings = unset_ram_timings_; + gp2x_read_battery = gp2x_read_battery_; + + gp2x_get_ticks_ms = plat_get_ticks_ms_good; + gp2x_get_ticks_us = plat_get_ticks_us_good; +} + +void dummy_finish(void) +{ + free(gp2x_screens[0]); +} + diff --git a/gp2x/soc_mmsp2.c b/gp2x/soc_mmsp2.c index 5217dda..155cdf9 100644 --- a/gp2x/soc_mmsp2.c +++ b/gp2x/soc_mmsp2.c @@ -41,8 +41,8 @@ static unsigned short gp2x_screenaddr_old[4]; static unsigned short memtimex_old[2]; static unsigned short reg0910; -extern unsigned int plat_get_ticks_ms_gtod(void); -extern unsigned int plat_get_ticks_us_gtod(void); +extern unsigned int plat_get_ticks_ms_good(void); +extern unsigned int plat_get_ticks_us_good(void); /* video stuff */ static void gp2x_video_flip_(void) @@ -512,8 +512,8 @@ void mmsp2_init(void) unset_ram_timings = unset_ram_timings_; gp2x_read_battery = gp2x_read_battery_; - gp2x_get_ticks_ms = plat_get_ticks_ms_gtod; - gp2x_get_ticks_us = plat_get_ticks_us_gtod; + gp2x_get_ticks_ms = plat_get_ticks_ms_good; + gp2x_get_ticks_us = plat_get_ticks_us_good; } void mmsp2_finish(void) diff --git a/linux/Makefile b/linux/Makefile index e2eaf46..9ca3295 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -99,7 +99,7 @@ ifeq "$(drc_debug)" "1" DEFINES += DRC_DEBUG=1 OBJS += cpu/sh2/mame/sh2dasm.o OBJS += host_dasm.o -LDFLAGS += -lbfd -lopcodes +LDFLAGS += -lbfd -lopcodes -liberty endif else OBJS += cpu/sh2/mame/sh2pico.o diff --git a/linux/host_dasm.c b/linux/host_dasm.c index 9947689..a3c0e00 100644 --- a/linux/host_dasm.c +++ b/linux/host_dasm.c @@ -21,10 +21,6 @@ static struct disassemble_info di; #define BFD_MACH bfd_mach_i386_i386_intel_syntax #endif -/* hacks for ARM */ -int floatformat_to_double; -int floatformat_ieee_single_little; - /* symbols */ static asymbol **symbols; static long symcount; diff --git a/linux/plat.c b/linux/plat.c index 166b4d6..842cd5b 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -19,8 +19,8 @@ int plat_is_dir(const char *path) #ifdef __GP2X__ /* Wiz has a borked gettimeofday().. */ -#define plat_get_ticks_ms plat_get_ticks_ms_gtod -#define plat_get_ticks_us plat_get_ticks_us_gtod +#define plat_get_ticks_ms plat_get_ticks_ms_good +#define plat_get_ticks_us plat_get_ticks_us_good #endif unsigned int plat_get_ticks_ms(void) -- 2.39.5