DeskBus.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:15k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       DeskBus.h
  3.  
  4.      Contains:   Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology: System 8.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1987-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __DESKBUS__
  18. #define __DESKBUS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __MIXEDMODE__
  23. #include "MixedMode.h"
  24. #endif
  25. #if PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41. #if TARGET_OS_MAC
  42. typedef SInt8                           ADBAddress;
  43. #if CALL_NOT_IN_CARBON
  44. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  45. /*
  46.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  47.              and cannot be written in a high-level language without 
  48.              the help of mixed mode or assembly glue.
  49. */
  50. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  51. /*
  52.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  53.              and cannot be written in a high-level language without 
  54.              the help of mixed mode or assembly glue.
  55. */
  56. /*
  57.     TempADBServiceRoutineUPP is needed because of circular definition of
  58.     ADBServiceRoutineProcPtr and ADBServiceRoutineUPP depending on each other.
  59. */
  60. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  61. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  62. /*
  63.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  64.              and cannot be written in a high-level language without 
  65.              the help of mixed mode or assembly glue.
  66. */
  67. typedef CALLBACK_API( void , ADBInitProcPtr )(SInt8 callOrder);
  68. /*
  69.     WARNING: ADBInitProcPtr uses register based parameters under classic 68k
  70.              and cannot be written in a high-level language without 
  71.              the help of mixed mode or assembly glue.
  72. */
  73. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  74. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)               ADBDeviceDriverUPP;
  75. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  76. typedef REGISTER_UPP_TYPE(ADBInitProcPtr)                       ADBInitUPP;
  77. struct ADBDataBlock {
  78.     SInt8                           devType;                    /* original handler ID */
  79.     SInt8                           origADBAddr;                /* original ADB Address */
  80.     ADBServiceRoutineUPP            dbServiceRtPtr;             /* service routine pointer */
  81.     Ptr                             dbDataAreaAddr;             /* this field is passed as the refCon parameter to the service routine */
  82. };
  83. typedef struct ADBDataBlock             ADBDataBlock;
  84. typedef ADBDataBlock *                  ADBDBlkPtr;
  85. struct ADBSetInfoBlock {
  86.     ADBServiceRoutineUPP            siService;                  /* service routine pointer */
  87.     Ptr                             siDataAreaAddr;             /* this field is passed as the refCon parameter to the service routine */
  88. };
  89. typedef struct ADBSetInfoBlock          ADBSetInfoBlock;
  90. typedef ADBSetInfoBlock *               ADBSInfoPtr;
  91. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  92. struct ADBOpBlock {
  93.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  94.     ADBServiceRoutineUPP            opServiceRtPtr;             /* completionProc: completion routine pointer */
  95.     Ptr                             opDataAreaPtr;              /* refCon: this field is passed as the refCon parameter to the completion routine */
  96. };
  97. typedef struct ADBOpBlock               ADBOpBlock;
  98. typedef ADBOpBlock *                    ADBOpBPtr;
  99. #endif  /* CALL_NOT_IN_CARBON */
  100. #if CALL_NOT_IN_CARBON
  101. EXTERN_API( void )
  102. ADBReInit                       (void)                                                      ONEWORDINLINE(0xA07B);
  103. /*
  104.     ADBOp has a different interface for 68k assembly than for everything else
  105.     for 68k assembly the interface is 
  106.     #pragma parameter __D0 ADBOp(__A0,__D0)
  107.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  108. */
  109. /*
  110.     IMPORTANT NOTE:
  111.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  112.     four parameters using 68k register based calling conventions, specifically the completion routine
  113.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  114.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  115.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  116.     the mistake cannot be corrected.
  117.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  118.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  119.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  120.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  121. */
  122. #endif  /* CALL_NOT_IN_CARBON */
  123. #if CALL_NOT_IN_CARBON
  124. EXTERN_API( OSErr )
  125. ADBOp                           (Ptr                    refCon,
  126.                                  ADBCompletionUPP       compRout,
  127.                                  Ptr                    buffer,
  128.                                  short                  commandNum);
  129. #endif  /* CALL_NOT_IN_CARBON */
  130. #if CALL_NOT_IN_CARBON
  131.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  132.                                                                                             #pragma parameter __D0 CountADBs
  133.                                                                                             #endif
  134. EXTERN_API( short )
  135. CountADBs                       (void)                                                      ONEWORDINLINE(0xA077);
  136.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  137.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  138.                                                                                             #endif
  139. EXTERN_API( ADBAddress )
  140. GetIndADB                       (ADBDataBlock *         info,
  141.                                  short                  devTableIndex)                      ONEWORDINLINE(0xA078);
  142.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  143.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  144.                                                                                             #endif
  145. EXTERN_API( OSErr )
  146. GetADBInfo                      (ADBDataBlock *         info,
  147.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  148.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  149.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  150.                                                                                             #endif
  151. EXTERN_API( OSErr )
  152. SetADBInfo                      (const ADBSetInfoBlock * info,
  153.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  154. #endif  /* CALL_NOT_IN_CARBON */
  155. #if OPAQUE_UPP_TYPES
  156. #if CALL_NOT_IN_CARBON
  157.     EXTERN_API(ADBCompletionUPP)
  158.     NewADBCompletionUPP            (ADBCompletionProcPtr    userRoutine);
  159.     EXTERN_API(ADBDeviceDriverUPP)
  160.     NewADBDeviceDriverUPP          (ADBDeviceDriverProcPtr  userRoutine);
  161.     EXTERN_API(ADBServiceRoutineUPP)
  162.     NewADBServiceRoutineUPP        (ADBServiceRoutineProcPtr userRoutine);
  163.     EXTERN_API(ADBInitUPP)
  164.     NewADBInitUPP                  (ADBInitProcPtr          userRoutine);
  165.     EXTERN_API(void)
  166.     DisposeADBCompletionUPP        (ADBCompletionUPP        userUPP);
  167.     EXTERN_API(void)
  168.     DisposeADBDeviceDriverUPP      (ADBDeviceDriverUPP      userUPP);
  169.     EXTERN_API(void)
  170.     DisposeADBServiceRoutineUPP    (ADBServiceRoutineUPP    userUPP);
  171.     EXTERN_API(void)
  172.     DisposeADBInitUPP              (ADBInitUPP              userUPP);
  173.     EXTERN_API(void)
  174.     InvokeADBCompletionUPP         (Ptr                     buffer,
  175.                                     Ptr                     refCon,
  176.                                     long                    command,
  177.                                     ADBCompletionUPP        userUPP);
  178.     EXTERN_API(void)
  179.     InvokeADBDeviceDriverUPP       (SInt8                   devAddress,
  180.                                     SInt8                   devType,
  181.                                     ADBDeviceDriverUPP      userUPP);
  182.     EXTERN_API(void)
  183.     InvokeADBServiceRoutineUPP     (Ptr                     buffer,
  184.                                     TempADBServiceRoutineUPP completionProc,
  185.                                     Ptr                     refCon,
  186.                                     long                    command,
  187.                                     ADBServiceRoutineUPP    userUPP);
  188.     EXTERN_API(void)
  189.     InvokeADBInitUPP               (SInt8                   callOrder,
  190.                                     ADBInitUPP              userUPP);
  191. #endif  /* CALL_NOT_IN_CARBON */
  192. #else
  193.     enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  194.     enum { uppADBDeviceDriverProcInfo = 0x00050802 };               /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  195.     enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  196.     enum { uppADBInitProcInfo = 0x00000802 };                       /* register no_return_value Func(1_byte:D0) */
  197.     #define NewADBCompletionUPP(userRoutine)                        (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  198.     #define NewADBDeviceDriverUPP(userRoutine)                      (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  199.     #define NewADBServiceRoutineUPP(userRoutine)                    (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  200.     #define NewADBInitUPP(userRoutine)                              (ADBInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBInitProcInfo, GetCurrentArchitecture())
  201.     #define DisposeADBCompletionUPP(userUPP)                        DisposeRoutineDescriptor(userUPP)
  202.     #define DisposeADBDeviceDriverUPP(userUPP)                      DisposeRoutineDescriptor(userUPP)
  203.     #define DisposeADBServiceRoutineUPP(userUPP)                    DisposeRoutineDescriptor(userUPP)
  204.     #define DisposeADBInitUPP(userUPP)                              DisposeRoutineDescriptor(userUPP)
  205.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  206.     /* InvokeADBCompletionUPP can't be called from classic 68k without glue code */
  207.     #else
  208.         #define InvokeADBCompletionUPP(buffer, refCon, command, userUPP)  CALL_THREE_PARAMETER_UPP((userUPP), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  209.     #endif
  210.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  211.     #pragma parameter InvokeADBDeviceDriverUPP(__D0, __D1, __A0)
  212.     void InvokeADBDeviceDriverUPP(SInt8 devAddress, SInt8 devType, ADBDeviceDriverUPP userUPP) = 0x4E90;
  213.     #else
  214.         #define InvokeADBDeviceDriverUPP(devAddress, devType, userUPP)  CALL_TWO_PARAMETER_UPP((userUPP), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  215.     #endif
  216.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  217.     /* InvokeADBServiceRoutineUPP can't be called from classic 68k without glue code */
  218.     #else
  219.         #define InvokeADBServiceRoutineUPP(buffer, completionProc, refCon, command, userUPP)  CALL_FOUR_PARAMETER_UPP((userUPP), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  220.     #endif
  221.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  222.     #pragma parameter InvokeADBInitUPP(__D0, __A0)
  223.     void InvokeADBInitUPP(SInt8 callOrder, ADBInitUPP userUPP) = 0x4E90;
  224.     #else
  225.         #define InvokeADBInitUPP(callOrder, userUPP)                    CALL_ONE_PARAMETER_UPP((userUPP), uppADBInitProcInfo, (callOrder))
  226.     #endif
  227. #endif
  228. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  229. #define NewADBCompletionProc(userRoutine)                       NewADBCompletionUPP(userRoutine)
  230. #define NewADBDeviceDriverProc(userRoutine)                     NewADBDeviceDriverUPP(userRoutine)
  231. #define NewADBServiceRoutineProc(userRoutine)                   NewADBServiceRoutineUPP(userRoutine)
  232. #define NewADBInitProc(userRoutine)                             NewADBInitUPP(userRoutine)
  233. #define CallADBCompletionProc(userRoutine, buffer, refCon, command) InvokeADBCompletionUPP(buffer, refCon, command, userRoutine)
  234. #define CallADBDeviceDriverProc(userRoutine, devAddress, devType) InvokeADBDeviceDriverUPP(devAddress, devType, userRoutine)
  235. #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command) InvokeADBServiceRoutineUPP(buffer, completionProc, refCon, command, userRoutine)
  236. #define CallADBInitProc(userRoutine, callOrder)                 InvokeADBInitUPP(callOrder, userRoutine)
  237. #endif  /* TARGET_OS_MAC */
  238. #if PRAGMA_STRUCT_ALIGN
  239.     #pragma options align=reset
  240. #elif PRAGMA_STRUCT_PACKPUSH
  241.     #pragma pack(pop)
  242. #elif PRAGMA_STRUCT_PACK
  243.     #pragma pack()
  244. #endif
  245. #ifdef PRAGMA_IMPORT_OFF
  246. #pragma import off
  247. #elif PRAGMA_IMPORT
  248. #pragma import reset
  249. #endif
  250. #ifdef __cplusplus
  251. }
  252. #endif
  253. #endif /* __DESKBUS__ */