home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / MixedMode.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  7.8 KB  |  302 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MixedMode.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT MixedMode;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __MIXEDMODE__}
  27. {$SETC __MIXEDMODE__ := 1}
  28.  
  29. {$I+}
  30. {$SETC MixedModeIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$PUSH}
  40. {$ALIGN MAC68K}
  41. {$LibExport+}
  42.  
  43. CONST
  44.     kRoutineDescriptorVersion    = 7;
  45.  
  46. { MixedModeMagic Magic Cookie/Trap number }
  47.     _MixedModeMagic                = $AAFE;
  48.  
  49. { Calling Conventions }
  50.     
  51. TYPE
  52.     CallingConventionType = INTEGER;
  53.  
  54.  
  55. CONST
  56.     kPascalStackBased            = 0;
  57.     kCStackBased                = 1;
  58.     kRegisterBased                = 2;
  59.     kD0DispatchedPascalStackBased = 8;
  60.     kD1DispatchedPascalStackBased = 12;
  61.     kD0DispatchedCStackBased    = 9;
  62.     kStackDispatchedPascalStackBased = 14;
  63.     kThinkCStackBased            = 5;
  64.  
  65. { ISA Types }
  66.     
  67. TYPE
  68.     ISAType = SInt8;
  69.  
  70.  
  71. CONST
  72.     kM68kISA                    = 0;
  73.     kPowerPCISA                    = 1;
  74.  
  75. { RTA Types }
  76.     
  77. TYPE
  78.     RTAType = SInt8;
  79.  
  80.  
  81. CONST
  82.     kOld68kRTA                    = 0+(0 * (2**(4)));
  83.     kPowerPCRTA                    = 0+(0 * (2**(4)));
  84.     kCFM68kRTA                    = 0+(1 * (2**(4)));
  85.  
  86. {$IFC GENERATINGPOWERPC }
  87.     GetCurrentISA                = kPowerPCISA;
  88.     GetCurrentRTA                = kPowerPCRTA;
  89.  
  90. {$ELSEC}
  91. {$IFC GENERATINGCFM }
  92.     GetCurrentISA                = kM68kISA;
  93.     GetCurrentRTA                = kCFM68kRTA;
  94.  
  95. {$ELSEC}
  96.     GetCurrentISA                = kM68kISA;
  97.     GetCurrentRTA                = kOld68kRTA;
  98.  
  99. {$ENDC}
  100. {$ENDC}
  101.     GetCurrentArchitecture        = 0+(GetCurrentISA + GetCurrentRTA);
  102.  
  103.     kRegisterD0                    = 0;
  104.     kRegisterD1                    = 1;
  105.     kRegisterD2                    = 2;
  106.     kRegisterD3                    = 3;
  107.     kRegisterD4                    = 8;
  108.     kRegisterD5                    = 9;
  109.     kRegisterD6                    = 10;
  110.     kRegisterD7                    = 11;
  111.     kRegisterA0                    = 4;
  112.     kRegisterA1                    = 5;
  113.     kRegisterA2                    = 6;
  114.     kRegisterA3                    = 7;
  115.     kRegisterA4                    = 12;
  116.     kRegisterA5                    = 13;
  117.     kRegisterA6                    = 14;
  118. { A7 is the same as the PowerPC SP }
  119.     kCCRegisterCBit                = 16;
  120.     kCCRegisterVBit                = 17;
  121.     kCCRegisterZBit                = 18;
  122.     kCCRegisterNBit                = 19;
  123.     kCCRegisterXBit                = 20;
  124.  
  125.     
  126. TYPE
  127.     registerSelectorType = INTEGER;
  128.  
  129. { SizeCodes we use everywhere }
  130.  
  131. CONST
  132.     kNoByteCode                    = 0;
  133.     kOneByteCode                = 1;
  134.     kTwoByteCode                = 2;
  135.     kFourByteCode                = 3;
  136.  
  137. { Mixed Mode Routine Records }
  138.     
  139. TYPE
  140.     ProcInfoType = LONGINT;
  141.  
  142. { Routine Flag Bits }
  143.     RoutineFlagsType = INTEGER;
  144.  
  145.  
  146. CONST
  147.     kProcDescriptorIsAbsolute    = $00;
  148.     kProcDescriptorIsRelative    = $01;
  149.  
  150.     kFragmentIsPrepared            = $00;
  151.     kFragmentNeedsPreparing        = $02;
  152.  
  153.     kUseCurrentISA                = $00;
  154.     kUseNativeISA                = $04;
  155.  
  156.     kPassSelector                = $0;
  157.     kDontPassSelector            = $08;
  158.  
  159.     kRoutineIsNotDispatchedDefaultRoutine = $0;
  160.     kRoutineIsDispatchedDefaultRoutine = $10;
  161.  
  162.  
  163. TYPE
  164.     RoutineRecord = RECORD
  165.         procInfo:                ProcInfoType;                            { calling conventions }
  166.         reserved1:                SInt8;                                    { Must be 0 }
  167.         ISA:                    ISAType;                                { Instruction Set Architecture }
  168.         routineFlags:            RoutineFlagsType;                        { Flags for each routine }
  169.         procDescriptor:            ProcPtr;                                { Where is the thing we’re calling? }
  170.         reserved2:                LONGINT;                                { Must be 0 }
  171.         selector:                LONGINT;                                { For dispatched routines, the selector }
  172.     END;
  173.     RoutineRecordPtr = ^RoutineRecord;
  174.     RoutineRecordHandle = ^RoutineRecordPtr;
  175.  
  176. { Mixed Mode Routine Descriptors }
  177. { Definitions of the Routine Descriptor Flag Bits }
  178.     RDFlagsType = UInt8;
  179.  
  180.  
  181. CONST
  182.     kSelectorsAreNotIndexable    = $00;
  183.     kSelectorsAreIndexable        = $01;
  184.  
  185. { Routine Descriptor Structure }
  186.  
  187. TYPE
  188.     RoutineDescriptor = PACKED RECORD
  189.         goMixedModeTrap:        INTEGER;                                { Our A-Trap }
  190.         version:                SInt8;                                    { Current Routine Descriptor version }
  191.         routineDescriptorFlags:    RDFlagsType;                            { Routine Descriptor Flags }
  192.         reserved1:                LONGINT;                                { Unused, must be zero }
  193.         reserved2:                UInt8;                                    { Unused, must be zero }
  194.         selectorInfo:            UInt8;                                    { If a dispatched routine, calling convention, else 0 }
  195.         routineCount:            INTEGER;                                { Number of routines in this RD }
  196.         routineRecords:            ARRAY [0..0] OF RoutineRecord;            { The individual routines }
  197.     END;
  198.     RoutineDescriptorPtr = ^RoutineDescriptor;
  199.     RoutineDescriptorHandle = ^RoutineDescriptorPtr;
  200.  
  201.  
  202. CONST
  203. { Calling Convention Offsets }
  204.     kCallingConventionWidth        = 4;
  205.     kCallingConventionPhase        = 0;
  206.     kCallingConventionMask        = $F;
  207. { Result Offsets }
  208.     kResultSizeWidth            = 2;
  209.     kResultSizePhase            = kCallingConventionWidth;
  210.     kResultSizeMask                = $30;
  211. { Parameter offsets & widths }
  212.     kStackParameterWidth        = 2;
  213.     kStackParameterPhase        = 0+(kCallingConventionWidth + kResultSizeWidth);
  214.     kStackParameterMask            = $FFFFFFC0;
  215. { Register Result Location offsets & widths }
  216.     kRegisterResultLocationWidth = 5;
  217.     kRegisterResultLocationPhase = 0+(kCallingConventionWidth + kResultSizeWidth);
  218. { Register Parameter offsets & widths }
  219.     kRegisterParameterWidth        = 5;
  220.     kRegisterParameterPhase        = 0+(kCallingConventionWidth + kResultSizeWidth + kRegisterResultLocationWidth);
  221.     kRegisterParameterSizePhase    = 0;
  222.     kRegisterParameterSizeWidth    = 2;
  223.     kRegisterParameterWhichPhase = kRegisterParameterSizeWidth;
  224.     kRegisterParameterWhichWidth = 3;
  225. { Dispatched Stack Routine Selector offsets & widths }
  226.     kDispatchedSelectorSizeWidth = 2;
  227.     kDispatchedSelectorSizePhase = 0+(kCallingConventionWidth + kResultSizeWidth);
  228. { Dispatched Stack Routine Parameter offsets }
  229.     kDispatchedParameterPhase    = 0+(kCallingConventionWidth + kResultSizeWidth + kDispatchedSelectorSizeWidth);
  230. { Special Case offsets & widths }
  231.     kSpecialCaseSelectorWidth    = 6;
  232.     kSpecialCaseSelectorPhase    = kCallingConventionWidth;
  233.     kSpecialCaseSelectorMask    = $3F0;
  234. { Component Manager Special Case offsets & widths }
  235.     kComponentMgrResultSizeWidth = 2;
  236.     kComponentMgrResultSizePhase = kCallingConventionWidth + kSpecialCaseSelectorWidth; { 4 + 6 = 10 }
  237.     kComponentMgrParameterWidth    = 2;
  238.     kComponentMgrParameterPhase    = kComponentMgrResultSizePhase + kComponentMgrResultSizeWidth; { 10 + 2 = 12 }
  239.  
  240.     kSpecialCase                = $0000000F;
  241.  
  242. { all of the special cases enumerated.  The selector field is 6 bits wide }
  243.     kSpecialCaseHighHook        = 0;
  244.     kSpecialCaseCaretHook        = 0;                            { same as kSpecialCaseHighHook }
  245.     kSpecialCaseEOLHook            = 1;
  246.     kSpecialCaseWidthHook        = 2;
  247.     kSpecialCaseTextWidthHook    = 2;                            { same as kSpecialCaseWidthHook }
  248.     kSpecialCaseNWidthHook        = 3;
  249.     kSpecialCaseDrawHook        = 4;
  250.     kSpecialCaseHitTestHook        = 5;
  251.     kSpecialCaseTEFindWord        = 6;
  252.     kSpecialCaseProtocolHandler    = 7;
  253.     kSpecialCaseSocketListener    = 8;
  254.     kSpecialCaseTERecalc        = 9;
  255.     kSpecialCaseTEDoText        = 10;
  256.     kSpecialCaseGNEFilterProc    = 11;
  257.     kSpecialCaseMBarHook        = 12;
  258.     kSpecialCaseComponentMgr    = 13;
  259.  
  260. {$IFC GENERATINGCFM }
  261.  
  262. FUNCTION NewRoutineDescriptor(theProc: ProcPtr; theProcInfo: ProcInfoType; theISA: ByteParameter): UniversalProcPtr;
  263.     {$IFC NOT GENERATINGCFM}
  264.     INLINE $7000, $AA59;
  265.     {$ENDC}
  266. PROCEDURE DisposeRoutineDescriptor(theProcPtr: UniversalProcPtr);
  267.     {$IFC NOT GENERATINGCFM}
  268.     INLINE $7001, $AA59;
  269.     {$ENDC}
  270. FUNCTION NewFatRoutineDescriptor(theM68kProc: ProcPtr; thePowerPCProc: ProcPtr; theProcInfo: ProcInfoType): UniversalProcPtr;
  271.     {$IFC NOT GENERATINGCFM}
  272.     INLINE $7002, $AA59;
  273.     {$ENDC}
  274. {$ELSEC}
  275.  
  276. FUNCTION NewRoutineDescriptor(theProc: ProcPtr; theProcInfo: ProcInfoType; theISA: ByteParameter): UniversalProcPtr;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $5C4F, $2E9F;
  279.     {$ENDC}
  280. PROCEDURE DisposeRoutineDescriptor(theProcPtr: UniversalProcPtr);
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $584F;
  283.     {$ENDC}
  284. {$ENDC}
  285. {$IFC CFMSYSTEMCALLS }
  286. {$IFC NOT LSPWRP & NOT LSP68K}
  287. FUNCTION CallUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  288. FUNCTION CallOSTrapUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  289. {$ENDC}
  290. {$ENDC}
  291.  
  292. {$ALIGN RESET}
  293. {$POP}
  294.  
  295. {$SETC UsingIncludes := MixedModeIncludes}
  296.  
  297. {$ENDC} {__MIXEDMODE__}
  298.  
  299. {$IFC NOT UsingIncludes}
  300.  END.
  301. {$ENDC}
  302.