Just a few notes, I'm don't have a CW for HCS12X here, so I just tiping, nothing tested.
First the __X_ prefix is added by the XGATE compiler to all function names to differentiate
HC12 code from XGATE code. Otherwise a XGATE function call could resolve to call a HC12 function, well would not work too good. So that's not some makefile magic. That's compiler magic.
Second the reason that the HCS12X compiler is using logical addresses for far HCS12X function pointers is that HC12 function pointers, (as opposed to far object pointers) are always logical. The value of functions pointers is loaded into PC/PPAGE and those registers are using only logical addresses. So if you want to get a global address instead, use an object pointer on the HCS12X side. I'm not sure if you have to declare the XGATE function also as HCS12X external variable or if declaring it as HCS12X external function works too, but declaring it as external object (with the __X_ prefix) does work. As external function maybe, not sure.
What else? Well make sure the XGATE and the HCS12X see the same struct layout, of course.
Hmm. You could also define some constants with the XGATE compiler and then refer to them as externl constants from the HCS12X. This might make the code clearer as the XGATE would be used to initialize XGATE pointers. Using the HCS12X to do this is possible, but a bit less straight forward.
What I mean, is something like this (not tested)
header.h
#include
#ifdef __XGATE__
typedef void (*XGATEFunPtr)(void);
#elif defined(__HC12__)
typedef int XGATEFunPtr; // just using any 16 bit type for the HCS12X side
#else
#error....
#endif
extern const XGATEFunPtr g_HaveFun;
hc12.c:
#include "header.h"
....= g_HaveFun;
xgate.cxgate:
#include "header.h"
void funny_xgate(void) {
}
const XGATEFunPtr g_HaveFun= funny_xgate;
This setup wastes some flash bytes for the constants, but it avoids any cross initialization of pointers.
Daniel