From 625520882c7c1c7a237802923d399f4699c157cd Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Wed, 12 Oct 2005 20:17:13 +0000 Subject: [PATCH] Ease 68K/ARM communication svn-id: r19042 --- backends/PalmOS/Src/args.cpp | 48 +++++++++++++++++++++++++++++++----- backends/PalmOS/Src/args.h | 9 ++++++- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/backends/PalmOS/Src/args.cpp b/backends/PalmOS/Src/args.cpp index d05f509daee..aa4a6dc87aa 100644 --- a/backends/PalmOS/Src/args.cpp +++ b/backends/PalmOS/Src/args.cpp @@ -1,9 +1,19 @@ #include +#include "palmdefs.h" #include "args.h" +#include "pace.h" Char **ArgsInit() { - MemHandle argvH = MemHandleNew(MAX_ARG * sizeof(Char *)); - Char **argvP = (Char **)MemHandleLock(argvH); + // first 4 bytes keep the real address of the chunk + MemHandle argvH = MemHandleNew(sizeof(Char *) + (MAX_ARG * sizeof(Char **) + 2)); + // real addr + Char *lockP = (Char *)MemHandleLock(argvH); + // 4byte aligned + Char **argvP = (Char **)ALIGN_4BYTE(lockP); + // save real addr + argvP[0] = lockP; + // initial position + argvP++; for(UInt8 count = 0; count < MAX_ARG; count++) argvP[count] = NULL; @@ -45,7 +55,8 @@ void ArgsFree(Char **argvP) { MemHandleFree(oldH); } - oldH = MemPtrRecoverHandle(argvP); + argvP--; + oldH = MemPtrRecoverHandle(argvP[0]); MemHandleUnlock(oldH); MemHandleFree(oldH); } @@ -60,10 +71,35 @@ void ArgsSetOwner(Char **argvP, UInt16 owner) { if (argvP[count]) { oldH = MemPtrRecoverHandle(argvP[count]); MemHandleSetOwner(oldH, owner); -// MemPtrSetOwner(argvP[count], 0); } - oldH = MemPtrRecoverHandle(argvP); + argvP--; + oldH = MemPtrRecoverHandle(argvP[0]); MemHandleSetOwner(oldH, owner); -// MemPtrSetOwner(argvP, 0); +} + +void ArgsExportInit(Char **argvP, UInt32 countArg, Boolean arm) { + if (arm) { + for(UInt8 count = 0; count < MAX_ARG; count++) + if (argvP[count]) + argvP[count] = (Char *)ByteSwap32(argvP[count]); + } + + FtrSet(appFileCreator, ftrArgsData , (UInt32)argvP); + FtrSet(appFileCreator, ftrArgsCount, (UInt32)countArg); +} + +void ArgsExportRelease(Boolean arm) { + if (arm) { + Char **argvP; + Err e = FtrGet(appFileCreator, ftrArgsData, (UInt32 *)&argvP); + + if (argvP) + for(UInt8 count = 0; count < MAX_ARG; count++) + if (argvP[count]) + argvP[count] = (Char *)ByteSwap32(argvP[count]); + } + + FtrUnregister(appFileCreator, ftrArgsCount); + FtrUnregister(appFileCreator, ftrArgsData); } diff --git a/backends/PalmOS/Src/args.h b/backends/PalmOS/Src/args.h index b6b81adafda..1ccd26a6a1b 100644 --- a/backends/PalmOS/Src/args.h +++ b/backends/PalmOS/Src/args.h @@ -3,9 +3,16 @@ #define MAX_ARG 25 +#define ftrArgsData 1300 +#define ftrArgsCount 1301 +#define ftrVars 1302 + Char **ArgsInit(); void ArgsAdd(Char **argvP, const Char *argP, const Char *parmP, UInt8 *countArgP); void ArgsFree(Char **argvP); void ArgsSetOwner(Char **argvP, UInt16 owner); -#endif \ No newline at end of file +void ArgsExportInit(Char **argvP, UInt32 countArg, Boolean arm); +void ArgsExportRelease(Boolean arm); + +#endif