Search
lxdream.org :: lxdream :: r1175:712c418cad83
lxdream 0.9.1
released Jun 29
Download Now
changeset1175:712c418cad83
parent1174:252d50f93cf6
child1176:70feb1749427
authorNathan Keynes <nkeynes@lxdream.org>
dateWed May 11 20:25:49 2011 +1000 (8 years ago)
Add xlat_get_address to find the SH4 address corresponding to a host code
address (for debugging purposes)
src/xlat/xltcache.c
1.1 --- a/src/xlat/xltcache.c Wed May 11 19:21:19 2011 +1000
1.2 +++ b/src/xlat/xltcache.c Wed May 11 20:25:49 2011 +1000
1.3 @@ -500,6 +500,35 @@
1.4 }
1.5
1.6 /**
1.7 + * Perform a reverse lookup to determine the SH4 address corresponding to
1.8 + * the start of the code block containing ptr. This is _slow_ - it does a
1.9 + * linear scan of the lookup table to find this.
1.10 + *
1.11 + * If the pointer cannot be found in any live block, returns -1 (as this
1.12 + * is not a legal PC)
1.13 + */
1.14 +sh4addr_t xlat_get_address( unsigned char *ptr )
1.15 +{
1.16 + int i,j;
1.17 + for( i=0; i<XLAT_LUT_PAGES; i++ ) {
1.18 + void **page = xlat_lut[i];
1.19 + if( page != NULL ) {
1.20 + for( j=0; j<XLAT_LUT_PAGE_ENTRIES; j++ ) {
1.21 + void *entry = page[j];
1.22 + if( ((uintptr_t)entry) > XLAT_LUT_ENTRY_USED ) {
1.23 + xlat_cache_block_t block = XLAT_BLOCK_FOR_CODE(entry);
1.24 + if( ptr >= block->code && ptr < block->code + block->size) {
1.25 + /* Found it */
1.26 + return (i<<13) | (j<<1);
1.27 + }
1.28 + }
1.29 + }
1.30 + }
1.31 + }
1.32 + return -1;
1.33 +}
1.34 +
1.35 +/**
1.36 * Sanity check that the given pointer is at least contained in one of cache
1.37 * regions, and has a sane-ish size. We don't do a full region walk atm.
1.38 */
.