]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_internal.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef _NETAT_ADSP_INTERNAL_H_
23 #define _NETAT_ADSP_INTERNAL_H_
24 #include <sys/appleapiopts.h>
26 #include <sys/types.h>
29 #ifdef __APPLE_API_PRIVATE
31 /* from h/adsp_portab.h */
33 /* TypeDefs for the basic data bytes. */
35 typedef unsigned char byte
, *bytePtr
;
43 typedef unsigned char boolean
;
45 typedef unsigned short word
;
47 typedef unsigned int dword
;
49 #define BYTE_AT(x) (*((byte PTR)(x)))
50 #define WORD_AT(x) (*((word PTR)(x)))
51 #define DWORD_AT(x) (*((dword PTR)(x)))
53 #define high(x) ((byte)((x) >> 8))
54 #define low(x) ((byte)(x))
55 #define hlword(h, l) (((byte)(l)) | (((byte)(h)) << 8))
59 * On a Mac, there is no need to byte-swap data on the network, so
60 * these macros do nothing
68 at_net network
; /* network number */
69 byte nodeid
; /* node number */
70 byte socket
; /* socket number */
71 } AddrBlk
, *AddrBlkPtr
;
76 } AddrUnion
, *AddrUnionPtr
;
80 /* from h/adsp_internal.h */
85 * Default Behavior for ADSP
87 #define ocIntervalDefault 6
88 #define ocMaximumDefault 10
89 #define probeIntervalDefault 180
92 * MACROS for comparing 32-bit sequence numbers
94 #define GT(x,y) (((long)(x-y)) > (long) 0)
95 #define LT(x,y) (((long)(x-y)) < (long) 0)
96 #define GTE(x,y) (((long)(x-y)) >= (long) 0)
97 #define LTE(x,y) (((long)(x-y)) <= (long) 0)
98 #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z))
101 * Use the kernel tick counter for SysTicks.
104 #define SysTicks() lbolt
107 * Timer element used for handling timings
109 typedef struct timerelem
{
110 struct timerelem
*link
;
113 unsigned onQ
:1; /* Bit-fields are faster than booleans */
116 typedef TimerElem
*TimerElemPtr
;
119 * For AppleTalk Phase 2 event queue
123 unsigned short qType
;
127 typedef LAPEventElem
*LAPEventElemPtr
;
130 * The Event types we're passed when an AppleTalk transition occurs
132 #define AOpenTransition 0
133 #define ACloseTransition 2
134 #define ANetworkTransition 5
137 * The element we're passed when a NetworkTransaction event occurs
139 typedef struct TNetworkTransition
{
140 Ptr
private; /* pointer used internally by NetShare */
141 ProcPtr netValidProc
; /* pointer to the network valid procedure */
142 } TNetworkTransition
, *TPNetworkTransition
;
144 typedef long (*NetworkTransitionProcPtr
)();
145 /* (TPNetworkTransition nettrans,
146 unsigned long thenet); */
148 * This is the connection control block
151 /*---These fields may not change order or size-----------*/
153 struct ccb
*ccbLink
; /* link to next ccb */
154 unsigned short state
; /* state of the connection end */
155 unsigned char userFlags
; /* flags for unsolicited connection events */
156 unsigned char localSocket
; /* socket number of this connection end */
157 AddrUnion remoteAddress
; /* internet address of remote end */
158 unsigned short attnCode
; /* attention code received */
159 unsigned short attnSize
; /* size of received attention data */
160 unsigned char *attnPtr
; /* ptr to received attention data */
161 unsigned short recvQPending
; /* # bytes in receive queue %%% */
162 /*------------------------------------------------------ */
164 struct adspcmd
*opb
; /* Outstanding open/close/remove/listens */
165 struct adspcmd
*spb
; /* Outstanding Sends */
166 struct adspcmd
*sapb
; /* Outstanding Send Attentions */
167 struct adspcmd
*frpb
; /* Outstanding Forward Resets */
168 struct adspcmd
*rpb
; /* Outstanding Read Requests */
170 struct ccb
*otccbLink
; /* link to next ccb */
171 int pid
; /* Process ID for CCB owner */
173 unsigned short remCID
; /* Remote Connection ID */
174 unsigned short locCID
; /* Local Connection ID */
175 int sendSeq
; /* Seq number of next char to send to remote */
176 int firstRtmtSeq
; /* oldest seq # in local send queue */
177 int sendWdwSeq
; /* Seq # of last char remote has bfr for */
178 int recvSeq
; /* Seq of # of next char expected from rmte */
179 int recvWdw
; /* # of bytes local end has buffer space for */
180 int attnSendSeq
; /* Seq # of next attn pkt to send to remote */
181 int attnRecvSeq
; /* Seq # of next packet local end expects */
182 int maxSendSeq
; /* Highest seq # we ever sent on connection */
184 /* These must be in the first 255 bytes of the CCB */
185 TimerElem ProbeTimer
; /* Timer element for probes (and open) */
186 TimerElem FlushTimer
; /* Timer element for flushing data */
187 TimerElem RetryTimer
; /* Timer element for retransmissions */
188 TimerElem AttnTimer
; /* Timer element for attention packets */
189 TimerElem ResetTimer
; /* Timer element for forward resets */
191 short openInterval
; /* Interval between open connection packets */
192 short probeInterval
; /* Interval between probes */
193 short sendInterval
; /* Interval before automatic flush */
194 short rtmtInterval
; /* Rexmit interval (dynamically determined) */
196 short sendCtl
; /* Send control message bits */
197 short sendBlocking
; /* Flush unsent data if > than sendBlocking */
198 short openRetrys
; /* # of retrys for Connect & Accept */
199 short rbuflen
; /* Total size of receive buffer */
200 short sbuflen
; /* Total size of receive buffer */
203 char badSeqMax
; /* retransmit advice send threshold */
204 char badSeqCnt
; /* # of of out-of-order packets received */
205 char useCheckSum
; /* true to use DDP checksums */
206 char openState
; /* Used for opening a connection (see below) */
208 gbuf_t
*rbuf_mb
; /* message block for the recv buffer */
210 gbuf_t
*sbuf_mb
; /* message block for the send buffer */
212 gbuf_t
*attn_mb
; /* message block for the attention buffer */
213 gbuf_t
*deferred_mb
; /* message block deferred for later processing */
216 char ioDone
; /* flag for when the adsp header is busy */
218 char probeCntr
; /* # of probes we can miss (counts down) */
219 char pktSendMax
; /* Max # of packets to send without an ack */
220 char pktSendCnt
; /* # of packets sent so far */
222 int sendStamp
; /* Time of last ackRequest */
223 int timerSeq
; /* Seq # of char corresponding to above time stamp */
224 short roundTrip
; /* Average Round-Trip time (in 6ths of a second) */
225 short deviation
; /* deviation from roundTrip time */
227 unsigned sData
:1; /* There's data in the send queue */
228 unsigned waitingAck
:1; /* We're waiting for an ack packet */
229 unsigned rData
:1; /* There's data in the receive queue */
230 unsigned resentData
:1; /* True when we resend data due to timeout */
231 unsigned sendDataAck
:1; /* True if he requested an ack */
232 unsigned sendAttnAck
:1; /* Must send attn acknowlege */
233 unsigned sendAttnData
:1; /* Must send attn data */
234 unsigned callSend
:1; /* Must call CheckSend() */
235 unsigned rbufFull
:1; /* We've closed our receive window. */
236 unsigned noXmitFlow
:1; /* True stops incrementing # of xmit
237 * packets to send in a row after receiving
239 unsigned secureCCB
:1; /* True if this is a secure connection */
240 unsigned removing
:1; /* There is a dspRemove pending */
241 unsigned writeFlush
:1; /* Flush send queue even if # bytes to
242 * send is less than send blocking. */
243 unsigned delay
:1; /* do not complete commands until user
244 * *** NO LONGER USED IN KERNEL *** */
245 ADSP_FRAME f
; /* Used to send every packet */
246 ADSP_OPEN_DATA of
; /* Holds the data for the open exchange */
247 gref_t
*gref
; /* The queue associated with the CCB */
256 * Change order and die !!! --- See the receive open packet code
258 #define O_STATE_NOTHING 0 /* Not opening */
259 #define O_STATE_LISTEN 1 /* Listening for open request */
260 #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open
262 #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */
263 #define O_STATE_OPEN 4 /* Connection is open */
266 * These bits are used in the sendCtl field to indicate what needs to be sent
268 #define B_CTL_PROBE 0x0001
269 #define B_CTL_OREQ 0x0002
270 #define B_CTL_OACK 0x0004
271 #define B_CTL_OREQACK 0x0008
272 #define B_CTL_ODENY 0x0010
273 #define B_CTL_CLOSE 0x0020
274 #define B_CTL_FRESET 0x0040
275 #define B_CTL_FRESETACK 0x0080
276 #define B_CTL_RETRANSMIT 0x0100
279 #define kProbeTimerType offsetof(CCB, ProbeTimer)
280 #define kFlushTimerType offsetof(CCB, FlushTimer)
281 #define kRetryTimerType offsetof(CCB, RetryTimer)
282 #define kAttnTimerType offsetof(CCB, AttnTimer)
283 #define kResetTimerType offsetof(CCB, ResetTimer)
286 * Used to manage the send receive queue
289 short len
; /* # of bytes in this fragment */
290 char flags
; /* See #define's below */
294 #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */
300 #define F_ENCRYPTED 0x20 /* %%% Needed ??? */
301 #define F_LAST 0x40 /* This is last block in buffer */
304 /* %%% Are these two used anymore? */
305 #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)])
306 #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)])
310 /* fron h/adsp_supp.h */
312 void CallUserRoutine(); /* (CCB FPTR sp); */
316 * Add queue element to end of queue. Pass Address of ptr to
317 * 1st element of queue
319 int qAddToEnd(); /* (void FPTR FPTR qhead, void FPTR qelem); */
322 * Hunt down a linked list of queue elements looking for an element with
323 * 'data' at 'offset' bytes into the queue element.
325 void *qfind_b(); /* (void *qhead, word offset, word data); */
326 void *qfind_w(); /* (void *qhead, word offset, word data); */
327 void *qfind_p(); /* (void *qhead, word offset, void *ptr); */
328 void *qfind_o(); /* (void *qhead, word offset, void *ptr); */
329 void *qfind_m(); /* (void *qhead, void *match,
330 ProcPtr compare_fnx); */
334 * Routines to handle sorted timer queues
336 void InsertTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t,
338 void RemoveTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t); */
339 void TimerQueueTick(); /* (TimerElemPtr *qhead);*/
341 /* from h/adsp_global.h */
344 void *ccbList
; /* Ptr to list of connection control blocks */
346 TimerElemPtr slowTimers
; /* The probe timer list */
347 TimerElemPtr fastTimers
; /* The fast timer list */
349 unsigned short lastCID
; /* Last connection ID assigned */
350 char inTimer
; /* We're inside timer routine */
353 extern GLOBAL adspGlobal
;
355 /* Address of ptr to list of ccb's */
356 #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList))
358 #endif /* __APPLE_API_PRIVATE */
361 #endif /* _NETAT_ADSP_INTERNAL_H_ */