summaryrefslogtreecommitdiff
path: root/v4.0/src/DEV/SMARTDRV/FL13.ASM
blob: 6ae1e4475fc5e7b644bd7911ec6ddad5ebf2d0b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
	TITLE	Assembler helper routines for FLUSH13

PAGE	58,132


memS	EQU	1		; Small model
?PLM	=	0		; Standard 'C'
?WIN	=	0		; Not windows

include cmacros.inc

;extern int	 IOCTLOpen(char *);
;extern int	 IOCTLWrite(int,char *,int);
;extern int	 IOCTLRead(int,status *,int);
;extern int	 IOCTLClose(int);

sBegin	CODE

assumes CS, CODE
assumes DS, DATA

;**	IOCTLOpen - Open the indicated device and make sure it's a device
;
;  ENTRY:
;	Pointer to name of device
;  EXIT:
;	AX = -1 if error, device not opened
;	else AX = handle of open device
;  USES:
;	Standard 'C'
;
cProc IOCTLOpen, <PUBLIC>, <si,di,es>

ParmW Nameptr

cBegin
	mov	dx,Nameptr
	MOV	AX,3D02H
	INT	21H		; Open the device
	JC	NO_DEV_ERR	; No device
	MOV	BX,AX
	MOV	AX,4400H
	INT	21H		; Make sure it IS a device
	JC	CLOSE_NO_DEV
	TEST	DX,4080H
	JZ	CLOSE_NO_DEV
	mov	ax,bx		; Return the handle
	jmp	short PXDONE

CLOSE_NO_DEV:
	mov	ax,3e00H	; Close
	int	21H
NO_DEV_ERR:
	mov	ax,-1
PXDONE:
cEnd

;**	IOCTLClose - Close the indicated handle
;
;  ENTRY:
;	Handle
;  EXIT:
;	None
;  USES:
;	Standard 'C'
;
cProc IOCTLClose, <PUBLIC>, <si,di,es>

ParmW Handle

cBegin
	mov	bx,Handle
	MOV	AX,3E00H
	INT	21H		; close the device
cEnd

;**	IOCTLWrite - Perform IOCTLWrite to device handle
;
;  ENTRY:
;	Handle to open device
;	Pointer to data to write
;	Count in bytes of data to write
;  EXIT:
;	AX = -1 error
;	else AX = input count
;  USES:
;	Standard 'C'
;
cProc IOCTLWrite, <PUBLIC>, <si,di,es>

ParmW WHandle
ParmW WDataPtr
ParmW WCount

cBegin
	mov	bx,WHandle
	mov	cx,WCount
	mov	dx,WDataPtr
	MOV	AX,4403H	; IOCTL Write
	INT	21H
	JC	Werr
	CMP	AX,CX
	JNZ	Werr
	jmp	short WDONE

WERR:
	mov	ax,-1
WDONE:
cEnd

;**	IOCTLRead - Perform IOCTLRead to device handle
;
;  ENTRY:
;	Handle to open device
;	Pointer to data area to read into
;	Count in bytes of size of data area
;  EXIT:
;	AX = -1 error
;	else AX = input count
;  USES:
;	Standard 'C'
;
cProc IOCTLRead, <PUBLIC>, <si,di,es>

ParmW RHandle
ParmW RDataPtr
ParmW RCount

cBegin
	mov	bx,RHandle
	mov	cx,RCount
	mov	dx,RDataPtr
	MOV	AX,4402H	; IOCTL Read
	INT	21H
	JC	Rerr
	CMP	AX,CX
	JNZ	Rerr
	jmp	short RDONE

RERR:
	mov	ax,-1
RDONE:
cEnd


sEnd	CODE

	end