Search
lxdream.org :: lxdream/src/sh4/ia32abi.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/ia32abi.h
changeset 736:a02d1475ccfd
prev669:ab344e42bca9
next899:18e0cdea76aa
author nkeynes
date Wed Jul 30 22:50:44 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Bug #61: OpenBSD support
(Modified) patch from bsdmaniak, thanks!
file annotate diff log raw
1.1 --- a/src/sh4/ia32abi.h Mon May 12 10:00:13 2008 +0000
1.2 +++ b/src/sh4/ia32abi.h Wed Jul 30 22:50:44 2008 +0000
1.3 @@ -17,8 +17,8 @@
1.4 * GNU General Public License for more details.
1.5 */
1.6
1.7 -#ifndef __lxdream_ia32abi_H
1.8 -#define __lxdream_ia32abi_H 1
1.9 +#ifndef lxdream_ia32abi_H
1.10 +#define lxdream_ia32abi_H 1
1.11
1.12 #define load_ptr( reg, ptr ) load_imm32( reg, (uint32_t)ptr );
1.13
1.14 @@ -99,7 +99,7 @@
1.15 PUSH_r32(R_EBP);
1.16 /* mov &sh4r, ebp */
1.17 load_ptr( R_EBP, ((uint8_t *)&sh4r) + 128 );
1.18 -
1.19 +
1.20 sh4_x86.in_delay_slot = FALSE;
1.21 sh4_x86.priv_checked = FALSE;
1.22 sh4_x86.fpuen_checked = FALSE;
1.23 @@ -109,7 +109,7 @@
1.24 sh4_x86.tlb_on = IS_MMU_ENABLED();
1.25 sh4_x86.tstate = TSTATE_NONE;
1.26 #ifdef STACK_ALIGN
1.27 - sh4_x86.stack_posn = 8;
1.28 + sh4_x86.stack_posn = 8;
1.29 #endif
1.30 }
1.31
1.32 @@ -122,9 +122,9 @@
1.33 ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6
1.34 load_spreg( R_EAX, R_PC );
1.35 if( sh4_x86.tlb_on ) {
1.36 - call_func1(xlat_get_code_by_vma,R_EAX);
1.37 + call_func1(xlat_get_code_by_vma,R_EAX);
1.38 } else {
1.39 - call_func1(xlat_get_code,R_EAX);
1.40 + call_func1(xlat_get_code,R_EAX);
1.41 }
1.42 POP_r32(R_EBP);
1.43 RET();
1.44 @@ -140,9 +140,9 @@
1.45 load_spreg( R_EAX, R_NEW_PC );
1.46 store_spreg( R_EAX, R_PC );
1.47 if( sh4_x86.tlb_on ) {
1.48 - call_func1(xlat_get_code_by_vma,R_EAX);
1.49 + call_func1(xlat_get_code_by_vma,R_EAX);
1.50 } else {
1.51 - call_func1(xlat_get_code,R_EAX);
1.52 + call_func1(xlat_get_code,R_EAX);
1.53 }
1.54 POP_r32(R_EBP);
1.55 RET();
1.56 @@ -159,11 +159,11 @@
1.57 load_imm32( R_ECX, pc ); // 5
1.58 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3
1.59 if( IS_IN_ICACHE(pc) ) {
1.60 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.61 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.62 } else if( sh4_x86.tlb_on ) {
1.63 - call_func1(xlat_get_code_by_vma,R_ECX);
1.64 + call_func1(xlat_get_code_by_vma,R_ECX);
1.65 } else {
1.66 - call_func1(xlat_get_code,R_ECX);
1.67 + call_func1(xlat_get_code,R_ECX);
1.68 }
1.69 AND_imm8s_r32( 0xFC, R_EAX ); // 3
1.70 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5
1.71 @@ -183,11 +183,11 @@
1.72 ADD_sh4r_r32( R_PC, R_ECX );
1.73 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3
1.74 if( IS_IN_ICACHE(pc) ) {
1.75 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.76 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5
1.77 } else if( sh4_x86.tlb_on ) {
1.78 - call_func1(xlat_get_code_by_vma,R_ECX);
1.79 + call_func1(xlat_get_code_by_vma,R_ECX);
1.80 } else {
1.81 - call_func1(xlat_get_code,R_ECX);
1.82 + call_func1(xlat_get_code,R_ECX);
1.83 }
1.84 AND_imm8s_r32( 0xFC, R_EAX ); // 3
1.85 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5
1.86 @@ -201,66 +201,66 @@
1.87 */
1.88 void sh4_translate_end_block( sh4addr_t pc ) {
1.89 if( sh4_x86.branch_taken == FALSE ) {
1.90 - // Didn't exit unconditionally already, so write the termination here
1.91 - exit_block_rel( pc, pc );
1.92 + // Didn't exit unconditionally already, so write the termination here
1.93 + exit_block_rel( pc, pc );
1.94 }
1.95 if( sh4_x86.backpatch_posn != 0 ) {
1.96 - unsigned int i;
1.97 - // Raise exception
1.98 - uint8_t *end_ptr = xlat_output;
1.99 - MOV_r32_r32( R_EDX, R_ECX );
1.100 - ADD_r32_r32( R_EDX, R_ECX );
1.101 - ADD_r32_sh4r( R_ECX, R_PC );
1.102 - MOV_moff32_EAX( &sh4_cpu_period );
1.103 - MUL_r32( R_EDX );
1.104 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.105 + unsigned int i;
1.106 + // Raise exception
1.107 + uint8_t *end_ptr = xlat_output;
1.108 + MOV_r32_r32( R_EDX, R_ECX );
1.109 + ADD_r32_r32( R_EDX, R_ECX );
1.110 + ADD_r32_sh4r( R_ECX, R_PC );
1.111 + MOV_moff32_EAX( &sh4_cpu_period );
1.112 + MUL_r32( R_EDX );
1.113 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.114
1.115 - call_func0( sh4_raise_exception );
1.116 - ADD_imm8s_r32( 4, R_ESP );
1.117 - load_spreg( R_EAX, R_PC );
1.118 - if( sh4_x86.tlb_on ) {
1.119 - call_func1(xlat_get_code_by_vma,R_EAX);
1.120 - } else {
1.121 - call_func1(xlat_get_code,R_EAX);
1.122 - }
1.123 - POP_r32(R_EBP);
1.124 - RET();
1.125 + call_func0( sh4_raise_exception );
1.126 + ADD_imm8s_r32( 4, R_ESP );
1.127 + load_spreg( R_EAX, R_PC );
1.128 + if( sh4_x86.tlb_on ) {
1.129 + call_func1(xlat_get_code_by_vma,R_EAX);
1.130 + } else {
1.131 + call_func1(xlat_get_code,R_EAX);
1.132 + }
1.133 + POP_r32(R_EBP);
1.134 + RET();
1.135
1.136 - // Exception already raised - just cleanup
1.137 - uint8_t *preexc_ptr = xlat_output;
1.138 - MOV_r32_r32( R_EDX, R_ECX );
1.139 - ADD_r32_r32( R_EDX, R_ECX );
1.140 - ADD_r32_sh4r( R_ECX, R_SPC );
1.141 - MOV_moff32_EAX( &sh4_cpu_period );
1.142 - MUL_r32( R_EDX );
1.143 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.144 - load_spreg( R_EAX, R_PC );
1.145 - if( sh4_x86.tlb_on ) {
1.146 - call_func1(xlat_get_code_by_vma,R_EAX);
1.147 - } else {
1.148 - call_func1(xlat_get_code,R_EAX);
1.149 - }
1.150 - POP_r32(R_EBP);
1.151 - RET();
1.152 + // Exception already raised - just cleanup
1.153 + uint8_t *preexc_ptr = xlat_output;
1.154 + MOV_r32_r32( R_EDX, R_ECX );
1.155 + ADD_r32_r32( R_EDX, R_ECX );
1.156 + ADD_r32_sh4r( R_ECX, R_SPC );
1.157 + MOV_moff32_EAX( &sh4_cpu_period );
1.158 + MUL_r32( R_EDX );
1.159 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );
1.160 + load_spreg( R_EAX, R_PC );
1.161 + if( sh4_x86.tlb_on ) {
1.162 + call_func1(xlat_get_code_by_vma,R_EAX);
1.163 + } else {
1.164 + call_func1(xlat_get_code,R_EAX);
1.165 + }
1.166 + POP_r32(R_EBP);
1.167 + RET();
1.168
1.169 - for( i=0; i< sh4_x86.backpatch_posn; i++ ) {
1.170 - uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];
1.171 - *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;
1.172 - if( sh4_x86.backpatch_list[i].exc_code < 0 ) {
1.173 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );
1.174 - int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;
1.175 - if( stack_adj > 0 ) {
1.176 - ADD_imm8s_r32( stack_adj, R_ESP );
1.177 - }
1.178 - int rel = preexc_ptr - xlat_output;
1.179 - JMP_rel(rel);
1.180 - } else {
1.181 - PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );
1.182 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );
1.183 - int rel = end_ptr - xlat_output;
1.184 - JMP_rel(rel);
1.185 - }
1.186 - }
1.187 + for( i=0; i< sh4_x86.backpatch_posn; i++ ) {
1.188 + uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];
1.189 + *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;
1.190 + if( sh4_x86.backpatch_list[i].exc_code < 0 ) {
1.191 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );
1.192 + int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;
1.193 + if( stack_adj > 0 ) {
1.194 + ADD_imm8s_r32( stack_adj, R_ESP );
1.195 + }
1.196 + int rel = preexc_ptr - xlat_output;
1.197 + JMP_rel(rel);
1.198 + } else {
1.199 + PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );
1.200 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );
1.201 + int rel = end_ptr - xlat_output;
1.202 + JMP_rel(rel);
1.203 + }
1.204 + }
1.205 }
1.206 }
1.207
1.208 @@ -268,25 +268,25 @@
1.209 {
1.210 void *result = NULL;
1.211 asm(
1.212 - "mov %%ebp, %%eax\n\t"
1.213 - "mov $0x8, %%ecx\n\t"
1.214 - "mov %1, %%edx\n"
1.215 -"frame_loop: test %%eax, %%eax\n\t"
1.216 - "je frame_not_found\n\t"
1.217 - "cmp (%%eax), %%edx\n\t"
1.218 - "je frame_found\n\t"
1.219 - "sub $0x1, %%ecx\n\t"
1.220 - "je frame_not_found\n\t"
1.221 - "movl (%%eax), %%eax\n\t"
1.222 - "jmp frame_loop\n"
1.223 -"frame_found: movl 0x4(%%eax), %0\n"
1.224 -"frame_not_found:"
1.225 - : "=r" (result)
1.226 - : "r" (((uint8_t *)&sh4r) + 128 )
1.227 - : "eax", "ecx", "edx" );
1.228 + "mov %%ebp, %%eax\n\t"
1.229 + "mov $0x8, %%ecx\n\t"
1.230 + "mov %1, %%edx\n"
1.231 + "frame_loop: test %%eax, %%eax\n\t"
1.232 + "je frame_not_found\n\t"
1.233 + "cmp (%%eax), %%edx\n\t"
1.234 + "je frame_found\n\t"
1.235 + "sub $0x1, %%ecx\n\t"
1.236 + "je frame_not_found\n\t"
1.237 + "movl (%%eax), %%eax\n\t"
1.238 + "jmp frame_loop\n"
1.239 + "frame_found: movl 0x4(%%eax), %0\n"
1.240 + "frame_not_found:"
1.241 + : "=r" (result)
1.242 + : "r" (((uint8_t *)&sh4r) + 128 )
1.243 + : "eax", "ecx", "edx" );
1.244 return result;
1.245 }
1.246
1.247 -#endif
1.248 +#endif /* !lxdream_ia32abi_H */
1.249
1.250
.