;       SCCSID = @(#)iohelp.asm	6.1 90/11/17
;	SCCSID = @(#)iohelp.asm      13.6 90/01/25
;
;*** IOHELP - performs I/O device helper calls and strategy 2 calls
;
; VOID CallAsyncIO( PEXECLIST pxlh, PFNV pStrat2 );
;
; UINT InitNfy( PPEXECLIST ppxlh );
;
;

INCL_DOSERRORS	equ	1	; Include the errors from bseerr.inc

include bseerr.inc
include devhlp.inc

.286

ifdef MEDIUM_MODEL
.model medium, pascal
else
.model small, pascal
endif

.data

extrn pDevHlp:dword 

ifdef MEDIUM_MODEL
.CODE	_TEXT
else
.CODE
endif

;**	CallAsyncIO - load up reg's and call strategy 2 entrypoint
;
;

public	CallAsyncIO
CallAsyncIO proc	uses ds si di, pxlh:dword, pstrat2:dword

	; Load ES:BX with the address of the exec-list
	mov	es,WORD Ptr pxlh+2  ; get selctor of pointer
	mov	bx,WORD Ptr pxlh    ; get offset

	; Call strat2
	call	DWORD Ptr [pstrat2] ; call the device driver

	ret
CallAsyncIO	endp



;**	InitNfy - Notify initialization routine
;
;   This routine is called by Notify routines written in C.
; it MUST be called BEFORE ANY OTHER C LINE in the routine.
;
; entry:
;	es:bx	==> pointer to exec-list or IO Request header
;	CF set if error occured
;
; on exit:
;	*pvHeader ==> pointer to exec-list or IO Request header
;	returns (in eax)  NO_ERROR if no error occured
;

public	InitNfy
InitNfy proc  uses si di, pvHeader:dword

;   Set up DS to point to our data segment
	mov	ax,_DATA
	mov	ds,ax

;     Save state of carry for boolean return
	mov	ax,NO_ERROR		; assume no error
	rcl	ax,1			; (ax) = 1, iff carry was set
.errnz	NO_ERROR

;	Move ES:BX to pvHeader

	mov	dx,es			; Save a copy of the selector

	les	di,pvHeader		; get a pointer to *pvHeader
	mov	es:[di],bx		; save the offset
	mov	es:[di+2],dx		; save selector

	ret
InitNfy endp

end
