I posted this same question on the CW forum yesterday, no replies. We're planning to port the same project over to design studio, resolution may be the same.
I’m using CW 2.10 classic for PPC and would appreciate ideas on solving a problem I’m having. I’ve compiled a target for FLASH (the OS) who’s task is to communicate with a host PC over a serial port. There’s a second SRAM target (the app) that’s compiled and can get downloaded through the serial port and executed (i.e. the core stops running the OS and jumps to the start of the app). The SRAM app can call previously compiled functions residing in the FLASH target, plus interrupts can occur while the app is running and the ISRs are located within the FLASH.
Per PPC EABI, the startup assembler sets R2 and R13 to the _SDA_BASE and _SDA2_BASE for the FLASH OS but when the app runs, it does the same thus changes R2 and R13 to its own small data section. The problem now is that when the app calls the FLASH functions to access OS global variables or when an ISR routine accesses OS globals, R13 isn’t correct for the FLASH code. I’m looking for a solution to this, here’s what I’ve considered:
Can anyone suggest a way to avoid this R13 corruption? I can make any defines, etc from the OS available to the app target if that helps with a solution. I think an elegant solution is one that prevents the OS from using small data and indexed addressing.