X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fnew_dynarec%2Flinkage_arm.s;h=aeb8baa3b08da87de70f9cf865ee583af85ad8a7;hp=f838fcbf0d93c8ed8e2f91e6d2b9eda8e4cef505;hb=b9b61529b6c9bf30a3146178e2dda31b15ff3614;hpb=57871462a0b157066bbc4a763c59b61085436609 diff --git a/libpcsxcore/new_dynarec/linkage_arm.s b/libpcsxcore/new_dynarec/linkage_arm.s index f838fcbf..aeb8baa3 100644 --- a/libpcsxcore/new_dynarec/linkage_arm.s +++ b/libpcsxcore/new_dynarec/linkage_arm.s @@ -34,12 +34,11 @@ rdram = 0x80000000 .global reg .global hi .global lo - .global reg_cop1_simple - .global reg_cop1_double .global reg_cop0 + .global reg_cop2d + .global reg_cop2c .global FCR0 .global FCR31 - .global rounding_modes .global next_interupt .global cycle_count .global last_count @@ -49,22 +48,26 @@ rdram = 0x80000000 .global invc_ptr .global address .global readmem_dword + .global readmem_word .global dword .global word .global hword .global byte .global branch_target .global PC - .global fake_pc .global mini_ht .global restore_candidate .global memory_map + /* psx */ + .global psxRegs + .global psxHLEt_addr + .bss .align 4 .type dynarec_local, %object - .size dynarec_local, 64 + .size dynarec_local, dynarec_local_end-dynarec_local dynarec_local: - .space 64+16+16+8+8+8+8+256+8+8+128+128+128+16+8+132+4+256+512+4194304 + .space dynarec_local_end-dynarec_local /*0x400630*/ next_interupt = dynarec_local + 64 .type next_interupt, %object .size next_interupt, 4 @@ -77,10 +80,7 @@ last_count = cycle_count + 4 pending_exception = last_count + 4 .type pending_exception, %object .size pending_exception, 4 -pcaddr = pending_exception + 4 - .type pcaddr, %object - .size pcaddr, 4 -stop = pcaddr + 4 +stop = pending_exception + 4 .type stop, %object .size stop, 4 invc_ptr = stop + 4 @@ -90,6 +90,7 @@ address = invc_ptr + 4 .type address, %object .size address, 4 readmem_dword = address + 4 +readmem_word = readmem_dword .type readmem_dword, %object .size readmem_dword, 8 dword = readmem_dword + 8 @@ -111,37 +112,55 @@ FCR31 = FCR0 + 4 .type FCR31, %object .size FCR31, 4 reg = FCR31 + 4 + +/* psxRegs */ +psxRegs = reg .type reg, %object - .size reg, 256 -hi = reg + 256 - .type hi, %object - .size hi, 8 -lo = hi + 8 + .size reg, 128 + .size psxRegs, psxRegs_end-psxRegs +lo = reg + 128 .type lo, %object - .size lo, 8 -reg_cop0 = lo + 8 + .size lo, 4 +hi = lo + 4 + .type hi, %object + .size hi, 4 +reg_cop0 = hi + 4 .type reg_cop0, %object .size reg_cop0, 128 -reg_cop1_simple = reg_cop0 + 128 - .type reg_cop1_simple, %object - .size reg_cop1_simple, 128 -reg_cop1_double = reg_cop1_simple + 128 - .type reg_cop1_double, %object - .size reg_cop1_double, 128 -rounding_modes = reg_cop1_double + 128 - .type rounding_modes, %object - .size rounding_modes, 16 -branch_target = rounding_modes + 16 - .type branch_target, %object - .size branch_target, 4 -PC = branch_target + 4 +reg_cop2d = reg_cop0 + 128 + .type reg_cop2d, %object + .size reg_cop2d, 128 +reg_cop2c = reg_cop2d + 128 + .type reg_cop2c, %object + .size reg_cop2c, 128 +PC = reg_cop2c + 128 +pcaddr = PC .type PC, %object .size PC, 4 -fake_pc = PC + 4 - .type fake_pc, %object - .size fake_pc, 132 -/* 4 bytes free */ -mini_ht = fake_pc + 136 +code = PC + 4 + .type code, %object + .size code, 4 +cycle = code + 4 + .type cycle, %object + .size cycle, 4 +interrupt = cycle + 4 + .type interrupt, %object + .size interrupt, 4 +intCycle = interrupt + 4 + .type intCycle, %object + .size intCycle, 128 +psxRegs_end = intCycle + 128 + +psxHLEt_addr = psxRegs_end + .type psxHLEt_addr, %object + .size psxHLEt_addr, 4 +align0 = psxHLEt_addr + 4 /* just for alignment */ + .type align0, %object + .size align0, 4 +branch_target = align0 + 4 + .type branch_target, %object + .size branch_target, 4 +mini_ht = branch_target + 4 .type mini_ht, %object .size mini_ht, 256 restore_candidate = mini_ht + 256 @@ -150,6 +169,7 @@ restore_candidate = mini_ht + 256 memory_map = restore_candidate + 512 .type memory_map, %object .size memory_map, 4194304 +dynarec_local_end = memory_map + 4194304 .text .align 2 @@ -158,17 +178,11 @@ memory_map = restore_candidate + 512 dyna_linker: /* r0 = virtual target address */ /* r1 = instruction to patch */ - ldr r4, .tlbptr - lsr r5, r0, #12 mov r12, r0 - cmp r0, #0xC0000000 mov r6, #4096 - ldrge r12, [r4, r5, lsl #2] mov r2, #0x80000 ldr r3, .jiptr - tst r12, r12 sub r6, r6, #1 - moveq r12, r0 ldr r7, [r1] eor r2, r2, r12, lsr #12 and r6, r6, r12, lsr #12 @@ -274,6 +288,7 @@ exec_pagefault: bl get_addr_ht mov pc, r0 .size exec_pagefault, .-exec_pagefault + /* Special dynamic linker for the case where a page fault may occur in a branch delay slot */ .global dyna_linker_ds @@ -281,17 +296,11 @@ exec_pagefault: dyna_linker_ds: /* r0 = virtual target address */ /* r1 = instruction to patch */ - ldr r4, .tlbptr - lsr r5, r0, #12 mov r12, r0 - cmp r0, #0xC0000000 mov r6, #4096 - ldrge r12, [r4, r5, lsl #2] mov r2, #0x80000 ldr r3, .jiptr - tst r12, r12 sub r6, r6, #1 - moveq r12, r0 ldr r7, [r1] eor r2, r2, r12, lsr #12 and r6, r6, r12, lsr #12 @@ -380,10 +389,9 @@ dyna_linker_ds: .word jump_in .jdptr: .word jump_dirty -.tlbptr: - .word tlb_LUT_r .htptr: .word hash_table + .align 2 .global jump_vaddr_r0 .type jump_vaddr_r0, %function @@ -484,6 +492,7 @@ jump_vaddr: ldr r10, [fp, #cycle_count-dynarec_local] mov pc, r0 .size jump_vaddr, .-jump_vaddr + .align 2 .global verify_code_ds .type verify_code_ds, %function @@ -493,30 +502,6 @@ verify_code_ds: .global verify_code_vm .type verify_code_vm, %function verify_code_vm: - /* r0 = instruction pointer (virtual address) */ - /* r1 = source (virtual address) */ - /* r2 = target */ - /* r3 = length */ - cmp r1, #0xC0000000 - blt verify_code - add r12, fp, #memory_map-dynarec_local - lsr r4, r1, #12 - add r5, r1, r3 - sub r5, #1 - ldr r6, [r12, r4, lsl #2] - lsr r5, r5, #12 - movs r7, r6 - bmi .D5 - add r1, r1, r6, lsl #2 - lsl r6, r6, #2 -.D1: - add r4, r4, #1 - teq r6, r7, lsl #2 - bne .D5 - ldr r7, [r12, r4, lsl #2] - cmp r4, r5 - bls .D1 - .size verify_code_vm, .-verify_code_vm .global verify_code .type verify_code, %function verify_code: @@ -553,6 +538,8 @@ verify_code: bl get_addr mov pc, r0 .size verify_code, .-verify_code + .size verify_code_vm, .-verify_code_vm + .align 2 .global cc_interrupt .type cc_interrupt, %function @@ -564,7 +551,8 @@ cc_interrupt: str r1, [fp, #pending_exception-dynarec_local] and r2, r2, r10, lsr #17 add r3, fp, #restore_candidate-dynarec_local - str r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ + str r10, [fp, #cycle-dynarec_local] /* PCSX cycles */ +@@ str r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ ldr r4, [r2, r3] mov r10, lr tst r4, r4 @@ -572,7 +560,7 @@ cc_interrupt: .E1: bl gen_interupt mov lr, r10 - ldr r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ + ldr r10, [fp, #cycle-dynarec_local] ldr r0, [fp, #next_interupt-dynarec_local] ldr r1, [fp, #pending_exception-dynarec_local] ldr r2, [fp, #stop-dynarec_local] @@ -601,8 +589,8 @@ cc_interrupt: tst r5, #31 bne .E5 b .E1 - .size cc_interrupt, .-cc_interrupt + .align 2 .global do_interrupt .type do_interrupt, %function @@ -610,7 +598,7 @@ do_interrupt: ldr r0, [fp, #pcaddr-dynarec_local] bl get_addr_ht ldr r1, [fp, #next_interupt-dynarec_local] - ldr r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ + ldr r10, [fp, #cycle-dynarec_local] str r1, [fp, #last_count-dynarec_local] sub r10, r10, r1 add r10, r10, #2 @@ -629,7 +617,7 @@ fp_exception: add r2, r2, #0x2c str r1, [fp, #reg_cop0+48-dynarec_local] /* Status */ str r2, [fp, #reg_cop0+52-dynarec_local] /* Cause */ - add r0, r3, #0x180 + add r0, r3, #0x80 bl get_addr_ht mov pc, r0 .size fp_exception, .-fp_exception @@ -640,6 +628,7 @@ fp_exception_ds: mov r2, #0x90000000 /* Set high bit if delay slot */ b .E7 .size fp_exception_ds, .-fp_exception_ds + .align 2 .global jump_syscall .type jump_syscall, %function @@ -651,25 +640,77 @@ jump_syscall: mov r2, #0x20 str r1, [fp, #reg_cop0+48-dynarec_local] /* Status */ str r2, [fp, #reg_cop0+52-dynarec_local] /* Cause */ - add r0, r3, #0x180 + add r0, r3, #0x80 bl get_addr_ht mov pc, r0 .size jump_syscall, .-jump_syscall .align 2 + + .align 2 + .global jump_syscall_hle + .type jump_syscall_hle, %function +jump_syscall_hle: + str r0, [fp, #pcaddr-dynarec_local] /* PC must be set to EPC for psxException */ + ldr r2, [fp, #last_count-dynarec_local] + mov r1, #0 /* in delay slot */ + add r2, r2, r10 + mov r0, #0x20 /* cause */ + str r2, [fp, #cycle-dynarec_local] /* PCSX cycle counter */ + bl psxException + + /* note: psxException might do recorsive recompiler call from it's HLE code, + * so be ready for this */ +pcsx_return: + ldr r1, [fp, #next_interupt-dynarec_local] + ldr r10, [fp, #cycle-dynarec_local] + ldr r0, [fp, #pcaddr-dynarec_local] + sub r10, r10, r1 + str r1, [fp, #last_count-dynarec_local] + bl get_addr_ht + mov pc, r0 + .size jump_syscall_hle, .-jump_syscall_hle + + .align 2 + .global jump_hlecall + .type jump_hlecall, %function +jump_hlecall: + ldr r2, [fp, #last_count-dynarec_local] + str r0, [fp, #pcaddr-dynarec_local] + and r1, r1, #7 + add r2, r2, r10 + ldr r3, [fp, #psxHLEt_addr-dynarec_local] /* psxHLEt */ + str r2, [fp, #cycle-dynarec_local] /* PCSX cycle counter */ + adr lr, pcsx_return + ldr pc, [r3, r1, lsl #2] @ FIXME + .size jump_hlecall, .-jump_hlecall + +new_dyna_leave: + .align 2 + .global new_dyna_leave + .type new_dyna_leave, %function + ldr r0, [fp, #last_count-dynarec_local] + add r12, fp, #28 + add r10, r0, r10 + str r10, [fp, #cycle-dynarec_local] + ldmia r12, {r4, r5, r6, r7, r8, r9, sl, fp, pc} + .size new_dyna_leave, .-new_dyna_leave + + /* these are used to call memhandlers */ + .align 2 .global indirect_jump_indexed .type indirect_jump_indexed, %function indirect_jump_indexed: ldr r0, [r0, r1, lsl #2] - .size indirect_jump_indexed, .-indirect_jump_indexed - .align 2 .global indirect_jump .type indirect_jump, %function indirect_jump: ldr r12, [fp, #last_count-dynarec_local] add r2, r2, r12 - str r2, [fp, #reg_cop0+36-dynarec_local] /* Count */ + str r2, [fp, #cycle-dynarec_local] mov pc, r0 .size indirect_jump, .-indirect_jump + .size indirect_jump_indexed, .-indirect_jump_indexed + .align 2 .global jump_eret .type jump_eret, %function @@ -679,7 +720,7 @@ jump_eret: bic r1, r1, #2 add r10, r0, r10 str r1, [fp, #reg_cop0+48-dynarec_local] /* Status */ - str r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ + str r10, [fp, #cycle-dynarec_local] bl check_interupt ldr r1, [fp, #next_interupt-dynarec_local] ldr r0, [fp, #reg_cop0+56-dynarec_local] /* EPC */ @@ -687,26 +728,7 @@ jump_eret: subs r10, r10, r1 bpl .E11 .E8: - add r6, fp, #reg+256-dynarec_local - mov r5, #248 - mov r1, #0 -.E9: - ldr r2, [r6, #-8]! - ldr r3, [r6, #4] - eor r3, r3, r2, asr #31 - subs r3, r3, #1 - adc r1, r1, r1 - subs r5, r5, #8 - bne .E9 - ldr r2, [fp, #hi-dynarec_local] - ldr r3, [fp, #hi+4-dynarec_local] - eors r3, r3, r2, asr #31 - ldr r2, [fp, #lo-dynarec_local] - ldreq r3, [fp, #lo+4-dynarec_local] - eoreq r3, r3, r2, asr #31 - subs r3, r3, #1 - adc r1, r1, r1 - bl get_addr_32 + bl get_addr mov pc, r0 .E11: str r0, [fp, #pcaddr-dynarec_local] @@ -714,24 +736,26 @@ jump_eret: ldr r0, [fp, #pcaddr-dynarec_local] b .E8 .size jump_eret, .-jump_eret + .align 2 .global new_dyna_start .type new_dyna_start, %function new_dyna_start: ldr r12, .dlptr - mov r0, #0xa4000000 stmia r12, {r4, r5, r6, r7, r8, r9, sl, fp, lr} sub fp, r12, #28 - add r0, r0, #0x40 - bl new_recompile_block - ldr r0, [fp, #next_interupt-dynarec_local] - ldr r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ - str r0, [fp, #last_count-dynarec_local] - sub r10, r10, r0 - mov pc, #0x7000000 + ldr r0, [fp, #pcaddr-dynarec_local] + /*bl new_recompile_block*/ + bl get_addr_ht + ldr r1, [fp, #next_interupt-dynarec_local] + ldr r10, [fp, #cycle-dynarec_local] + str r1, [fp, #last_count-dynarec_local] + sub r10, r10, r1 + mov pc, r0 .dlptr: .word dynarec_local+28 .size new_dyna_start, .-new_dyna_start + .align 2 .global write_rdram_new .type write_rdram_new, %function @@ -761,18 +785,7 @@ write_rdramh_new: strh r0, [r2] b .E12 .size write_rdramh_new, .-write_rdramh_new - .align 2 - .global write_rdramd_new - .type write_rdramd_new, %function -write_rdramd_new: - ldr r2, [fp, #address-dynarec_local] -/* ldrd r0, [fp, #dword-dynarec_local]*/ - ldr r0, [fp, #dword-dynarec_local] - ldr r1, [fp, #dword+4-dynarec_local] - str r0, [r2, #4] - str r1, [r2] - b .E12 - .size write_rdramd_new, .-write_rdramd_new + .align 2 .global do_invalidate .type do_invalidate, %function @@ -786,10 +799,17 @@ do_invalidate: beq invalidate_block mov pc, lr .size do_invalidate, .-do_invalidate + .align 2 .global read_nomem_new .type read_nomem_new, %function -read_nomem_new: +/*read_nomem_new:*/ +read_nomemb_new: +read_nomemh_new: +read_nomemd_new: + /* should never happen */ + b read_nomem_new +/* ldr r2, [fp, #address-dynarec_local] add r12, fp, #memory_map-dynarec_local lsr r0, r2, #12 @@ -800,63 +820,12 @@ read_nomem_new: ldr r0, [r2, r12, lsl #2] str r0, [fp, #readmem_dword-dynarec_local] mov pc, lr +*/ .size read_nomem_new, .-read_nomem_new +/* .align 2 .global read_nomemb_new .type read_nomemb_new, %function -read_nomemb_new: - ldr r2, [fp, #address-dynarec_local] - add r12, fp, #memory_map-dynarec_local - lsr r0, r2, #12 - ldr r12, [r12, r0, lsl #2] - mov r1, #8 - tst r12, r12 - bmi tlb_exception - eor r2, r2, #3 - ldrb r0, [r2, r12, lsl #2] - str r0, [fp, #readmem_dword-dynarec_local] - mov pc, lr - .size read_nomemb_new, .-read_nomemb_new - .align 2 - .global read_nomemh_new - .type read_nomemh_new, %function -read_nomemh_new: - ldr r2, [fp, #address-dynarec_local] - add r12, fp, #memory_map-dynarec_local - lsr r0, r2, #12 - ldr r12, [r12, r0, lsl #2] - mov r1, #8 - tst r12, r12 - bmi tlb_exception - lsl r12, r12, #2 - eor r2, r2, #2 - ldrh r0, [r2, r12] - str r0, [fp, #readmem_dword-dynarec_local] - mov pc, lr - .size read_nomemh_new, .-read_nomemh_new - .align 2 - .global read_nomemd_new - .type read_nomemd_new, %function -read_nomemd_new: - ldr r2, [fp, #address-dynarec_local] - add r12, fp, #memory_map-dynarec_local - lsr r0, r2, #12 - ldr r12, [r12, r0, lsl #2] - mov r1, #8 - tst r12, r12 - bmi tlb_exception - lsl r12, r12, #2 -/* ldrd r0, [r2, r12]*/ - add r3, r2, #4 - ldr r0, [r2, r12] - ldr r1, [r3, r12] - str r0, [fp, #readmem_dword+4-dynarec_local] - str r1, [fp, #readmem_dword-dynarec_local] - mov pc, lr - .size read_nomemd_new, .-read_nomemd_new - .align 2 - .global write_nomem_new - .type write_nomem_new, %function write_nomem_new: str r3, [fp, #24] str lr, [fp, #28] @@ -874,6 +843,7 @@ write_nomem_new: str r0, [r2, r12, lsl #2] mov pc, lr .size write_nomem_new, .-write_nomem_new + .align 2 .global write_nomemb_new .type write_nomemb_new, %function @@ -895,6 +865,7 @@ write_nomemb_new: strb r0, [r2, r12, lsl #2] mov pc, lr .size write_nomemb_new, .-write_nomemb_new + .align 2 .global write_nomemh_new .type write_nomemh_new, %function @@ -916,82 +887,7 @@ write_nomemh_new: strh r0, [r2, r12] mov pc, lr .size write_nomemh_new, .-write_nomemh_new - .align 2 - .global write_nomemd_new - .type write_nomemd_new, %function -write_nomemd_new: - str r3, [fp, #24] - str lr, [fp, #28] - bl do_invalidate - ldr r2, [fp, #address-dynarec_local] - add r12, fp, #memory_map-dynarec_local - ldr lr, [fp, #28] - lsr r0, r2, #12 - ldr r3, [fp, #24] - ldr r12, [r12, r0, lsl #2] - mov r1, #0xc - lsls r12, #2 - bcs tlb_exception - add r3, r2, #4 - ldr r0, [fp, #dword+4-dynarec_local] - ldr r1, [fp, #dword-dynarec_local] -/* strd r0, [r2, r12]*/ - str r0, [r2, r12] - str r1, [r3, r12] - mov pc, lr - .size write_nomemd_new, .-write_nomemd_new - .align 2 - .global tlb_exception - .type tlb_exception, %function -tlb_exception: - /* r1 = cause */ - /* r2 = address */ - /* r3 = instr addr/flags */ - ldr r4, [fp, #reg_cop0+48-dynarec_local] /* Status */ - add r5, fp, #memory_map-dynarec_local - lsr r6, r3, #12 - orr r1, r1, r3, lsl #31 - orr r4, r4, #2 - ldr r7, [r5, r6, lsl #2] - bic r8, r3, #3 - str r4, [fp, #reg_cop0+48-dynarec_local] /* Status */ - mov r6, #0x6000000 - str r1, [fp, #reg_cop0+52-dynarec_local] /* Cause */ - orr r6, r6, #0x22 - ldr r0, [r8, r7, lsl #2] - add r4, r8, r1, asr #29 - add r5, fp, #reg-dynarec_local - str r4, [fp, #reg_cop0+56-dynarec_local] /* EPC */ - mov r7, #0xf8 - ldr r8, [fp, #reg_cop0+16-dynarec_local] /* Context */ - lsl r1, r0, #16 - lsr r4, r0, #26 - and r7, r7, r0, lsr #18 - mvn r9, #0xF000000F - sub r2, r2, r1, asr #16 - bic r9, r9, #0x0F800000 - rors r6, r6, r4 - mov r0, #0x80000000 - ldrcs r2, [r5, r7] - bic r8, r8, r9 - tst r3, #2 - str r2, [r5, r7] - add r4, r2, r1, asr #16 - add r6, fp, #reg+4-dynarec_local - asr r3, r2, #31 - str r4, [fp, #reg_cop0+32-dynarec_local] /* BadVAddr */ - add r0, r0, #0x180 - and r4, r9, r4, lsr #9 - strne r3, [r6, r7] - orr r8, r8, r4 - str r8, [fp, #reg_cop0+16-dynarec_local] /* Context */ - bl get_addr_ht - ldr r1, [fp, #next_interupt-dynarec_local] - ldr r10, [fp, #reg_cop0+36-dynarec_local] /* Count */ - str r1, [fp, #last_count-dynarec_local] - sub r10, r10, r1 - mov pc, r0 - .size tlb_exception, .-tlb_exception +*/ .align 2 .global breakpoint .type breakpoint, %function