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

  1. {
  2.      File:        ADSP.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 ADSP;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __ADSP__}
  27. {$SETC __ADSP__ := 1}
  28.  
  29. {$I+}
  30. {$SETC ADSPIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __APPLETALK__}
  40. {$I AppleTalk.p}
  41. {$ENDC}
  42. {    Types.p                                                        }
  43. {    OSUtils.p                                                    }
  44. {        MixedMode.p                                                }
  45. {        Memory.p                                                }
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51. CONST
  52.     dspInit                        = 255;                            { create a new connection end }
  53.     dspRemove                    = 254;                            { remove a connection end }
  54.     dspOpen                        = 253;                            { open a connection }
  55.     dspClose                    = 252;                            { close a connection }
  56.     dspCLInit                    = 251;                            { create a connection listener }
  57.     dspCLRemove                    = 250;                            { remove a connection listener }
  58.     dspCLListen                    = 249;                            { post a listener request }
  59.     dspCLDeny                    = 248;                            { deny an open connection request }
  60.     dspStatus                    = 247;                            { get status of connection end }
  61.     dspRead                        = 246;                            { read data from the connection }
  62.     dspWrite                    = 245;                            { write data on the connection }
  63.     dspAttention                = 244;                            { send an attention message }
  64.  
  65.     dspOptions                    = 243;                            { set connection end options }
  66.     dspReset                    = 242;                            { forward reset the connection }
  67.     dspNewCID                    = 241;                            { generate a cid for a connection end }
  68. { connection opening modes }
  69.     ocRequest                    = 1;                            { request a connection with remote }
  70.     ocPassive                    = 2;                            { wait for a connection request from remote }
  71.     ocAccept                    = 3;                            { accept request as delivered by listener }
  72.     ocEstablish                    = 4;                            { consider connection to be open }
  73. { connection end states }
  74.     sListening                    = 1;                            { for connection listeners }
  75.     sPassive                    = 2;                            { waiting for a connection request from remote }
  76.     sOpening                    = 3;                            { requesting a connection with remote }
  77.     sOpen                        = 4;                            { connection is open }
  78.     sClosing                    = 5;                            { connection is being torn down }
  79.     sClosed                        = 6;                            { connection end state is closed }
  80. { client event flags }
  81.     eClosed                        = $80;                            { received connection closed advice }
  82.     eTearDown                    = $40;                            { connection closed due to broken connection }
  83.     eAttention                    = $20;                            { received attention message }
  84.     eFwdReset                    = $10;                            { received forward reset advice }
  85. { miscellaneous constants }
  86.     attnBufSize                    = 570;                            { size of client attention buffer }
  87.     minDSPQueueSize                = 100;                            { Minimum size of receive or send Queue }
  88.  
  89. { connection control block }
  90.  
  91. TYPE
  92.     TRCCB = PACKED RECORD
  93.         ccbLink:                ^TRCCB;                                    { link to next ccb }
  94.         refNum:                    UInt16;                                    { user reference number }
  95.         state:                    UInt16;                                    { state of the connection end }
  96.         userFlags:                UInt8;                                    { flags for unsolicited connection events }
  97.         localSocket:            UInt8;                                    { socket number of this connection end }
  98.         remoteAddress:            AddrBlock;                                { internet address of remote end }
  99.         attnCode:                UInt16;                                    { attention code received }
  100.         attnSize:                UInt16;                                    { size of received attention data }
  101.         attnPtr:                Ptr;                                    { ptr to received attention data }
  102.         reserved:                PACKED ARRAY [0..219] OF UInt8;            { for adsp internal use }
  103.     END;
  104.     TPCCB = ^TRCCB;
  105.  
  106.     DSPPBPtr = ^DSPParamBlock;
  107.  
  108.     {
  109.         ADSPConnectionEventProcPtr uses register based parameters on the 68k and cannot
  110.         be written in or called from a high-level language without the help of
  111.         mixed mode or assembly glue.
  112.  
  113.         In:
  114.          => sourceCCB       A1.L
  115.     }
  116.     ADSPConnectionEventProcPtr = ProcPtr;  { PROCEDURE ADSPConnectionEvent(sourceCCB: TPCCB); }
  117.     {
  118.         ADSPCompletionProcPtr uses register based parameters on the 68k and cannot
  119.         be written in or called from a high-level language without the help of
  120.         mixed mode or assembly glue.
  121.  
  122.         In:
  123.          => thePBPtr        A0.L
  124.     }
  125.     ADSPCompletionProcPtr = ProcPtr;  { PROCEDURE ADSPCompletion(thePBPtr: DSPPBPtr); }
  126.     ADSPConnectionEventUPP = UniversalProcPtr;
  127.     ADSPCompletionUPP = UniversalProcPtr;
  128.  
  129.     DSPParamBlock = PACKED RECORD
  130.         qLink:                    ^QElem;
  131.         qType:                    INTEGER;
  132.         ioTrap:                    INTEGER;
  133.         ioCmdAddr:                Ptr;
  134.         ioCompletion:            ADSPCompletionUPP;
  135.         ioResult:                OSErr;
  136.         ioNamePtr:                StringPtr;
  137.         ioVRefNum:                INTEGER;
  138.         ioCRefNum:                INTEGER;                                { adsp driver refNum }
  139.         csCode:                    INTEGER;                                { adsp driver control code }
  140.         qStatus:                LONGINT;                                { adsp internal use }
  141.         ccbRefNum:                INTEGER;
  142.         CASE INTEGER OF
  143.         0: (
  144.             ccbPtr:                        TPCCB;                                { pointer to connection control block }
  145.             userRoutine:                ADSPConnectionEventUPP;                { client routine to call on event }
  146.             sendQSize:                    UInt16;                                { size of send queue (0..64K bytes) }
  147.             sendQueue:                    Ptr;                                { client passed send queue buffer }
  148.             recvQSize:                    UInt16;                                { size of receive queue (0..64K bytes) }
  149.             recvQueue:                    Ptr;                                { client passed receive queue buffer }
  150.             attnPtr:                    Ptr;                                { client passed receive attention buffer }
  151.             localSocket:                UInt8;                                { local socket number }
  152.             filler1:                    UInt8;                                { filler for proper byte alignment }
  153.            );
  154.         1: (
  155.             localCID:                    UInt16;                                { local connection id }
  156.             remoteCID:                    UInt16;                                { remote connection id }
  157.             remoteAddress:                AddrBlock;                            { address of remote end }
  158.             filterAddress:                AddrBlock;                            { address filter }
  159.             sendSeq:                    UInt32;                                { local send sequence number }
  160.             sendWindow:                    UInt16;                                { send window size }
  161.             recvSeq:                    UInt32;                                { receive sequence number }
  162.             attnSendSeq:                UInt32;                                { attention send sequence number }
  163.             attnRecvSeq:                UInt32;                                { attention receive sequence number }
  164.             ocMode:                        UInt8;                                { open connection mode }
  165.             ocInterval:                    UInt8;                                { open connection request retry interval }
  166.             ocMaximum:                    UInt8;                                { open connection request retry maximum }
  167.             filler2:                    UInt8;                                { filler for proper byte alignment }
  168.            );
  169.         2: (
  170.             abort:                        UInt8;                                { abort connection immediately if non-zero }
  171.             filler3:                    UInt8;                                { filler for proper byte alignment }
  172.            );
  173.         3: (
  174.             reqCount:                    UInt16;                                { requested number of bytes }
  175.             actCount:                    UInt16;                                { actual number of bytes }
  176.             dataPtr:                    Ptr;                                { pointer to data buffer }
  177.             eom:                        UInt8;                                { indicates logical end of message }
  178.             flush:                        UInt8;                                { send data now }
  179.            );
  180.         4: (
  181.             attnCode:                    UInt16;                                { client attention code }
  182.             attnSize:                    UInt16;                                { size of attention data }
  183.             attnData:                    Ptr;                                { pointer to attention data }
  184.             attnInterval:                UInt8;                                { retransmit timer in 10-tick intervals }
  185.             filler4:                    UInt8;                                { filler for proper byte alignment }
  186.            );
  187.         5: (
  188.             statusCCB:                    TPCCB;                                { pointer to ccb }
  189.             sendQPending:                UInt16;                                { pending bytes in send queue }
  190.             sendQFree:                    UInt16;                                { available buffer space in send queue }
  191.             recvQPending:                UInt16;                                { pending bytes in receive queue }
  192.             recvQFree:                    UInt16;                                { available buffer space in receive queue }
  193.            );
  194.         6: (
  195.             sendBlocking:                UInt16;                                { quantum for data packets }
  196.             sendTimer:                    UInt8;                                { send timer in 10-tick intervals }
  197.             rtmtTimer:                    UInt8;                                { retransmit timer in 10-tick intervals }
  198.             badSeqMax:                    UInt8;                                { threshold for sending retransmit advice }
  199.             useCheckSum:                UInt8;                                { use ddp packet checksum }
  200.            );
  201.         7: (
  202.             newcid:                        UInt16;                                { new connection id returned }
  203.            );
  204.     END;
  205. CONST
  206.     uppADSPConnectionEventProcInfo = $0000B802; { Register PROCEDURE (4 bytes in A1); }
  207.     uppADSPCompletionProcInfo = $00009802; { Register PROCEDURE (4 bytes in A0); }
  208.  
  209. FUNCTION NewADSPConnectionEventProc(userRoutine: ADSPConnectionEventProcPtr): ADSPConnectionEventUPP;
  210.     {$IFC NOT GENERATINGCFM }
  211.     INLINE $2E9F;
  212.     {$ENDC}
  213.  
  214. FUNCTION NewADSPCompletionProc(userRoutine: ADSPCompletionProcPtr): ADSPCompletionUPP;
  215.     {$IFC NOT GENERATINGCFM }
  216.     INLINE $2E9F;
  217.     {$ENDC}
  218.  
  219. PROCEDURE CallADSPConnectionEventProc(sourceCCB: TPCCB; userRoutine: ADSPConnectionEventUPP);
  220.     {$IFC NOT GENERATINGCFM}
  221.     {To be implemented:  Glue to move parameters into registers.}
  222.     {$ENDC}
  223.  
  224. PROCEDURE CallADSPCompletionProc(thePBPtr: DSPPBPtr; userRoutine: ADSPCompletionUPP);
  225.     {$IFC NOT GENERATINGCFM}
  226.     {To be implemented:  Glue to move parameters into registers.}
  227.     {$ENDC}
  228.  
  229. {$ALIGN RESET}
  230. {$POP}
  231.  
  232. {$SETC UsingIncludes := ADSPIncludes}
  233.  
  234. {$ENDC} {__ADSP__}
  235.  
  236. {$IFC NOT UsingIncludes}
  237.  END.
  238. {$ENDC}
  239.