revision 1175:712c418cad83
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1175:712c418cad83 |
parent | 1174:252d50f93cf6 |
child | 1176:70feb1749427 |
author | Nathan Keynes <nkeynes@lxdream.org> |
date | Wed May 11 20:25:49 2011 +1000 (12 years ago) |
Add xlat_get_address to find the SH4 address corresponding to a host code
address (for debugging purposes)
address (for debugging purposes)
1.1 --- a/src/xlat/xltcache.c Wed May 11 19:21:19 2011 +10001.2 +++ b/src/xlat/xltcache.c Wed May 11 20:25:49 2011 +10001.3 @@ -500,6 +500,35 @@1.4 }1.6 /**1.7 + * Perform a reverse lookup to determine the SH4 address corresponding to1.8 + * the start of the code block containing ptr. This is _slow_ - it does a1.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 this1.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 cache1.37 * regions, and has a sane-ish size. We don't do a full region walk atm.1.38 */
.