summaryrefslogtreecommitdiff
path: root/x86
diff options
context:
space:
mode:
authorDavid Guillen Fandos2021-03-08 18:44:03 +0100
committerDavid Guillen Fandos2021-03-08 18:44:03 +0100
commit56dc6ecb70e6fc76d32d6a7194acb273b76bfe0e (patch)
treecf3b14a8d1bc593248398d0c544251ea8987b40e /x86
parent02e35339ee89f92d346d290c24497bbbae59ea79 (diff)
downloadpicogpsp-56dc6ecb70e6fc76d32d6a7194acb273b76bfe0e.tar.gz
picogpsp-56dc6ecb70e6fc76d32d6a7194acb273b76bfe0e.tar.bz2
picogpsp-56dc6ecb70e6fc76d32d6a7194acb273b76bfe0e.zip
Remove libco
This removes libco and all the usages of it (+pthreads). Rewired all dynarecs and interpreter to return after every frame so that libretro can process events. This required to make dynarec re-entrant. Dynarecs were updated to check for new frame on every update (IRQ, cycle exhaustion, I/O write, etc). The performance impact of doing so should be minimal (and definitely outweight the libco gains). While at it, fixed small issues to get a bit more perf: arm dynarec was not idling correctly, mips was using stack when not needed, etc. Tested on PSP (mips), OGA (armv7), Linux (x86 and interpreter). Not tested on Android though.
Diffstat (limited to 'x86')
-rw-r--r--x86/x86_stub.S44
1 files changed, 40 insertions, 4 deletions
diff --git a/x86/x86_stub.S b/x86/x86_stub.S
index dd98f7a..ba997ba 100644
--- a/x86/x86_stub.S
+++ b/x86/x86_stub.S
@@ -95,6 +95,7 @@
.equ CPU_MODE, (29 * 4)
.equ CPU_HALT_STATE, (30 * 4)
.equ CHANGED_PC_STATUS, (31 * 4)
+.equ COMPLETED_FRAME, (32 * 4)
# destroys ecx and edx
@@ -150,6 +151,11 @@ _x86_update_gba:
call _update_gba # process the next event
mov %eax, %edi # edi = new cycle count
+
+ # did we just complete a frame? go back to main then
+ cmpl $0, COMPLETED_FRAME(%ebx)
+ jne return_to_main
+
# did the PC change?
cmpl $1, CHANGED_PC_STATUS(%ebx)
je lookup_pc
@@ -197,6 +203,10 @@ write_epilogue:
alert_loop:
call _update_gba # process the next event
+
+ # did we just complete a frame? go back to main then
+ cmpl $0, COMPLETED_FRAME(%ebx)
+ jne return_to_main
# see if the halt status has changed
mov CPU_HALT_STATE(%ebx), %edx
@@ -509,24 +519,50 @@ lookup_pc_arm:
# eax: cycle counter
_execute_arm_translate:
- movl (_reg), %ebx # load base register
+ # Save main context, since we need to return gracefully
+ pushl %ebx
+ pushl %esi
+ pushl %edi
+ pushl %ebp
+
+ movl $_reg, %ebx # load base register
extract_flags # load flag variables
movl %eax, %edi # load edi cycle counter
movl REG_PC(%ebx), %eax # load PC
+ # (if the CPU is halted, do not start executing but
+ # loop in the alert loop until it wakes up)
+ cmp $0, CPU_HALT_STATE(%ebx)
+ je 1f
+ call alert_loop # Need to push something to the stack
+
+1:
testl $0x20, REG_CPSR(%ebx)
- jnz 1f
+ jnz 2f
call _block_lookup_address_arm
jmp *%eax # jump to it
-1:
+2:
call _block_lookup_address_thumb
jmp *%eax
+return_to_main:
+ add $4, %esp # remove current return addr
+ popl %ebp
+ popl %edi
+ popl %esi
+ popl %ebx
+ ret
+
+.data
+.align 64
+
+_reg:
+ .space 0x100, 0
+
.comm _memory_map_read 0x8000
.comm _memory_map_write 0x8000
-.comm _reg 4