Memory handler issues
Posted: Sat Aug 22, 2015 7:34 pm
I've identified a potential memory handler problem in some code that is ported from OS3.
1. The example code for exec AddMemHandler() in the autodoc shows the interrupt structure ln_Type element being set to NT_INTERRUPT but the exec includes show that it should be NT_EXTINTERRUPT for native code. Which is correct?
2. The prototypes for and OS3 memory handler and OS4 memory handler appear to be different. In the ported code I'm working on, the memory handler function has not been changed from the original OS3 version. I need to know if it needs to be changed.
The OS3 AddMemHandler() autodocs state that the interrupt arguments are passed in registers A0 (pointer to struct MemHandlerData), A1 (pointer to is_Data {userdata?} and A6 (execbase). The example handler is in 68k assembler. The handler function in the program has this prototype:
int low_mem_handler(REG(a0,struct MemHandlerData *memh), REG(a1, struct LibData *data));
Based on the register specifications in the prototype it would appear to be correct for OS3.
The OS4 AddMemHandler() autodocs state that interrupt arguments are passed in registers r3 (execbase), r4 ( struct MemHandlerData) and r5 (is_Data). The example handler is in C and this is the prototype:
LONG myhandler_code(struct ExecBase *ExecBase,
struct MemHandlerData *memHandlerData,
APTR is_Data UNUSED);
The handler arguments appear to be in a different order than the OS3 handler arguments. Do I need to change the handler function in the program to the order shown in the OS4 exec AddMemHandler() autodoc?
3. The prototypes for interrupt handlers shown in the exec SetIntVector() and AddIntServer() look like this:
exec.library/SetIntVector
void interruptHandler(struct ExceptionContext *Context, struct ExecBase *SysBase, void *UserData);
exec.library/AddIntServer
ULONG handler(struct ExceptionContext *Context, struct ExecBase *SysBase, APTR userData);
If the low memory handler is an interrupt (or interrupt handler) how can the arguments be in a different order? The execBase argument is second argument for an interrupt vector or server and first argument for the low memory handler. Are the autodocs correct or is there some error?
1. The example code for exec AddMemHandler() in the autodoc shows the interrupt structure ln_Type element being set to NT_INTERRUPT but the exec includes show that it should be NT_EXTINTERRUPT for native code. Which is correct?
2. The prototypes for and OS3 memory handler and OS4 memory handler appear to be different. In the ported code I'm working on, the memory handler function has not been changed from the original OS3 version. I need to know if it needs to be changed.
The OS3 AddMemHandler() autodocs state that the interrupt arguments are passed in registers A0 (pointer to struct MemHandlerData), A1 (pointer to is_Data {userdata?} and A6 (execbase). The example handler is in 68k assembler. The handler function in the program has this prototype:
int low_mem_handler(REG(a0,struct MemHandlerData *memh), REG(a1, struct LibData *data));
Based on the register specifications in the prototype it would appear to be correct for OS3.
The OS4 AddMemHandler() autodocs state that interrupt arguments are passed in registers r3 (execbase), r4 ( struct MemHandlerData) and r5 (is_Data). The example handler is in C and this is the prototype:
LONG myhandler_code(struct ExecBase *ExecBase,
struct MemHandlerData *memHandlerData,
APTR is_Data UNUSED);
The handler arguments appear to be in a different order than the OS3 handler arguments. Do I need to change the handler function in the program to the order shown in the OS4 exec AddMemHandler() autodoc?
3. The prototypes for interrupt handlers shown in the exec SetIntVector() and AddIntServer() look like this:
exec.library/SetIntVector
void interruptHandler(struct ExceptionContext *Context, struct ExecBase *SysBase, void *UserData);
exec.library/AddIntServer
ULONG handler(struct ExceptionContext *Context, struct ExecBase *SysBase, APTR userData);
If the low memory handler is an interrupt (or interrupt handler) how can the arguments be in a different order? The execBase argument is second argument for an interrupt vector or server and first argument for the low memory handler. Are the autodocs correct or is there some error?