Skip to content

Commit

Permalink
libretro, build fixes ffor android/ios
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Jul 14, 2020
1 parent 3539116 commit e6b80af
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pprof: platform/linux/pprof.c
$(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)

pico/pico_int_offs.h: tools/mkoffsets.sh
make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)"
make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)" XPLATFORM="$(platform)"

%.o: %.c
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
Expand Down
6 changes: 3 additions & 3 deletions Makefile.libretro
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ else
CXX += -miphoneos-version-min=5.0
CC_AS += -miphoneos-version-min=5.0
CFLAGS += -miphoneos-version-min=5.0
use_svpdrc = 0
endif

# tvOS
Expand Down Expand Up @@ -558,9 +557,10 @@ endif

ifeq ($(NO_ARM_ASM),1)
use_cyclone = 0
use_fame ?= 1
use_fame = 1
use_drz80 = 0
use_cz80 ?= 1
use_cz80 = 1
use_svpdrc = 0

asm_memory = 0
asm_render = 0
Expand Down
23 changes: 13 additions & 10 deletions cpu/drc/emit_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#define M6(x,y,z,a,b,c) (M5(x,y,z,a,b)|M1(c))
#define M10(a,b,c,d,e,f,g,h,i,j) (M5(a,b,c,d,e)|M5(f,g,h,i,j))

// avoid a warning with clang
static inline uintptr_t pabs(intptr_t v) { return labs(v); }

// sys_cacheflush always flushes whole pages, and it's rather expensive on ARMs
// hold a list of pending cache updates and merge requests to reduce cacheflush
static struct { void *base, *end; } pageflush[4];
Expand Down Expand Up @@ -341,33 +344,33 @@ static void emith_flush(void)
#define EOP_C_AM3_REG(cond,u,l,rn,rd,s,h,rm) EOP_C_AM3(cond,u,0,l,rn,rd,s,h,rm)

/* ldr and str */
#define EOP_LDR_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,0,1,rn,rd,abs(offset_12))
#define EOP_LDRB_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,1,1,rn,rd,abs(offset_12))
#define EOP_STR_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,0,0,rn,rd,abs(offset_12))
#define EOP_LDR_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,0,1,rn,rd,pabs(offset_12))
#define EOP_LDRB_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,1,1,rn,rd,pabs(offset_12))
#define EOP_STR_IMM2(cond,rd,rn,offset_12) EOP_C_AM2_IMM(cond,(offset_12) >= 0,0,0,rn,rd,pabs(offset_12))

#define EOP_LDR_IMM( rd,rn,offset_12) EOP_C_AM2_IMM(A_COND_AL,(offset_12) >= 0,0,1,rn,rd,abs(offset_12))
#define EOP_LDR_IMM( rd,rn,offset_12) EOP_C_AM2_IMM(A_COND_AL,(offset_12) >= 0,0,1,rn,rd,pabs(offset_12))
#define EOP_LDR_SIMPLE(rd,rn) EOP_C_AM2_IMM(A_COND_AL,1,0,1,rn,rd,0)
#define EOP_STR_IMM( rd,rn,offset_12) EOP_C_AM2_IMM(A_COND_AL,(offset_12) >= 0,0,0,rn,rd,abs(offset_12))
#define EOP_STR_IMM( rd,rn,offset_12) EOP_C_AM2_IMM(A_COND_AL,(offset_12) >= 0,0,0,rn,rd,pabs(offset_12))
#define EOP_STR_SIMPLE(rd,rn) EOP_C_AM2_IMM(A_COND_AL,1,0,0,rn,rd,0)

#define EOP_LDR_REG_LSL(cond,rd,rn,rm,shift_imm) EOP_C_AM2_REG(cond,1,0,1,rn,rd,shift_imm,A_AM1_LSL,rm)
#define EOP_LDR_REG_LSL_WB(cond,rd,rn,rm,shift_imm) EOP_C_AM2_REG(cond,1,0,3,rn,rd,shift_imm,A_AM1_LSL,rm)
#define EOP_LDRB_REG_LSL(cond,rd,rn,rm,shift_imm) EOP_C_AM2_REG(cond,1,1,1,rn,rd,shift_imm,A_AM1_LSL,rm)
#define EOP_STR_REG_LSL_WB(cond,rd,rn,rm,shift_imm) EOP_C_AM2_REG(cond,1,0,2,rn,rd,shift_imm,A_AM1_LSL,rm)

#define EOP_LDRH_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,0,1,abs(offset_8))
#define EOP_LDRH_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,0,1,pabs(offset_8))
#define EOP_LDRH_REG2(cond,rd,rn,rm) EOP_C_AM3_REG(cond,1,1,rn,rd,0,1,rm)

#define EOP_LDRH_IMM( rd,rn,offset_8) EOP_C_AM3_IMM(A_COND_AL,(offset_8) >= 0,1,rn,rd,0,1,abs(offset_8))
#define EOP_LDRH_IMM( rd,rn,offset_8) EOP_C_AM3_IMM(A_COND_AL,(offset_8) >= 0,1,rn,rd,0,1,pabs(offset_8))
#define EOP_LDRH_SIMPLE(rd,rn) EOP_C_AM3_IMM(A_COND_AL,1,1,rn,rd,0,1,0)
#define EOP_LDRH_REG( rd,rn,rm) EOP_C_AM3_REG(A_COND_AL,1,1,rn,rd,0,1,rm)
#define EOP_STRH_IMM( rd,rn,offset_8) EOP_C_AM3_IMM(A_COND_AL,(offset_8) >= 0,0,rn,rd,0,1,abs(offset_8))
#define EOP_STRH_IMM( rd,rn,offset_8) EOP_C_AM3_IMM(A_COND_AL,(offset_8) >= 0,0,rn,rd,0,1,pabs(offset_8))
#define EOP_STRH_SIMPLE(rd,rn) EOP_C_AM3_IMM(A_COND_AL,1,0,rn,rd,0,1,0)
#define EOP_STRH_REG( rd,rn,rm) EOP_C_AM3_REG(A_COND_AL,1,0,rn,rd,0,1,rm)

#define EOP_LDRSB_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,1,0,abs(offset_8))
#define EOP_LDRSB_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,1,0,pabs(offset_8))
#define EOP_LDRSB_REG2(cond,rd,rn,rm) EOP_C_AM3_REG(cond,1,1,rn,rd,1,0,rm)
#define EOP_LDRSH_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,1,1,abs(offset_8))
#define EOP_LDRSH_IMM2(cond,rd,rn,offset_8) EOP_C_AM3_IMM(cond,(offset_8) >= 0,1,rn,rd,1,1,pabs(offset_8))
#define EOP_LDRSH_REG2(cond,rd,rn,rm) EOP_C_AM3_REG(cond,1,1,rn,rd,1,1,rm)

/* ldm and stm */
Expand Down
34 changes: 17 additions & 17 deletions jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use_musashi := 0
use_drz80 := 0
use_cz80 := 1
use_sh2drc := 0
use_sh2mame := 1
use_svpdrc := 0

asm_memory := 0
Expand All @@ -31,22 +30,21 @@ asm_32xdraw := 0
asm_32xmemory := 0

ifeq ($(TARGET_ARCH),arm)
use_cyclone := 1
use_fame := 0
use_drz80 := 1
use_cz80 := 0
use_sh2mame := 0
# use_cyclone := 1
# use_fame := 0
# use_drz80 := 1
# use_cz80 := 0
use_sh2drc := 1
use_svpdrc := 1

asm_memory := 1
asm_render := 1
asm_ym2612 := 1
asm_misc := 1
asm_cdmemory := 1
asm_mix := 1
asm_32xdraw := 1
asm_32xmemory := 1
# use_svpdrc := 1

# asm_memory := 1
# asm_render := 1
# asm_ym2612 := 1
# asm_misc := 1
# asm_cdmemory := 1
# asm_mix := 1
# asm_32xdraw := 1
# asm_32xmemory := 1
endif

ifeq ($(TARGET_ARCH_ABI),armeabi)
Expand All @@ -57,6 +55,7 @@ include $(COMMON_DIR)/common.mak

SOURCES_C := $(LIBRETRO_DIR)/libretro.c \
$(COMMON_DIR)/mp3.c \
$(COMMON_DIR)/mp3_sync.c \
$(COMMON_DIR)/mp3_dummy.c \
$(UNZIP_DIR)/unzip.c

Expand All @@ -69,7 +68,8 @@ endif

ifneq ($(filter armeabi%, $(TARGET_ARCH_ABI)),)
$(CORE_DIR)/pico/pico_int_offs.h:
cp $(CORE_DIR)/tools/offsets/generic32-offsets.h $@
cp $(CORE_DIR)/tools/offsets/generic-ilp32-offsets.h $@
.PHONY: $(CORE_DIR)/pico/pico_int_offs.h

$(filter %.S,$(SRCS_COMMON)): $(CORE_DIR)/pico/pico_int_offs.h
endif
Expand Down
4 changes: 2 additions & 2 deletions pico/carthw/svp/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ static int tr_aop_ssp2arm(int op)
/* spacial version of call for calling C needed on ios, since we use r9.. */
static void emith_call_c_func(void *target)
{
EOP_STMFD_SP(A_R7M|A_R9M);
EOP_STMFD_SP(M2(7,9));
emith_call(target);
EOP_LDMFD_SP(A_R7M|A_R9M);
EOP_LDMFD_SP(M2(7,9));
}
#else
#define emith_call_c_func emith_call
Expand Down
6 changes: 5 additions & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ TARGETS = amalgamate textfilter
HOSTCC ?= cc

all:
CC="$(XCC)" CFLAGS="$(XCFLAGS)" sh ./mkoffsets.sh ../pico
if [ -f "offsets/$(XPLATFORM)-offsets.h" ]; then \
ln -sf "../tools/offsets/$(XPLATFORM)-offsets.h" ../pico/pico_int_offs.h; \
else \
CC="$(XCC)" CFLAGS="$(XCFLAGS)" sh ./mkoffsets.sh ../pico; \
fi

$(TARGETS): $(addsuffix .c,$(TARGETS))
$(HOSTCC) -o $@ -O $@.c
Expand Down
10 changes: 5 additions & 5 deletions tools/mkoffsets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ check_obj ()
fi
# find the start line of the .rodata section; read the next line
ro=$($OBJDUMP -s /tmp/getoffs.o | awk '\
/Contents of section.*(__const|.rodata|.sdata)/ {o=1; next} \
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; o=0}}')
/Contents of section.*(__const|.r[o]?data|.sdata)/ {o=1; next} \
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; exit}}')
# no working tool for extracting the ro data; stop here
if [ -z "$ro" ]; then
echo "/* mkoffset.sh: no readelf or not ELF, offset table not created */" >$fn
Expand All @@ -79,8 +79,8 @@ compile_rodata ()
elif [ -n "$OBJDUMP" ]; then
# find the start line of the .rodata section; read the next line
ro=$($OBJDUMP -s /tmp/getoffs.o | awk '\
/Contents of section.*(__const|.rodata|.sdata)/ {o=1; next} \
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; o=0}}')
/Contents of section.*(__const|.r[o]?data|.sdata)/ {o=1; next} \
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; exit}}')
fi
if [ "$ENDIAN" = "le" ]; then
# swap needed for le target
Expand All @@ -104,7 +104,7 @@ get_define () # prefix struct member member...
name=$(echo $* | sed 's/ /_/g')
echo '#include <stdint.h>' > /tmp/getoffs.c
echo '#include "pico/pico_int.h"' >> /tmp/getoffs.c
echo "static const struct $struct p;" >> /tmp/getoffs.c
echo "static struct $struct p;" >> /tmp/getoffs.c
echo "const int32_t val = (char *)&p.$field - (char*)&p;" >>/tmp/getoffs.c
compile_rodata
line=$(printf "#define %-20s 0x%04x" $prefix$name $rodata)
Expand Down
39 changes: 39 additions & 0 deletions tools/offsets/generic-ilp32-offsets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* autogenerated by mkoffset.sh, do not edit */
/* target endianess: le, compiled with: mipsel-linux-gnu-gcc -mabi=32 */
#define OFS_Pico_video_reg 0x0000
#define OFS_Pico_m_rotate 0x0040
#define OFS_Pico_m_z80Run 0x0041
#define OFS_Pico_m_dirtyPal 0x0046
#define OFS_Pico_m_hardware 0x0047
#define OFS_Pico_m_z80_reset 0x004f
#define OFS_Pico_m_sram_reg 0x0049
#define OFS_Pico_sv 0x008c
#define OFS_Pico_sv_data 0x008c
#define OFS_Pico_sv_start 0x0090
#define OFS_Pico_sv_end 0x0094
#define OFS_Pico_sv_flags 0x0098
#define OFS_Pico_rom 0x0554
#define OFS_Pico_romsize 0x0558
#define OFS_Pico_est 0x00c8
#define OFS_EST_DrawScanline 0x0000
#define OFS_EST_rendstatus 0x0004
#define OFS_EST_DrawLineDest 0x0008
#define OFS_EST_HighCol 0x000c
#define OFS_EST_HighPreSpr 0x0010
#define OFS_EST_Pico 0x0014
#define OFS_EST_PicoMem_vram 0x0018
#define OFS_EST_PicoMem_cram 0x001c
#define OFS_EST_PicoOpt 0x0020
#define OFS_EST_Draw2FB 0x0024
#define OFS_EST_HighPal 0x0028
#define OFS_PMEM_vram 0x10000
#define OFS_PMEM_vsram 0x22100
#define OFS_PMEM32x_pal_native 0x90e00
#define OFS_SH2_is_slave 0x055c
#define OFS_SH2_p_bios 0x0080
#define OFS_SH2_p_da 0x0084
#define OFS_SH2_p_sdram 0x0088
#define OFS_SH2_p_rom 0x008c
#define OFS_SH2_p_dram 0x0090
#define OFS_SH2_p_drcblk_da 0x0094
#define OFS_SH2_p_drcblk_ram 0x0098
39 changes: 39 additions & 0 deletions tools/offsets/generic-llp64-offsets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* autogenerated by mkoffset.sh, do not edit */
/* target endianess: le, compiled with: x86_64-w64-mingw32-gcc */
#define OFS_Pico_video_reg 0x0000
#define OFS_Pico_m_rotate 0x0040
#define OFS_Pico_m_z80Run 0x0041
#define OFS_Pico_m_dirtyPal 0x0046
#define OFS_Pico_m_hardware 0x0047
#define OFS_Pico_m_z80_reset 0x004f
#define OFS_Pico_m_sram_reg 0x0049
#define OFS_Pico_sv 0x0090
#define OFS_Pico_sv_data 0x0090
#define OFS_Pico_sv_start 0x0098
#define OFS_Pico_sv_end 0x009c
#define OFS_Pico_sv_flags 0x00a0
#define OFS_Pico_rom 0x0588
#define OFS_Pico_romsize 0x0590
#define OFS_Pico_est 0x00d8
#define OFS_EST_DrawScanline 0x0000
#define OFS_EST_rendstatus 0x0004
#define OFS_EST_DrawLineDest 0x0008
#define OFS_EST_HighCol 0x0010
#define OFS_EST_HighPreSpr 0x0018
#define OFS_EST_Pico 0x0020
#define OFS_EST_PicoMem_vram 0x0028
#define OFS_EST_PicoMem_cram 0x0030
#define OFS_EST_PicoOpt 0x0038
#define OFS_EST_Draw2FB 0x0040
#define OFS_EST_HighPal 0x0048
#define OFS_PMEM_vram 0x10000
#define OFS_PMEM_vsram 0x22100
#define OFS_PMEM32x_pal_native 0x90e00
#define OFS_SH2_is_slave 0x0a18
#define OFS_SH2_p_bios 0x0098
#define OFS_SH2_p_da 0x00a0
#define OFS_SH2_p_sdram 0x00a8
#define OFS_SH2_p_rom 0x00b0
#define OFS_SH2_p_dram 0x00b8
#define OFS_SH2_p_drcblk_da 0x00c0
#define OFS_SH2_p_drcblk_ram 0x00c8
39 changes: 39 additions & 0 deletions tools/offsets/generic-lp64-offsets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* autogenerated by mkoffset.sh, do not edit */
/* target endianess: le, compiled with: mipsel-linux-gnu-gcc -mabi=64 */
#define OFS_Pico_video_reg 0x0000
#define OFS_Pico_m_rotate 0x0040
#define OFS_Pico_m_z80Run 0x0041
#define OFS_Pico_m_dirtyPal 0x0046
#define OFS_Pico_m_hardware 0x0047
#define OFS_Pico_m_z80_reset 0x004f
#define OFS_Pico_m_sram_reg 0x0049
#define OFS_Pico_sv 0x0090
#define OFS_Pico_sv_data 0x0090
#define OFS_Pico_sv_start 0x0098
#define OFS_Pico_sv_end 0x009c
#define OFS_Pico_sv_flags 0x00a0
#define OFS_Pico_rom 0x0588
#define OFS_Pico_romsize 0x0590
#define OFS_Pico_est 0x00d8
#define OFS_EST_DrawScanline 0x0000
#define OFS_EST_rendstatus 0x0004
#define OFS_EST_DrawLineDest 0x0008
#define OFS_EST_HighCol 0x0010
#define OFS_EST_HighPreSpr 0x0018
#define OFS_EST_Pico 0x0020
#define OFS_EST_PicoMem_vram 0x0028
#define OFS_EST_PicoMem_cram 0x0030
#define OFS_EST_PicoOpt 0x0038
#define OFS_EST_Draw2FB 0x0040
#define OFS_EST_HighPal 0x0048
#define OFS_PMEM_vram 0x10000
#define OFS_PMEM_vsram 0x22100
#define OFS_PMEM32x_pal_native 0x90e00
#define OFS_SH2_is_slave 0x0a18
#define OFS_SH2_p_bios 0x0098
#define OFS_SH2_p_da 0x00a0
#define OFS_SH2_p_sdram 0x00a8
#define OFS_SH2_p_rom 0x00b0
#define OFS_SH2_p_dram 0x00b8
#define OFS_SH2_p_drcblk_da 0x00c0
#define OFS_SH2_p_drcblk_ram 0x00c8

0 comments on commit e6b80af

Please sign in to comment.