Annotation of XNU/bsd/netat/adsp_misc.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      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.
                     11:  * 
                     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
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: #include <sys/errno.h>
                     23: #include <sys/types.h>
                     24: #include <sys/param.h>
                     25: #include <machine/spl.h>
                     26: #include <sys/systm.h>
                     27: #include <sys/kernel.h>
                     28: #include <sys/proc.h>
                     29: #include <sys/filedesc.h>
                     30: #include <sys/fcntl.h>
                     31: #include <sys/mbuf.h>
                     32: #include <sys/socket.h>
                     33: 
                     34: #include <netat/sysglue.h>
                     35: #include <netat/appletalk.h>
                     36: #include <netat/at_pcb.h>
                     37: #include <netat/debug.h>
                     38: #include <netat/adsp.h>
                     39: #include <netat/adsp_internal.h>
                     40: 
                     41: /*
                     42:  * These function replace the Mk68 assembly routines found in qAddToEnd.s and
                     43:  * q????.s
                     44:  *    Modified for MP, 1996 by Tuyen Nguyen
                     45:  *   Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
                     46:  */
                     47: extern atlock_t adspgen_lock;
                     48: 
                     49: 
                     50: struct qlink {
                     51:        struct qlink *qlinkp;
                     52: };
                     53: 
                     54: /* ----------------------------------------------------------------------
                     55:  * void qAddToEnd(void *qhead, void *qelem)
                     56:  * 
                     57:  * INPUTS:
                     58:  *             Ptr             to ptr to 1st item in queue
                     59:  *             Ptr             to item to add to end of queue
                     60:  * OUTPUTS:
                     61:  *             none
                     62:  *
                     63:  * Assumptions: The link field is the FIRST field of the qelem structure.
                     64:  * ----------------------------------------------------------------------
                     65:  */
                     66: int qAddToEnd(qhead, qelem)
                     67:        struct qlink **qhead;
                     68:        struct qlink *qelem;
                     69: {
                     70:        /* define our own type to access the next field. NOTE THAT THE "NEXT"
                     71:          * FIELD IS ASSUMED TO BE THE FIRST FIELD OF THE STRUCTURE
                     72:         */
                     73: 
                     74:        register struct qlink *q;
                     75: 
                     76:        /* Scan the linked list to the end and update the previous
                     77:          * element next field. (do that protocted).
                     78:          */
                     79: 
                     80:        q = *qhead;
                     81:        if (q) {
                     82:                while (q->qlinkp) {
                     83:                        /* are we about to link to ourself */
                     84:                        if (q == qelem)
                     85:                                goto breakit;
                     86:                        q = q->qlinkp;
                     87:                }
                     88:                q->qlinkp = qelem;
                     89:        }
                     90:        else {
                     91:                *qhead = qelem;
                     92:        }
                     93:        qelem->qlinkp = (struct qlink *) 0;
                     94: breakit:
                     95: #ifdef NOTDEF
                     96:        DPRINTF("%s: qhead=%x added elem=%x\n","qAddToEnd", qhead, qelem);
                     97: #endif
                     98:        return 0;
                     99: }
                    100: 
                    101: 
                    102: 
                    103: /* ----------------------------------------------------------------------
                    104:  *  qfind_m
                    105:  *     void* qfind_m(void *qhead, void NPTR match, ProcPtr compare_fnx)
                    106:  *  
                    107:  *  Hunt down a linked list of queue elements calling the compare 
                    108:  *  function on each item. When the compare function returns true, 
                    109:  *  return ptr to the queue element.
                    110:  * 
                    111:  * 
                    112:  *  INPUTS:
                    113:  *             qhead   Address of ptr to first item in queue
                    114:  *             match   
                    115:  *             compare_fnx
                    116:  *  OUTPUTS:
                    117:  *             D0 & A0 Ptr to queue element or NIL
                    118:  *  REGISTERS:
                    119:  *     D0,D1,A0,A1
                    120:  * ----------------------------------------------------------------------
                    121:  */
                    122: void* qfind_m(qhead, match, compare_fnx)
                    123:        CCBPtr  qhead;
                    124:        void  *match;
                    125:        ProcPtr compare_fnx;
                    126: {
                    127:        int s;
                    128:        CCBPtr queue_item = qhead;
                    129: 
                    130:        ATDISABLE(s, adspgen_lock);
                    131:        while (queue_item) { 
                    132:                if ((*compare_fnx)(queue_item,match)) 
                    133:                        break;
                    134:                
                    135:                queue_item = queue_item->ccbLink;
                    136:        }
                    137:        ATENABLE(s, adspgen_lock);
                    138: 
                    139:        return (queue_item);
                    140: }

unix.superglobalmegacorp.com

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