14.1.2.17 ramfunc

The ramfunc attribute is available for dsPIC33A and PIC32A devices. This attribute directs the language tool chain to allocate the designated function into RAM for execution out of RAM. Once a variable is placed into RAM, it may be called as normal.

By default we will allocate functions into a named section called ramfunc which will be allocate contiguously. Current dsPIC33A and PIC32A devices allow for one executable RAM section to be active at any one time. If there is a ramfunc section defined, the startup-code will mark this section executable at startup. This will prevent further writing to this area of memory.

ramfunc maybe combined with a section attribute to give the allocation section a unique name; however, this will not become active at startup. This may become active by using the builtin function __builtin_set_BMXRAM(), e.g:


void __attribute__((ramfunc,section(".not.executable.yet"))) foo() {
}

The above function will be allocated in RAM in a unique section; but not made executable. The following call will make this area of memory executable.

  __builtin_set_BMXRAM(".not.executable.yet");

The argument must be a string-literal.