Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC System Software /
Chapter 2 - Mixed Mode Manager


Summary of the Mixed Mode Manager

C Summary

Constants

/*Gestalt selector and response bits*/
#define gestaltMixedModeAttr     'mixd'   /*Mixed Mode Mgr attributes*/
enum {
   gestaltPowerPCAware           = 0      /*true if MMMgr supports PowerPC*/
};
enum {
   /*current version of RoutineDescriptor data type*/
   kRoutineDescriptorVersion     = 7
};

Routine Flags

enum {
   kProcDescriptorIsAbsolute     = (RoutineFlagsType)0x00,
   kProcDescriptorIsRelative     = (RoutineFlagsType)0x01
};
enum {
   kFragmentIsPrepared           = (RoutineFlagsType)0x00,
   kFragmentNeedsPreparing       = (RoutineFlagsType)0x02
};
enum {
   kUseCurrentISA                = (RoutineFlagsType)0x00,
   kUseNativeISA                 = (RoutineFlagsType)0x04
};
enum {
   kPassSelector                 = (RoutineFlagsType)0x00,
   kDontPassSelector             = (RoutineFlagsType)0x08
};
enum {
   kRoutineIsNotDispatchedDefaultRoutine
                                 = (RoutineFlagsType)0x00,
   kRoutineIsDispatchedDefaultRoutine
                                 = (RoutineFlagsType)0x10
};

Instruction Set Architectures

enum {
   kM68kISA                      = (ISAType)0,     /*MC680x0 architecture*/
   kPowerPCISA                   = (ISAType)1      /*PowerPC architecture*/
};

Routine Descriptor Flags

enum {
   kSelectorsAreNotIndexable     = (RDFlagsType)0x00,
   kSelectorsAreIndexable        = (RDFlagsType)0x01
};

Procedure Information

enum {
   /*size codes*/
   kNoByteCode                   = 0,
   kOneByteCode                  = 1,
   kTwoByteCode                  = 2,
   kFourByteCode                 = 3
};
/*offsets to and widths of procedure information fields*/
#define kCallingConventionPhase                       0
#define kCallingConventionWidth                       4
#define kResultSizePhase                              kCallingConventionWidth
#define kResultSizeWidth                              2
#define kResultSizeMask                               0x30
#define kStackParameterPhase                          6
#define kStackParameterWidth                          2
#define kRegisterResultLocationPhase                  \
                           (kCallingConventionWidth + kResultSizeWidth)
#define kRegisterResultLocationWidth                  5


#define kRegisterParameterPhase                       \
                           (kCallingConventionWidth + kResultSizeWidth + \
                              kRegisterResultLocationWidth)
#define kRegisterParameterWidth                       5
#define kRegisterParameterWhichPhase                  2
#define kRegisterParameterSizePhase                   0
#define kDispatchedSelectorSizeWidth                  2
#define kDispatchedSelectorSizePhase                  \
                           (kCallingConventionWidth + kResultSizeWidth)
#define kDispatchedParameterPhase                     \
                           (kCallingConventionWidth + kResultSizeWidth + \
                              kDispatchedSelectorSizeWidth)
enum {
   /*calling conventions*/
   kPascalStackBased                   = (CallingConventionType)0,
   kCStackBased                        = (CallingConventionType)1,
   kRegisterBased                      = (CallingConventionType)2,
   kThinkCStackBased                   = (CallingConventionType)5,
   kD0DispatchedPascalStackBased       = (CallingConventionType)8,
   kD0DispatchedCStackBased            = (CallingConventionType)9,
   kD1DispatchedPascalStackBased       = (CallingConventionType)12,
   kStackDispatchedPascalStackBased    = (CallingConventionType)14,
   kSpecialCase                        = (CallingConventionType)15
};
enum {
   /*special cases*/
   kSpecialCaseHighHook          = 0,
   kSpecialCaseCaretHook         = kSpecialCaseHighHook,
   kSpecialCaseEOLHook           = 1,
   kSpecialCaseWidthHook         = 2,
   kSpecialCaseNWidthHook        = 3,
   kSpecialCaseTextWidthHook     = kSpecialCaseWidthHook,
   kSpecialCaseDrawHook          = 4,
   kSpecialCaseHitTestHook       = 5,
   kSpecialCaseTEFindWord        = 6,
   kSpecialCaseProtocolHandler   = 7,
   kSpecialCaseSocketListener    = 8,
   kSpecialCaseTERecalc          = 9,
   kSpecialCaseTEDoText          = 10,
   kSpecialCaseGNEFilterProc     = 11,
   kSpecialCaseMBarHook          = 12
};
enum {
   /*680x0 registers*/
   kRegisterD0                   = 0,
   kRegisterD1                   = 1,
   kRegisterD2                   = 2,
   kRegisterD3                   = 3,
   kRegisterD4                   = 8,
   kRegisterD5                   = 9,
   kRegisterD6                   = 10,
   kRegisterD7                   = 11,
   kRegisterA0                   = 4,
   kRegisterA1                   = 5,
   kRegisterA2                   = 6,
   kRegisterA3                   = 7,
   kRegisterA4                   = 12,
   kRegisterA5                   = 13,
   kRegisterA6                   = 14,
   kCCRegisterCBit               = 16,
   kCCRegisterVBit               = 17,
   kCCRegisterZBit               = 18,
   kCCRegisterNBit               = 19,
   kCCRegisterXBit               = 20
};

Data Types

typedef unsigned char ISAType;            /*instruction set architecture*/
typedef unsigned short CallingConventionType;   /*calling convention*/
typedef unsigned long ProcInfoType;       /*procedure information*/
typedef unsigned short RegisterSelectorType;
typedef unsigned short RoutineFlagsType;
struct RoutineRecord {
   ProcInfoType         procInfo;         /*calling conventions*/
   unsigned char        reserved1;        /*reserved*/
   ISAType              ISA;              /*instruction set architecture*/
   RoutineFlagsType     routineFlags;     /*flags for each routine*/
   ProcPtr              procDescriptor;   /*the thing we're calling*/
   unsigned long        reserved2;        /*reserved*/
   unsigned long        selector;         /*selector for dispatched calls*/
};
typedef struct RoutineRecord RoutineRecord;
typedef RoutineRecord *RoutineRecordPtr, **RoutineRecordHandle;
typedef unsigned char RDFlagsType;        /*routine descriptor flags*/
struct RoutineDescriptor {
   unsigned short       goMixedModeTrap;  /*mixed-mode A-trap*/
   char                 version;          /*routine descriptor version*/
   RDFlagsType          routineDescriptorFlags;
                                          /*routine descriptor flags*/
   unsigned long        reserved1;        /*reserved*/
   unsigned char        reserved2;        /*reserved*/
   unsigned char        selectorInfo;     /*selector information*/
   short                routineCount;     /*index of last RR in this RD*/
   RoutineRecord        routineRecords[1];/*the individual routines*/
};
typedef struct RoutineDescriptor RoutineDescriptor;
typedef RoutineDescriptor *UniversalProcPtr, **UniversalProcHandle;
typedef RoutineDescriptor *RoutineDescriptorPtr, **RoutineDescriptorHandle;

Mixed Mode Manager Routines

Creating and Disposing of Routine Descriptors

pascal UniversalProcPtr NewRoutineDescriptor
                  (ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA);
pascal UniversalProcPtr NewFatRoutineDescriptor
                  (ProcPtr theM68kProc, ProcPtr thePowerPCProc, 
                   ProcInfoType theProcInfo);
pascal void DisposeRoutineDescriptor
                  (UniversalProcPtr theProcPtr);

Calling Routines via Universal Procedure Pointers

long CallUniversalProc  (UniversalProcPtr theProcPtr, 
                         ProcInfoType theProcInfo, ...);
long CallOSTrapUniversalProc
                        (UniversalProcPtr theProcPtr, 
                         ProcInfoType theProcInfo, ...);

Determining Instruction Set Architectures

ISAType GetCurrentISA   (void);

C Language Macros for Defining Procedure Information

#define SIZE_CODE(size) (((size) == 4) ? kFourByteCode : \
   (((size) == 2) ? kTwoByteCode : (((size) == 1) ? kOneByteCode : 0)))
#define RESULT_SIZE(sizeCode) ((ProcInfoType)(sizeCode) << kResultSizePhase)
#define STACK_ROUTINE_PARAMETER(whichParam, sizeCode) \
   ((ProcInfoType)(sizeCode) << (kStackParameterPhase + \
                  (((whichParam) - 1) * kStackParameterWidth)))
#define DISPATCHED_STACK_ROUTINE_PARAMETER(whichParam, sizeCode) \
   ((ProcInfoType)(sizeCode) << (kDispatchedParameterPhase + \
                  (((whichParam) - 1) * kStackParameterWidth)))
#define DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(sizeCode) \
   ((ProcInfoType)(sizeCode) << kDispatchedSelectorSizePhase)
#define REGISTER_RESULT_LOCATION(whichReg) \
   ((ProcInfoType)(whichReg) << kRegisterResultLocationPhase)
#define REGISTER_ROUTINE_PARAMETER(whichParam, whichReg, sizeCode) \
   ((((ProcInfoType)(sizeCode) << kRegisterParameterSizePhase) | \
   ((ProcInfoType)(whichReg) << kRegisterParameterWhichPhase)) << \
   (kRegisterParameterPhase + (((whichParam)- 1) * kRegisterParameterWidth)))
#define SPECIAL_CASE_PROCINFO(specialCaseCode) \
   (kSpecialCase | ((ProcInfoType)(specialCaseCode) << 4))


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996