Got more time...
In hivawe.h, when __XGATE__ is defined, you have this line for XGATE code:
#pragma CODE_SEG XGATE_CODE
This is the same for both cases, but prm files do differ when you choose RAM and when you choose FLASH.
XGATE_CODE placement may go to RAM segments and may go to flash segments.
You may control by hand placement of each function and XGATE vectors table.
1) to place function to flash add this line above function definition
#pragma CODE_SEG XGATE_CODE_FLASH
void myfoo(void){...
2) to place function to RAM add this above function
#pragma CODE_SEG XGATE_CODE_RAM
Please disregard suggestion to use #pragma CODE_SEG DEFAULT. You can't use it with XGATE, else you routine will be placed in wrong part of flash. To return to project default placement add this below the function.
#pragma CODE_SEG XGATE_CODE
So to force some XGATE function to RAM you put your function between these pragmas
#pragma CODE_SEG XGATE_CODE_RAM
foo()
{
}
#pragma CODE_SEG XGATE_CODE
And to force to flash
#pragma CODE_SEG XGATE_CODE_FLASH
foo()
{
}
#pragma CODE_SEG XGATE_CODE
You may also force XGATE vectors to flash or RAM. Placing it in flash will worse interrupt response times a bit, but you may save some RAM.
#pragma CONST_SEG XGATE_CONST_RAM
#pragma CONST_SEG XGATE_CONST_FLASH