source: trunk/src/win32k/test/dosa.asm@ 10367

Last change on this file since 10367 was 3829, checked in by bird, 25 years ago

Early development.

File size: 7.3 KB
Line 
1; $Id: dosa.asm,v 1.1 2000-07-16 22:18:14 bird Exp $
2;
3; 16-bits Dos calls overloader
4;
5; Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
6;
7; Project Odin Software License can be found in LICENSE.TXT
8;
9 .386
10
11
12;
13; Include files
14;
15 include devsegdf.inc
16 include os2.inc
17 include devsym.inc
18
19
20;
21; Exported symbols
22;
23 public DOS16OPEN
24 public DOS16CLOSE
25 public DOS16DEVIOCTL
26
27
28;
29; extrns
30;
31 extrn _strategyAsm0:FAR
32 extrn _DOS16OPEN:FAR ;70
33 extrn _DOS16CLOSE:FAR ;59
34
35 extrn ThunkStack16To32:PROC
36 extrn ThunkStack32To16:PROC
37 extrn TKSSBase:PROC
38
39 extrn _TKSSBase16:DWORD
40 extrn _R0FlatCS16:WORD
41 extrn _R0FlatDS16:WORD
42
43DATA16 SEGMENT
44DATA16 ENDS
45
46
47
48CODE16 SEGMENT
49 ASSUME cs:CODE16, ds:DATA16
50
51hElf EQU 0fE1Fh ; Value of the elf handle
52
53;;
54; Fake opening of $elf.
55;
56; PASCAL convention: Parameters pushed left to right of C prototype.
57; We'll have to do the cleanup.
58;
59; @cproto APIRET APIENTRY DosOpen(
60; PSZ pszFname,
61; PHFILE phfOpen,
62; PUSHORT pusAction,
63; ULONG ulFSize,
64; USHORT usAttr,
65; USHORT fsOpenFlags,
66; USHORT fsOpenMode,
67; ULONG ulReserved);
68;
69; @returns
70; @param pszFname bp +1c dd
71; @param phfOpen bp +18 dd
72; @param pusAction bp +14 dd
73; @param ulFSize bp +10 dd
74; @param usAttr bp + e dw
75; @param fsOpenFlags bp + c dw
76; @param fsOpenMode bp + a dw
77; @param ulReserved bp + 6 dd
78;
79; @uses
80; @equiv
81; @time
82; @sketch
83; @status
84; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
85; @remark
86DOS16OPEN PROC FAR
87 ASSUME CS:CODE16, DS:NOTHING, ES:NOTHING, SS:NOTHING
88 push bp
89 mov bp, sp
90
91 ;
92 ; Is this an attempt to open the ELF device driver?
93 ;
94 push ds
95 push bx
96 xor ebx, ebx
97 lds bx, [bp + 1ch]
98 mov eax, ds:[ebx]
99 cmp eax, 'ved\' ;'\dev' assumes low-case!
100 jne do_notelf
101 mov eax, ds:[ebx+4]
102 cmp eax, 'fle\' ;'\elf'
103 jne do_notelf
104 mov eax, ds:[ebx+8]
105 cmp ax, '$' ; '$'\0
106 jnz do_notelf
107
108 ;
109 ; found filename string equal to "\dev\$elf".
110 ;
111 ; return phFile equal to Elf handle and pusAction set to 1 (FILE EXISTED).
112 ;
113 lds bx, [bp + 18h]
114 mov word ptr ds:[bx], hElf ; *phFile <- hElf
115 lds bx, [bp + 14h]
116 mov word ptr ds:[bx], 1 ; *pusAction <- File existed.
117
118do_ret:
119 ;
120 ; restore bx and ds and return successfully.
121 ;
122 pop bx
123 pop ds
124 xor eax, eax
125 leave
126 ret 01ah
127
128do_notelf:
129 push dword ptr [bp +01ch]
130 push dword ptr [bp +018h]
131 push dword ptr [bp +014h]
132 push dword ptr [bp +010h]
133 push word ptr [bp + 0eh]
134 push word ptr [bp + 0ch]
135 push word ptr [bp + 0ah]
136 push dword ptr [bp + 06h]
137 call far ptr _DOS16OPEN
138 pop bx
139 pop ds
140 leave
141 ret 01ah
142DOS16OPEN ENDP
143
144
145;;
146; Fake close of $elf
147; @cproto APIRET APIENTRY DosClose(HFILE hf);
148; @returns OS/2 return code. (NO_ERROR)
149; @param hFile bp + 6
150; @uses EAX
151; @status completly implemented.
152; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
153DOS16CLOSE PROC FAR
154 ASSUME CS:CODE16, DS:NOTHING, ES:NOTHING, SS:NOTHING
155 push bp
156 mov bp, sp
157
158 ;
159 ; Is it the elf handle?
160 ;
161 mov ax, [bp + 6]
162 cmp ax, hElf
163 jne dc_notelf
164 xor eax, eax
165 leave
166 ret 2
167
168dc_notelf:
169 push word ptr [bp + 6] ; can't jump to higher privilege
170 call _DOS16CLOSE
171 leave
172 ret 2
173DOS16CLOSE ENDP
174
175
176
177;;
178;
179; @cproto APIRET APIENTRY DosDevIOCtl(
180; PVOID pData,
181; PVOID pParms,
182; USHORT usFun,
183; USHORT usCategory,
184; HFILE hDev);
185; @returns
186; @param pData bp +10 dd
187; @param pParms bp + c dd
188; @param usFun bp + a dw
189; @param usCategory bp + 8 dw
190; @param hDev bp + 6 dw
191; @param
192; @uses eax
193; @sketch
194; @status completly implemented
195; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
196; @remark
197DOS16DEVIOCTL PROC FAR
198 ASSUME CS:CODE16, DS:NOTHING, ES:NOTHING, SS:NOTHING
199 LOCAL pkt:Packet
200
201 push bx
202 push es
203
204
205 ;
206 ; Check that it really is the elf handle.
207 ;
208 mov ax, word ptr [bp + 6]
209 cmp word ptr [bp + 6], hElf
210 jne ddioc_invalidhandle
211
212 ;
213 ; Then we'll have to call _strategyAsm0. But first will have to
214 ; build a request packet for this IOCtl
215 ;
216 mov pkt.PktLen, LENGenIOCTL ; PktLen db ? ; length in bytes of packet
217 mov pkt.PktUnit, 0 ; PktUnit db ? ; subunit number of block device
218 mov pkt.PktCmd, CMDGenIOCTL ; PktCmd db ? ; command code
219 mov pkt.PktStatus, 0 ; PktStatus dw ? ; status word
220 mov pkt.PktFlag, 0 ; PktFlag db ? ; disk driver internal flags
221 mov pkt.PktFlag+1, 0 ; db 3 dup(?) ; reserved
222 mov pkt.PktFlag+2, 0 ;
223 mov pkt.PktFlag+3, 0 ;
224 mov pkt.PktDevLink, 0 ; PktDevLink dd ? ; device multiple-request link
225 mov ax, [bp + 8]
226 mov byte ptr pkt.PktData + 0, al ; Category Code
227 mov ax, [bp + 0ah]
228 mov byte ptr pkt.PktData + 1, al ; Function code
229 mov eax, [bp + 0ch]
230 mov dword ptr pkt.PktData + 2, eax ; pointer to parameter packet
231 mov eax, [bp + 10h]
232 mov dword ptr pkt.PktData + 6, eax ; pointer to data packet
233 mov word ptr pkt.PktData + 10, 0 ; SFN of the driver.
234
235 ; do the call - who cleans up the stack?
236 mov bx, ss
237 mov es, bx
238 lea bx, pkt
239 ;call far ptr _strategyAsm0 ; why did this make it into a 16:32 call?
240 call far ptr CODE16:_strategyAsm0
241
242 ;
243 ; We'll check if the status to see wether it failed or not.
244 ;
245 test pkt.PktStatus, STERR
246 jnz ddioc_error
247 test pkt.PktStatus, STDON
248 jz ddioc_notdone
249 test pkt.PktStatus, STINTER
250 jnz ddioc_interchar
251 test pkt.PktStatus, STBUI
252 jnz ddioc_busy
253 xor eax, eax ; return NO_ERROR
254 jmp ddioc_ret
255
256ddioc_error:
257 mov ax, pkt.PktStatus
258 and ax, STECODE
259 jmp ddioc_ret
260
261ddioc_notdone:
262 mov eax, 31 ; ERROR_GEN_FAILURE
263 jmp ddioc_ret
264
265ddioc_interchar:
266 mov eax, 31 ; ERROR_GEN_FAILURE
267 jmp ddioc_ret
268
269ddioc_busy:
270 mov eax, 31 ; ERROR_GEN_FAILURE
271 jmp ddioc_ret
272
273ddioc_invalidhandle:
274 mov eax, 6 ; ERROR_INVALID_HANDLE
275 jmp ddioc_ret
276
277ddioc_ret:
278 pop es
279 pop bx
280 leave
281 ret 0eh
282DOS16DEVIOCTL ENDP
283
284
285
286CODE16 ENDS
287
288END
289
290
Note: See TracBrowser for help on using the repository browser.