]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netat/adsp_Read.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / netat / adsp_Read.c
index 6c6c2390c4c09ea70f423dae1f2ea290ef67f214..ca6cbf87442336b2c048ccd743eebd678f356ccf 100644 (file)
@@ -1,23 +1,31 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * This file contains Original Code and/or Modifications of Original Code 
+ * as defined in and that are subject to the Apple Public Source License 
+ * Version 2.0 (the 'License'). You may not use this file except in 
+ * compliance with the License.  The rights granted to you under the 
+ * License may not be used to create, or enable the creation or 
+ * redistribution of, unlawful or unlicensed copies of an Apple operating 
+ * system, or to circumvent, violate, or enable the circumvention or 
+ * violation of, any terms of an Apple operating system software license 
+ * agreement.
+ *
+ * Please obtain a copy of the License at 
+ * http://www.opensource.apple.com/apsl/ and read it before using this 
+ * file.
+ *
+ * The Original Code and all software distributed under the License are 
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
+ * Please see the License for the specific language governing rights and 
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
  */
 /*
  *
@@ -62,6 +70,7 @@ int CheckReadQueue(sp)                /* (CCBPtr sp) */
     register CCBPtr sp;
 {
     register struct adspcmd *pb;
+    int s;
     unsigned short cnt;
     char eom = 0;
     register gbuf_t *mp;
@@ -71,6 +80,7 @@ int CheckReadQueue(sp)                /* (CCBPtr sp) */
     dPrintf(D_M_ADSP, D_L_TRACE, ("CheckReadQueue: sp=0x%x\n", (unsigned)sp));
     KERNEL_DEBUG(DBG_ADSP_READ, 0, sp, sp->rbuf_mb, sp->rpb, sp->delay);
     trace_mbufs(D_M_ADSP_LOW, "    bCQR m", sp->rbuf_mb);
+    ATDISABLE(s, sp->lock);
 
     while (sp->rData && (pb = sp->rpb)) {              /* have data */
         dPrintf(D_M_ADSP, D_L_TRACE, 
@@ -231,6 +241,7 @@ int CheckReadQueue(sp)              /* (CCBPtr sp) */
        sp->sendDataAck = 1;
        sp->callSend = 1;
     }
+    ATENABLE(s, sp->lock);
 
     KERNEL_DEBUG(DBG_ADSP_READ, 0x11, sp, 0, 0, 0);
     trace_mbufs(D_M_ADSP_LOW, "    eCQR m", sp->rbuf_mb);
@@ -254,12 +265,14 @@ int CheckAttn(sp, pb)             /* (CCBPtr sp) */
     register CCBPtr sp;
     register struct adspcmd *pb;
 {
+    int s;
     gbuf_t *mp;
     gref_t *gref;
        
     dPrintf(D_M_ADSP, D_L_TRACE, 
            ("CheckAttn: sp=0x%x, pb=0x%x\n", (unsigned)sp, (unsigned)pb));
 
+    ATDISABLE(s, sp->lock);
     if (mp = sp->attn_mb) {
 
        /*
@@ -291,6 +304,7 @@ int CheckAttn(sp, pb)               /* (CCBPtr sp) */
     if (mp) {
        SndMsgUp(gref, mp);
        }
+    ATENABLE(s, sp->lock);
     return 0;
 }
 
@@ -316,6 +330,7 @@ int adspRead(sp, pb)                /* (DSPPBPtr pb) */
     register struct adspcmd *pb;
 {
     register gbuf_t *mp;
+    int        s;
 
     dPrintf(D_M_ADSP, D_L_TRACE, 
            ("adspRead: sp=0x%x, pb=0x%x\n", (unsigned)sp, (unsigned)pb));
@@ -330,15 +345,19 @@ int adspRead(sp, pb)              /* (DSPPBPtr pb) */
     /*
      * It's OK to read on a closed, or closing session
      */
+    ATDISABLE(s, sp->lock);
     if (sp->state != sOpen && sp->state != sClosing && sp->state != sClosed) {
+       ATENABLE(s, sp->lock);
        pb->ioResult = errState;
        return EINVAL;
     }
     if (sp->rData && (sp->rpb == 0)) { /* if data, and no queue of pbs */
        qAddToEnd(&sp->rpb, pb); /* deliver data to user directly */
+       ATENABLE(s, sp->lock);
        CheckReadQueue(sp);
     } else if ((pb->u.ioParams.reqCount == 0) && (sp->rpb == 0)) {
            /* empty read */
+           ATENABLE(s, sp->lock);
            pb->ioResult = 0;
            adspioc_ack(0, pb->ioc, pb->gref);
            return 0;
@@ -350,7 +369,9 @@ int adspRead(sp, pb)                /* (DSPPBPtr pb) */
                pb->ioc = 0;
                pb->mp = mp;
                qAddToEnd(&sp->rpb, pb); /* and queue it for later */
+               ATENABLE(s, sp->lock);
        } else {
+               ATENABLE(s, sp->lock);
                pb->ioResult = errDSPQueueSize;
                return ENOBUFS;
        }