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
+pico/pico_int_offs.h: tools/mkoffsets.sh
make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)"
.s.o:
#define emith_save_caller_regs(mask) do { \
int _c, _r1, _r2; u32 _m = mask & 0x3ffff; \
if (__builtin_parity(_m) == 1) _m |= 0x40000; /* hardware align */ \
- for (_c = HOST_REGS, _r1 = -1; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
+ for (_c = HOST_REGS-1, _r1 = -1; _m && _c >= 0; _m &= ~(1 << _c), _c--)\
if (_m & (1 << _c)) { \
_r2 = _r1, _r1 = _c; \
if (_r2 != -1) { \
if (__builtin_parity(_m) == 1) _m |= 0x1; /* ABI align */ \
int _s = count_bits(_m) * 4, _o = _s; \
if (_s) emith_sub_r_imm(SP, _s); \
- for (_c = HOST_REGS; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
+ for (_c = HOST_REGS-1; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
if (_m & (1 << _c)) \
{ _o -= 4; if (_c) emith_write_r_r_offs(_c, SP, _o); } \
} while (0)
if (__builtin_parity(_m) == 1) _m |= 0x1; /* ABI align for SP is 8 */ \
int _s = count_bits(_m) * 4 + 16, _o = _s; /* 16 byte arg save area */ \
if (_s) emith_sub_r_imm(SP, _s); \
- for (_c = HOST_REGS; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
+ for (_c = HOST_REGS-1; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
if (_m & (1 << _c)) \
{ _o -= 4; if (_c) emith_write_r_r_offs(_c, SP, _o); } \
} while (0)
#define emith_save_caller_regs(mask) do { \
int _c; u32 _m = mask & 0xfc7; /* AX, CX, DX, SI, DI, 8, 9, 10, 11 */ \
if (__builtin_parity(_m) == 1) _m |= 0x8; /* BX for ABI align */ \
- for (_c = HOST_REGS; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
+ for (_c = HOST_REGS-1; _m && _c >= 0; _m &= ~(1 << _c), _c--) \
if (_m & (1 << _c)) emith_push(_c); \
} while (0)
if ((a & 0x30) == 0x20) {
unsigned int cycles = SekCyclesDone();
- if (cycles - msh2.m68krcycles_done > 244)
+ if (CYCLES_GT(cycles - msh2.m68krcycles_done, 244))
p32x_sync_sh2s(cycles);
if (m68k_poll_detect(a, cycles, P32XF_68KCPOLL)) {
if (a == 2) { // INTM, INTS
unsigned int cycles = SekCyclesDone();
- if (cycles - msh2.m68krcycles_done > 64)
+ if (CYCLES_GT(cycles - msh2.m68krcycles_done, 64))
p32x_sync_sh2s(cycles);
goto out;
}
return;
case 0x03: // irq ctl
if ((d ^ r[0x02 / 2]) & 3) {
- int cycles = SekCyclesDone();
+ unsigned int cycles = SekCyclesDone();
p32x_sync_sh2s(cycles);
r[0x02 / 2] = d & 3;
p32x_update_cmd_irq(NULL, cycles);
case 0x2c/2:
case 0x2e/2:
if (r[a / 2] != d) {
- int cycles = SekCyclesDone();
+ unsigned int cycles = SekCyclesDone();
- if (cycles - (int)msh2.m68krcycles_done > 30)
+ if (CYCLES_GT(cycles - msh2.m68krcycles_done, 64))
p32x_sync_sh2s(cycles);
r[a / 2] = d;
}
Pico32x.vdp_regs[0x06 / 2] = a;
Pico32x.vdp_regs[0x08 / 2] = d;
- if (sh2 != NULL && len > 4) {
+ if (sh2 != NULL && len > 8) {
Pico32x.vdp_regs[0x0a / 2] |= P32XV_nFEN;
// supposedly takes 3 bus/6 sh2 cycles? or 3 sh2 cycles?
p32x_event_schedule_sh2(sh2, P32X_EVENT_FILLEND, 3 + len);
if (Pico32x.sh2_regs[4 / 2] != d) {
unsigned int cycles = sh2_cycles_done_m68k(sh2);
Pico32x.sh2_regs[4 / 2] = d;
- sh2_end_run(sh2, 4);
p32x_sh2_poll_event(sh2->other_sh2, SH2_STATE_CPOLL, cycles);
+ sh2_end_run(sh2, 4);
sh2_poll_write(a & ~1, d, cycles, sh2);
}
return;
unsigned int cycles = sh2_cycles_done_m68k(sh2);
REG8IN16(r, a) = d;
- sh2_end_run(sh2, 1);
p32x_m68k_poll_event(P32XF_68KCPOLL);
p32x_sh2_poll_event(sh2->other_sh2, SH2_STATE_CPOLL, cycles);
+ sh2_end_run(sh2, 1);
sh2_poll_write(a & ~1, r[a / 2], cycles, sh2);
}
return;
unsigned int cycles = sh2_cycles_done_m68k(sh2);
Pico32x.regs[a / 2] = d;
- sh2_end_run(sh2, 1);
p32x_m68k_poll_event(P32XF_68KCPOLL);
p32x_sh2_poll_event(sh2->other_sh2, SH2_STATE_CPOLL, cycles);
+ sh2_end_run(sh2, 1);
sh2_poll_write(a, d, cycles, sh2);
}
return;
unsigned cycles;
DRC_SAVE_SR(sh2);
- sh2_end_run(sh2, 1);
cycles = sh2_cycles_done_m68k(sh2);
sh2_poll_write(a, d, cycles, sh2);
p32x_sh2_poll_event(sh2->other_sh2, SH2_STATE_RPOLL, cycles);
+ sh2_end_run(sh2, 1);
DRC_RESTORE_SR(sh2);
}
# compile with target C compiler and extract value from .rodata section
compile_rodata ()
{
- # $CC $CFLAGS -I .. -shared /tmp/getoffs.c -o /tmp/getoffs.o || exit 1
- echo 'void dummy(void) { asm(""::"r" (&val)); }' >> /tmp/getoffs.c
- $CC $CFLAGS -I .. -nostdlib -Wl,-edummy /tmp/getoffs.c \
- -o /tmp/getoffs.o || exit 1
+ $CC $CFLAGS -I .. -c /tmp/getoffs.c -o /tmp/getoffs.o || exit 1
+ # echo 'void dummy(void) { asm(""::"r" (&val)); }' >> /tmp/getoffs.c
+ # $CC $CFLAGS -I .. -nostdlib -Wl,-edummy /tmp/getoffs.c \
+ # -o /tmp/getoffs.o || exit 1
# find the name of the .rodata section (in case -fdata-sections is used)
rosect=$(readelf -S /tmp/getoffs.o | grep '\.rodata' |
sed 's/^[^.]*././;s/ .*//')
line=$(printf "#define %-20s 0x%04x" $prefix$name $rodata)
}
+CFLAGS="$CFLAGS -fno-lto"
# determine endianess
echo "const int val = 1;" >/tmp/getoffs.c
compile_rodata