]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
1c79356b | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
1c79356b A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | #ifndef _NETAT_ADSP_INTERNAL_H_ | |
24 | #define _NETAT_ADSP_INTERNAL_H_ | |
9bccf70c A |
25 | |
26 | #include <sys/types.h> | |
1c79356b | 27 | |
91447636 A |
28 | #ifdef __APPLE_API_OBSOLETE |
29 | #ifdef KERNEL_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 | ||
91447636 A |
144 | typedef long (*NetworkTransitionProcPtr)(TPNetworkTransition nettrans, |
145 | unsigned long thenet); | |
1c79356b A |
146 | /* |
147 | * This is the connection control block | |
148 | */ | |
149 | typedef struct ccb { | |
150 | /*---These fields may not change order or size-----------*/ | |
151 | ||
152 | struct ccb *ccbLink; /* link to next ccb */ | |
153 | unsigned short state; /* state of the connection end */ | |
154 | unsigned char userFlags; /* flags for unsolicited connection events */ | |
155 | unsigned char localSocket; /* socket number of this connection end */ | |
156 | AddrUnion remoteAddress; /* internet address of remote end */ | |
157 | unsigned short attnCode; /* attention code received */ | |
158 | unsigned short attnSize; /* size of received attention data */ | |
159 | unsigned char *attnPtr; /* ptr to received attention data */ | |
160 | unsigned short recvQPending; /* # bytes in receive queue %%% */ | |
161 | /*------------------------------------------------------ */ | |
162 | ||
163 | struct adspcmd *opb; /* Outstanding open/close/remove/listens */ | |
164 | struct adspcmd *spb; /* Outstanding Sends */ | |
165 | struct adspcmd *sapb; /* Outstanding Send Attentions */ | |
166 | struct adspcmd *frpb; /* Outstanding Forward Resets */ | |
167 | struct adspcmd *rpb; /* Outstanding Read Requests */ | |
168 | ||
169 | struct ccb *otccbLink; /* link to next ccb */ | |
170 | int pid; /* Process ID for CCB owner */ | |
171 | ||
172 | unsigned short remCID; /* Remote Connection ID */ | |
173 | unsigned short locCID; /* Local Connection ID */ | |
174 | int sendSeq; /* Seq number of next char to send to remote */ | |
175 | int firstRtmtSeq; /* oldest seq # in local send queue */ | |
176 | int sendWdwSeq; /* Seq # of last char remote has bfr for */ | |
177 | int recvSeq; /* Seq of # of next char expected from rmte */ | |
178 | int recvWdw; /* # of bytes local end has buffer space for */ | |
179 | int attnSendSeq; /* Seq # of next attn pkt to send to remote */ | |
180 | int attnRecvSeq; /* Seq # of next packet local end expects */ | |
181 | int maxSendSeq; /* Highest seq # we ever sent on connection */ | |
182 | ||
183 | /* These must be in the first 255 bytes of the CCB */ | |
184 | TimerElem ProbeTimer; /* Timer element for probes (and open) */ | |
185 | TimerElem FlushTimer; /* Timer element for flushing data */ | |
186 | TimerElem RetryTimer; /* Timer element for retransmissions */ | |
187 | TimerElem AttnTimer; /* Timer element for attention packets */ | |
188 | TimerElem ResetTimer; /* Timer element for forward resets */ | |
189 | ||
190 | short openInterval; /* Interval between open connection packets */ | |
191 | short probeInterval; /* Interval between probes */ | |
192 | short sendInterval; /* Interval before automatic flush */ | |
193 | short rtmtInterval; /* Rexmit interval (dynamically determined) */ | |
194 | ||
195 | short sendCtl; /* Send control message bits */ | |
196 | short sendBlocking; /* Flush unsent data if > than sendBlocking */ | |
197 | short openRetrys; /* # of retrys for Connect & Accept */ | |
198 | short rbuflen; /* Total size of receive buffer */ | |
199 | short sbuflen; /* Total size of receive buffer */ | |
200 | char pad; | |
201 | char lockFlag; | |
202 | char badSeqMax; /* retransmit advice send threshold */ | |
203 | char badSeqCnt; /* # of of out-of-order packets received */ | |
204 | char useCheckSum; /* true to use DDP checksums */ | |
205 | char openState; /* Used for opening a connection (see below) */ | |
206 | ||
207 | gbuf_t *rbuf_mb; /* message block for the recv buffer */ | |
208 | gbuf_t *crbuf_mb; | |
209 | gbuf_t *sbuf_mb; /* message block for the send buffer */ | |
210 | gbuf_t *csbuf_mb; | |
211 | gbuf_t *attn_mb; /* message block for the attention buffer */ | |
212 | gbuf_t *deferred_mb; /* message block deferred for later processing */ | |
213 | ||
214 | #ifdef NOT_USED | |
215 | char ioDone; /* flag for when the adsp header is busy */ | |
216 | #endif | |
217 | char probeCntr; /* # of probes we can miss (counts down) */ | |
218 | char pktSendMax; /* Max # of packets to send without an ack */ | |
219 | char pktSendCnt; /* # of packets sent so far */ | |
220 | ||
221 | int sendStamp; /* Time of last ackRequest */ | |
222 | int timerSeq; /* Seq # of char corresponding to above time stamp */ | |
223 | short roundTrip; /* Average Round-Trip time (in 6ths of a second) */ | |
224 | short deviation; /* deviation from roundTrip time */ | |
225 | ||
226 | unsigned sData:1; /* There's data in the send queue */ | |
227 | unsigned waitingAck:1; /* We're waiting for an ack packet */ | |
228 | unsigned rData:1; /* There's data in the receive queue */ | |
229 | unsigned resentData:1; /* True when we resend data due to timeout */ | |
230 | unsigned sendDataAck:1; /* True if he requested an ack */ | |
231 | unsigned sendAttnAck:1; /* Must send attn acknowlege */ | |
232 | unsigned sendAttnData:1; /* Must send attn data */ | |
233 | unsigned callSend:1; /* Must call CheckSend() */ | |
234 | unsigned rbufFull:1; /* We've closed our receive window. */ | |
235 | unsigned noXmitFlow:1; /* True stops incrementing # of xmit | |
236 | * packets to send in a row after receiving | |
237 | * an ack packet. */ | |
238 | unsigned secureCCB:1; /* True if this is a secure connection */ | |
239 | unsigned removing:1; /* There is a dspRemove pending */ | |
240 | unsigned writeFlush:1; /* Flush send queue even if # bytes to | |
241 | * send is less than send blocking. */ | |
242 | unsigned delay:1; /* do not complete commands until user | |
243 | * *** NO LONGER USED IN KERNEL *** */ | |
244 | ADSP_FRAME f; /* Used to send every packet */ | |
245 | ADSP_OPEN_DATA of; /* Holds the data for the open exchange */ | |
246 | gref_t *gref; /* The queue associated with the CCB */ | |
247 | gbuf_t *sp_mp; | |
248 | atlock_t lock; | |
249 | atlock_t lockClose; | |
250 | atlock_t lockRemove; | |
251 | } CCB, *CCBPtr; | |
252 | ||
253 | ||
254 | /* | |
255 | * Change order and die !!! --- See the receive open packet code | |
256 | */ | |
257 | #define O_STATE_NOTHING 0 /* Not opening */ | |
258 | #define O_STATE_LISTEN 1 /* Listening for open request */ | |
259 | #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open | |
260 | * request */ | |
261 | #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */ | |
262 | #define O_STATE_OPEN 4 /* Connection is open */ | |
263 | ||
264 | /* | |
265 | * These bits are used in the sendCtl field to indicate what needs to be sent | |
266 | */ | |
267 | #define B_CTL_PROBE 0x0001 | |
268 | #define B_CTL_OREQ 0x0002 | |
269 | #define B_CTL_OACK 0x0004 | |
270 | #define B_CTL_OREQACK 0x0008 | |
271 | #define B_CTL_ODENY 0x0010 | |
272 | #define B_CTL_CLOSE 0x0020 | |
273 | #define B_CTL_FRESET 0x0040 | |
274 | #define B_CTL_FRESETACK 0x0080 | |
275 | #define B_CTL_RETRANSMIT 0x0100 | |
276 | ||
277 | ||
278 | #define kProbeTimerType offsetof(CCB, ProbeTimer) | |
279 | #define kFlushTimerType offsetof(CCB, FlushTimer) | |
280 | #define kRetryTimerType offsetof(CCB, RetryTimer) | |
281 | #define kAttnTimerType offsetof(CCB, AttnTimer) | |
282 | #define kResetTimerType offsetof(CCB, ResetTimer) | |
283 | ||
284 | /* | |
285 | * Used to manage the send receive queue | |
286 | */ | |
287 | typedef struct { | |
288 | short len; /* # of bytes in this fragment */ | |
289 | char flags; /* See #define's below */ | |
290 | char data[1]; | |
291 | } HDR, *HDRPtr; | |
292 | ||
293 | #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */ | |
294 | ||
295 | #define F_GAP 0x03 | |
296 | #define F_EOM 0x04 | |
297 | #define F_WRAP 0x08 | |
298 | #define F_VALID 0x10 | |
299 | #define F_ENCRYPTED 0x20 /* %%% Needed ??? */ | |
300 | #define F_LAST 0x40 /* This is last block in buffer */ | |
301 | ||
302 | ||
303 | /* %%% Are these two used anymore? */ | |
304 | #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)]) | |
305 | #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)]) | |
306 | ||
307 | /* End Internal.h */ | |
308 | ||
309 | /* fron h/adsp_supp.h */ | |
310 | ||
91447636 | 311 | void CallUserRoutine(CCBPtr sp); /* (CCB FPTR sp); */ |
1c79356b A |
312 | |
313 | ||
314 | /* | |
315 | * Add queue element to end of queue. Pass Address of ptr to | |
316 | * 1st element of queue | |
91447636 | 317 | int qAddToEnd(struct qlink **qhead, struct qlink *qelem); |
1c79356b | 318 | */ |
91447636 | 319 | /* (void FPTR FPTR qhead, void FPTR qelem); */ |
1c79356b A |
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 | */ | |
91447636 A |
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(CCBPtr qhead, void *match, ProcPtr compare_fnx); | |
1c79356b A |
330 | |
331 | ||
332 | /* | |
333 | * Routines to handle sorted timer queues | |
334 | */ | |
91447636 A |
335 | void InsertTimerElem(TimerElemPtr *qhead, TimerElemPtr t, int val); |
336 | void RemoveTimerElem(TimerElemPtr *qhead, TimerElemPtr t); | |
337 | void TimerQueueTick(TimerElemPtr *qhead); | |
1c79356b A |
338 | |
339 | /* from h/adsp_global.h */ | |
340 | ||
341 | typedef struct { | |
342 | void *ccbList; /* Ptr to list of connection control blocks */ | |
343 | ||
344 | TimerElemPtr slowTimers; /* The probe timer list */ | |
345 | TimerElemPtr fastTimers; /* The fast timer list */ | |
346 | ||
347 | unsigned short lastCID; /* Last connection ID assigned */ | |
348 | char inTimer; /* We're inside timer routine */ | |
349 | } GLOBAL; | |
350 | ||
351 | extern GLOBAL adspGlobal; | |
352 | ||
353 | /* Address of ptr to list of ccb's */ | |
354 | #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList)) | |
355 | ||
91447636 A |
356 | #endif /* KERNEL_PRIVATE */ |
357 | #endif /* __APPLE_API_OBSOLETE */ | |
1c79356b A |
358 | |
359 | #endif /* _NETAT_ADSP_INTERNAL_H_ */ |