Reading and writing of cache and memory data in Nios II

Source: Internet
Author: User
Tags one more line

Nios uses 31bit in the address to indicate whether the access is bypass cache.
If bit 31=0 indicates that the cache is not bypass, it uses the data in the cache, and if bit 31=1 represents the bypass cache, the data in the mem is used directly.
such as the alt_remap_uncached function

1 #ifdef nios2_mmu_present2 /*Convert KERNEL Region address to IO region address*/3 #defineBypass_dcache_mask (0x1 << 29)4 #else5 /*Set bit of address to bypass D-cache*/6 #defineBypass_dcache_mask (0x1 << 31)7 #endif8 9 /*Ten * Convert A pointer to a block of cached memory, into a block of One * uncached memory. A  */ -  - volatile void* Alt_remap_uncached (void*ptr, alt_u32 len) the { - Alt_dcache_flush (PTR, Len); -   return(volatile void*) (((ALT_U32) ptr) |bypass_dcache_mask); -}

which

1 #ifdef nios2_flushda_supported2 #defineAlt_flush_data (i) __asm__ volatile ("Flushda (%0)":: "R" (i));3 #else4 #defineAlt_flush_data (i) __asm__ volatile ("flushd (%0)":: "R" (i));5 #endif/* nios2_flushda_supported */6 7 /*8 * Alt_dcache_flush () is called to flush the data cache for a memory9 * Region of the length "Len" bytes, starting at address "start".Ten  * One * Any dirty lines in the data cache is written back to memory. A  */ -  - voidAlt_dcache_flush (void*start, alt_u32 len) the { - #ifNios2_dcache_size > 0 -  -   Char*i; +   Char*end; -  +   /* A * This is the most of we would ever need to flush. at    * - * SPR 196942, 2006.01.13:the cache flush loop below 'll use the - * ' flushda ' instruction if its available; - * must is flushed individually, and thus ' Len ' cannot be trimmed. -    */ - #ifndef nios2_flushda_supported in   if(Len >nios2_dcache_size) -   { toLen =nios2_dcache_size; +   } -   #endif the  *End = ((Char*) Start) +Len; $ Panax Notoginseng    for(i = start; i < end; i+=nios2_dcache_line_size) -   {  the Alt_flush_data (i); +   } A  the   /*  + * For a unaligned flush request, we ' ve got one more line left. - * Note that this was dependent on nios2_dcache_line_size to be a $ * Multiple of 2 (which it always is). $    */ -  -   if((ALT_U32) Start) & (Nios2_dcache_line_size-1)) the   { - Alt_flush_data (i);Wuyi   } the  - #endif/* nios2_dcache_size > 0 */ Wu}

Reading and writing of cache and memory data in Nios II

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.