]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Status.c
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@
25 * From Mike Shoemaker v01.04 06/15/90 mbs
26 * Modified for MP, 1996 by Tuyen Nguyen
27 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
30 #include <sys/errno.h>
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <machine/spl.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/filedesc.h>
38 #include <sys/fcntl.h>
40 #include <sys/socket.h>
42 #include <netat/sysglue.h>
43 #include <netat/appletalk.h>
44 #include <netat/at_pcb.h>
45 #include <netat/adsp.h>
46 #include <netat/adsp_internal.h>
54 * # of bytes avail in local send queue
56 int CalcSendQFree(sp
) /* (CCBPtr sp) */
61 bytes
= calcSendQ(sp
);
62 bytes
= sp
->sbuflen
- bytes
;
75 if (sp
->sData
) { /* There is data in buffer */
76 if (mp
= sp
->sbuf_mb
) {
78 bytes
+= gbuf_msgsize(mp
);
82 if (mp
= sp
->csbuf_mb
)
83 bytes
+= gbuf_msgsize(mp
);
92 * --> ccbRefNum refnum of connection end
95 * <-- statusCCB Pointer to the connection control block
96 * <-- sendQPending bytes waiting to be sent or acknowledged
97 * <-- sendQFree available buffer in bytes of send queue
98 * <-- recvQPending bytes waiting to be read from queue
99 * <-- recvQFree available buffer in bytes of receive queue
102 * errRefNum bad connection refnum
103 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
105 int adspStatus(sp
, pb
) /* (DSPPBPtr pb) */
107 register struct adspcmd
*pb
;
114 pb
->ioResult
= errRefNum
;
118 pb
->u
.statusParams
.ccbPtr
= (TPCCB
)sp
;
119 ATDISABLE(s
, sp
->lock
);
122 * pending bytes in send queue
125 bytes
= calcSendQ(sp
);
128 pb
->u
.statusParams
.sendQPending
= bytes
;
130 /* available buffer space in send queue */
131 pb
->u
.statusParams
.sendQFree
= CalcSendQFree(sp
);
134 * pending bytes in recv queue
137 bytes
= calcRecvQ(sp
);
140 pb
->u
.statusParams
.recvQPending
= bytes
;
142 /* available buffer space in receive queue */
143 pb
->u
.statusParams
.recvQFree
= CalcRecvWdw(sp
);
145 ATENABLE(s
, sp
->lock
);
147 adspioc_ack(0, pb
->ioc
, pb
->gref
);