some reference :
nios ii software developer's hand book
( chaper 6: Developing Programs Using the Hardware Abstraction Layer)
chapter 9 : Cache and Tightly-Coupled Memory)
some functions:
Advanced Placement Options
In your program source code, you can specify a target memory section for each piece of code. In C or C++, you can use the section attribute. This attribute must be placed in a function prototype; you cannot place it in the function declaration itself.
The code in Example 6–16 places a variable foo in the memory named ext_ram, and the function bar() in the memory named sdram. In assembly you do this using the .section directive. For example, all code after the following line is placed in the memory device named ext_ram:
.section .ext_ram.txt
Example 6–16. Manually Assigning C Code to a Specific Memory Section
/* data should be initialized when using the section attribute */
int foo __attribute__ ((section (".ext_ram.rwdata"))) = 0;
void bar (void) __attribute__ ((section (".sdram.txt")));
void bar (void)
{
foo++;
}
you can use a function malloc
By default, the HAL performs no stack or heap checking. This makes function calls and memory allocation faster, but it means that malloc() (in C) and new (in C++) are unable to detect heap exhaustion. You can enable run-time stack checking by manipulating BSP settings. With stack checking on, malloc() and new() can detect heap exhaustion
if you use HAL,The HAL application program interface (API) provides the following functions for managing cache memory:
■ alt_dcache_flush()
■ alt_dcache_flush_all()
■ alt_icache_flush()
■ alt_icache_flush_all()
■ alt_uncached_malloc()
■ alt_uncached_free()
■ alt_remap_uncached()
■ alt_remap_cached()
hope this will help you. because i just want to know which part is placed at which ,so i don't try this !
hope this will help u!