-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsrdummy.asm
executable file
·383 lines (323 loc) · 11.5 KB
/
srdummy.asm
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
;
; ReSizeable RAMDisk dummy disk driver to take up drive letters
;
; Copyright (C) 1992-1996, 2005 Marko Kohtala
; Released under GNU GPL, read the file 'COPYING' for more information
;
; To compile with TASM, find the appropriate srd???.asm file and:
; tasm /m2 srd???.asm
; tlink /t srd???.obj,srd???.sys
include dosstruc.inc
include define.inc
;**************************************************************************
;
; Device driver start and the structures
;
;**************************************************************************
d_seg segment page public
assume ds:d_seg, cs:d_seg
org 0
; Device driver header
drhdr_next dd -1 ; Pointer to next device (now last)
drhdr_attr dw DHATTR_NOFAT
drhdr_strategy dw offset strategy ; Offset to strategy function
drhdr_commands dw offset commands ; Offset to commands function
drhdr_units db 0 ; Number of units
config_s struc
c_BPB_bps dw 512 ; Sector size
c_BPB_spc db 2 ; Cluster size in sectors
c_BPB_reserved dw 1 ; The boot sector is reserved
c_BPB_FATs db 2 ; One FAT copy
c_BPB_dir dw 112 ; 112 entries in root directory
c_BPB_sectors dw 720 ; number of sectors on 16-bit disk
c_BPB_media db 0FDh ; Media
c_BPB_FATsectors dw 2 ; Sectors per one FAT
c_BPB_spt dw 9 ; Sectors per track
c_BPB_heads dw 2 ; Number of heads
c_BPB_hiddenl dw 0 ; # of hidden sectors (low word)
config_s ends
;conf config_s <>
; TASM 3.0 bugs force this approach:
conf config_s <512,2,1,2,112,720,0FDh,2,9,2,0>
;**************************************************************************
;
; Set request header address
;
; Called by DOS to set the request structure pointer
;
;**************************************************************************
strategy proc far
mov word ptr cs:req_ptr,bx
mov word ptr cs:req_ptr+2,es
ret
strategy endp
;**************************************************************************
;
; Commands
;
; Called by DOS. Always tells that the drive is not ready.
;
;**************************************************************************
commands proc far
assume ds:nothing
push si
push ds
lds si,req_ptr
assume ds:nothing
mov [si].rhStatus,DRIVE_NOT_READY OR ERROR OR DONE
cmp [si].rhFunction,0
jnz cmd_error
call cmd_init
cmd_error:
pop ds
pop si
retf
assume ds:d_seg
commands endp
;**************************************************************************
;
; Other internal and resident data
;
; The order of this data is not significant as it will not be used outside
;
;**************************************************************************
req_ptr dd ? ; Request structure pointer
BPB equ byte ptr conf.c_BPB_bps
; Pointers to BPB (for cmd_init)
; This must be the last of the resident data, since end of resident is
; calculated from this pointer and number of units
pBPB dw offset BPB ; First unit (C)
dw offset BPB ; D
dw offset BPB ; E
dw offset BPB ; F
dw offset BPB ; G
dw offset BPB ; H
dw offset BPB ; I
dw offset BPB ; J
dw offset BPB ; K
dw offset BPB ; L
dw offset BPB ; M
dw offset BPB ; N
dw offset BPB ; O
dw offset BPB ; P
dw offset BPB ; Q
dw offset BPB ; R
dw offset BPB ; S
dw offset BPB ; T
dw offset BPB ; U
dw offset BPB ; V
dw offset BPB ; W
dw offset BPB ; X
dw offset BPB ; Y
dw offset BPB ; Z
;**************************************************************************
;
; prints macro
;
; This macro is used by initialization routines to display text.
; dx must point to the '$' terminated text about to be displayed.
;**************************************************************************
prints macro
mov ah,9
int 21h
endm
;**************************************************************************
;
; Initialization time variables
;
;**************************************************************************
dos_drive db 0 ; DOS reported drive
def_drive db 0 ; User requested drive
;**************************************************************************
;
; INIT command
;
; Init command does the following:
; - displays sign-on message
; - read command line for drive letter
; - abort on syntax errors
; - set everything necessary up
;**************************************************************************
cmd_init proc near
pushf
push ax
push bx
push cx
push dx
push si
push di
push ds
push es
cld
; Sign on message
push cs
pop ds
mov dx,offset s_sign_on ; "ReSizeable RAMdisk ver..."
prints
; Find out the features about DOS and the drive letter
call init_dos
mov dx,offset errs_nodrive
jc cmd_init_err
cmp dos_drive,0
jz cmd_init_err
cmd_init_read:
call init_read_cmdline
jnc cmd_init3
; call returned with DX set to error text
cmd_init_err:
prints
mov al,0
jmp cmd_init1
cmd_init3:
mov al,def_drive
sub al,dos_drive
cmp al,1
jge cmd_init1
mov al,0
cmd_init1:
lds bx,req_ptr
assume ds:nothing
mov drhdr_units,al
mov [bx].irUnits,al
xor ah,ah
cmp al,0
jz cmd_init2
shl ax,1
add ax,offset pBPB
cmd_init2:
mov word ptr [bx].irEndAddress,ax
mov word ptr [bx].irEndAddress+2,cs
mov word ptr [bx].irParamAddress,offset pBPB
mov word ptr [bx].irParamAddress+2,cs
mov [bx].rhStatus,DONE
pop es
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
popf
ret
assume ds:d_seg
cmd_init endp
;**************************************************************************
;
; CHECK DOS VERSION AND CAPABILITIES
;
;**************************************************************************
init_dos proc near
mov al,0
mov dos_drive,al
mov ax,4452h ; DR-DOS?
stc
int 21h
jc idos_notc
cmp ax,dx
jne idos_notc
cmp ah,10h
jne idos_notc ; Not installed
cmp al,67h ; DR-DOS version 6.0 ?
jne idos_notc ; If not, treat it like MS-DOS
les si,req_ptr
mov al,es:[si].irDriveNumber
add al,'A'
mov dos_drive,al
jmp idos_x
idos_notc:
les si,req_ptr
cmp byte ptr es:[si],16h ; Device number supported?
jbe idos_fail
les si,req_ptr
mov al,es:[si].irDriveNumber
add al,'A'
mov dos_drive,al
idos_x:
cmp dos_drive,'C' ; Is invalid drive?
jb idos_fail
cmp dos_drive,'Z'
jb idosx2
idos_fail:
stc
ret
idosx2:
clc
ret
init_dos endp
;**************************************************************************
;
; READ COMMAND LINE
;
; Return carry set if error
;**************************************************************************
init_read_cmdline proc near
push ds
les bx,req_ptr
lds si,es:[bx].irParamAddress ; Pointer to cmd line
assume ds:nothing
irc1: lodsb ; Skip over the driver name
cmp al,9 ;tab
je irc2
cmp al,' '
je irc2
ja irc1
jmp irc_eol
irc2:
irc_narg: call irc_skip_space
cmp al,' ' ; Every ctrl character ends
jb irc_eol
and al,11011111b ; Make lowercase to uppercase
cmp al,'A'
jb irc_syntax
cmp al,'Z'
ja irc_syntax
cmp byte ptr [si],':'
jne irc3
inc si ; Skip ':'
irc3:
mov cs:def_drive,al
jmp irc_narg
irc_syntax: mov dx,offset errs_syntax
stc
pop ds
ret
irc_eol: clc
pop ds
ret
init_read_cmdline endp
irc_skip_space proc near
ircs1: lodsb
cmp al,' '
je ircs1
cmp al,9 ;tab
je ircs1
ret
irc_skip_space endp
assume ds:d_seg
;**************************************************************************
;
; Initialization strings
;
;**************************************************************************
errs_syntax db 'SRDUMMY: Syntax error', 0Dh, 0Ah, 0Dh, 0Ah
db 'Syntax: SRDUMMY.SYS [d:]', 0Dh, 0Ah, 0Dh, 0Ah
db ' d:', 9, 'Drive that the next block device should go to.'
db 0Dh, 0Ah, '$'
errs_nodrive db 'SRDUMMY: This DOS version does not tell the drive '
db 'letter to device driver.', 0Dh, 0Ah
db ' Can not install.', 0Dh, 0Ah, 0Dh, 0Ah, '$'
s_sign_on db 0Dh, 0Ah, 'SRDISK dummy disk driver'
db ' version ', SRD_VERSION, '. '
db 'Copyright (c) 2005 Marko Kohtala.'
db 0Dh, 0Ah, '$'
;**************************************************************************
;
; A note for binary debuggers
;
;**************************************************************************
db 0Dh, 0Ah, "Copyright (c) 1992-2005 Marko Kohtala. "
db 0Dh, 0Ah, "Contact at 'kohtala@users.sourceforge.net'."
db 0Dh, 0Ah
d_seg ends
end