BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / pmax / dev / asc.c
index 17a6d49..4b36ea1 100644 (file)
@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)asc.c       8.1 (Berkeley) 6/10/93
+ *     @(#)asc.c       8.2 (Berkeley) 1/4/94
  */
 
 /* 
  */
 
 /* 
@@ -898,9 +898,10 @@ again:
                        readback(regs->asc_cmd);
                        DELAY(2);
                }
                        readback(regs->asc_cmd);
                        DELAY(2);
                }
-               if (len) {
+               if (len && (state->flags & DMA_IN_PROGRESS)) {
                        /* save number of bytes still to be sent or received */
                        state->dmaresid = len;
                        /* save number of bytes still to be sent or received */
                        state->dmaresid = len;
+                       state->flags &= ~DMA_IN_PROGRESS;
 #ifdef DEBUG
                        if (asc_logp == asc_log)
                                asc_log[NLOG - 1].resid = len;
 #ifdef DEBUG
                        if (asc_logp == asc_log)
                                asc_log[NLOG - 1].resid = len;
@@ -919,7 +920,7 @@ again:
                                 */
                                if (len & 1) {
                                        printf("asc_intr: msg in len %d (fifo %d)\n",
                                 */
                                if (len & 1) {
                                        printf("asc_intr: msg in len %d (fifo %d)\n",
-                                               len, fifo);
+                                               len, fifo); /* XXX */
                                        len = state->dmalen - len;
                                        goto do_in;
                                }
                                        len = state->dmalen - len;
                                        goto do_in;
                                }
@@ -930,49 +931,51 @@ again:
                                        &asc_scripts[SCRIPT_RESUME_DMA_OUT];
                        else
                                state->script = asc->script;
                                        &asc_scripts[SCRIPT_RESUME_DMA_OUT];
                        else
                                state->script = asc->script;
-               } else {
+               } else if (state->flags & DMA_IN) {
+                       if (len)
+                               printf("asc_intr: 1: len %d (fifo %d)\n", len,
+                                       fifo); /* XXX */
                        /* setup state to resume to */
                        /* setup state to resume to */
-                       if (state->flags & DMA_IN) {
-                               if (state->flags & DMA_IN_PROGRESS) {
-                                       len = state->dmalen;
-                               do_in:
-                                       state->flags &= ~DMA_IN_PROGRESS;
-                                       (*asc->dma_end)(asc, state, ASCDMA_READ);
-                                       bcopy(state->dmaBufAddr, state->buf,
-                                               len);
-                                       state->buf += len;
-                                       state->buflen -= len;
-                               }
-                               if (state->buflen)
-                                       state->script =
-                                           &asc_scripts[SCRIPT_RESUME_IN];
-                               else
-                                       state->script =
-                                           &asc_scripts[SCRIPT_RESUME_NO_DATA];
-                       } else if (state->flags & DMA_OUT) {
-                               /*
-                                * If this is the last chunk, the next expected
-                                * state is to get status.
-                                */
-                               if (state->flags & DMA_IN_PROGRESS) {
-                                       state->flags &= ~DMA_IN_PROGRESS;
-                                       (*asc->dma_end)(asc, state, ASCDMA_WRITE);
-                                       len = state->dmalen;
-                                       state->buf += len;
-                                       state->buflen -= len;
-                               }
-                               if (state->buflen)
-                                       state->script =
-                                           &asc_scripts[SCRIPT_RESUME_OUT];
-                               else
-                                       state->script =
-                                           &asc_scripts[SCRIPT_RESUME_NO_DATA];
-                       } else if (asc->script == &asc_scripts[SCRIPT_SIMPLE])
+                       if (state->flags & DMA_IN_PROGRESS) {
+                               len = state->dmalen;
+                               state->flags &= ~DMA_IN_PROGRESS;
+                       do_in:
+                               (*asc->dma_end)(asc, state, ASCDMA_READ);
+                               bcopy(state->dmaBufAddr, state->buf, len);
+                               state->buf += len;
+                               state->buflen -= len;
+                       }
+                       if (state->buflen)
                                state->script =
                                state->script =
-                                       &asc_scripts[SCRIPT_RESUME_NO_DATA];
+                                   &asc_scripts[SCRIPT_RESUME_IN];
                        else
                        else
-                               state->script = asc->script;
-               }
+                               state->script =
+                                   &asc_scripts[SCRIPT_RESUME_NO_DATA];
+               } else if (state->flags & DMA_OUT) {
+                       if (len)
+                               printf("asc_intr: 2: len %d (fifo %d)\n", len,
+                                       fifo); /* XXX */
+                       /*
+                        * If this is the last chunk, the next expected
+                        * state is to get status.
+                        */
+                       if (state->flags & DMA_IN_PROGRESS) {
+                               state->flags &= ~DMA_IN_PROGRESS;
+                               (*asc->dma_end)(asc, state, ASCDMA_WRITE);
+                               len = state->dmalen;
+                               state->buf += len;
+                               state->buflen -= len;
+                       }
+                       if (state->buflen)
+                               state->script =
+                                   &asc_scripts[SCRIPT_RESUME_OUT];
+                       else
+                               state->script =
+                                   &asc_scripts[SCRIPT_RESUME_NO_DATA];
+               } else if (asc->script == &asc_scripts[SCRIPT_SIMPLE])
+                       state->script = &asc_scripts[SCRIPT_RESUME_NO_DATA];
+               else
+                       state->script = asc->script;
 
                /* setup to receive a message */
                asc->script = &asc_scripts[SCRIPT_MSG_IN];
 
                /* setup to receive a message */
                asc->script = &asc_scripts[SCRIPT_MSG_IN];