Skip to content

Commit

Permalink
Add icache_enable function to simple_system_common.h
Browse files Browse the repository at this point in the history
  • Loading branch information
GregAC committed Jan 31, 2024
1 parent 8ec0c6f commit 0cbbe90
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/sw/simple_system/common/simple_system_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,19 @@ void timer_disable(void);
*/
uint64_t get_elapsed_time(void);

/**
* Enables/disables the instruction cache. This has no effect on Ibex
* configurations that do not have an instruction cache and in particular is
* safe to execute on those configurations.
*
* @param enable if non-zero enables, otherwise disables
*/
static inline void icache_enable(int enable) {
if (enable) {
asm volatile("csrs 0x7c0, 1");
} else {
asm volatile("csrc 0x7c0, 1");
}
}

#endif

0 comments on commit 0cbbe90

Please sign in to comment.