;       SCCSID = @(#)smgdmaor.asm	6.1 90/11/18
;      SCCSID = @(#)smgdmaor.asm	6.4 90/01/29
   PAGE 60,132
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************

;***************************************************************************
;
; Source File Name:	SMGDMAOR.ASM
;
; Subroutine Name:	DOSSMDMAOVERRN
;
; Descriptive Name:	DMA overrun daemon
;
; Function:	Calls the diskette device driver to handle DMA
;		overruns.  This thread processes DMA overruns.
;
; Notes:
;	Dependencies:	This procedure is called via DOSCREATETHREAD.
;
;	Restrictions:	None
;
;	Change History:
;
; Entry Point:
;	Linkage:  EXTRN DOSSMDMAOVERRN:FAR
;
; Inputs:
;	None
;
; Exit Normal:
;	None
;
; Exit Errors:
;	None
;
; Effects:	The DD DevHelp will set/reset the DMAOverrunFlag
;		whose address was returned by the Dossystemservice call.
;
; Internal References:
;	   Data:
;
;	   Routines:
;
; External References:
;	   Data:
;	   Routines: ;; DOSOPEN
;		     ;; DOSDEVIOCTL
;			DOSSYSTEMSERVICE
;			DOSEXIT
;
;***************************************************************************
;
;      REPEAT (Infinite DMA overrun loop)
;	 DOSSYSTEMSERVICE (Wait for diskette DD to wake up thread)
;	 LEAVE (on error)
;	 WHILE (DMA Overrun)
;	 ENDWHILE
;      UNTIL
;      DOSEXIT (if error retured from DosSystemService)
;
;***************************************************************************

.286C
   EXTRN DOSEXIT	  : FAR 	; Terminate thread if error
   EXTRN DOSSYSTEMSERVICE : FAR 	; Wait for DMA overrun event
   .xlist
   .xcref
   INCLUDE STRUC.INC
   .cref
   .list
CODE SEGMENT WORD PUBLIC 'CODE'
   ASSUME CS:CODE,DS:NOTHING,SS:NOTHING,ES:NOTHING

   PUBLIC DOSSMDMAOVERRN
DOSSMDMAOVERRN PROC FAR

   Local_Bytes	    EQU  6
   DMAResPacket     EQU  SS:[BP][-4]	  ; DosSystemService response pkt
   DMAActPacket     EQU  SS:[BP][-6]	  ; DosSystemService action pkt

   ENTER Local_Bytes,0			  ; Get storage for local variable

;  *****************************************************************
;  *  Process DMA overrun when notified by diskette device driver  *
;  *****************************************************************
   .REPEAT				  ; Infinite loop
     PUSH 3				  ; VideoPause screen services
     PUSH SS				  ; Action packet address
     LEA  AX, DMAActPacket		  ;
     PUSH AX				  ;
     PUSH SS				  ; Response packet address
     LEA  AX, DMAResPacket		  ;
     PUSH AX				  ;
     CALL DosSystemService		  ;

     .LEAVE <AX ne 0>			  ; Exit on error
     LDS SI, DMAResPacket		  ; Get Flag address

     .WHILE <<DS:BYTE PTR [SI]> ne 0>	  ; Loop if DMA overrun encountered
     .ENDWHILE				  ; Until flag is reset to 0

   .UNTIL				  ;

;  ********************************************************
;  *  Terminate the thread, if an error was encountered.  *
;  ********************************************************
   PUSH 0
   PUSH 0
   CALL DOSEXIT

   LEAVE				   ;

DOSSMDMAOVERRN ENDP

CODE ENDS
   END
