Search
lxdream.org :: lxdream/src/sh4/ia64abi.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia64abi.h
changeset 571:9bc09948d0f2
prev570:d2893980fbf5
next577:a181aeacd6e8
author nkeynes
date Thu Jan 10 08:28:37 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change More MMU work in progess. Much better now...
file annotate diff log raw
1.1 --- a/src/sh4/ia64abi.h Sun Jan 06 12:24:18 2008 +0000
1.2 +++ b/src/sh4/ia64abi.h Thu Jan 10 08:28:37 2008 +0000
1.3 @@ -50,7 +50,7 @@
1.4 call_func0(ptr);
1.5 }
1.6
1.7 -#define MEM_WRITE_DOUBLE_SIZE 39
1.8 +#define MEM_WRITE_DOUBLE_SIZE 35
1.9 /**
1.10 * Write a double (64-bit) value into memory, with the first word in arg2a, and
1.11 * the second in arg2b
1.12 @@ -60,10 +60,10 @@
1.13 PUSH_r32(arg2b);
1.14 PUSH_r32(addr);
1.15 call_func2(sh4_write_long, addr, arg2a);
1.16 - POP_r32(addr);
1.17 - POP_r32(arg2b);
1.18 - ADD_imm8s_r32(4, addr);
1.19 - call_func2(sh4_write_long, addr, arg2b);
1.20 + POP_r32(R_EDI);
1.21 + POP_r32(R_ESI);
1.22 + ADD_imm8s_r32(4, R_EDI);
1.23 + call_func0(sh4_write_long);
1.24 }
1.25
1.26 #define MEM_READ_DOUBLE_SIZE 43
1.27 @@ -101,8 +101,9 @@
1.28 sh4_x86.fpuen_checked = FALSE;
1.29 sh4_x86.branch_taken = FALSE;
1.30 sh4_x86.backpatch_posn = 0;
1.31 + sh4_x86.recovery_posn = 0;
1.32 sh4_x86.block_start_pc = pc;
1.33 - sh4_x86.tlb_on = MMIO_READ(MMU,MMUCR)&MMUCR_AT;
1.34 + sh4_x86.tlb_on = IS_MMU_ENABLED();
1.35 sh4_x86.tstate = TSTATE_NONE;
1.36 }
1.37
1.38 @@ -124,7 +125,7 @@
1.39 RET();
1.40 }
1.41
1.42 -#define EXIT_BLOCK_SIZE 35
1.43 +#define EXIT_BLOCK_SIZE(pc) (25 + (IS_IN_ICACHE(pc)?10:CALL_FUNC1_SIZE))
1.44 /**
1.45 * Exit the block to an absolute PC
1.46 */
1.47 @@ -132,8 +133,39 @@
1.48 {
1.49 load_imm32( R_ECX, pc ); // 5
1.50 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3
1.51 - REXW(); MOV_moff32_EAX( xlat_get_lut_entry(pc) );
1.52 - REXW(); AND_imm8s_r32( 0xFC, R_EAX ); // 3
1.53 + if( IS_IN_ICACHE(pc) ) {
1.54 + REXW(); MOV_moff32_EAX( xlat_get_lut_entry(pc) );
1.55 + } else if( sh4_x86.tlb_on ) {
1.56 + call_func1(xlat_get_code_by_vma, R_ECX);
1.57 + } else {
1.58 + call_func1(xlat_get_code,R_ECX);
1.59 + }
1.60 + REXW(); AND_imm8s_r32( 0xFC, R_EAX ); // 4
1.61 + load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5
1.62 + ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6
1.63 + POP_r32(R_EBP);
1.64 + RET();
1.65 +}
1.66 +
1.67 +
1.68 +#define EXIT_BLOCK_REL_SIZE(pc) (28 + (IS_IN_ICACHE(pc)?10:CALL_FUNC1_SIZE))
1.69 +
1.70 +/**
1.71 + * Exit the block to a relative PC
1.72 + */
1.73 +void exit_block_rel( sh4addr_t pc, sh4addr_t endpc )
1.74 +{
1.75 + load_imm32( R_ECX, pc - sh4_x86.block_start_pc ); // 5
1.76 + ADD_sh4r_r32( R_PC, R_ECX );
1.77 + store_spreg( R_ECX, REG_OFFSET(pc) ); // 3
1.78 + if( IS_IN_ICACHE(pc) ) {
1.79 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.80 + } else if( sh4_x86.tlb_on ) {
1.81 + call_func1(xlat_get_code_by_vma,R_ECX);
1.82 + } else {
1.83 + call_func1(xlat_get_code,R_ECX);
1.84 + }
1.85 + REXW(); AND_imm8s_r32( 0xFC, R_EAX ); // 4
1.86 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5
1.87 ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6
1.88 POP_r32(R_EBP);
1.89 @@ -146,22 +178,21 @@
1.90 void sh4_translate_end_block( sh4addr_t pc ) {
1.91 if( sh4_x86.branch_taken == FALSE ) {
1.92 // Didn't exit unconditionally already, so write the termination here
1.93 - exit_block( pc, pc );
1.94 + exit_block_rel( pc, pc );
1.95 }
1.96 if( sh4_x86.backpatch_posn != 0 ) {
1.97 unsigned int i;
1.98 // Raise exception
1.99 uint8_t *end_ptr = xlat_output;
1.100 - load_spreg( R_ECX, REG_OFFSET(pc) );
1.101 + MOV_r32_r32( R_EDX, R_ECX );
1.102 ADD_r32_r32( R_EDX, R_ECX );
1.103 - ADD_r32_r32( R_EDX, R_ECX );
1.104 - store_spreg( R_ECX, REG_OFFSET(pc) );
1.105 + ADD_r32_sh4r( R_ECX, R_PC );
1.106 MOV_moff32_EAX( &sh4_cpu_period );
1.107 MUL_r32( R_EDX );
1.108 ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.109
1.110 call_func0( sh4_raise_exception );
1.111 - load_spreg( R_EAX, REG_OFFSET(pc) );
1.112 + load_spreg( R_EAX, R_PC );
1.113 if( sh4_x86.tlb_on ) {
1.114 call_func1(xlat_get_code_by_vma,R_EAX);
1.115 } else {
1.116 @@ -172,18 +203,17 @@
1.117
1.118 // Exception already raised - just cleanup
1.119 uint8_t *preexc_ptr = xlat_output;
1.120 - load_imm32( R_ECX, sh4_x86.block_start_pc );
1.121 + MOV_r32_r32( R_EDX, R_ECX );
1.122 ADD_r32_r32( R_EDX, R_ECX );
1.123 - ADD_r32_r32( R_EDX, R_ECX );
1.124 - store_spreg( R_ECX, REG_OFFSET(spc) );
1.125 + ADD_r32_sh4r( R_ECX, R_SPC );
1.126 MOV_moff32_EAX( &sh4_cpu_period );
1.127 MUL_r32( R_EDX );
1.128 ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.129 - load_spreg( R_EAX, REG_OFFSET(pc) );
1.130 + load_spreg( R_EDI, R_PC );
1.131 if( sh4_x86.tlb_on ) {
1.132 - call_func1(xlat_get_code_by_vma,R_EAX);
1.133 + call_func0(xlat_get_code_by_vma);
1.134 } else {
1.135 - call_func1(xlat_get_code,R_EAX);
1.136 + call_func0(xlat_get_code);
1.137 }
1.138 POP_r32(R_EBP);
1.139 RET();
.