]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
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. | |
1c79356b | 11 | * |
de355530 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | #ifndef _NETAT_ADSP_INTERNAL_H_ | |
23 | #define _NETAT_ADSP_INTERNAL_H_ | |
9bccf70c A |
24 | #include <sys/appleapiopts.h> |
25 | ||
26 | #include <sys/types.h> | |
1c79356b A |
27 | |
28 | #ifdef KERNEL | |
9bccf70c | 29 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
30 | |
31 | /* from h/adsp_portab.h */ | |
32 | ||
33 | /* TypeDefs for the basic data bytes. */ | |
34 | ||
35 | typedef unsigned char byte, *bytePtr; | |
36 | ||
37 | #ifdef NOT_USED | |
38 | typedef char int8; | |
39 | typedef short int16; | |
40 | typedef int int32; | |
41 | #endif | |
42 | ||
43 | typedef unsigned char boolean; | |
44 | ||
45 | typedef unsigned short word; | |
46 | ||
47 | typedef unsigned int dword; | |
48 | ||
49 | #define BYTE_AT(x) (*((byte PTR)(x))) | |
50 | #define WORD_AT(x) (*((word PTR)(x))) | |
51 | #define DWORD_AT(x) (*((dword PTR)(x))) | |
52 | ||
53 | #define high(x) ((byte)((x) >> 8)) | |
54 | #define low(x) ((byte)(x)) | |
55 | #define hlword(h, l) (((byte)(l)) | (((byte)(h)) << 8)) | |
56 | ||
1c79356b A |
57 | |
58 | /* | |
59 | * On a Mac, there is no need to byte-swap data on the network, so | |
60 | * these macros do nothing | |
61 | */ | |
62 | ||
63 | #define netw(x) x | |
64 | #define netdw(x) x | |
65 | ||
66 | typedef struct | |
67 | { | |
68 | at_net network; /* network number */ | |
69 | byte nodeid; /* node number */ | |
70 | byte socket; /* socket number */ | |
71 | } AddrBlk, *AddrBlkPtr; | |
72 | ||
73 | typedef union | |
74 | { | |
75 | at_inet_t a; | |
76 | } AddrUnion, *AddrUnionPtr; | |
77 | ||
78 | /* End Portab.h */ | |
79 | ||
80 | /* from h/adsp_internal.h */ | |
81 | ||
82 | #undef T_IDLE | |
83 | ||
84 | /* | |
85 | * Default Behavior for ADSP | |
86 | */ | |
87 | #define ocIntervalDefault 6 | |
88 | #define ocMaximumDefault 10 | |
89 | #define probeIntervalDefault 180 | |
90 | ||
91 | /* | |
92 | * MACROS for comparing 32-bit sequence numbers | |
93 | */ | |
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)) | |
99 | ||
100 | /* | |
101 | * Use the kernel tick counter for SysTicks. | |
102 | */ | |
103 | ||
104 | #define SysTicks() lbolt | |
105 | ||
106 | /* | |
107 | * Timer element used for handling timings | |
108 | */ | |
109 | typedef struct timerelem { | |
110 | struct timerelem *link; | |
111 | short timer; | |
112 | char type; | |
113 | unsigned onQ:1; /* Bit-fields are faster than booleans */ | |
114 | } TimerElem; | |
115 | ||
116 | typedef TimerElem *TimerElemPtr; | |
117 | ||
118 | /* | |
119 | * For AppleTalk Phase 2 event queue | |
120 | */ | |
121 | typedef struct { | |
122 | Ptr qLink; | |
123 | unsigned short qType; | |
124 | ProcPtr callAddr; | |
125 | } LAPEventElem; | |
126 | ||
127 | typedef LAPEventElem *LAPEventElemPtr; | |
128 | ||
129 | /* | |
130 | * The Event types we're passed when an AppleTalk transition occurs | |
131 | */ | |
132 | #define AOpenTransition 0 | |
133 | #define ACloseTransition 2 | |
134 | #define ANetworkTransition 5 | |
135 | ||
136 | /* | |
137 | * The element we're passed when a NetworkTransaction event occurs | |
138 | */ | |
139 | typedef struct TNetworkTransition { | |
140 | Ptr private; /* pointer used internally by NetShare */ | |
141 | ProcPtr netValidProc; /* pointer to the network valid procedure */ | |
142 | } TNetworkTransition, *TPNetworkTransition; | |
143 | ||
144 | typedef long (*NetworkTransitionProcPtr)(); | |
145 | /* (TPNetworkTransition nettrans, | |
146 | unsigned long thenet); */ | |
147 | /* | |
148 | * This is the connection control block | |
149 | */ | |
150 | typedef struct ccb { | |
151 | /*---These fields may not change order or size-----------*/ | |
152 | ||
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 | /*------------------------------------------------------ */ | |
163 | ||
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 */ | |
169 | ||
170 | struct ccb *otccbLink; /* link to next ccb */ | |
171 | int pid; /* Process ID for CCB owner */ | |
172 | ||
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 */ | |
183 | ||
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 */ | |
190 | ||
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) */ | |
195 | ||
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 */ | |
201 | char pad; | |
202 | char lockFlag; | |
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) */ | |
207 | ||
208 | gbuf_t *rbuf_mb; /* message block for the recv buffer */ | |
209 | gbuf_t *crbuf_mb; | |
210 | gbuf_t *sbuf_mb; /* message block for the send buffer */ | |
211 | gbuf_t *csbuf_mb; | |
212 | gbuf_t *attn_mb; /* message block for the attention buffer */ | |
213 | gbuf_t *deferred_mb; /* message block deferred for later processing */ | |
214 | ||
215 | #ifdef NOT_USED | |
216 | char ioDone; /* flag for when the adsp header is busy */ | |
217 | #endif | |
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 */ | |
221 | ||
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 */ | |
226 | ||
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 | |
238 | * an ack packet. */ | |
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 */ | |
248 | gbuf_t *sp_mp; | |
249 | atlock_t lock; | |
250 | atlock_t lockClose; | |
251 | atlock_t lockRemove; | |
252 | } CCB, *CCBPtr; | |
253 | ||
254 | ||
255 | /* | |
256 | * Change order and die !!! --- See the receive open packet code | |
257 | */ | |
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 | |
261 | * request */ | |
262 | #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */ | |
263 | #define O_STATE_OPEN 4 /* Connection is open */ | |
264 | ||
265 | /* | |
266 | * These bits are used in the sendCtl field to indicate what needs to be sent | |
267 | */ | |
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 | |
277 | ||
278 | ||
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) | |
284 | ||
285 | /* | |
286 | * Used to manage the send receive queue | |
287 | */ | |
288 | typedef struct { | |
289 | short len; /* # of bytes in this fragment */ | |
290 | char flags; /* See #define's below */ | |
291 | char data[1]; | |
292 | } HDR, *HDRPtr; | |
293 | ||
294 | #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */ | |
295 | ||
296 | #define F_GAP 0x03 | |
297 | #define F_EOM 0x04 | |
298 | #define F_WRAP 0x08 | |
299 | #define F_VALID 0x10 | |
300 | #define F_ENCRYPTED 0x20 /* %%% Needed ??? */ | |
301 | #define F_LAST 0x40 /* This is last block in buffer */ | |
302 | ||
303 | ||
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)]) | |
307 | ||
308 | /* End Internal.h */ | |
309 | ||
310 | /* fron h/adsp_supp.h */ | |
311 | ||
312 | void CallUserRoutine(); /* (CCB FPTR sp); */ | |
313 | ||
314 | ||
315 | /* | |
316 | * Add queue element to end of queue. Pass Address of ptr to | |
317 | * 1st element of queue | |
318 | */ | |
319 | int qAddToEnd(); /* (void FPTR FPTR qhead, void FPTR qelem); */ | |
320 | ||
321 | /* | |
322 | * Hunt down a linked list of queue elements looking for an element with | |
323 | * 'data' at 'offset' bytes into the queue element. | |
324 | */ | |
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); */ | |
331 | ||
332 | ||
333 | /* | |
334 | * Routines to handle sorted timer queues | |
335 | */ | |
336 | void InsertTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t, | |
337 | word val); */ | |
338 | void RemoveTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t); */ | |
339 | void TimerQueueTick(); /* (TimerElemPtr *qhead);*/ | |
340 | ||
341 | /* from h/adsp_global.h */ | |
342 | ||
343 | typedef struct { | |
344 | void *ccbList; /* Ptr to list of connection control blocks */ | |
345 | ||
346 | TimerElemPtr slowTimers; /* The probe timer list */ | |
347 | TimerElemPtr fastTimers; /* The fast timer list */ | |
348 | ||
349 | unsigned short lastCID; /* Last connection ID assigned */ | |
350 | char inTimer; /* We're inside timer routine */ | |
351 | } GLOBAL; | |
352 | ||
353 | extern GLOBAL adspGlobal; | |
354 | ||
355 | /* Address of ptr to list of ccb's */ | |
356 | #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList)) | |
357 | ||
9bccf70c | 358 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
359 | #endif /* KERNEL */ |
360 | ||
361 | #endif /* _NETAT_ADSP_INTERNAL_H_ */ |