]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 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. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | #ifndef _NETAT_ADSP_INTERNAL_H_ | |
29 | #define _NETAT_ADSP_INTERNAL_H_ | |
9bccf70c A |
30 | |
31 | #include <sys/types.h> | |
1c79356b | 32 | |
91447636 A |
33 | #ifdef __APPLE_API_OBSOLETE |
34 | #ifdef KERNEL_PRIVATE | |
1c79356b A |
35 | |
36 | /* from h/adsp_portab.h */ | |
37 | ||
38 | /* TypeDefs for the basic data bytes. */ | |
39 | ||
40 | typedef unsigned char byte, *bytePtr; | |
41 | ||
42 | #ifdef NOT_USED | |
43 | typedef char int8; | |
44 | typedef short int16; | |
45 | typedef int int32; | |
46 | #endif | |
47 | ||
48 | typedef unsigned char boolean; | |
49 | ||
50 | typedef unsigned short word; | |
51 | ||
52 | typedef unsigned int dword; | |
53 | ||
54 | #define BYTE_AT(x) (*((byte PTR)(x))) | |
55 | #define WORD_AT(x) (*((word PTR)(x))) | |
56 | #define DWORD_AT(x) (*((dword PTR)(x))) | |
57 | ||
58 | #define high(x) ((byte)((x) >> 8)) | |
59 | #define low(x) ((byte)(x)) | |
60 | #define hlword(h, l) (((byte)(l)) | (((byte)(h)) << 8)) | |
61 | ||
1c79356b A |
62 | |
63 | /* | |
64 | * On a Mac, there is no need to byte-swap data on the network, so | |
65 | * these macros do nothing | |
66 | */ | |
67 | ||
68 | #define netw(x) x | |
69 | #define netdw(x) x | |
70 | ||
71 | typedef struct | |
72 | { | |
73 | at_net network; /* network number */ | |
74 | byte nodeid; /* node number */ | |
75 | byte socket; /* socket number */ | |
76 | } AddrBlk, *AddrBlkPtr; | |
77 | ||
78 | typedef union | |
79 | { | |
80 | at_inet_t a; | |
81 | } AddrUnion, *AddrUnionPtr; | |
82 | ||
83 | /* End Portab.h */ | |
84 | ||
85 | /* from h/adsp_internal.h */ | |
86 | ||
87 | #undef T_IDLE | |
88 | ||
89 | /* | |
90 | * Default Behavior for ADSP | |
91 | */ | |
92 | #define ocIntervalDefault 6 | |
93 | #define ocMaximumDefault 10 | |
94 | #define probeIntervalDefault 180 | |
95 | ||
96 | /* | |
97 | * MACROS for comparing 32-bit sequence numbers | |
98 | */ | |
99 | #define GT(x,y) (((long)(x-y)) > (long) 0) | |
100 | #define LT(x,y) (((long)(x-y)) < (long) 0) | |
101 | #define GTE(x,y) (((long)(x-y)) >= (long) 0) | |
102 | #define LTE(x,y) (((long)(x-y)) <= (long) 0) | |
103 | #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z)) | |
104 | ||
105 | /* | |
106 | * Use the kernel tick counter for SysTicks. | |
107 | */ | |
108 | ||
109 | #define SysTicks() lbolt | |
110 | ||
111 | /* | |
112 | * Timer element used for handling timings | |
113 | */ | |
114 | typedef struct timerelem { | |
115 | struct timerelem *link; | |
116 | short timer; | |
117 | char type; | |
118 | unsigned onQ:1; /* Bit-fields are faster than booleans */ | |
119 | } TimerElem; | |
120 | ||
121 | typedef TimerElem *TimerElemPtr; | |
122 | ||
123 | /* | |
124 | * For AppleTalk Phase 2 event queue | |
125 | */ | |
126 | typedef struct { | |
127 | Ptr qLink; | |
128 | unsigned short qType; | |
129 | ProcPtr callAddr; | |
130 | } LAPEventElem; | |
131 | ||
132 | typedef LAPEventElem *LAPEventElemPtr; | |
133 | ||
134 | /* | |
135 | * The Event types we're passed when an AppleTalk transition occurs | |
136 | */ | |
137 | #define AOpenTransition 0 | |
138 | #define ACloseTransition 2 | |
139 | #define ANetworkTransition 5 | |
140 | ||
141 | /* | |
142 | * The element we're passed when a NetworkTransaction event occurs | |
143 | */ | |
144 | typedef struct TNetworkTransition { | |
145 | Ptr private; /* pointer used internally by NetShare */ | |
146 | ProcPtr netValidProc; /* pointer to the network valid procedure */ | |
147 | } TNetworkTransition, *TPNetworkTransition; | |
148 | ||
91447636 A |
149 | typedef long (*NetworkTransitionProcPtr)(TPNetworkTransition nettrans, |
150 | unsigned long thenet); | |
1c79356b A |
151 | /* |
152 | * This is the connection control block | |
153 | */ | |
154 | typedef struct ccb { | |
155 | /*---These fields may not change order or size-----------*/ | |
156 | ||
157 | struct ccb *ccbLink; /* link to next ccb */ | |
158 | unsigned short state; /* state of the connection end */ | |
159 | unsigned char userFlags; /* flags for unsolicited connection events */ | |
160 | unsigned char localSocket; /* socket number of this connection end */ | |
161 | AddrUnion remoteAddress; /* internet address of remote end */ | |
162 | unsigned short attnCode; /* attention code received */ | |
163 | unsigned short attnSize; /* size of received attention data */ | |
164 | unsigned char *attnPtr; /* ptr to received attention data */ | |
165 | unsigned short recvQPending; /* # bytes in receive queue %%% */ | |
166 | /*------------------------------------------------------ */ | |
167 | ||
168 | struct adspcmd *opb; /* Outstanding open/close/remove/listens */ | |
169 | struct adspcmd *spb; /* Outstanding Sends */ | |
170 | struct adspcmd *sapb; /* Outstanding Send Attentions */ | |
171 | struct adspcmd *frpb; /* Outstanding Forward Resets */ | |
172 | struct adspcmd *rpb; /* Outstanding Read Requests */ | |
173 | ||
174 | struct ccb *otccbLink; /* link to next ccb */ | |
175 | int pid; /* Process ID for CCB owner */ | |
176 | ||
177 | unsigned short remCID; /* Remote Connection ID */ | |
178 | unsigned short locCID; /* Local Connection ID */ | |
179 | int sendSeq; /* Seq number of next char to send to remote */ | |
180 | int firstRtmtSeq; /* oldest seq # in local send queue */ | |
181 | int sendWdwSeq; /* Seq # of last char remote has bfr for */ | |
182 | int recvSeq; /* Seq of # of next char expected from rmte */ | |
183 | int recvWdw; /* # of bytes local end has buffer space for */ | |
184 | int attnSendSeq; /* Seq # of next attn pkt to send to remote */ | |
185 | int attnRecvSeq; /* Seq # of next packet local end expects */ | |
186 | int maxSendSeq; /* Highest seq # we ever sent on connection */ | |
187 | ||
188 | /* These must be in the first 255 bytes of the CCB */ | |
189 | TimerElem ProbeTimer; /* Timer element for probes (and open) */ | |
190 | TimerElem FlushTimer; /* Timer element for flushing data */ | |
191 | TimerElem RetryTimer; /* Timer element for retransmissions */ | |
192 | TimerElem AttnTimer; /* Timer element for attention packets */ | |
193 | TimerElem ResetTimer; /* Timer element for forward resets */ | |
194 | ||
195 | short openInterval; /* Interval between open connection packets */ | |
196 | short probeInterval; /* Interval between probes */ | |
197 | short sendInterval; /* Interval before automatic flush */ | |
198 | short rtmtInterval; /* Rexmit interval (dynamically determined) */ | |
199 | ||
200 | short sendCtl; /* Send control message bits */ | |
201 | short sendBlocking; /* Flush unsent data if > than sendBlocking */ | |
202 | short openRetrys; /* # of retrys for Connect & Accept */ | |
203 | short rbuflen; /* Total size of receive buffer */ | |
204 | short sbuflen; /* Total size of receive buffer */ | |
205 | char pad; | |
206 | char lockFlag; | |
207 | char badSeqMax; /* retransmit advice send threshold */ | |
208 | char badSeqCnt; /* # of of out-of-order packets received */ | |
209 | char useCheckSum; /* true to use DDP checksums */ | |
210 | char openState; /* Used for opening a connection (see below) */ | |
211 | ||
212 | gbuf_t *rbuf_mb; /* message block for the recv buffer */ | |
213 | gbuf_t *crbuf_mb; | |
214 | gbuf_t *sbuf_mb; /* message block for the send buffer */ | |
215 | gbuf_t *csbuf_mb; | |
216 | gbuf_t *attn_mb; /* message block for the attention buffer */ | |
217 | gbuf_t *deferred_mb; /* message block deferred for later processing */ | |
218 | ||
219 | #ifdef NOT_USED | |
220 | char ioDone; /* flag for when the adsp header is busy */ | |
221 | #endif | |
222 | char probeCntr; /* # of probes we can miss (counts down) */ | |
223 | char pktSendMax; /* Max # of packets to send without an ack */ | |
224 | char pktSendCnt; /* # of packets sent so far */ | |
225 | ||
226 | int sendStamp; /* Time of last ackRequest */ | |
227 | int timerSeq; /* Seq # of char corresponding to above time stamp */ | |
228 | short roundTrip; /* Average Round-Trip time (in 6ths of a second) */ | |
229 | short deviation; /* deviation from roundTrip time */ | |
230 | ||
231 | unsigned sData:1; /* There's data in the send queue */ | |
232 | unsigned waitingAck:1; /* We're waiting for an ack packet */ | |
233 | unsigned rData:1; /* There's data in the receive queue */ | |
234 | unsigned resentData:1; /* True when we resend data due to timeout */ | |
235 | unsigned sendDataAck:1; /* True if he requested an ack */ | |
236 | unsigned sendAttnAck:1; /* Must send attn acknowlege */ | |
237 | unsigned sendAttnData:1; /* Must send attn data */ | |
238 | unsigned callSend:1; /* Must call CheckSend() */ | |
239 | unsigned rbufFull:1; /* We've closed our receive window. */ | |
240 | unsigned noXmitFlow:1; /* True stops incrementing # of xmit | |
241 | * packets to send in a row after receiving | |
242 | * an ack packet. */ | |
243 | unsigned secureCCB:1; /* True if this is a secure connection */ | |
244 | unsigned removing:1; /* There is a dspRemove pending */ | |
245 | unsigned writeFlush:1; /* Flush send queue even if # bytes to | |
246 | * send is less than send blocking. */ | |
247 | unsigned delay:1; /* do not complete commands until user | |
248 | * *** NO LONGER USED IN KERNEL *** */ | |
249 | ADSP_FRAME f; /* Used to send every packet */ | |
250 | ADSP_OPEN_DATA of; /* Holds the data for the open exchange */ | |
251 | gref_t *gref; /* The queue associated with the CCB */ | |
252 | gbuf_t *sp_mp; | |
1c79356b A |
253 | } CCB, *CCBPtr; |
254 | ||
255 | ||
256 | /* | |
257 | * Change order and die !!! --- See the receive open packet code | |
258 | */ | |
259 | #define O_STATE_NOTHING 0 /* Not opening */ | |
260 | #define O_STATE_LISTEN 1 /* Listening for open request */ | |
261 | #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open | |
262 | * request */ | |
263 | #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */ | |
264 | #define O_STATE_OPEN 4 /* Connection is open */ | |
265 | ||
266 | /* | |
267 | * These bits are used in the sendCtl field to indicate what needs to be sent | |
268 | */ | |
269 | #define B_CTL_PROBE 0x0001 | |
270 | #define B_CTL_OREQ 0x0002 | |
271 | #define B_CTL_OACK 0x0004 | |
272 | #define B_CTL_OREQACK 0x0008 | |
273 | #define B_CTL_ODENY 0x0010 | |
274 | #define B_CTL_CLOSE 0x0020 | |
275 | #define B_CTL_FRESET 0x0040 | |
276 | #define B_CTL_FRESETACK 0x0080 | |
277 | #define B_CTL_RETRANSMIT 0x0100 | |
278 | ||
279 | ||
280 | #define kProbeTimerType offsetof(CCB, ProbeTimer) | |
281 | #define kFlushTimerType offsetof(CCB, FlushTimer) | |
282 | #define kRetryTimerType offsetof(CCB, RetryTimer) | |
283 | #define kAttnTimerType offsetof(CCB, AttnTimer) | |
284 | #define kResetTimerType offsetof(CCB, ResetTimer) | |
285 | ||
286 | /* | |
287 | * Used to manage the send receive queue | |
288 | */ | |
289 | typedef struct { | |
290 | short len; /* # of bytes in this fragment */ | |
291 | char flags; /* See #define's below */ | |
292 | char data[1]; | |
293 | } HDR, *HDRPtr; | |
294 | ||
295 | #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */ | |
296 | ||
297 | #define F_GAP 0x03 | |
298 | #define F_EOM 0x04 | |
299 | #define F_WRAP 0x08 | |
300 | #define F_VALID 0x10 | |
301 | #define F_ENCRYPTED 0x20 /* %%% Needed ??? */ | |
302 | #define F_LAST 0x40 /* This is last block in buffer */ | |
303 | ||
304 | ||
305 | /* %%% Are these two used anymore? */ | |
306 | #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)]) | |
307 | #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)]) | |
308 | ||
309 | /* End Internal.h */ | |
310 | ||
311 | /* fron h/adsp_supp.h */ | |
312 | ||
91447636 | 313 | void CallUserRoutine(CCBPtr sp); /* (CCB FPTR sp); */ |
1c79356b A |
314 | |
315 | ||
316 | /* | |
317 | * Add queue element to end of queue. Pass Address of ptr to | |
318 | * 1st element of queue | |
91447636 | 319 | int qAddToEnd(struct qlink **qhead, struct qlink *qelem); |
1c79356b | 320 | */ |
91447636 | 321 | /* (void FPTR FPTR qhead, void FPTR qelem); */ |
1c79356b A |
322 | |
323 | /* | |
324 | * Hunt down a linked list of queue elements looking for an element with | |
325 | * 'data' at 'offset' bytes into the queue element. | |
326 | */ | |
91447636 A |
327 | void *qfind_b(void *qhead, word offset, word data); |
328 | void *qfind_w(void *qhead, word offset, word data); | |
329 | void *qfind_p(void *qhead, word offset, void *ptr); | |
330 | void *qfind_o(void *qhead, word offset, void *ptr); | |
331 | void *qfind_m(CCBPtr qhead, void *match, ProcPtr compare_fnx); | |
1c79356b A |
332 | |
333 | ||
334 | /* | |
335 | * Routines to handle sorted timer queues | |
336 | */ | |
91447636 A |
337 | void InsertTimerElem(TimerElemPtr *qhead, TimerElemPtr t, int val); |
338 | void RemoveTimerElem(TimerElemPtr *qhead, TimerElemPtr t); | |
339 | void TimerQueueTick(TimerElemPtr *qhead); | |
1c79356b A |
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 | ||
91447636 A |
358 | #endif /* KERNEL_PRIVATE */ |
359 | #endif /* __APPLE_API_OBSOLETE */ | |
1c79356b A |
360 | |
361 | #endif /* _NETAT_ADSP_INTERNAL_H_ */ |