Annotation of kernel/bsd/netat/adsp_attention.c, revision 1.1

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: /*
        !            30:  * dspAttention
        !            31:  * 
        !            32:  * INPUTS:
        !            33:  *     --> ccbRefNum           refnum of connection end
        !            34:  *     --> attnCode            client attention code
        !            35:  *     --> attnSize            size in bytes of attention data
        !            36:  *     --> attnData            pointer to attention data
        !            37:  *     --> attnInterval        attention retransmit interval 
        !            38:  *                             (ignored by ADSP 1.5 & up)
        !            39:  *
        !            40:  * OUTPUTS:
        !            41:  *     none
        !            42:  *
        !            43:  * ERRORS:
        !            44:  *     errRefNum               bad connection refnum
        !            45:  *     errState                connection is not open
        !            46:  *     errAttention            attention message too long
        !            47:  *     errAborted              request aborted by Remove or Close call
        !            48:  */
        !            49: int adspAttention(sp, pb)      /* (DSPPBPtr pb) */
        !            50:     register struct adspcmd *pb;
        !            51:     register CCBPtr sp;
        !            52: {
        !            53:     int        s;
        !            54:     OSErr err;
        !            55:     register gbuf_t *mp, *nmp;
        !            56:     unsigned char uerr;
        !            57:        
        !            58:     if (sp == 0) {
        !            59:        pb->ioResult = errRefNum;
        !            60:        return EINVAL;
        !            61:     }
        !            62:        
        !            63:     if (sp->state != sOpen) {  /* If we're not open, tell user to go away */
        !            64:        pb->ioResult = errState;
        !            65:        uerr = ENOTCONN;
        !            66: l_err:
        !            67:        gbuf_set_type(pb->mp, MSG_ERROR);
        !            68:        *gbuf_rptr(pb->mp) = uerr;
        !            69:        gbuf_wset(pb->mp,1);
        !            70:        completepb(sp, pb);
        !            71:        return 0;
        !            72:     }
        !            73:        
        !            74:     if (pb->u.attnParams.attnSize > attnBufSize) /* If data too big, bye-bye */
        !            75:     {
        !            76:        pb->ioResult = errAttention;
        !            77:        uerr = ERANGE;
        !            78:        goto l_err;
        !            79:     }
        !            80: 
        !            81:     /*
        !            82:      * Copy in attention data.
        !            83:      */
        !            84:     mp = pb->mp;
        !            85:     if (pb->u.attnParams.attnSize) {
        !            86: 
        !            87:   nmp = gbuf_cont(mp);
        !            88:   if (gbuf_len(mp) > sizeof(struct adspcmd)) {
        !            89:        if ((nmp = gbuf_dupb(mp)) == 0) {
        !            90:                gbuf_wset(mp,sizeof(struct adspcmd));
        !            91:            uerr = ENOSR;
        !            92:            goto l_err;
        !            93:        }
        !            94:        gbuf_wset(mp,sizeof(struct adspcmd));
        !            95:        gbuf_rinc(nmp,sizeof(struct adspcmd));
        !            96:        gbuf_cont(nmp) = gbuf_cont(mp);
        !            97:        gbuf_cont(mp) = nmp;
        !            98:   }
        !            99:     }
        !           100:     pb->ioDirection = 1;       /* outgoing attention data */
        !           101:     ATDISABLE(s, sp->lock);
        !           102:     if (sp->sapb) {            /* Pending attentions already? */
        !           103:        qAddToEnd(&sp->sapb, pb); /* Just add to end of queue */
        !           104:        ATENABLE(s, sp->lock);
        !           105:     } else {
        !           106:        sp->sendAttnData = 1;   /* Start off this attention */
        !           107:        pb->qLink = 0;
        !           108:        sp->sapb = pb;
        !           109:        ATENABLE(s, sp->lock);
        !           110:        CheckSend(sp);
        !           111:     }
        !           112:     pb->ioResult = 1;  /* indicate that the IO is not complete */
        !           113:     return 0;
        !           114: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.