filename | src/sh4/xltcache.c |
changeset | 596:dfc0c93d882e |
prev | 592:4343cbfdd21b |
next | 617:476a717a54f3 |
author | nkeynes |
date | Tue Jan 22 10:11:45 2008 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Invoke emulator single-step for untranslatable delay slots (and fix a few related bugs) |
file | annotate | diff | log | raw |
1.1 --- a/src/sh4/xltcache.c Thu Jan 17 10:17:32 2008 +00001.2 +++ b/src/sh4/xltcache.c Tue Jan 22 10:11:45 2008 +00001.3 @@ -211,23 +211,24 @@1.4 xlat_recovery_record_t xlat_get_recovery( void *code, void *native_pc, gboolean recover_after )1.5 {1.6 if( code != NULL ) {1.7 + uintptr_t pc_offset = ((uint8_t *)native_pc) - ((uint8_t *)code);1.8 xlat_cache_block_t block = BLOCK_FOR_CODE(code);1.9 uint32_t count = block->recover_table_size;1.10 xlat_recovery_record_t records = (xlat_recovery_record_t)(&block->code[block->recover_table_offset]);1.11 uint32_t posn;1.12 if( recover_after ) {1.13 - if( records[count-1].xlat_pc <= (uintptr_t)native_pc ) {1.14 + if( records[count-1].xlat_offset <= pc_offset ) {1.15 return NULL;1.16 }1.17 for( posn=count-1; posn > 0; posn-- ) {1.18 - if( records[posn-1].xlat_pc < (uintptr_t)native_pc ) {1.19 + if( records[posn-1].xlat_offset < pc_offset ) {1.20 return &records[posn];1.21 }1.22 }1.23 return &records[0]; // shouldn't happen1.24 } else {1.25 for( posn = 1; posn < count; posn++ ) {1.26 - if( records[posn].xlat_pc >= (uintptr_t)native_pc ) {1.27 + if( records[posn].xlat_offset >= pc_offset ) {1.28 return &records[posn-1];1.29 }1.30 }1.31 @@ -322,6 +323,8 @@1.32 start_block->active = 1;1.33 start_block->size = allocation;1.34 start_block->lut_entry = block->lut_entry;1.35 + start_block->recover_table_offset = block->recover_table_offset;1.36 + start_block->recover_table_size = block->recover_table_size;1.37 *block->lut_entry = &start_block->code;1.38 memcpy( start_block->code, block->code, block->size );1.39 xlat_old_cache_ptr = xlat_cut_block(start_block, size );1.40 @@ -343,6 +346,9 @@1.41 do {1.42 if( curr->active == BLOCK_USED ) {1.43 xlat_promote_to_old_space( curr );1.44 + } else if( curr->active == BLOCK_ACTIVE ) {1.45 + // Active but not used, release block1.46 + *((uintptr_t *)curr->lut_entry) &= ((uintptr_t)0x03);1.47 }1.48 allocation += curr->size + sizeof(struct xlat_cache_block);1.49 curr = NEXT(curr);1.50 @@ -362,6 +368,8 @@1.51 start_block->active = 1;1.52 start_block->size = allocation;1.53 start_block->lut_entry = block->lut_entry;1.54 + start_block->recover_table_offset = block->recover_table_offset;1.55 + start_block->recover_table_size = block->recover_table_size;1.56 *block->lut_entry = &start_block->code;1.57 memcpy( start_block->code, block->code, block->size );1.58 xlat_temp_cache_ptr = xlat_cut_block(start_block, size );1.59 @@ -482,7 +490,7 @@1.60 cache = NEXT(cache);1.61 }1.62 assert( cache == tail );1.63 - assert( foundptr == 1 );1.64 + assert( foundptr == 1 || tail == ptr );1.65 }1.67 void xlat_check_integrity( )
.