mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
Track when PilotMain is called reentrantly (as when beaming via
ExgMgr) and don't unload pnolet when exiting inner invocation. Also remove printfs no longer needed.
This commit is contained in:
parent
1586797fef
commit
6344be1b75
1 changed files with 22 additions and 26 deletions
|
@ -57,21 +57,20 @@ void
|
||||||
storageCallback( void/*PnoletUserData*/* _dataP )
|
storageCallback( void/*PnoletUserData*/* _dataP )
|
||||||
{
|
{
|
||||||
PnoletUserData* dataP = (PnoletUserData*)_dataP;
|
PnoletUserData* dataP = (PnoletUserData*)_dataP;
|
||||||
char buf[48];
|
|
||||||
UInt32 offset;
|
UInt32 offset;
|
||||||
PNOFtrHeader* ftrBase;
|
PNOFtrHeader* ftrBase;
|
||||||
|
|
||||||
StrPrintF( buf, "storageCallback(%lx)", dataP );
|
if ( dataP->recursive ) {
|
||||||
WinDrawChars( buf, StrLen(buf), 5, 40 );
|
WinDrawChars( "ERROR: overwriting", 13, 5, 60 );
|
||||||
|
#ifdef DEBUG
|
||||||
StrPrintF( buf, "src=%lx; dest=%lx", dataP->stateSrc, dataP->stateDest );
|
for ( ; ; ); /* make sure we see it. :-) */
|
||||||
WinDrawChars( buf, StrLen(buf), 5, 50 );
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ftrBase = (PNOFtrHeader*)dataP->pnoletEntry;
|
ftrBase = (PNOFtrHeader*)dataP->pnoletEntry;
|
||||||
--ftrBase; /* back up over header */
|
--ftrBase; /* back up over header */
|
||||||
offset = (char*)dataP->stateDest - (char*)ftrBase;
|
offset = (char*)dataP->stateDest - (char*)ftrBase;
|
||||||
DmWrite( ftrBase, offset, dataP->stateSrc, sizeof(PNOState) );
|
DmWrite( ftrBase, offset, dataP->stateSrc, sizeof(PNOState) );
|
||||||
WinDrawChars( "callback done", 13, 5, 60 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -103,14 +102,18 @@ countOrLoadPNOCs( UInt32* pnoSizeP, UInt8* base, UInt32 offset )
|
||||||
}
|
}
|
||||||
} /* countOrLoadPNOCs */
|
} /* countOrLoadPNOCs */
|
||||||
|
|
||||||
static void
|
/* Return true if we had to load the pnolet. If we didn't, then we're being
|
||||||
|
* called recursively (probably because of ExgMgr activity); in that case the
|
||||||
|
* caller better not unload!
|
||||||
|
*/
|
||||||
|
static Boolean
|
||||||
setupPnolet( UInt32** entryP, UInt32** gotTableP )
|
setupPnolet( UInt32** entryP, UInt32** gotTableP )
|
||||||
{
|
{
|
||||||
char buf[64];
|
|
||||||
PNOFtrHeader* ftrBase;
|
PNOFtrHeader* ftrBase;
|
||||||
Err err = FtrGet( APPID, PNOLET_STORE_FEATURE, (UInt32*)&ftrBase );
|
Err err = FtrGet( APPID, PNOLET_STORE_FEATURE, (UInt32*)&ftrBase );
|
||||||
|
XP_Bool mustLoad = err != errNone;
|
||||||
|
|
||||||
if ( err != errNone ) {
|
if ( mustLoad ) {
|
||||||
UInt32* gotTable;
|
UInt32* gotTable;
|
||||||
UInt32 pnoSize, gotSize, pad;
|
UInt32 pnoSize, gotSize, pad;
|
||||||
UInt32 ftrSize = sizeof( PNOFtrHeader );
|
UInt32 ftrSize = sizeof( PNOFtrHeader );
|
||||||
|
@ -139,10 +142,6 @@ setupPnolet( UInt32** entryP, UInt32** gotTableP )
|
||||||
FtrPtrNew( APPID, PNOLET_STORE_FEATURE, ftrSize, (void**)&ftrBase );
|
FtrPtrNew( APPID, PNOLET_STORE_FEATURE, ftrSize, (void**)&ftrBase );
|
||||||
pnoCode = (UInt32*)&ftrBase[1];
|
pnoCode = (UInt32*)&ftrBase[1];
|
||||||
|
|
||||||
StrPrintF( buf, "code ends at 0x%lx",
|
|
||||||
((char*)ftrBase) + ftrSize );
|
|
||||||
WinDrawChars( buf, StrLen(buf), 5, 10 );
|
|
||||||
|
|
||||||
countOrLoadPNOCs( NULL, (UInt8*)ftrBase, sizeof(PNOFtrHeader) );
|
countOrLoadPNOCs( NULL, (UInt8*)ftrBase, sizeof(PNOFtrHeader) );
|
||||||
|
|
||||||
if ( gotSize > 0 ) {
|
if ( gotSize > 0 ) {
|
||||||
|
@ -166,8 +165,7 @@ setupPnolet( UInt32** entryP, UInt32** gotTableP )
|
||||||
*gotTableP = ftrBase->gotTable;
|
*gotTableP = ftrBase->gotTable;
|
||||||
*entryP = (UInt32*)&ftrBase[1];
|
*entryP = (UInt32*)&ftrBase[1];
|
||||||
|
|
||||||
StrPrintF( buf, "got at 0x%lx", *gotTableP );
|
return mustLoad;
|
||||||
WinDrawChars( buf, StrLen(buf), 5, 20 );
|
|
||||||
} /* setupPnolet */
|
} /* setupPnolet */
|
||||||
|
|
||||||
static Boolean
|
static Boolean
|
||||||
|
@ -206,15 +204,15 @@ PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
it unless the user's said not to. */
|
it unless the user's said not to. */
|
||||||
|
|
||||||
if ( shouldRunPnolet() ) {
|
if ( shouldRunPnolet() ) {
|
||||||
char buf[64];
|
|
||||||
UInt32* gotTable;
|
UInt32* gotTable;
|
||||||
PnoletUserData* dataP;
|
PnoletUserData* dataP;
|
||||||
UInt32* pnoCode;
|
UInt32* pnoCode;
|
||||||
UInt32 result;
|
UInt32 result;
|
||||||
|
|
||||||
setupPnolet( &pnoCode, &gotTable );
|
Boolean loaded = setupPnolet( &pnoCode, &gotTable );
|
||||||
|
|
||||||
dataP = (PnoletUserData*)MemPtrNew( sizeof(PnoletUserData) );
|
dataP = (PnoletUserData*)MemPtrNew( sizeof(PnoletUserData) );
|
||||||
|
dataP->recursive = !loaded;
|
||||||
|
|
||||||
dataP->pnoletEntry = pnoCode;
|
dataP->pnoletEntry = pnoCode;
|
||||||
dataP->gotTable = gotTable;
|
dataP->gotTable = gotTable;
|
||||||
dataP->storageCallback = storageCallback;
|
dataP->storageCallback = storageCallback;
|
||||||
|
@ -223,21 +221,19 @@ PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
dataP->cmd = cmd;
|
dataP->cmd = cmd;
|
||||||
dataP->launchFlags = launchFlags;
|
dataP->launchFlags = launchFlags;
|
||||||
|
|
||||||
StrPrintF( buf, "armlet starts at 0x%lx", pnoCode );
|
|
||||||
WinDrawChars( buf, StrLen(buf), 5, 30 );
|
|
||||||
|
|
||||||
result = PceNativeCall((NativeFuncType*)pnoCode, (void*)dataP );
|
result = PceNativeCall((NativeFuncType*)pnoCode, (void*)dataP );
|
||||||
MemPtrFree( dataP );
|
MemPtrFree( dataP );
|
||||||
|
|
||||||
/* Might want to hang onto this, though it's a bit selfish.... */
|
if ( loaded ) {
|
||||||
FtrPtrFree( APPID, PNOLET_STORE_FEATURE );
|
FtrPtrFree( APPID, PNOLET_STORE_FEATURE );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef FEATURE_PNOAND68K
|
#ifdef FEATURE_PNOAND68K
|
||||||
result = PM2(PilotMain)( cmd, cmdPBP, launchFlags);
|
result = PM2(PilotMain)( cmd, cmdPBP, launchFlags);
|
||||||
#else
|
#else
|
||||||
(void)FrmCustomAlert( XW_ERROR_ALERT_ID,
|
(void)FrmCustomAlert( XW_ERROR_ALERT_ID,
|
||||||
"Arm-only Crosswords won't run on this device",
|
"Arm-only Crosswords won't run on this "
|
||||||
" ", " " );
|
"device", " ", " " );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue