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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       ADSP.h
  3.  
  4.      Contains:   AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology: System 7.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1986-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 __ADSP__
  18. #define __ADSP__
  19. #ifndef __MACERRORS__
  20. #include "MacErrors.h"
  21. #endif
  22. #ifndef __APPLETALK__
  23. #include "AppleTalk.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. /*driver control csCodes*/
  42. enum {
  43.     dspInit                     = 255,                          /* create a new connection end */
  44.     dspRemove                   = 254,                          /* remove a connection end */
  45.     dspOpen                     = 253,                          /* open a connection */
  46.     dspClose                    = 252,                          /* close a connection */
  47.     dspCLInit                   = 251,                          /* create a connection listener */
  48.     dspCLRemove                 = 250,                          /* remove a connection listener */
  49.     dspCLListen                 = 249,                          /* post a listener request */
  50.     dspCLDeny                   = 248,                          /* deny an open connection request */
  51.     dspStatus                   = 247,                          /* get status of connection end */
  52.     dspRead                     = 246,                          /* read data from the connection */
  53.     dspWrite                    = 245,                          /* write data on the connection */
  54.     dspAttention                = 244,                          /* send an attention message */
  55.     dspOptions                  = 243,                          /* set connection end options */
  56.     dspReset                    = 242,                          /* forward reset the connection */
  57.     dspNewCID                   = 241                           /* generate a cid for a connection end */
  58. };
  59. enum {
  60.                                                                 /* connection opening modes */
  61.     ocRequest                   = 1,                            /* request a connection with remote */
  62.     ocPassive                   = 2,                            /* wait for a connection request from remote */
  63.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  64.     ocEstablish                 = 4                             /* consider connection to be open */
  65. };
  66. enum {
  67.                                                                 /* connection end states */
  68.     sListening                  = 1,                            /* for connection listeners */
  69.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  70.     sOpening                    = 3,                            /* requesting a connection with remote */
  71.     sOpen                       = 4,                            /* connection is open */
  72.     sClosing                    = 5,                            /* connection is being torn down */
  73.     sClosed                     = 6                             /* connection end state is closed */
  74. };
  75. enum {
  76.                                                                 /* client event flags */
  77.     eClosed                     = 0x80,                         /* received connection closed advice */
  78.     eTearDown                   = 0x40,                         /* connection closed due to broken connection */
  79.     eAttention                  = 0x20,                         /* received attention message */
  80.     eFwdReset                   = 0x10                          /* received forward reset advice */
  81. };
  82. enum {
  83.                                                                 /* miscellaneous constants */
  84.     attnBufSize                 = 570,                          /* size of client attention buffer */
  85.     minDSPQueueSize             = 100                           /* Minimum size of receive or send Queue */
  86. };
  87. /* connection control block */
  88. typedef struct TRCCB                    TRCCB;
  89. typedef TRCCB *                         TPCCB;
  90. struct TRCCB {
  91.     TPCCB                           ccbLink;                    /* link to next ccb */
  92.     UInt16                          refNum;                     /* user reference number */
  93.     UInt16                          state;                      /* state of the connection end */
  94.     UInt8                           userFlags;                  /* flags for unsolicited connection events */
  95.     UInt8                           localSocket;                /* socket number of this connection end */
  96.     AddrBlock                       remoteAddress;              /* internet address of remote end */
  97.     UInt16                          attnCode;                   /* attention code received */
  98.     UInt16                          attnSize;                   /* size of received attention data */
  99.     void *                          attnPtr;                    /* ptr to received attention data */
  100.     UInt8                           reserved[220];              /* for adsp internal use */
  101. };
  102. typedef CALLBACK_API( void , ADSPConnectionEventProcPtr )(TPCCB sourceCCB);
  103. /*
  104.     WARNING: ADSPConnectionEventProcPtr uses register based parameters under classic 68k
  105.              and cannot be written in a high-level language without 
  106.              the help of mixed mode or assembly glue.
  107. */
  108. typedef struct DSPParamBlock            DSPParamBlock;
  109. typedef DSPParamBlock *                 DSPPBPtr;
  110. typedef CALLBACK_API( void , ADSPCompletionProcPtr )(DSPPBPtr thePBPtr);
  111. /*
  112.     WARNING: ADSPCompletionProcPtr uses register based parameters under classic 68k
  113.              and cannot be written in a high-level language without 
  114.              the help of mixed mode or assembly glue.
  115. */
  116. typedef REGISTER_UPP_TYPE(ADSPConnectionEventProcPtr)           ADSPConnectionEventUPP;
  117. typedef REGISTER_UPP_TYPE(ADSPCompletionProcPtr)                ADSPCompletionUPP;
  118. struct TRinitParams {
  119.     TPCCB                           ccbPtr;                     /* pointer to connection control block */
  120.     ADSPConnectionEventUPP          userRoutine;                /* client routine to call on event */
  121.     UInt16                          sendQSize;                  /* size of send queue (0..64K bytes) */
  122.     void *                          sendQueue;                  /* client passed send queue buffer */
  123.     UInt16                          recvQSize;                  /* size of receive queue (0..64K bytes) */
  124.     void *                          recvQueue;                  /* client passed receive queue buffer */
  125.     void *                          attnPtr;                    /* client passed receive attention buffer */
  126.     UInt8                           localSocket;                /* local socket number */
  127.     UInt8                           filler1;                    /* filler for proper byte alignment */
  128. };
  129. typedef struct TRinitParams             TRinitParams;
  130. struct TRopenParams {
  131.     UInt16                          localCID;                   /* local connection id */
  132.     UInt16                          remoteCID;                  /* remote connection id */
  133.     AddrBlock                       remoteAddress;              /* address of remote end */
  134.     AddrBlock                       filterAddress;              /* address filter */
  135.     UInt32                          sendSeq;                    /* local send sequence number */
  136.     UInt16                          sendWindow;                 /* send window size */
  137.     UInt32                          recvSeq;                    /* receive sequence number */
  138.     UInt32                          attnSendSeq;                /* attention send sequence number */
  139.     UInt32                          attnRecvSeq;                /* attention receive sequence number */
  140.     UInt8                           ocMode;                     /* open connection mode */
  141.     UInt8                           ocInterval;                 /* open connection request retry interval */
  142.     UInt8                           ocMaximum;                  /* open connection request retry maximum */
  143.     UInt8                           filler2;                    /* filler for proper byte alignment */
  144. };
  145. typedef struct TRopenParams             TRopenParams;
  146. struct TRcloseParams {
  147.     UInt8                           abort;                      /* abort connection immediately if non-zero */
  148.     UInt8                           filler3;                    /* filler for proper byte alignment */
  149. };
  150. typedef struct TRcloseParams            TRcloseParams;
  151. struct TRioParams {
  152.     UInt16                          reqCount;                   /* requested number of bytes */
  153.     UInt16                          actCount;                   /* actual number of bytes */
  154.     void *                          dataPtr;                    /* pointer to data buffer */
  155.     UInt8                           eom;                        /* indicates logical end of message */
  156.     UInt8                           flush;                      /* send data now */
  157. };
  158. typedef struct TRioParams               TRioParams;
  159. struct TRattnParams {
  160.     UInt16                          attnCode;                   /* client attention code */
  161.     UInt16                          attnSize;                   /* size of attention data */
  162.     void *                          attnData;                   /* pointer to attention data */
  163.     UInt8                           attnInterval;               /* retransmit timer in 10-tick intervals */
  164.     UInt8                           filler4;                    /* filler for proper byte alignment */
  165. };
  166. typedef struct TRattnParams             TRattnParams;
  167. struct TRstatusParams {
  168.     TPCCB                           statusCCB;                  /* pointer to ccb */
  169.     UInt16                          sendQPending;               /* pending bytes in send queue */
  170.     UInt16                          sendQFree;                  /* available buffer space in send queue */
  171.     UInt16                          recvQPending;               /* pending bytes in receive queue */
  172.     UInt16                          recvQFree;                  /* available buffer space in receive queue */
  173. };
  174. typedef struct TRstatusParams           TRstatusParams;
  175. struct TRoptionParams {
  176.     UInt16                          sendBlocking;               /* quantum for data packets */
  177.     UInt8                           sendTimer;                  /* send timer in 10-tick intervals */
  178.     UInt8                           rtmtTimer;                  /* retransmit timer in 10-tick intervals */
  179.     UInt8                           badSeqMax;                  /* threshold for sending retransmit advice */
  180.     UInt8                           useCheckSum;                /* use ddp packet checksum */
  181. };
  182. typedef struct TRoptionParams           TRoptionParams;
  183. struct TRnewcidParams {
  184.     UInt16                          newcid;                     /* new connection id returned */
  185. };
  186. typedef struct TRnewcidParams           TRnewcidParams;
  187. struct DSPParamBlock {
  188.     QElem *                         qLink;
  189.     short                           qType;
  190.     short                           ioTrap;
  191.     Ptr                             ioCmdAddr;
  192.     ADSPCompletionUPP               ioCompletion;
  193.     OSErr                           ioResult;
  194.     StringPtr                       ioNamePtr;
  195.     short                           ioVRefNum;
  196.     short                           ioCRefNum;                  /* adsp driver refNum */
  197.     short                           csCode;                     /* adsp driver control code */
  198.     long                            qStatus;                    /* adsp internal use */
  199.     short                           ccbRefNum;
  200.     union {
  201.         TRinitParams                    initParams;
  202.         TRopenParams                    openParams;
  203.         TRcloseParams                   closeParams;            /*dspClose, dspRemove*/
  204.         TRioParams                      ioParams;               /*dspRead, dspWrite*/
  205.         TRattnParams                    attnParams;             /*dspAttention*/
  206.         TRstatusParams                  statusParams;           /*dspStatus*/
  207.         TRoptionParams                  optionParams;           /*dspOptions*/
  208.         TRnewcidParams                  newCIDParams;           /*dspNewCID*/
  209.     }                                 u;
  210. };
  211. #if OPAQUE_UPP_TYPES
  212. #if CALL_NOT_IN_CARBON
  213.     EXTERN_API(ADSPConnectionEventUPP)
  214.     NewADSPConnectionEventUPP      (ADSPConnectionEventProcPtr userRoutine);
  215.     EXTERN_API(ADSPCompletionUPP)
  216.     NewADSPCompletionUPP           (ADSPCompletionProcPtr   userRoutine);
  217.     EXTERN_API(void)
  218.     DisposeADSPConnectionEventUPP    (ADSPConnectionEventUPP userUPP);
  219.     EXTERN_API(void)
  220.     DisposeADSPCompletionUPP       (ADSPCompletionUPP       userUPP);
  221.     EXTERN_API(void)
  222.     InvokeADSPConnectionEventUPP    (TPCCB                  sourceCCB,
  223.                                     ADSPConnectionEventUPP  userUPP);
  224.     EXTERN_API(void)
  225.     InvokeADSPCompletionUPP        (DSPPBPtr                thePBPtr,
  226.                                     ADSPCompletionUPP       userUPP);
  227. #endif  /* CALL_NOT_IN_CARBON */
  228. #else
  229.     enum { uppADSPConnectionEventProcInfo = 0x0000B802 };           /* register no_return_value Func(4_bytes:A1) */
  230.     enum { uppADSPCompletionProcInfo = 0x00009802 };                /* register no_return_value Func(4_bytes:A0) */
  231.     #define NewADSPConnectionEventUPP(userRoutine)                  (ADSPConnectionEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  232.     #define NewADSPCompletionUPP(userRoutine)                       (ADSPCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  233.     #define DisposeADSPConnectionEventUPP(userUPP)                  DisposeRoutineDescriptor(userUPP)
  234.     #define DisposeADSPCompletionUPP(userUPP)                       DisposeRoutineDescriptor(userUPP)
  235.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  236.     #pragma parameter InvokeADSPConnectionEventUPP(__A1, __A0)
  237.     void InvokeADSPConnectionEventUPP(TPCCB sourceCCB, ADSPConnectionEventUPP userUPP) = 0x4E90;
  238.     #else
  239.         #define InvokeADSPConnectionEventUPP(sourceCCB, userUPP)        CALL_ONE_PARAMETER_UPP((userUPP), uppADSPConnectionEventProcInfo, (sourceCCB))
  240.     #endif
  241.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  242.     #pragma parameter InvokeADSPCompletionUPP(__A0, __A1)
  243.     void InvokeADSPCompletionUPP(DSPPBPtr thePBPtr, ADSPCompletionUPP userUPP) = 0x4E91;
  244.     #else
  245.         #define InvokeADSPCompletionUPP(thePBPtr, userUPP)              CALL_ONE_PARAMETER_UPP((userUPP), uppADSPCompletionProcInfo, (thePBPtr))
  246.     #endif
  247. #endif
  248. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  249. #define NewADSPConnectionEventProc(userRoutine)                 NewADSPConnectionEventUPP(userRoutine)
  250. #define NewADSPCompletionProc(userRoutine)                      NewADSPCompletionUPP(userRoutine)
  251. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)     InvokeADSPConnectionEventUPP(sourceCCB, userRoutine)
  252. #define CallADSPCompletionProc(userRoutine, thePBPtr)           InvokeADSPCompletionUPP(thePBPtr, userRoutine)
  253. #if PRAGMA_STRUCT_ALIGN
  254.     #pragma options align=reset
  255. #elif PRAGMA_STRUCT_PACKPUSH
  256.     #pragma pack(pop)
  257. #elif PRAGMA_STRUCT_PACK
  258.     #pragma pack()
  259. #endif
  260. #ifdef PRAGMA_IMPORT_OFF
  261. #pragma import off
  262. #elif PRAGMA_IMPORT
  263. #pragma import reset
  264. #endif
  265. #ifdef __cplusplus
  266. }
  267. #endif
  268. #endif /* __ADSP__ */