|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: ! 26: #include <adsp_local.h> ! 27: ! 28: /* ! 29: * calcSendFree ! 30: * ! 31: * INPUTS: ! 32: * sp ADSP Stream ! 33: * OUTPUTS: ! 34: * # of bytes avail in local send queue ! 35: */ ! 36: int CalcSendQFree(sp) /* (CCBPtr sp) */ ! 37: CCBPtr sp; ! 38: { ! 39: int bytes; ! 40: ! 41: bytes = calcSendQ(sp); ! 42: bytes = sp->sbuflen - bytes; ! 43: ! 44: if (bytes < 0) ! 45: return 0; ! 46: return bytes; ! 47: } ! 48: ! 49: calcSendQ(sp) ! 50: CCBPtr sp; ! 51: { ! 52: register gbuf_t *mp; ! 53: int bytes = 0; ! 54: ! 55: if (sp->sData) { /* There is data in buffer */ ! 56: if (mp = sp->sbuf_mb) { ! 57: do { ! 58: bytes += gbuf_msgsize(mp); ! 59: mp = gbuf_next(mp); ! 60: } while (mp); ! 61: } ! 62: if (mp = sp->csbuf_mb) ! 63: bytes += gbuf_msgsize(mp); ! 64: } ! 65: return bytes; ! 66: } ! 67: ! 68: /* ! 69: * dspStatus ! 70: * ! 71: * INPUTS: ! 72: * --> ccbRefNum refnum of connection end ! 73: * ! 74: * OUTPUTS: ! 75: * <-- statusCCB Pointer to the connection control block ! 76: * <-- sendQPending bytes waiting to be sent or acknowledged ! 77: * <-- sendQFree available buffer in bytes of send queue ! 78: * <-- recvQPending bytes waiting to be read from queue ! 79: * <-- recvQFree available buffer in bytes of receive queue ! 80: * ! 81: * ERRORS: ! 82: * errRefNum bad connection refnum ! 83: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! 84: */ ! 85: int adspStatus(sp, pb) /* (DSPPBPtr pb) */ ! 86: CCBPtr sp; ! 87: register struct adspcmd *pb; ! 88: { ! 89: OSErr err; ! 90: short bytes; ! 91: int s; ! 92: ! 93: if (sp == 0) { ! 94: pb->ioResult = errRefNum; ! 95: return EINVAL; ! 96: } ! 97: ! 98: pb->u.statusParams.ccbPtr = (TPCCB)sp; ! 99: ATDISABLE(s, sp->lock); ! 100: ! 101: /* ! 102: * pending bytes in send queue ! 103: */ ! 104: if (sp->sData) ! 105: bytes = calcSendQ(sp); ! 106: else ! 107: bytes = 0; ! 108: pb->u.statusParams.sendQPending = bytes; ! 109: ! 110: /* available buffer space in send queue */ ! 111: pb->u.statusParams.sendQFree = CalcSendQFree(sp); ! 112: ! 113: /* ! 114: * pending bytes in recv queue ! 115: */ ! 116: if (sp->rData) ! 117: bytes = calcRecvQ(sp); ! 118: else ! 119: bytes = 0; ! 120: pb->u.statusParams.recvQPending = bytes; ! 121: ! 122: /* available buffer space in receive queue */ ! 123: pb->u.statusParams.recvQFree = CalcRecvWdw(sp); ! 124: ! 125: ATENABLE(s, sp->lock); ! 126: pb->ioResult = 0; ! 127: adspioc_ack(0, pb->ioc, pb->gref); ! 128: return 0; ! 129: ! 130: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.