Fix for bug#4312. Conditionalized patching of StackSpace so it's only done when patching is allowed. Also removed obsolete 68k code, and replaced uses of the BUILD_ROUTINE_DESCRIPTOR macro with calls to NewRoutineDescriptor.
git-svn-id: svn://10.0.0.236/trunk@31074 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
0d74684235
commit
1cf19f1ca3
@ -24,13 +24,9 @@
|
||||
|
||||
#include <LowMem.h>
|
||||
|
||||
// This should be in LowMem.h
|
||||
#ifndef LMSetStackLowPoint
|
||||
#define LMSetStackLowPoint(value) \
|
||||
*((UInt32 *)(0x110)) = (value)
|
||||
#endif
|
||||
|
||||
PRThread *gPrimaryThread = NULL;
|
||||
TimerUPP gTimerCallbackUPP = NULL;
|
||||
PRThread * gPrimaryThread = NULL;
|
||||
|
||||
PR_IMPLEMENT(PRThread *) PR_GetPrimaryThread()
|
||||
{
|
||||
@ -111,16 +107,7 @@ void _MD_InitStack(PRThreadStack *ts, int redZoneBytes)
|
||||
((UInt32 *)ts->stackBottom)[0] = 0xCAFEBEEF;
|
||||
#else
|
||||
#pragma unused (ts)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Turn off the snack stiffer. The NSPR stacks are allocated in the
|
||||
** application's heap; this throws the stack sniffer for a tizzy.
|
||||
** Note that the sniffer does not run on machines running the thread manager.
|
||||
** Yes, we will blast the low-mem every time a new stack is created. We can afford
|
||||
** a couple extra cycles.
|
||||
*/
|
||||
LMSetStackLowPoint(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void _MD_ClearStack(PRThreadStack *ts)
|
||||
@ -176,71 +163,17 @@ pascal void TimerCallback(TMTaskPtr tmTaskPtr)
|
||||
PrimeTime((QElemPtr)tmTaskPtr, kMacTimerInMiliSecs);
|
||||
}
|
||||
|
||||
#if GENERATINGCFM
|
||||
|
||||
RoutineDescriptor gTimerCallbackRD = BUILD_ROUTINE_DESCRIPTOR(uppTimerProcInfo, &TimerCallback);
|
||||
|
||||
#else
|
||||
|
||||
asm void gTimerCallbackRD(void)
|
||||
{
|
||||
// Check out LocalA5. If it is zero, then
|
||||
// it is our first time through, and we should
|
||||
// store away our A5. If not, then we are
|
||||
// a real time manager callback, so we should
|
||||
// store away A5, set up our local a5, jsr
|
||||
// to our callback, and then restore the
|
||||
// previous A5.
|
||||
|
||||
lea LocalA5, a0
|
||||
move.l (a0), d0
|
||||
cmpi.l #0, d0
|
||||
bne TimerProc
|
||||
|
||||
move.l a5, (a0)
|
||||
rts
|
||||
|
||||
TimerProc:
|
||||
|
||||
// Save A5, restore our local A5
|
||||
|
||||
move.l a5, -(sp)
|
||||
move.l d0, a5
|
||||
|
||||
// Jump to our C routine
|
||||
|
||||
move.l a1, -(sp)
|
||||
jsr TimerCallback
|
||||
|
||||
// Restore the previous A5
|
||||
|
||||
move.l (sp)+, a5
|
||||
|
||||
rts
|
||||
|
||||
LocalA5:
|
||||
|
||||
dc.l 0
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void _MD_StartInterrupts(void)
|
||||
{
|
||||
gPrimaryThread = _PR_MD_CURRENT_THREAD();
|
||||
|
||||
// If we are not generating CFM-happy code, then make sure that
|
||||
// we call our callback wrapper once so that we can
|
||||
// save away our A5.
|
||||
|
||||
#if !GENERATINGCFM
|
||||
gTimerCallbackRD();
|
||||
#endif
|
||||
if ( !gTimerCallbackUPP )
|
||||
gTimerCallbackUPP = NewTimerProc(TimerCallback);
|
||||
|
||||
// Fill in the Time Manager queue element
|
||||
|
||||
gTimeManagerTaskElem.tmAddr = (TimerUPP)&gTimerCallbackRD;
|
||||
gTimeManagerTaskElem.tmAddr = (TimerUPP)gTimerCallbackUPP;
|
||||
gTimeManagerTaskElem.tmCount = 0;
|
||||
gTimeManagerTaskElem.tmWakeUp = 0;
|
||||
gTimeManagerTaskElem.tmReserved = 0;
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <Files.h>
|
||||
#include <Errors.h>
|
||||
#include <Folders.h>
|
||||
#include <Gestalt.h>
|
||||
#include <Events.h>
|
||||
#include <Processes.h>
|
||||
#include <TextUtils.h>
|
||||
@ -65,8 +66,11 @@ extern PRThread *gPrimaryThread;
|
||||
|
||||
UniversalProcPtr gStackSpacePatchCallThru = NULL;
|
||||
pascal long StackSpacePatch(UInt16);
|
||||
RoutineDescriptor StackSpacePatchRD = BUILD_ROUTINE_DESCRIPTOR(uppStackSpaceProcInfo, &StackSpacePatch);
|
||||
|
||||
typedef CALLBACK_API( long , StackSpacePatchPtr )(UInt16 trapNo);
|
||||
typedef REGISTER_UPP_TYPE(StackSpacePatchPtr) StackSpacePatchUPP;
|
||||
#define NewStackSpaceProc(userRoutine) (StackSpacePatchUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppStackSpaceProcInfo, GetCurrentArchitecture())
|
||||
StackSpacePatchUPP gStackSpacePatchUPP = NULL;
|
||||
|
||||
//##############################################################################
|
||||
//##############################################################################
|
||||
@ -208,8 +212,9 @@ void _MD_GetRegisters(PRUint32 *to)
|
||||
|
||||
void _MD_EarlyInit()
|
||||
{
|
||||
Handle environmentVariables;
|
||||
|
||||
Handle environmentVariables;
|
||||
long systemVersion;
|
||||
OSErr err;
|
||||
|
||||
#if !defined(MAC_NSPR_STANDALONE)
|
||||
// MacintoshInitializeMemory(); Moved to mdmacmem.c: AllocateRawMemory(Size blockSize)
|
||||
@ -251,11 +256,39 @@ void _MD_EarlyInit()
|
||||
_MD_PutEnv ("NSPR_LOG_MODULES=clock:6,cmon:6,io:6,mon:6,linker:6,cvar:6,sched:6,thread:6");
|
||||
#endif
|
||||
|
||||
gStackSpacePatchCallThru = GetOSTrapAddress(0x0065);
|
||||
SetOSTrapAddress((UniversalProcPtr)&StackSpacePatchRD, 0x0065);
|
||||
err = Gestalt(gestaltSystemVersion,&systemVersion);
|
||||
if (systemVersion < 0x00000A00) // we still need to patch StackSpace()
|
||||
{
|
||||
long foo;
|
||||
foo = StackSpace();
|
||||
CFragConnectionID connID;
|
||||
Str255 errMessage;
|
||||
Ptr interfaceLibAddr;
|
||||
CFragSymbolClass symClass;
|
||||
UniversalProcPtr (*getOSTrapAddressProc)(UInt16);
|
||||
void (*setOSTrapAddressProc)(UniversalProcPtr, UInt16);
|
||||
|
||||
// open connection to "InterfaceLib"
|
||||
err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,
|
||||
&connID, &interfaceLibAddr, errMessage);
|
||||
PR_ASSERT(err == noErr);
|
||||
|
||||
// get symbol GetOSTrapAddress and get trap address for StackSpace (A065)
|
||||
err = FindSymbol(connID, "\pGetOSTrapAddress", &(Ptr)getOSTrapAddressProc, &symClass);
|
||||
PR_ASSERT(err == noErr);
|
||||
PR_ASSERT(symClass == kTVectorCFragSymbol);
|
||||
if (err == noErr)
|
||||
{
|
||||
gStackSpacePatchCallThru = getOSTrapAddressProc(0x0065);
|
||||
}
|
||||
|
||||
// get symbol SetOSTrapAddress and set trap address for _StackSpace (A065)
|
||||
err = FindSymbol(connID, "\pSetOSTrapAddress", &(Ptr)setOSTrapAddressProc, &symClass);
|
||||
PR_ASSERT(err == noErr);
|
||||
PR_ASSERT(symClass == kTVectorCFragSymbol);
|
||||
if (err == noErr && gStackSpacePatchCallThru)
|
||||
{
|
||||
gStackSpacePatchUPP = NewStackSpaceProc(StackSpacePatch);
|
||||
setOSTrapAddressProc(gStackSpacePatchUPP, 0x0065);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user