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