/*
===================================================================
GraphicsOSSInstallVBLInterrupts()
This routine is specific for VBL interrupts and assumes that
a driver's 'driver-ist' only pertains to VBL's. The Video
Services Library (VSL) kHBLService and kFrameService are ignored.
Interrogate the HAL to get the interrupt handler, the interrupt
enabler, the interrupt disabler, and the VBL 'refCon' (private HAL
data that the HAL might need to carry out the functions).
This version of GDX interrupt handling isolates the HAL from knowing
stuff about how the handlers are installed. Conventions interrupt
routines must follow:
interrupt handler: clear the hw interrupt source
interrupt enabler: enable the hw interrupt source
interrupt disabler: disable the hw interrupt source and:
return true if interrupts were enabled before the call
return false if interrupts were disabled before the call
-> regEntryID Name Registry RegEntryID that
should have the propertyName
==========================================================================
*/
GDXErr GraphicsOSSInstallVBLInterrupts(RegEntryID *regEntryID) {
Boolean installVBLInterrupts;
InterruptEnabler enabler;
InterruptDisabler disabler;
OSSData *ossData;
GDXErr err;
/* Ask HAL if OSS should install VBL routines */
installVBLInterrupts = false;
/* Use default enabler if HAL's enabler is NULL */
enabler = NULL;
ossData = GraphicsOSSGetOSSData();
/* Use default disabler if HAL's disabler is NULL */
disabler = NULL;
err = GraphicsHALGetVBLInterruptRoutines(
&installVBLInterrupts,
&ossData->chainDefault,
&ossData->halVBLHandler,
&ossData->halVBLEnabler,
&ossData->halVBLDisabler,
&ossData->vblRefCon);
if (err != noErr)
goto ErrorExit;
if (installVBLInterrupts) {
/* The OSS should handle the HAL's vbl interrupts
It is possible that OSS should install the routines
but doesn't have the InterruptSetMember */
if (ossData->hasInterruptSetMember) {
InterruptServiceIDType vslServiceID;
OSStatus osStatusErr;
OSErr osErr;
osStatusErr = GetInterruptFunctions(
ossData->interruptSetMember.setID,
ossData->interruptSetMember.member,
&ossData->defaultRefCon,
&ossData->defaultVBLHandler,
&ossData->defaultVBLEnabler,
&ossData->defaultVBLDisabler );
if (osStatusErr != noErr) {
err = kGDXErrOSSNoDefaultVBLRoutines;
goto ErrorExit;
}
/* If the HAL's enabler/disabler functions are
NULL, that indicates that the HAL can use the
default enabler/disabler function. Otherwise,
the OSS enabler/disabler functions will be
installed. NOTE: Making a call to
InstallInterruptFunctions() with NULL as the
enabler/disabler, than the enablers currently
installed (the 'default enablers') are used. */
if (NULL != ossData->halVBLEnabler)
enabler = GraphicsOSSVBLInterruptEnabler;
if (NULL != ossData->halVBLDisabler)
disabler = GraphicsOSSVBLInterruptDisabler;
osStatusErr = InstallInterruptFunctions(
ossData->interruptSetMember.setID,
ossData->interruptSetMember.member,
ossData->vblRefCon,
GraphicsOSSVBLInterruptHandler,
enabler, disabler);
if (osStatusErr != noErr) {
err = kGDXErrOSSUnableToInstallVBLRoutines;
goto ErrorExit;
}
// Successfully installed the routines.
ossData->installedHALVBLRoutines = true;
} else {
err = kGDXErrOSSNoISTProperty;
goto ErrorExit;
}
}
ErrorExit:
return err;
}
|