]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_internal.h
9b7c4e83cc3e4d4ff67ec11761bbb997ecf489ba
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_
27 /* from h/adsp_portab.h */
29 /* TypeDefs for the basic data bytes. */
31 typedef unsigned char byte
, *bytePtr
;
39 typedef unsigned char boolean
;
41 typedef unsigned short word
;
43 typedef unsigned int dword
;
45 #define BYTE_AT(x) (*((byte PTR)(x)))
46 #define WORD_AT(x) (*((word PTR)(x)))
47 #define DWORD_AT(x) (*((dword PTR)(x)))
49 #define high(x) ((byte)((x) >> 8))
50 #define low(x) ((byte)(x))
51 #define hlword(h, l) (((byte)(l)) | (((byte)(h)) << 8))
53 #define offsetof(typ,id) (size_t)&(((typ*)0)->id)
56 * On a Mac, there is no need to byte-swap data on the network, so
57 * these macros do nothing
65 at_net network
; /* network number */
66 byte nodeid
; /* node number */
67 byte socket
; /* socket number */
68 } AddrBlk
, *AddrBlkPtr
;
73 } AddrUnion
, *AddrUnionPtr
;
77 /* from h/adsp_internal.h */
82 * Default Behavior for ADSP
84 #define ocIntervalDefault 6
85 #define ocMaximumDefault 10
86 #define probeIntervalDefault 180
89 * MACROS for comparing 32-bit sequence numbers
91 #define GT(x,y) (((long)(x-y)) > (long) 0)
92 #define LT(x,y) (((long)(x-y)) < (long) 0)
93 #define GTE(x,y) (((long)(x-y)) >= (long) 0)
94 #define LTE(x,y) (((long)(x-y)) <= (long) 0)
95 #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z))
98 * Use the kernel tick counter for SysTicks.
101 #define SysTicks() lbolt
104 * Timer element used for handling timings
106 typedef struct timerelem
{
107 struct timerelem
*link
;
110 unsigned onQ
:1; /* Bit-fields are faster than booleans */
113 typedef TimerElem
*TimerElemPtr
;
116 * For AppleTalk Phase 2 event queue
120 unsigned short qType
;
124 typedef LAPEventElem
*LAPEventElemPtr
;
127 * The Event types we're passed when an AppleTalk transition occurs
129 #define AOpenTransition 0
130 #define ACloseTransition 2
131 #define ANetworkTransition 5
134 * The element we're passed when a NetworkTransaction event occurs
136 typedef struct TNetworkTransition
{
137 Ptr
private; /* pointer used internally by NetShare */
138 ProcPtr netValidProc
; /* pointer to the network valid procedure */
139 } TNetworkTransition
, *TPNetworkTransition
;
141 typedef long (*NetworkTransitionProcPtr
)();
142 /* (TPNetworkTransition nettrans,
143 unsigned long thenet); */
145 * This is the connection control block
148 /*---These fields may not change order or size-----------*/
150 struct ccb
*ccbLink
; /* link to next ccb */
151 unsigned short state
; /* state of the connection end */
152 unsigned char userFlags
; /* flags for unsolicited connection events */
153 unsigned char localSocket
; /* socket number of this connection end */
154 AddrUnion remoteAddress
; /* internet address of remote end */
155 unsigned short attnCode
; /* attention code received */
156 unsigned short attnSize
; /* size of received attention data */
157 unsigned char *attnPtr
; /* ptr to received attention data */
158 unsigned short recvQPending
; /* # bytes in receive queue %%% */
159 /*------------------------------------------------------ */
161 struct adspcmd
*opb
; /* Outstanding open/close/remove/listens */
162 struct adspcmd
*spb
; /* Outstanding Sends */
163 struct adspcmd
*sapb
; /* Outstanding Send Attentions */
164 struct adspcmd
*frpb
; /* Outstanding Forward Resets */
165 struct adspcmd
*rpb
; /* Outstanding Read Requests */
167 struct ccb
*otccbLink
; /* link to next ccb */
168 int pid
; /* Process ID for CCB owner */
170 unsigned short remCID
; /* Remote Connection ID */
171 unsigned short locCID
; /* Local Connection ID */
172 int sendSeq
; /* Seq number of next char to send to remote */
173 int firstRtmtSeq
; /* oldest seq # in local send queue */
174 int sendWdwSeq
; /* Seq # of last char remote has bfr for */
175 int recvSeq
; /* Seq of # of next char expected from rmte */
176 int recvWdw
; /* # of bytes local end has buffer space for */
177 int attnSendSeq
; /* Seq # of next attn pkt to send to remote */
178 int attnRecvSeq
; /* Seq # of next packet local end expects */
179 int maxSendSeq
; /* Highest seq # we ever sent on connection */
181 /* These must be in the first 255 bytes of the CCB */
182 TimerElem ProbeTimer
; /* Timer element for probes (and open) */
183 TimerElem FlushTimer
; /* Timer element for flushing data */
184 TimerElem RetryTimer
; /* Timer element for retransmissions */
185 TimerElem AttnTimer
; /* Timer element for attention packets */
186 TimerElem ResetTimer
; /* Timer element for forward resets */
188 short openInterval
; /* Interval between open connection packets */
189 short probeInterval
; /* Interval between probes */
190 short sendInterval
; /* Interval before automatic flush */
191 short rtmtInterval
; /* Rexmit interval (dynamically determined) */
193 short sendCtl
; /* Send control message bits */
194 short sendBlocking
; /* Flush unsent data if > than sendBlocking */
195 short openRetrys
; /* # of retrys for Connect & Accept */
196 short rbuflen
; /* Total size of receive buffer */
197 short sbuflen
; /* Total size of receive buffer */
200 char badSeqMax
; /* retransmit advice send threshold */
201 char badSeqCnt
; /* # of of out-of-order packets received */
202 char useCheckSum
; /* true to use DDP checksums */
203 char openState
; /* Used for opening a connection (see below) */
205 gbuf_t
*rbuf_mb
; /* message block for the recv buffer */
207 gbuf_t
*sbuf_mb
; /* message block for the send buffer */
209 gbuf_t
*attn_mb
; /* message block for the attention buffer */
210 gbuf_t
*deferred_mb
; /* message block deferred for later processing */
213 char ioDone
; /* flag for when the adsp header is busy */
215 char probeCntr
; /* # of probes we can miss (counts down) */
216 char pktSendMax
; /* Max # of packets to send without an ack */
217 char pktSendCnt
; /* # of packets sent so far */
219 int sendStamp
; /* Time of last ackRequest */
220 int timerSeq
; /* Seq # of char corresponding to above time stamp */
221 short roundTrip
; /* Average Round-Trip time (in 6ths of a second) */
222 short deviation
; /* deviation from roundTrip time */
224 unsigned sData
:1; /* There's data in the send queue */
225 unsigned waitingAck
:1; /* We're waiting for an ack packet */
226 unsigned rData
:1; /* There's data in the receive queue */
227 unsigned resentData
:1; /* True when we resend data due to timeout */
228 unsigned sendDataAck
:1; /* True if he requested an ack */
229 unsigned sendAttnAck
:1; /* Must send attn acknowlege */
230 unsigned sendAttnData
:1; /* Must send attn data */
231 unsigned callSend
:1; /* Must call CheckSend() */
232 unsigned rbufFull
:1; /* We've closed our receive window. */
233 unsigned noXmitFlow
:1; /* True stops incrementing # of xmit
234 * packets to send in a row after receiving
236 unsigned secureCCB
:1; /* True if this is a secure connection */
237 unsigned removing
:1; /* There is a dspRemove pending */
238 unsigned writeFlush
:1; /* Flush send queue even if # bytes to
239 * send is less than send blocking. */
240 unsigned delay
:1; /* do not complete commands until user
241 * *** NO LONGER USED IN KERNEL *** */
242 ADSP_FRAME f
; /* Used to send every packet */
243 ADSP_OPEN_DATA of
; /* Holds the data for the open exchange */
244 gref_t
*gref
; /* The queue associated with the CCB */
253 * Change order and die !!! --- See the receive open packet code
255 #define O_STATE_NOTHING 0 /* Not opening */
256 #define O_STATE_LISTEN 1 /* Listening for open request */
257 #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open
259 #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */
260 #define O_STATE_OPEN 4 /* Connection is open */
263 * These bits are used in the sendCtl field to indicate what needs to be sent
265 #define B_CTL_PROBE 0x0001
266 #define B_CTL_OREQ 0x0002
267 #define B_CTL_OACK 0x0004
268 #define B_CTL_OREQACK 0x0008
269 #define B_CTL_ODENY 0x0010
270 #define B_CTL_CLOSE 0x0020
271 #define B_CTL_FRESET 0x0040
272 #define B_CTL_FRESETACK 0x0080
273 #define B_CTL_RETRANSMIT 0x0100
276 #define kProbeTimerType offsetof(CCB, ProbeTimer)
277 #define kFlushTimerType offsetof(CCB, FlushTimer)
278 #define kRetryTimerType offsetof(CCB, RetryTimer)
279 #define kAttnTimerType offsetof(CCB, AttnTimer)
280 #define kResetTimerType offsetof(CCB, ResetTimer)
283 * Used to manage the send receive queue
286 short len
; /* # of bytes in this fragment */
287 char flags
; /* See #define's below */
291 #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */
297 #define F_ENCRYPTED 0x20 /* %%% Needed ??? */
298 #define F_LAST 0x40 /* This is last block in buffer */
301 /* %%% Are these two used anymore? */
302 #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)])
303 #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)])
307 /* fron h/adsp_supp.h */
309 void CallUserRoutine(); /* (CCB FPTR sp); */
313 * Add queue element to end of queue. Pass Address of ptr to
314 * 1st element of queue
316 int qAddToEnd(); /* (void FPTR FPTR qhead, void FPTR qelem); */
319 * Hunt down a linked list of queue elements looking for an element with
320 * 'data' at 'offset' bytes into the queue element.
322 void *qfind_b(); /* (void *qhead, word offset, word data); */
323 void *qfind_w(); /* (void *qhead, word offset, word data); */
324 void *qfind_p(); /* (void *qhead, word offset, void *ptr); */
325 void *qfind_o(); /* (void *qhead, word offset, void *ptr); */
326 void *qfind_m(); /* (void *qhead, void *match,
327 ProcPtr compare_fnx); */
331 * Routines to handle sorted timer queues
333 void InsertTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t,
335 void RemoveTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t); */
336 void TimerQueueTick(); /* (TimerElemPtr *qhead);*/
338 /* from h/adsp_global.h */
341 void *ccbList
; /* Ptr to list of connection control blocks */
343 TimerElemPtr slowTimers
; /* The probe timer list */
344 TimerElemPtr fastTimers
; /* The fast timer list */
346 unsigned short lastCID
; /* Last connection ID assigned */
347 char inTimer
; /* We're inside timer routine */
350 extern GLOBAL adspGlobal
;
352 /* Address of ptr to list of ccb's */
353 #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList))
357 #endif /* _NETAT_ADSP_INTERNAL_H_ */