/* * The maximum number of pages we support up to when doing ranged dcache * flushing. Anything exceeding this will simply flush the dcache in its * entirety.
*/ #define MAX_OCACHE_PAGES 32 #define MAX_ICACHE_PAGES 32
#ifdef CONFIG_CACHE_WRITEBACK staticvoid sh2a_flush_oc_line(unsignedlong v, int way)
{ unsignedlong addr = (v & 0x000007f0) | (way << 11); unsignedlong data;
data = __raw_readl(CACHE_OC_ADDRESS_ARRAY | addr); if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) {
data &= ~SH_CACHE_UPDATED;
__raw_writel(data, CACHE_OC_ADDRESS_ARRAY | addr);
}
} #endif
staticvoid sh2a_invalidate_line(unsignedlong cache_addr, unsignedlong v)
{ /* Set associative bit to hit all ways */ unsignedlong addr = (v & 0x000007f0) | SH_CACHE_ASSOC;
__raw_writel((addr & CACHE_PHYSADDR_MASK), cache_addr | addr);
}
/* * Write back the dirty D-caches, but not invalidate them.
*/ staticvoid sh2a__flush_wback_region(void *start, int size)
{ #ifdef CONFIG_CACHE_WRITEBACK unsignedlong v; unsignedlong begin, end; unsignedlong flags; int nr_ways;
begin = (unsignedlong)start & ~(L1_CACHE_BYTES-1);
end = ((unsignedlong)start + size + L1_CACHE_BYTES-1)
& ~(L1_CACHE_BYTES-1);
nr_ways = current_cpu_data.dcache.ways;
local_irq_save(flags);
jump_to_uncached();
/* If there are too many pages then flush the entire cache */ if (((end - begin) >> PAGE_SHIFT) >= MAX_OCACHE_PAGES) {
begin = CACHE_OC_ADDRESS_ARRAY;
end = begin + (nr_ways * current_cpu_data.dcache.way_size);
for (v = begin; v < end; v += L1_CACHE_BYTES) { unsignedlong data = __raw_readl(v); if (data & SH_CACHE_UPDATED)
__raw_writel(data & ~SH_CACHE_UPDATED, v);
}
} else { int way; for (way = 0; way < nr_ways; way++) { for (v = begin; v < end; v += L1_CACHE_BYTES)
sh2a_flush_oc_line(v, way);
}
}
/* * Write back the dirty D-caches and invalidate them.
*/ staticvoid sh2a__flush_purge_region(void *start, int size)
{ unsignedlong v; unsignedlong begin, end; unsignedlong flags;
begin = (unsignedlong)start & ~(L1_CACHE_BYTES-1);
end = ((unsignedlong)start + size + L1_CACHE_BYTES-1)
& ~(L1_CACHE_BYTES-1);
local_irq_save(flags);
jump_to_uncached();
for (v = begin; v < end; v+=L1_CACHE_BYTES) { #ifdef CONFIG_CACHE_WRITEBACK int way; int nr_ways = current_cpu_data.dcache.ways; for (way = 0; way < nr_ways; way++)
sh2a_flush_oc_line(v, way); #endif
sh2a_invalidate_line(CACHE_OC_ADDRESS_ARRAY, v);
}
back_to_cached();
local_irq_restore(flags);
}
/* * Invalidate the D-caches, but no write back please
*/ staticvoid sh2a__flush_invalidate_region(void *start, int size)
{ unsignedlong v; unsignedlong begin, end; unsignedlong flags;
begin = (unsignedlong)start & ~(L1_CACHE_BYTES-1);
end = ((unsignedlong)start + size + L1_CACHE_BYTES-1)
& ~(L1_CACHE_BYTES-1);
local_irq_save(flags);
jump_to_uncached();
/* If there are too many pages then just blow the cache */ if (((end - begin) >> PAGE_SHIFT) >= MAX_OCACHE_PAGES) {
__raw_writel(__raw_readl(SH_CCR) | CCR_OCACHE_INVALIDATE,
SH_CCR);
} else { for (v = begin; v < end; v += L1_CACHE_BYTES)
sh2a_invalidate_line(CACHE_OC_ADDRESS_ARRAY, v);
}
back_to_cached();
local_irq_restore(flags);
}
/* * Write back the range of D-cache, and purge the I-cache.
*/ staticvoid sh2a_flush_icache_range(void *args)
{ struct flusher_data *data = args; unsignedlong start, end; unsignedlong v; unsignedlong flags;
/* I-Cache invalidate */ /* If there are too many pages then just blow the cache */ if (((end - start) >> PAGE_SHIFT) >= MAX_ICACHE_PAGES) {
__raw_writel(__raw_readl(SH_CCR) | CCR_ICACHE_INVALIDATE,
SH_CCR);
} else { for (v = start; v < end; v += L1_CACHE_BYTES)
sh2a_invalidate_line(CACHE_IC_ADDRESS_ARRAY, v);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.