#include <Types.h>
#include <DeskBus.h>
#include <MixedMode.h>
// Instead of making the ADBOp directly, call MyADBOp which makes the appropriate
// call depending on the target architecture. For CFM68K, the ADBOpBlock structure
// is filled in and the ADBGlue routine above is called. For regular 68K and PPC,
// the ADBOp call is made straightaway.
pascal OSErr MyADBOp(
Ptr refCon,
ADBServiceRoutineUPP compRout,
Ptr buffer,
short commandNum)
{
#if TARGET_CPU_68K && TARGET_RT_MAC_CFM
ADBOpBlock adbOpBlock;
adbOpBlock.dataBuffPtr = buffer;
adbOpBlock.opServiceRtPtr = compRout;
adbOpBlock.opDataAreaPtr = refCon;
// Important note: In this sample, we declare the adbOpBlock structure
// as a stack variable. Normally this is a bad practice to use a stack
// parameter for any asynchronous call. ADBOp makes a copy of the
// contents of the structure, so the structure does not need to exist
// for the life of the asynchronous call.
// Note that the refCon value is placed into the ADBOpBlock structure
// for completeness. This program sample assumes that a completion
// routine will access the refCon and the data buffer as globals
// to the process, which is possible under CFM.
return (OSErr) CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xA07C,0),
kRegisterBased |
RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) |
REGISTER_RESULT_LOCATION(kRegisterD0) |
REGISTER_ROUTINE_PARAMETER(1,
kRegisterA0,
SIZE_CODE(sizeof(&gADBOpBlock))) |
REGISTER_ROUTINE_PARAMETER(2,
kRegisterD0,
SIZE_CODE(sizeof(commandNum))),
&gADBOpBlock,
commandNum);
#else // TARGET_CPU_68K && TARGET_RT_MAC_CFM
return (ADBOp(refCon, compRout, buffer, commandNum));
#endif // TARGET_CPU_68K && TARGET_RT_MAC_CFM
}
|