-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDEV.INC
139 lines (103 loc) · 3.3 KB
/
DEV.INC
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
; Device Unit for file lister <C> 1992 Created by Dàrk Shàde
.CONST
DEVHeader db '\F ID Seg Attr Strat Int Name\n \n', 0
DEVEntry db '\7 %2h %4h %4h %4h %4h ', 0
DEVBlock db '%c: - %c:', 0
.CODE
; System Device
_sysdev STRUC
_sysNext dd ? ; Pointer to the next driver (ofs = -1 if last)
_sysAttr dw ? ; Device attributes
_sysStrat dw ? ; Device strategy
_sysInt dw ? ; Device interrupt
UNION
_sysDrives dw ? ; Number of Drivess supported (BLOCK device)
_sysName db 8 dup(?) ; Device driver name
ENDS
_sysdev ENDS
LoadDEV PROC
xor di, di
mov si, OFFSET DEVHeader
call TellFStr
mov ah, 52h
int 21h
add bx, 22h
push es
pop fs ; fs = Device Driver segment
mov si, bx
mov es, ScrSeg
xor cx, cx
ShowDEV: call TellDEV
; Load the next device in fs:si
push DWORD PTR fs:[si + OFFSET _sysdev._sysNext]
pop si
pop fs
cmp si, 0FFFFh
jne ShowDEV
jmp Quit
LoadDEV ENDP
; Procedure to write the device driver details
; @Input
; fs:si = Device driver header
; cx = Device indices (Start at 0)
; @Output
; cx = Next device indices
TellDEV PROC
LOCAL DEVCount: BYTE, BDEVCount: BYTE, DEVName: BYTE: 9 = AUTO_SIZE
push bp
mov bp, sp
sub sp, AUTO_SIZE
mov DEVCount, cl
mov BDEVCount, ch
push fs:[si + _sysdev._sysInt]
push fs:[si + _sysdev._sysStrat]
push fs:[si + _sysdev._sysAttr]
push fs
xor ch, ch
push cx
mov bx, sp
push si
mov si, OFFSET DEVEntry
call TellFStr
pop si
mov sp, bx
push si
push ds
; Device Name
test WORD PTR fs:[si + _sysdev._sysAttr], 08000h
jnz DevCharDev
; It's a logical device
; Increase the starting drive
mov al, BDEVCount
add al, 'A'
mov dl, al
add al, fs:[si + OFFSET _sysdev._sysDrives]
push ax
push dx
sub al, 'A'
mov BDEVCount, al
mov si, OFFSET DEVBlock
jmp DevNotDev
; It's a character device
DevCharDev:mov eax, fs:[si + OFFSET _sysdev._sysName]
mov edx, fs:[si + OFFSET _sysdev._sysName + 4]
mov si, OFFSET DEVName
mov DWORD PTR ss:[si], eax
mov DWORD PTR ss:[si + 4], edx
mov BYTE PTR ss:[si + 8], 0
mov ah, 3
push ss
pop ds
DevNotDev: mov bx, sp
call TellFStr
mov sp, bx
pop ds
pop si
call AdjustDI
mov cl, DEVCount
inc cl
mov ch, BDEVCount
mov sp, bp
pop bp
ret
TellDEV ENDP