Search
lxdream.org :: lxdream/src/sh4/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.c
changeset 407:d24ab36150c4
prev400:049d72a7a229
next410:5f8413358e7f
author nkeynes
date Fri Sep 28 07:26:35 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Add xlat_get_lut_entry method
Force blocks to be 32-bit aligned (slight optimization)
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.c Thu Sep 20 08:35:04 2007 +0000
1.2 +++ b/src/sh4/xltcache.c Fri Sep 28 07:26:35 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: xltcache.c,v 1.5 2007-09-20 08:35:04 nkeynes Exp $
1.6 + * $Id: xltcache.c,v 1.6 2007-09-28 07:26:35 nkeynes Exp $
1.7 *
1.8 * Translation cache management. This part is architecture independent.
1.9 *
1.10 @@ -197,18 +197,31 @@
1.11
1.12 void *xlat_get_code( sh4addr_t address )
1.13 {
1.14 + void *result;
1.15 void **page = xlat_lut[XLAT_LUT_PAGE(address)];
1.16 + if( page != NULL ) {
1.17 + result = (void *)(((uint32_t)page[XLAT_LUT_ENTRY(address)]) & 0xFFFFFFFC);
1.18 + }
1.19 + return result;
1.20 +}
1.21 +
1.22 +void **xlat_get_lut_entry( sh4addr_t address )
1.23 +{
1.24 + void **page = xlat_lut[XLAT_LUT_PAGE(address)];
1.25 +
1.26 + /* Add the LUT entry for the block */
1.27 if( page == NULL ) {
1.28 - return NULL;
1.29 + xlat_lut[XLAT_LUT_PAGE(address)] = page =
1.30 + mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,
1.31 + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.32 + memset( page, 0, XLAT_LUT_PAGE_SIZE );
1.33 }
1.34 - void *result = page[XLAT_LUT_ENTRY(address)];
1.35 - if( result == ((void *)(1)) ) {
1.36 - return NULL;
1.37 - } else {
1.38 - return result;
1.39 - }
1.40 +
1.41 + return &page[XLAT_LUT_ENTRY(address)];
1.42 }
1.43
1.44 +
1.45 +
1.46 uint32_t xlat_get_block_size( void *block )
1.47 {
1.48 xlat_cache_block_t xlt = (xlat_cache_block_t)(((char *)block)-sizeof(struct xlat_cache_block));
1.49 @@ -223,6 +236,7 @@
1.50 */
1.51 static inline xlat_cache_block_t xlat_cut_block( xlat_cache_block_t block, int cutsize )
1.52 {
1.53 + cutsize = (cutsize + 3) & 0xFFFFFFFC; // force word alignment
1.54 if( block->size > cutsize + MIN_TOTAL_SIZE ) {
1.55 int oldsize = block->size;
1.56 block->size = cutsize;
.