Search
lxdream.org :: lxdream :: r407:d24ab36150c4
lxdream 0.9.1
released Jun 29
Download Now
changeset407:d24ab36150c4
parent406:9289b62f8f33
child408:af496b734734
authornkeynes
dateFri Sep 28 07:26:35 2007 +0000 (13 years ago)
Add xlat_get_lut_entry method
Force blocks to be 32-bit aligned (slight optimization)
src/sh4/xltcache.c
src/sh4/xltcache.h
1.1 --- a/src/sh4/xltcache.c Fri Sep 28 07:25:22 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;
2.1 --- a/src/sh4/xltcache.h Fri Sep 28 07:25:22 2007 +0000
2.2 +++ b/src/sh4/xltcache.h Fri Sep 28 07:26:35 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: xltcache.h,v 1.4 2007-09-20 08:35:04 nkeynes Exp $
2.6 + * $Id: xltcache.h,v 1.5 2007-09-28 07:26:35 nkeynes Exp $
2.7 *
2.8 * Translation cache support (architecture independent)
2.9 *
2.10 @@ -69,6 +69,12 @@
2.11 void *xlat_get_code( sh4addr_t address );
2.12
2.13 /**
2.14 + * Retrieve the address of the lookup table entry corresponding to the
2.15 + * given SH4 address.
2.16 + */
2.17 +void **xlat_get_lut_entry( sh4addr_t address );
2.18 +
2.19 +/**
2.20 * Retrieve the size of the code block starting at the specified pointer. If the
2.21 * pointer is not a valid code block, the return value is undefined.
2.22 */
.