zephyr/arch/nios2/core/cache.c
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00

63 lines
1.7 KiB
C

/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <arch/cpu.h>
#include <misc/__assert.h>
/**
* Flush the entire instruction cache and pipeline.
*
* You will need to call this function if the application writes new program
* text to memory, such as a boot copier or runtime synthesis of code. If the
* new text was written with instructions that do not bypass cache memories,
* this should immediately be followed by an invocation of
* _nios2_dcache_flush_all() so that cached instruction data is committed to
* RAM.
*
* See Chapter 9 of the Nios II Gen 2 Software Developer's Handbook for more
* information on cache considerations.
*/
#if ALT_CPU_ICACHE_SIZE > 0
void _nios2_icache_flush_all(void)
{
uint32_t i;
for (i = 0; i < ALT_CPU_ICACHE_SIZE; i += ALT_CPU_ICACHE_LINE_SIZE) {
_nios2_icache_flush(i);
}
/* Get rid of any stale instructions in the pipeline */
_nios2_pipeline_flush();
}
#endif
/**
* Flush the entire data cache.
*
* This will be typically needed after writing new program text to memory
* after flushing the instruction cache.
*
* The Nios II does not support hardware cache coherency for multi-master
* or multi-processor systems and software coherency must be implemented
* when communicating with shared memory. If support for this is introduced
* in Zephyr additional APIs for flushing ranges of the data cache will need
* to be implemented.
*
* See Chapter 9 of the Nios II Gen 2 Software Developer's Handbook for more
* information on cache considerations.
*/
#if ALT_CPU_DCACHE_SIZE > 0
void _nios2_dcache_flush_all(void)
{
uint32_t i;
for (i = 0; i < ALT_CPU_DCACHE_SIZE; i += ALT_CPU_DCACHE_LINE_SIZE) {
_nios2_dcache_flush(i);
}
}
#endif