Forum Discussion
Altera_Forum
Honored Contributor
21 years agosometype_t *p = (sometype_t *)(ADDRESS | 0x80000000); This will work only if ADDRESS is of type int - otherwise the compiler should complain. But there is a HAL function which will do this for you (and will correctly flush the cache if required at the same time): #include <sys/alt_cache.h>
sometype_t *p = (sometype_t *)alt_remap_uncached(ADDRESS, LEN); Using the HAL function guarantees that your code will work on all future processors, even if they use a slightly different method for marking pointers or memory areas as uncached. note that adding 0x80000000 onto the pointer will only set bit31 for pointers of type char *. for all other pointers it will do nothing on a 32 bit processor such as nios2 (the arithmetic will overflow).