VirtualBox

source: vbox/trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFA.asm@ 46563

Last change on this file since 46563 was 33540, checked in by vboxsync, 14 years ago

*: spelling fixes, thanks Timeless!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 46.8 KB
Line 
1; $Id: VBoxSFA.asm 33540 2010-10-28 09:27:05Z vboxsync $
2;; @file
3; VBoxSF - OS/2 Shared Folders, all assembly code (16 -> 32 thunking mostly).
4;
5
6;
7; Copyright (c) 2007 knut st. osmundsen <[email protected]>
8;
9; Permission is hereby granted, free of charge, to any person
10; obtaining a copy of this software and associated documentation
11; files (the "Software"), to deal in the Software without
12; restriction, including without limitation the rights to use,
13; copy, modify, merge, publish, distribute, sublicense, and/or sell
14; copies of the Software, and to permit persons to whom the
15; Software is furnished to do so, subject to the following
16; conditions:
17;
18; The above copyright notice and this permission notice shall be
19; included in all copies or substantial portions of the Software.
20;
21; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28; OTHER DEALINGS IN THE SOFTWARE.
29;
30
31
32;*******************************************************************************
33;* Header Files *
34;*******************************************************************************
35%define RT_INCL_16BIT_SEGMENTS
36%include "iprt/asmdefs.mac"
37%include "iprt/err.mac"
38%include "VBox/VBoxGuest.mac"
39
40
41;*******************************************************************************
42;* Defined Constants And Macros *
43;*******************************************************************************
44%define ERROR_NOT_SUPPORTED 50
45%define ERROR_INVALID_PARAMETER 87
46%define DevHlp_AttachDD 2ah
47
48;;
49; Prints a string to the VBox log port.
50%macro DEBUG_STR16 1
51%ifdef DEBUG
52segment DATA16
53%%my_dbg_str: db %1, 0ah, 0
54segment CODE16
55 push ax
56 mov ax, %%my_dbg_str
57 call NAME(dbgstr16)
58 pop ax
59%endif
60%endmacro
61
62
63%macro VBOXSF_EP16_BEGIN 2
64global %1
65%1:
66 DEBUG_STR16 {'VBoxSF: ', %2}
67
68%endmacro
69
70%macro VBOXSF_EP16_END 1
71global %1_EndProc
72%1_EndProc:
73%endmacro
74
75;;
76; Used to taking us to 32-bit and reserving a parameter frame.
77;
78; @param %1 The function name
79; @param %2 The number of bytes to reserve
80;
81%macro VBOXSF_TO_32 2
82 ; prologue
83 push ebp
84 mov ebp, esp ; bp
85 push ds ; bp - 2
86 push es ; bp - 4
87
88 ; Reserve the 32-bit parameter and align the stack on a 16 byte
89 ; boundary to make GCC really happy.
90 sub sp, %2
91 and sp, 0fff0h
92
93 ;jmp far dword NAME(%i %+ _32) wrt FLAT
94 db 066h
95 db 0eah
96 dd NAME(%1 %+ _32) ;wrt FLAT
97 dw TEXT32 wrt FLAT
98segment TEXT32
99GLOBALNAME %1 %+ _32
100 mov ax, DATA32 wrt FLAT
101 mov ds, ax
102 mov es, ax
103
104 call KernThunkStackTo32
105
106%endmacro VBOXSF_TO_32 1
107
108;;
109; The counter part to VBOXSF_TO_32
110;
111; @param %1 The function name
112;
113%macro VBOXSF_TO_16 1
114 push eax
115 call KernThunkStackTo16
116 pop eax
117
118 ;jmp far dword NAME(%1 %+ _16) wrt CODE16
119 db 066h
120 db 0eah
121 dw NAME(%1 %+ _16) wrt CODE16
122 dw CODE16
123segment CODE16
124GLOBALNAME %1 %+ _16
125
126 ; Epilogue
127 lea sp, [bp - 4h]
128 pop es
129 pop ds
130 mov esp, ebp
131 pop ebp
132%endmacro
133
134;;
135; Thunks the given 16:16 pointer to a flat pointer.
136;
137; @param %1 The negated ebp offset of the input.
138; @param %2 The esp offset of the output.
139; @users eax, edx, ecx
140;
141%macro VBOXSF_FARPTR_2_FLAT 2
142 movzx eax, word [ebp - (%1) + 2]
143 push eax
144 call KernSelToFlat
145 movzx edx, word [ebp - (%1)]
146 add eax, edx
147 mov [esp + (%2)], eax
148%endmacro
149
150;;
151; Thunks the given 16:16 struct sffsd pointer to a flat pointer.
152;
153; @param %1 The negated ebp offset of the input.
154; @param %2 The esp offset of the output.
155; @users eax, ecx
156;
157%macro VBOXSF_PSFFSD_2_FLAT 2
158 lds cx, [ebp - (%1)]
159 and ecx, 0ffffh
160 mov eax, dword [ecx]
161 mov cx, DATA32 wrt FLAT
162 mov [esp + (%2)], eax
163 mov ds, cx
164%endmacro
165
166
167;;
168; Thunks the given 16:16 struct cdfsd pointer to a flat pointer.
169;
170; @param %1 The negated ebp offset of the input.
171; @param %2 The esp offset of the output.
172; @users eax, ecx
173;
174%macro VBOXSF_PCDFSD_2_FLAT 2
175 lds cx, [ebp - (%1)]
176 and ecx, 0ffffh
177 mov eax, dword [ecx]
178 mov cx, DATA32 wrt FLAT
179 mov [esp + (%2)], eax
180 mov ds, cx
181%endmacro
182
183;;
184; Thunks the given 16:16 struct fsfsd pointer to a flat pointer.
185;
186; @param %1 The negated ebp offset of the input.
187; @param %2 The esp offset of the output.
188; @users eax, ecx
189;
190%macro VBOXSF_PFSFSD_2_FLAT 2
191 lds cx, [ebp - (%1)]
192 and ecx, 0ffffh
193 mov eax, dword [ecx]
194 mov cx, DATA32 wrt FLAT
195 mov [esp + (%2)], eax
196 mov ds, cx
197%endmacro
198
199
200
201;*******************************************************************************
202;* External Symbols *
203;*******************************************************************************
204segment CODE32
205extern KernThunkStackTo32
206extern KernThunkStackTo16
207extern KernSelToFlat
208segment CODE16
209extern FSH_FORCENOSWAP
210extern DOS16WRITE
211
212segment CODE32
213extern NAME(FS32_ALLOCATEPAGESPACE)
214extern NAME(FS32_ATTACH)
215extern NAME(FS32_CANCELLOCKREQUEST)
216extern NAME(FS32_CANCELLOCKREQUESTL)
217extern NAME(FS32_CHDIR)
218extern FS32_CHGFILEPTRL
219extern NAME(FS32_CLOSE)
220extern NAME(FS32_COMMIT)
221extern NAME(FS32_COPY)
222extern NAME(FS32_DELETE)
223extern NAME(FS32_DOPAGEIO)
224extern NAME(FS32_EXIT)
225extern NAME(FS32_FILEATTRIBUTE)
226extern NAME(FS32_FILEINFO)
227extern NAME(FS32_FILEIO)
228extern NAME(FS32_FILELOCKS)
229extern NAME(FS32_FILELOCKSL)
230extern NAME(FS32_FINDCLOSE)
231extern NAME(FS32_FINDFIRST)
232extern NAME(FS32_FINDFROMNAME)
233extern NAME(FS32_FINDNEXT)
234extern NAME(FS32_FINDNOTIFYCLOSE)
235extern NAME(FS32_FINDNOTIFYFIRST)
236extern NAME(FS32_FINDNOTIFYNEXT)
237extern NAME(FS32_FLUSHBUF)
238extern NAME(FS32_FSCTL)
239extern NAME(FS32_FSINFO)
240extern NAME(FS32_IOCTL)
241extern NAME(FS32_MKDIR)
242extern NAME(FS32_MOUNT)
243extern NAME(FS32_MOVE)
244extern NAME(FS32_NEWSIZEL)
245extern NAME(FS32_NMPIPE)
246extern NAME(FS32_OPENCREATE)
247extern NAME(FS32_OPENPAGEFILE)
248extern NAME(FS32_PATHINFO)
249extern NAME(FS32_PROCESSNAME)
250extern FS32_READ
251extern NAME(FS32_RMDIR)
252extern NAME(FS32_SETSWAP)
253extern NAME(FS32_SHUTDOWN)
254extern FS32_WRITE
255
256extern NAME(VBoxSFR0Init)
257
258
259
260;*******************************************************************************
261;* Global Variables *
262;*******************************************************************************
263segment DATA16
264
265;;
266; The file system name.
267global FS_NAME
268FS_NAME:
269 db 'VBOXSF',0
270
271;;
272; File system attributes
273; The 32-bit version is only used to indicate that this is a 32-bit file system.
274;
275%define FSA_REMOTE 0001h ; remote file system.
276%define FSA_UNC 0002h ; implements UNC.
277%define FSA_LOCK 0004h ; needs lock notification.
278%define FSA_LVL7 0008h ; accept level 7 (case preserving path request).
279%define FSA_PSVR 0010h ; (named) pipe server.
280%define FSA_LARGEFILE 0020h ; large file support.
281align 16
282global FS_ATTRIBUTE
283global FS32_ATTRIBUTE
284FS_ATTRIBUTE:
285FS32_ATTRIBUTE:
286 dd FSA_REMOTE + FSA_LARGEFILE ;+ FSA_LVL7 + FSA_LOCK
287
288;; 64-bit mask.
289; bit 0 - don't get the ring-0 spinlock.
290; bit 6 - don't get the subsystem ring-0 spinlock.
291global FS_MPSAFEFLAGS2
292FS_MPSAFEFLAGS2:
293 dd 0
294 dd 0
295
296;;
297; Set after VBoxSFR0Init16Bit has been called.
298GLOBALNAME g_fDoneRing0
299 db 0
300
301align 4
302;;
303; The device helper (IPRT expects this name).
304; (This is set by FS_INIT.)
305GLOBALNAME g_fpfnDevHlp
306 dd 0
307
308;;
309; Whether initialization should be verbose or quiet.
310GLOBALNAME g_fVerbose
311 db 1
312
313;; DEBUGGING DEBUGGING
314GLOBALNAME g_u32Info
315 dd 0
316
317;; Far pointer to DOS16WRITE (corrected set before called).
318; Just a 'temporary' hack to work around a wlink/nasm issue.
319GLOBALNAME g_fpfnDos16Write
320 dw DOS16WRITE
321 dw seg DOS16WRITE
322
323;;
324; The attach dd data.
325GLOBALNAME g_VBoxGuestAttachDD
326 dd 0
327 dw 0
328 dd 0
329 dw 0
330;;
331; The AttachDD name of the VBoxGuest.sys driver.
332GLOBALNAME g_szVBoxGuestName
333 db VBOXGUEST_DEVICE_NAME, 0
334;;
335; The VBoxGuest IDC connection data.
336GLOBALNAME g_VBoxGuestIDC
337 times VBGOS2IDC_size db 0
338
339;;
340; This must be present, we've got fixups against it.
341segment DATA32
342g_pfnDos16Write:
343 dd DOS16WRITE ; flat
344
345
346
347
348
349
350
351;
352;
353; 16-bit entry point thunking.
354; 16-bit entry point thunking.
355; 16-bit entry point thunking.
356;
357;
358segment CODE16
359
360
361;;
362; @cproto int FS_ALLOCATEPAGESPACE(PSFFSI psffsi, PVBOXSFFSD psffsd, ULONG cb, USHORT cbWantContig)
363VBOXSF_EP16_BEGIN FS_ALLOCATEPAGESPACE, 'FS_ALLOCATEPAGESPACE'
364VBOXSF_TO_32 FS_ALLOCATEPAGESPACE, 4*4
365 movzx ecx, word [ebp + 08h] ; cbWantContig
366 mov [esp + 3*4], ecx
367 mov edx, [ebp + 0ah] ; cb
368 mov [esp + 2*4], edx
369 VBOXSF_PSFFSD_2_FLAT 0eh, 1*4 ; psffsd
370 VBOXSF_FARPTR_2_FLAT 12h, 0*4 ; psffsi
371 call NAME(FS32_ALLOCATEPAGESPACE)
372VBOXSF_TO_16 FS_ALLOCATEPAGESPACE
373 retf 0eh
374VBOXSF_EP16_END FS_ALLOCATEPAGESPACE
375
376;;
377; @cproto int FS_ATTACH(USHORT flag, PCSZ pszDev, PVPFSD pvpfsd, PCDFSD pcdfsd, PBYTE pszParm, PUSHORT pcbParm)
378;
379VBOXSF_EP16_BEGIN FS_ATTACH, 'FS_ATTACH'
380 ;
381 ; Initialized ring-0 yet? (this is a likely first entry point)
382 ;
383 push ds
384 mov ax, DATA16
385 mov ds, ax
386 test byte [NAME(g_fDoneRing0)], 1
387 jnz .DoneRing0
388 call NAME(VBoxSFR0Init16Bit)
389.DoneRing0:
390 pop ds
391
392VBOXSF_TO_32 FS_ATTACH, 6*4
393 VBOXSF_FARPTR_2_FLAT 08h, 5*4 ; pcbParm
394 VBOXSF_FARPTR_2_FLAT 0ch, 4*4 ; pszParm
395 VBOXSF_FARPTR_2_FLAT 10h, 3*4 ; pcdfsd
396 VBOXSF_FARPTR_2_FLAT 14h, 2*4 ; pvpfsd
397 VBOXSF_FARPTR_2_FLAT 18h, 1*4 ; pszDev
398 movzx ecx, word [ebp + 1ch] ; fFlag
399 mov [esp], ecx
400 call NAME(FS32_ATTACH)
401VBOXSF_TO_16 FS_ATTACH
402 retf 16h
403VBOXSF_EP16_END FS_ATTACH
404
405
406;;
407; @cproto int FS_CANCELLOCKREQUEST(PSFFSI psffsi, PVBOXSFFSD psffsd, struct filelock far *pLockRange)
408VBOXSF_EP16_BEGIN FS_CANCELLOCKREQUEST, 'FS_CANCELLOCKREQUEST'
409VBOXSF_TO_32 FS_CANCELLOCKREQUEST, 3*4
410 VBOXSF_FARPTR_2_FLAT 08h, 2*4 ; pLockRange
411 VBOXSF_PSFFSD_2_FLAT 0ch, 1*4 ; psffsd
412 VBOXSF_FARPTR_2_FLAT 10h, 0*4 ; psffsi
413 call NAME(FS32_CANCELLOCKREQUEST)
414VBOXSF_TO_16 FS_CANCELLOCKREQUEST
415 retf 0ch
416VBOXSF_EP16_END FS_CANCELLOCKREQUEST
417
418
419;;
420; @cproto int FS_CANCELLOCKREQUESTL(PSFFSI psffsi, PVBOXSFFSD psffsd, struct filelockl far *pLockRange)
421VBOXSF_EP16_BEGIN FS_CANCELLOCKREQUESTL, 'FS_CANCELLOCKREQUESTL'
422VBOXSF_TO_32 FS_CANCELLOCKREQUESTL, 3*4
423 VBOXSF_FARPTR_2_FLAT 08h, 2*4 ; pLockRange
424 VBOXSF_PSFFSD_2_FLAT 0ch, 1*4 ; psffsd
425 VBOXSF_FARPTR_2_FLAT 10h, 0*4 ; psffsi
426 call NAME(FS32_CANCELLOCKREQUESTL)
427VBOXSF_TO_16 FS_CANCELLOCKREQUESTL
428 retf 0ch
429VBOXSF_EP16_END FS_CANCELLOCKREQUESTL
430
431
432;;
433; @cproto int FS_CHDIR(USHORT flag, PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszDir, USHORT iCurDirEnd)
434VBOXSF_EP16_BEGIN FS_CHDIR, 'FS_CHDIR'
435VBOXSF_TO_32 FS_CHDIR, 5*4
436 movzx ecx, word [ebp + 08h] ; iCurDirEnd
437 mov [esp + 4*4], ecx
438 VBOXSF_FARPTR_2_FLAT 0ah, 3*4 ; pszDir
439 VBOXSF_FARPTR_2_FLAT 0eh, 2*4 ; pcdfsd (use slow thunk here, see flag)
440 VBOXSF_FARPTR_2_FLAT 12h, 1*4 ; pcdfsi
441 movzx eax, word [ebp + 16h] ; flag
442 mov [esp], eax
443 call NAME(FS32_CHDIR)
444VBOXSF_TO_16 FS_CHDIR
445 retf 10h
446VBOXSF_EP16_END FS_CHDIR
447
448
449; @cproto int FS_CHGFILEPTR(PSFFSI psffsi, PVBOXSFFSD psffsd, LONG off, USHORT usMethod, USHORT IOflag)
450VBOXSF_EP16_BEGIN FS_CHGFILEPTR, 'FS_CHGFILEPTR'
451VBOXSF_TO_32 FS_CHGFILEPTR, 6*4
452 movzx ecx, word [ebp + 08h] ; IOflag
453 mov [esp + 5*4], ecx
454 movzx edx, word [ebp + 0ah] ; usMethod
455 mov [esp + 4*4], edx
456 mov eax, [ebp + 0ch] ; off
457 mov [esp + 2*4], eax
458 rol eax, 1 ; high dword - is there a better way than this?
459 and eax, 1
460 mov edx, 0ffffffffh
461 mul edx
462 mov [esp + 3*4], eax
463 VBOXSF_PSFFSD_2_FLAT 10h, 1*4 ; psffsd
464 VBOXSF_FARPTR_2_FLAT 14h, 0*4 ; psffsi
465 call FS32_CHGFILEPTRL
466VBOXSF_TO_16 FS_CHGFILEPTR
467 retf 10h
468VBOXSF_EP16_END FS_CHGFILEPTR
469
470
471;;
472; @cproto int FS_CLOSE(USHORT type, USHORT IOflag, PSFFSI psffsi, PVBOXSFFSD psffsd)
473;
474VBOXSF_EP16_BEGIN FS_CLOSE, 'FS_CLOSE'
475VBOXSF_TO_32 FS_CLOSE, 4*4
476 VBOXSF_PSFFSD_2_FLAT 08h, 3*4 ; psffsd
477 VBOXSF_FARPTR_2_FLAT 0ch, 2*4 ; psffsi
478 movzx ecx, word [ebp + 10h] ; IOflag
479 mov [esp + 1*4], ecx
480 movzx edx, word [ebp + 12h] ; type
481 mov [esp], edx
482 call NAME(FS32_CLOSE)
483VBOXSF_TO_16 FS_CLOSE
484 retf 0ch
485VBOXSF_EP16_END FS_CLOSE
486
487
488;;
489; @cproto int FS_COMMIT(USHORT type, USHORT IOflag, PSFFSI psffsi, PVBOXSFFSD psffsd)
490;
491VBOXSF_EP16_BEGIN FS_COMMIT, 'FS_COMMIT'
492VBOXSF_TO_32 FS_COMMIT, 4*4
493 VBOXSF_PSFFSD_2_FLAT 08h, 3*4 ; psffsd
494 VBOXSF_FARPTR_2_FLAT 0ch, 2*4 ; psffsi
495 movzx ecx, word [ebp + 10h] ; IOflag
496 mov [esp + 1*4], ecx
497 movzx edx, word [ebp + 12h] ; type
498 mov [esp], edx
499 call NAME(FS32_COMMIT)
500VBOXSF_TO_16 FS_COMMIT
501 retf 0ch
502VBOXSF_EP16_END FS_COMMIT
503
504;;
505; @cproto int FS_COPY(USHORT flag, PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszSrc, USHORT iSrcCurDirEnd
506; PCSZ pszDst, USHORT iDstCurDirEnd, USHORT nameType);
507VBOXSF_EP16_BEGIN FS_COPY, 'FS_COPY'
508VBOXSF_TO_32 FS_COPY, 8*4
509 movzx ecx, word [ebp + 08h] ; flag
510 mov [esp + 7*4], ecx
511 movzx edx, word [ebp + 0ah] ; iDstCurDirEnd
512 mov [esp + 6*4], edx
513 VBOXSF_FARPTR_2_FLAT 0ch, 5*4 ; pszDst
514 movzx eax, word [ebp + 10h] ; iSrcCurDirEnd
515 mov [esp + 4*4], eax
516 VBOXSF_FARPTR_2_FLAT 12h, 3*4 ; pszSrc
517 VBOXSF_PCDFSD_2_FLAT 16h, 2*4 ; psffsd
518 VBOXSF_FARPTR_2_FLAT 1ah, 1*4 ; psffsi
519 movzx ecx, word [ebp + 1eh] ; flag
520 mov [esp], ecx
521 call NAME(FS32_COPY)
522VBOXSF_TO_16 FS_COPY
523 retf 18h
524VBOXSF_EP16_END FS_COPY
525
526
527;;
528; @cproto int FS_DELETE(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszFile, USHORT iCurDirEnd);
529VBOXSF_EP16_BEGIN FS_DELETE, 'FS_DELETE'
530VBOXSF_TO_32 FS_DELETE, 4*4
531 movzx ecx, word [ebp + 08h] ; iCurDirEnd
532 mov [esp + 3*4], ecx
533 VBOXSF_FARPTR_2_FLAT 0ah, 2*4 ; pszFile
534 VBOXSF_PCDFSD_2_FLAT 0eh, 1*4 ; pcdfsd
535 VBOXSF_FARPTR_2_FLAT 12h, 0*4 ; pcdfsi
536 call NAME(FS32_DELETE)
537VBOXSF_TO_16 FS_DELETE
538 retf 0eh
539VBOXSF_EP16_END FS_DELETE
540
541
542;;
543; @cproto int FS_DOPAGEIO(PSFFSI psffsi, PVBOXSFFSD psffsd, struct PageCmdHeader far *pList)
544VBOXSF_EP16_BEGIN FS_DOPAGEIO, 'FS_DOPAGEIO'
545VBOXSF_TO_32 FS_DOPAGEIO, 3*4
546 VBOXSF_FARPTR_2_FLAT 08h, 2*4 ; pList
547 VBOXSF_PSFFSD_2_FLAT 0ch, 1*4 ; psffsd
548 VBOXSF_FARPTR_2_FLAT 10h, 0*4 ; psffsi
549 call NAME(FS32_DOPAGEIO)
550VBOXSF_TO_16 FS_DOPAGEIO
551 retf 0ch
552VBOXSF_EP16_END FS_DOPAGEIO
553
554;;
555; @cproto void FS_EXIT(USHORT uid, USHORT pid, USHORT pdb)
556VBOXSF_EP16_BEGIN FS_EXIT, 'FS_EXIT'
557 ;
558 ; Initialized ring-0 yet? (this is a likely first entry point)
559 ;
560 push ds
561 mov ax, DATA16
562 mov ds, ax
563 test byte [NAME(g_fDoneRing0)], 1
564 jnz .DoneRing0
565 call NAME(VBoxSFR0Init16Bit)
566.DoneRing0:
567 pop ds
568
569VBOXSF_TO_32 FS_EXIT, 3*4
570 movzx ecx, word [ebp + 08h] ; pdb
571 mov [esp + 2*4], ecx
572 movzx edx, word [ebp + 0ah] ; pib
573 mov [esp + 1*4], edx
574 movzx eax, word [ebp + 0ch] ; uid
575 mov [esp], eax
576 call NAME(FS32_EXIT)
577VBOXSF_TO_16 FS_EXIT
578 retf 6h
579VBOXSF_EP16_END FS_EXIT
580
581
582;;
583; @cproto int FS_FILEATTRIBUTE(USHORT flag, PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd, PUSHORT pAttr);
584;
585VBOXSF_EP16_BEGIN FS_FILEATTRIBUTE, 'FS_FILEATTRIBUTE'
586VBOXSF_TO_32 FS_FILEATTRIBUTE, 6*4
587 VBOXSF_FARPTR_2_FLAT 08h, 5*4 ; pAttr
588 movzx ecx, word [ebp + 0ch] ; iCurDirEnd
589 mov [esp + 4*4], ecx
590 VBOXSF_FARPTR_2_FLAT 0eh, 3*4 ; pszName
591 VBOXSF_PCDFSD_2_FLAT 12h, 2*4 ; pcdfsd
592 VBOXSF_FARPTR_2_FLAT 16h, 1*4 ; pcdfsi
593 movzx edx, word [ebp + 1ah] ; flag
594 mov [esp], edx
595 call NAME(FS32_FILEATTRIBUTE)
596VBOXSF_TO_16 FS_FILEATTRIBUTE
597 retf 14h
598VBOXSF_EP16_END FS_FILEATTRIBUTE
599
600
601;;
602; @cproto int FS_FILEINFO(USHORT flag, PSFFSI psffsi, PVBOXSFFSD psffsd, USHORT level,
603; PBYTE pData, USHORT cbData, USHORT IOflag);
604VBOXSF_EP16_BEGIN FS_FILEINFO, 'FS_FILEINFO'
605VBOXSF_TO_32 FS_FILEINFO, 7*4
606 movzx ecx, word [ebp + 08h] ; IOflag
607 mov [esp + 6*4], ecx
608 movzx edx, word [ebp + 0ah] ; cbData
609 mov [esp + 5*4], edx
610 VBOXSF_FARPTR_2_FLAT 0ch, 4*4 ; pData
611 movzx eax, word [ebp + 10h] ; level
612 mov [esp + 3*4], eax
613 VBOXSF_PSFFSD_2_FLAT 12h, 2*4 ; psffsd
614 VBOXSF_FARPTR_2_FLAT 16h, 1*4 ; psffsi
615 movzx ecx, word [ebp + 1ah] ; flag
616 mov [esp], ecx
617 call NAME(FS32_FILEINFO)
618VBOXSF_TO_16 FS_FILEINFO
619 retf 14h
620VBOXSF_EP16_END FS_FILEINFO
621
622
623;;
624; @cproto int FS_FILEIO(PSFFSI psffsi, PVBOXSFFSD psffsd, PBYTE pCmdList, USHORT cbCmdList,
625; PUSHORT poError, USHORT IOflag);
626VBOXSF_EP16_BEGIN FS_FILEIO, 'FS_FILEIO'
627VBOXSF_TO_32 FS_FILEIO, 6*4
628 movzx ecx, word [ebp + 08h] ; IOFlag
629 mov [esp + 5*4], ecx
630 VBOXSF_FARPTR_2_FLAT 0ah, 4*4 ; poError
631 movzx edx, word [ebp + 0eh] ; cbCmdList
632 mov [esp + 3*4], edx
633 VBOXSF_FARPTR_2_FLAT 10h, 2*4 ; pCmdList
634 VBOXSF_PSFFSD_2_FLAT 14h, 1*4 ; psffsd
635 VBOXSF_FARPTR_2_FLAT 18h, 0*4 ; psffsi
636 call NAME(FS32_FILEIO)
637VBOXSF_TO_16 FS_FILEIO
638 retf 14h
639VBOXSF_EP16_END FS_FILEIO
640
641
642;;
643; @cproto int FS_FILELOCKS(PSFFSI psffsi, PVBOXSFFSD psffsd, struct filelock far *pUnLockRange
644; struct filelock far *pLockRange, ULONG timeout, ULONG flags)
645VBOXSF_EP16_BEGIN FS_FILELOCKS, 'FS_FILELOCKS'
646VBOXSF_TO_32 FS_FILELOCKS, 6*4
647 mov ecx, [ebp + 08h] ; flags
648 mov [esp + 5*4], ecx
649 mov edx, [ebp + 0ch] ; timeout
650 mov [esp + 4*4], edx
651 VBOXSF_FARPTR_2_FLAT 10h, 3*4 ; pLockRange
652 VBOXSF_FARPTR_2_FLAT 14h, 2*4 ; pUnLockRange
653 VBOXSF_PSFFSD_2_FLAT 18h, 1*4 ; psffsd
654 VBOXSF_FARPTR_2_FLAT 1ch, 0*4 ; psffsi
655 call NAME(FS32_FILELOCKS)
656VBOXSF_TO_16 FS_FILELOCKS
657 retf 18h
658VBOXSF_EP16_END FS_FILELOCKS
659
660
661;;
662; @cproto int FS_FILELOCKSL(PSFFSI psffsi, PVBOXSFFSD psffsd, struct filelockl far *pUnLockRange
663; struct filelockl far *pLockRange, ULONG timeout, ULONG flags)
664VBOXSF_EP16_BEGIN FS_FILELOCKSL, 'FS_FILELOCKSL'
665VBOXSF_TO_32 FS_FILELOCKSL, 6*4
666 mov ecx, [ebp + 08h] ; flags
667 mov [esp + 5*4], ecx
668 mov edx, [ebp + 0ch] ; timeout
669 mov [esp + 4*4], edx
670 VBOXSF_FARPTR_2_FLAT 10h, 3*4 ; pLockRange
671 VBOXSF_FARPTR_2_FLAT 14h, 2*4 ; pUnLockRange
672 VBOXSF_PSFFSD_2_FLAT 18h, 1*4 ; psffsd
673 VBOXSF_FARPTR_2_FLAT 1ch, 0*4 ; psffsi
674 call NAME(FS32_FILELOCKS)
675VBOXSF_TO_16 FS_FILELOCKSL
676 retf 18h
677VBOXSF_EP16_END FS_FILELOCKSL
678
679
680;;
681; @cproto int FS_FINDCLOSE(PFSFSI pfsfsi, PVBOXSFFS pfsfsd);
682;
683VBOXSF_EP16_BEGIN FS_FINDCLOSE, 'FS_FINDCLOSE'
684VBOXSF_TO_32 FS_FINDCLOSE, 2*4
685 VBOXSF_PFSFSD_2_FLAT 08h, 1*4 ; pfsfsd
686 VBOXSF_FARPTR_2_FLAT 0ch, 0*4 ; pfsfsi
687 call NAME(FS32_FINDCLOSE)
688VBOXSF_TO_16 FS_FINDCLOSE
689 retf 8h
690VBOXSF_EP16_END FS_FINDCLOSE
691
692
693;;
694; @cproto int FS_FINDFIRST(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd, USHORT attr,
695; PFSFSI pfsfsi, PVBOXSFFS pfsfsd, PBYTE pbData, USHORT cbData, PUSHORT pcMatch,
696; USHORT level, USHORT flags);
697;
698VBOXSF_EP16_BEGIN FS_FINDFIRST, 'FS_FINDFIRST'
699VBOXSF_TO_32 FS_FINDFIRST, 12*4
700 movzx ecx, word [ebp + 08h] ; flags
701 mov [esp + 11*4], ecx
702 movzx edx, word [ebp + 0ah] ; level
703 mov [esp + 10*4], edx
704 VBOXSF_FARPTR_2_FLAT 0ch, 9*4 ; pcMatch
705 movzx eax, word [ebp + 10h] ; cbData
706 mov [esp + 8*4], eax
707 VBOXSF_FARPTR_2_FLAT 12h, 7*4 ; pbData
708 VBOXSF_FARPTR_2_FLAT 16h, 6*4 ; pfsfsd
709 VBOXSF_FARPTR_2_FLAT 1ah, 5*4 ; pfsfsi
710 movzx ecx, word [ebp + 1eh] ; attr
711 mov [esp + 4*4], ecx
712 movzx edx, word [ebp + 20h] ; iCurDirEnd
713 mov [esp + 3*4], edx
714 VBOXSF_FARPTR_2_FLAT 22h, 2*4 ; pszName
715 VBOXSF_PCDFSD_2_FLAT 26h, 1*4 ; pcdfsd
716 VBOXSF_FARPTR_2_FLAT 2ah, 0*4 ; pcdfsi
717 call NAME(FS32_FINDFIRST)
718VBOXSF_TO_16 FS_FINDFIRST
719 retf 26h
720VBOXSF_EP16_END FS_FINDFIRST
721
722
723;;
724; @cproto int FS_FINDFROMNAME(PFSFSI pfsfsi, PVBOXSFFS pfsfsd, PBYTE pbData, USHORT cbData, PUSHORT pcMatch,
725; USHORT level, ULONG position, PCSZ pszName, USHORT flag)
726;
727VBOXSF_EP16_BEGIN FS_FINDFROMNAME, 'FS_FINDFROMNAME'
728VBOXSF_TO_32 FS_FINDFROMNAME, 9*4
729 movzx ecx, word [ebp + 08h] ; flags
730 mov [esp + 8*4], ecx
731 VBOXSF_FARPTR_2_FLAT 0ah, 7*4 ; pszName
732 mov edx, [ebp + 0eh] ; position
733 mov [esp + 6*4], edx
734 movzx eax, word [ebp + 12h] ; level
735 mov [esp + 5*4], eax
736 VBOXSF_FARPTR_2_FLAT 14h, 4*4 ; pcMatch
737 movzx eax, word [ebp + 18h] ; cbData
738 mov [esp + 3*4], eax
739 VBOXSF_FARPTR_2_FLAT 1ah, 2*4 ; pbData
740 VBOXSF_PFSFSD_2_FLAT 1eh, 1*4 ; pfsfsd
741 VBOXSF_FARPTR_2_FLAT 22h, 0*4 ; pfsfsi
742 call NAME(FS32_FINDFROMNAME)
743VBOXSF_TO_16 FS_FINDFROMNAME
744 retf 1eh
745VBOXSF_EP16_END FS_FINDFROMNAME
746
747
748;;
749; @cproto int FS_FINDNEXT(PFSFSI pfsfsi, PVBOXSFFS pfsfsd, PBYTE pbData, USHORT cbData, PUSHORT pcMatch,
750; USHORT level, USHORT flag)
751;
752VBOXSF_EP16_BEGIN FS_FINDNEXT, 'FS_FINDNEXT'
753VBOXSF_TO_32 FS_FINDNEXT, 7*4
754 movzx ecx, word [ebp + 08h] ; flags
755 mov [esp + 6*4], ecx
756 movzx eax, word [ebp + 0ah] ; level
757 mov [esp + 5*4], eax
758 VBOXSF_FARPTR_2_FLAT 0ch, 4*4 ; pcMatch
759 movzx eax, word [ebp + 10h] ; cbData
760 mov [esp + 3*4], eax
761 VBOXSF_FARPTR_2_FLAT 12h, 2*4 ; pbData
762 VBOXSF_PFSFSD_2_FLAT 16h, 1*4 ; pfsfsd
763 VBOXSF_FARPTR_2_FLAT 1ah, 0*4 ; pfsfsi
764 call NAME(FS32_FINDNEXT)
765VBOXSF_TO_16 FS_FINDNEXT
766 retf 16h
767VBOXSF_EP16_END FS_FINDNEXT
768
769
770;;
771; @cproto int FS_FINDNOTIFYCLOSE(USHORT handle);
772;
773VBOXSF_EP16_BEGIN FS_FINDNOTIFYCLOSE, 'FS_FINDNOTIFYCLOSE'
774VBOXSF_TO_32 FS_FINDNOTIFYCLOSE, 1*4
775 movzx ecx, word [ebp + 08h] ; handle
776 mov [esp], ecx
777 call NAME(FS32_FINDNOTIFYCLOSE)
778VBOXSF_TO_16 FS_FINDNOTIFYCLOSE
779 retf 2h
780VBOXSF_EP16_END FS_FINDNOTIFYCLOSE
781
782
783;;
784; @cproto int FS_FINDNOTIFYFIRST(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd, USHORT attr,
785; PUSHORT pHandle, PBYTE pbData, USHORT cbData, PUSHORT pcMatch,
786; USHORT level, USHORT flags);
787;
788VBOXSF_EP16_BEGIN FS_FINDNOTIFYFIRST, 'FS_FINDNOTIFYFIRST'
789VBOXSF_TO_32 FS_FINDNOTIFYFIRST, 11*4
790 movzx ecx, word [ebp + 08h] ; flags
791 mov [esp + 10*4], ecx
792 movzx edx, word [ebp + 0ah] ; level
793 mov [esp + 9*4], edx
794 VBOXSF_FARPTR_2_FLAT 0ch, 8*4 ; pcMatch
795 movzx eax, word [ebp + 10h] ; cbData
796 mov [esp + 7*4], eax
797 VBOXSF_FARPTR_2_FLAT 12h, 6*4 ; pbData
798 VBOXSF_FARPTR_2_FLAT 16h, 5*4 ; pHandle
799 movzx ecx, word [ebp + 1ah] ; attr
800 mov [esp + 4*4], ecx
801 movzx edx, word [ebp + 1ch] ; iCurDirEnd
802 mov [esp + 3*4], edx
803 VBOXSF_FARPTR_2_FLAT 1eh, 2*4 ; pszName
804 VBOXSF_PCDFSD_2_FLAT 22h, 1*4 ; pcdfsd
805 VBOXSF_FARPTR_2_FLAT 26h, 0*4 ; pcdfsi
806 call NAME(FS32_FINDNOTIFYFIRST)
807VBOXSF_TO_16 FS_FINDNOTIFYFIRST
808 retf 22h
809VBOXSF_EP16_END FS_FINDNOTIFYFIRST
810
811
812;;
813; @cproto int FS_FINDNOTIFYNEXT(USHORT handle, PBYTE pbData, USHORT cbData, PUSHORT pcMatch,
814; USHORT level, ULONG timeout)
815;
816VBOXSF_EP16_BEGIN FS_FINDNOTIFYNEXT, 'FS_FINDNOTIFYNEXT'
817VBOXSF_TO_32 FS_FINDNOTIFYNEXT, 6*4
818 mov ecx, [ebp + 08h] ; timeout
819 mov [esp + 5*4], ecx
820 movzx edx, word [ebp + 0ch] ; level
821 mov [esp + 4*4], edx
822 VBOXSF_FARPTR_2_FLAT 0eh, 3*4 ; pcMatch
823 movzx eax, word [ebp + 12h] ; cbData
824 mov [esp + 2*4], eax
825 VBOXSF_FARPTR_2_FLAT 14h, 1*4 ; pbData
826 movzx ecx, word [ebp + 18h] ; handle
827 mov [esp], ecx
828 call NAME(FS32_FINDNOTIFYNEXT)
829VBOXSF_TO_16 FS_FINDNOTIFYNEXT
830 retf 12h
831VBOXSF_EP16_END FS_FINDNOTIFYNEXT
832
833
834;; @cproto int FS_FLUSHBUF(USHORT hVPB, USHORT flag);
835VBOXSF_EP16_BEGIN FS_FLUSHBUF, 'FS_FLUSHBUF'
836VBOXSF_TO_32 FS_FLUSHBUF, 2*4
837 movzx edx, word [ebp + 08h] ; flag
838 mov [esp + 1*4], edx
839 movzx eax, word [ebp + 0ch] ; hVPB
840 mov [esp + 0*4], eax
841 call NAME(FS32_FLUSHBUF)
842VBOXSF_TO_16 FS_FLUSHBUF
843 retf 4h
844VBOXSF_EP16_END FS_FLUSHBUF
845
846
847;; @cproto int FS_FSCTL(union argdat far *pArgdat, USHORT iArgType, USHORT func,
848; PVOID pParm, USHORT lenParm, PUSHORT plenParmIO,
849; PVOID pData, USHORT lenData, PUSHORT plenDataIO);
850VBOXSF_EP16_BEGIN FS_FSCTL, 'FS_FSCTL'
851 ;
852 ; Initialized ring-0 yet? (this is a likely first entry point)
853 ;
854 push ds
855 mov ax, DATA16
856 mov ds, ax
857 test byte [NAME(g_fDoneRing0)], 1
858 jnz .DoneRing0
859 call NAME(VBoxSFR0Init16Bit)
860.DoneRing0:
861 pop ds
862
863VBOXSF_TO_32 FS_FSCTL, 9*4
864 VBOXSF_FARPTR_2_FLAT 08h, 8*4 ; plenDataIO
865 movzx ecx, word [ebp + 0ch] ; lenData
866 mov [esp + 7*4], ecx
867 VBOXSF_FARPTR_2_FLAT 0eh, 6*4 ; pData
868 VBOXSF_FARPTR_2_FLAT 12h, 5*4 ; plenDataIO
869 movzx ecx, word [ebp + 16h] ; lenData
870 mov [esp + 4*4], ecx
871 VBOXSF_FARPTR_2_FLAT 18h, 3*4 ; pData
872 movzx edx, word [ebp + 1ch] ; func
873 mov [esp + 2*4], edx
874 movzx eax, word [ebp + 1eh] ; iArgType
875 mov [esp + 1*4], eax
876 VBOXSF_FARPTR_2_FLAT 20h, 0*4 ; pArgdat
877 call NAME(FS32_FSCTL)
878VBOXSF_TO_16 FS_FSCTL
879 retf 1ch
880VBOXSF_EP16_END FS_FSCTL
881
882
883;; @cproto int FS_FSINFO(USHORT flag, USHORT hVPB, PBYTE pbData, USHORT cbData, USHORT level)
884VBOXSF_EP16_BEGIN FS_FSINFO, 'FS_FSINFO'
885VBOXSF_TO_32 FS_FSINFO, 5*4
886 movzx ecx, word [ebp + 08h] ; level
887 mov [esp + 10h], ecx
888 movzx edx, word [ebp + 0ah] ; cbData
889 mov [esp + 0ch], edx
890 VBOXSF_FARPTR_2_FLAT 0ch, 2*4 ; pbData
891 movzx edx, word [ebp + 10h] ; hVPB
892 mov [esp], edx
893 movzx eax, word [ebp + 12h] ; flag
894 mov [esp], eax
895 call NAME(FS32_FSINFO)
896VBOXSF_TO_16 FS_FSINFO
897 retf 14h
898VBOXSF_EP16_END FS_FSINFO
899
900
901;;
902; @cproto int FS_IOCTL(PSFFSI psffsi, PVBOXSFFSD psffsd, USHORT cat, USHORT func,
903; PVOID pParm, USHORT lenParm, PUSHORT plenParmIO,
904; PVOID pData, USHORT lenData, PUSHORT plenDataIO);
905VBOXSF_EP16_BEGIN FS_IOCTL, 'FS_IOCTL'
906VBOXSF_TO_32 FS_IOCTL, 10*4
907 VBOXSF_FARPTR_2_FLAT 08h, 9*4 ; plenDataIO
908 movzx ecx, word [ebp + 0ch] ; lenData
909 mov [esp + 8*4], ecx
910 VBOXSF_FARPTR_2_FLAT 0eh, 7*4 ; pData
911 VBOXSF_FARPTR_2_FLAT 12h, 6*4 ; plenDataIO
912 movzx ecx, word [ebp + 16h] ; lenData
913 mov [esp + 5*4], ecx
914 VBOXSF_FARPTR_2_FLAT 18h, 4*4 ; pData
915 movzx edx, word [ebp + 1ch] ; cat
916 mov [esp + 3*4], edx
917 movzx eax, word [ebp + 1eh] ; func
918 mov [esp + 2*4], eax
919 VBOXSF_PSFFSD_2_FLAT 20h, 1*4 ; psffsd
920 VBOXSF_FARPTR_2_FLAT 24h, 0*4 ; pData
921 call NAME(FS32_IOCTL)
922VBOXSF_TO_16 FS_IOCTL
923 retf 20h
924VBOXSF_EP16_END FS_IOCTL
925
926
927;;
928; @cproto int FS_MKDIR(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd,
929; PBYTE pEABuf, USHORT flag);
930VBOXSF_EP16_BEGIN FS_MKDIR, 'FS_MKDIR'
931VBOXSF_TO_32 FS_MKDIR, 6*4
932 movzx ecx, word [ebp + 08h] ; flag
933 mov [esp + 5*4], ecx
934 VBOXSF_FARPTR_2_FLAT 0ah, 4*4 ; pEABuf
935 movzx edx, word [ebp + 0eh] ; iCurDirEnd
936 mov [esp + 3*4], edx
937 VBOXSF_FARPTR_2_FLAT 10h, 2*4 ; pszName
938 VBOXSF_PCDFSD_2_FLAT 14h, 1*4 ; pcdfsd
939 VBOXSF_FARPTR_2_FLAT 18h, 0*4 ; pcdfsi
940 call NAME(FS32_MKDIR)
941VBOXSF_TO_16 FS_MKDIR
942 retf 14h
943VBOXSF_EP16_END FS_MKDIR
944
945
946;;
947; @cproto int FS_MOUNT(USHORT flag, PVPFSI pvpfsi, PVBOXSFVP pvpfsd, USHORT hVPB, PCSZ pszBoot)
948VBOXSF_EP16_BEGIN FS_MOUNT, 'FS_MOUNT'
949 ;
950 ; Initialized ring-0 yet? (this is a likely first entry point)
951 ;
952 push ds
953 mov ax, DATA16
954 mov ds, ax
955 test byte [NAME(g_fDoneRing0)], 1
956 jnz .DoneRing0
957 call NAME(VBoxSFR0Init16Bit)
958.DoneRing0:
959 pop ds
960
961VBOXSF_TO_32 FS_MOUNT, 5*4
962 VBOXSF_FARPTR_2_FLAT 08h, 4*4 ; pszBoot
963 movzx ecx, word [ebp + 0ch] ; hVPB
964 mov [esp + 3*4], ecx
965 VBOXSF_FARPTR_2_FLAT 0eh, 2*4 ; pvpfsd
966 VBOXSF_FARPTR_2_FLAT 12h, 1*4 ; pvpfsi
967 movzx ecx, word [ebp + 16h] ; flag
968 mov [esp], ecx
969 call NAME(FS32_MOUNT)
970VBOXSF_TO_16 FS_MOUNT
971 retf 10h
972VBOXSF_EP16_END FS_MOUNT
973
974
975;;
976; @cproto int FS_MOVE(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszSrc, USHORT iSrcCurDirEnd
977; PCSZ pszDst, USHORT iDstCurDirEnd, USHORT type)
978VBOXSF_EP16_BEGIN FS_MOVE, 'FS_MOVE'
979VBOXSF_TO_32 FS_MOVE, 7*4
980 movzx ecx, word [ebp + 08h] ; type
981 mov [esp + 6*4], ecx
982 movzx edx, word [ebp + 0ah] ; iDstCurDirEnd
983 mov [esp + 5*4], edx
984 VBOXSF_FARPTR_2_FLAT 0ch, 4*4 ; pszDst
985 movzx eax, word [ebp + 10h] ; iSrcCurDirEnd
986 mov [esp + 3*4], eax
987 VBOXSF_FARPTR_2_FLAT 12h, 2*4 ; pszSrc
988 VBOXSF_PCDFSD_2_FLAT 16h, 1*4 ; psffsd
989 VBOXSF_FARPTR_2_FLAT 1ah, 0*4 ; psffsi
990 call NAME(FS32_MOVE)
991VBOXSF_TO_16 FS_MOVE
992 retf 16h
993VBOXSF_EP16_END FS_MOVE
994
995
996;;
997; @cproto int FS_NEWSIZE(PSFFSI psffsi, PVBOXSFFSD psffsd, ULONG cbFile, USHORT IOflag);
998VBOXSF_EP16_BEGIN FS_NEWSIZE, 'FS_NEWSIZE'
999VBOXSF_TO_32 FS_NEWSIZE, 5*4 ; thunking to longlong edition.
1000 movzx ecx, word [ebp + 08h] ; IOflag
1001 mov [esp + 4*4], ecx
1002 mov eax, [ebp + 0ah] ; cbFile (ULONG -> LONGLONG)
1003 mov dword [esp + 3*4], 0
1004 mov [esp + 2*4], eax
1005 VBOXSF_PSFFSD_2_FLAT 0eh, 1*4 ; psffsd
1006 VBOXSF_FARPTR_2_FLAT 12h, 0*4 ; psffsi
1007 call NAME(FS32_NEWSIZEL)
1008VBOXSF_TO_16 FS_NEWSIZE
1009 retf 0eh
1010VBOXSF_EP16_END FS_NEWSIZE
1011
1012
1013;;
1014; @cproto int FS_NEWSIZEL(PSFFSI psffsi, PVBOXSFFSD psffsd, LONGLONG cbFile, USHORT IOflag);
1015VBOXSF_EP16_BEGIN FS_NEWSIZEL, 'FS_NEWSIZEL'
1016VBOXSF_TO_32 FS_NEWSIZEL, 5*4
1017 movzx ecx, word [ebp + 08h] ; IOflag
1018 mov [esp + 4*4], ecx
1019 mov eax, [ebp + 0ah] ; cbFile
1020 mov edx, [ebp + 0eh]
1021 mov [esp + 3*4], edx
1022 mov [esp + 2*4], eax
1023 VBOXSF_PSFFSD_2_FLAT 12h, 1*4 ; psffsd
1024 VBOXSF_FARPTR_2_FLAT 16h, 0*4 ; psffsi
1025 call NAME(FS32_NEWSIZEL)
1026VBOXSF_TO_16 FS_NEWSIZEL
1027 retf 12h
1028VBOXSF_EP16_END FS_NEWSIZEL
1029
1030
1031;;
1032; @cproto int FS_NMPIPE(PSFFSI psffsi, PVBOXSFFSD psffsd, USHORT OpType, union npoper far *pOpRec,
1033; PBYTE pData, PCSZ pszName);
1034VBOXSF_EP16_BEGIN FS_NMPIPE, 'FS_NMPIPE'
1035VBOXSF_TO_32 FS_NMPIPE, 6*4
1036 VBOXSF_FARPTR_2_FLAT 08h, 5*4 ; pszName
1037 VBOXSF_FARPTR_2_FLAT 0ch, 4*4 ; pData
1038 VBOXSF_FARPTR_2_FLAT 10h, 3*4 ; pOpRec
1039 movzx ecx, word [ebp + 14h] ; OpType
1040 mov [esp + 2*4], ecx
1041 VBOXSF_FARPTR_2_FLAT 16h, 1*4 ; psffsd (take care...)
1042 VBOXSF_FARPTR_2_FLAT 1ah, 0*4 ; psffsi
1043 call NAME(FS32_NMPIPE)
1044VBOXSF_TO_16 FS_NMPIPE
1045 retf 16h
1046VBOXSF_EP16_END FS_NMPIPE
1047
1048
1049;;
1050; @cproto int FS_OPENCREATE(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd,
1051; PSFFSI psffsi, PVBOXSFFSD psffsd, ULONG ulOpenMode, USHORT usOpenFlag,
1052; PUSHORT pusAction, USHORT usAttr, PBYTE pcEABuf, PUSHORT pfgenflag);
1053VBOXSF_EP16_BEGIN FS_OPENCREATE, 'FS_OPENCREATE'
1054VBOXSF_TO_32 FS_OPENCREATE, 12*4
1055 VBOXSF_FARPTR_2_FLAT 08h, 11*4 ; pfgenflag
1056 VBOXSF_FARPTR_2_FLAT 0ch, 10*4 ; pcEABuf
1057 movzx ecx, word [ebp + 10h] ; usAttr
1058 mov [esp + 9*4], ecx
1059 VBOXSF_FARPTR_2_FLAT 12h, 8*4 ; pusAction
1060 movzx edx, word [ebp + 16h] ; usOpenFlag
1061 mov [esp + 7*4], edx
1062 mov eax, [ebp + 18h] ; ulOpenMode
1063 mov [esp + 6*4], eax
1064 VBOXSF_FARPTR_2_FLAT 1ch, 5*4 ; psffsd (new, no short cuts)
1065 VBOXSF_FARPTR_2_FLAT 20h, 4*4 ; psffsi
1066 movzx ecx, word [ebp + 24h] ; iCurDirEnd
1067 mov [esp + 3*4], ecx
1068 VBOXSF_FARPTR_2_FLAT 26h, 2*4 ; pszName
1069 VBOXSF_PCDFSD_2_FLAT 2ah, 1*4 ; pcdfsd
1070 VBOXSF_FARPTR_2_FLAT 2eh, 0*4 ; pcdfsi
1071 call NAME(FS32_OPENCREATE)
1072VBOXSF_TO_16 FS_OPENCREATE
1073 retf 42
1074VBOXSF_EP16_END FS_OPENCREATE
1075
1076
1077;;
1078; @cproto int FS_OPENPAGEFILE(PULONG pFlag, PULONG pcMaxReq, PCSZ pszName, PSFFSI psffsi, PVBOXSFFSD psffsd,
1079; USHORT ulOpenMode, USHORT usOpenFlag, USHORT usAttr, ULONG Reserved)
1080VBOXSF_EP16_BEGIN FS_OPENPAGEFILE, 'FS_OPENPAGEFILE'
1081VBOXSF_TO_32 FS_OPENPAGEFILE, 9*4
1082 mov ecx, [ebp + 08h] ; Reserved
1083 mov [esp + 8*4], ecx
1084 movzx edx, word [ebp + 0ch] ; usAttr
1085 mov [esp + 7*4], edx
1086 movzx eax, word [ebp + 0eh] ; usOpenFlag
1087 mov [esp + 6*4], eax
1088 movzx ecx, word [ebp + 10h] ; usOpenMode
1089 mov [esp + 5*4], ecx
1090 VBOXSF_FARPTR_2_FLAT 12h, 4*4 ; psffsd (new, no short cuts)
1091 VBOXSF_FARPTR_2_FLAT 16h, 3*4 ; psffsi
1092 VBOXSF_FARPTR_2_FLAT 1ah, 2*4 ; pszName
1093 VBOXSF_FARPTR_2_FLAT 1eh, 1*4 ; pcMaxReq
1094 VBOXSF_FARPTR_2_FLAT 22h, 0*4 ; pFlag
1095 call NAME(FS32_OPENPAGEFILE)
1096VBOXSF_TO_16 FS_OPENPAGEFILE
1097 retf 1eh
1098VBOXSF_EP16_END FS_OPENPAGEFILE
1099
1100
1101;;
1102; @cproto int FS_PATHINFO(USHORT flag, PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnt,
1103; USHORT level, PBYTE pData, USHORT cbData);
1104VBOXSF_EP16_BEGIN FS_PATHINFO, 'FS_PATHINFO'
1105VBOXSF_TO_32 FS_PATHINFO, 8*4
1106 movzx ecx, word [ebp + 08h] ; cbData
1107 mov [esp + 7*4], ecx
1108 VBOXSF_FARPTR_2_FLAT 0ah, 6*4 ; pData
1109 movzx edx, word [ebp + 0eh] ; level
1110 mov [esp + 5*4], edx
1111 movzx eax, word [ebp + 10h] ; iCurDirEnd
1112 mov [esp + 4*4], eax
1113 VBOXSF_FARPTR_2_FLAT 12h, 3*4 ; pszName
1114 VBOXSF_PCDFSD_2_FLAT 16h, 2*4 ; pcdfsd
1115 VBOXSF_FARPTR_2_FLAT 1ah, 1*4 ; pcdfsi
1116 movzx edx, word [ebp + 1eh] ; flag
1117 mov [esp], edx
1118 call NAME(FS32_PATHINFO)
1119VBOXSF_TO_16 FS_PATHINFO
1120 retf 18h
1121VBOXSF_EP16_END FS_PATHINFO
1122
1123
1124;; @cproto int FS_PROCESSNAME(PSZ pszName);
1125VBOXSF_EP16_BEGIN FS_PROCESSNAME, 'FS_PROCESSNAME'
1126VBOXSF_TO_32 FS_PROCESSNAME, 1*4
1127 VBOXSF_FARPTR_2_FLAT 08h, 0*4 ; pszName
1128 call NAME(FS32_PROCESSNAME)
1129VBOXSF_TO_16 FS_PROCESSNAME
1130 retf 4h
1131VBOXSF_EP16_END FS_PROCESSNAME
1132
1133
1134;;
1135; @cproto int FS_READ(PSFFSI psffsi, PVBOXSFFSD psffsd, PBYTE pbData, PUSHORT pcbData, USHORT IOflag)
1136VBOXSF_EP16_BEGIN FS_READ, 'FS_READ'
1137VBOXSF_TO_32 FS_READ, 6*4 ; extra local for ULONG cbDataTmp.
1138 movzx ecx, word [ebp + 08h] ; IOflag
1139 mov [esp + 4*4], ecx
1140 les dx, [ebp + 0ah] ; cbDataTmp = *pcbData;
1141 movzx edx, dx
1142 lea ecx, [esp + 5*4] ; pcbData = &cbDataTmp
1143 movzx eax, word [es:edx]
1144 mov [ecx], eax
1145 mov [esp + 3*4], ecx
1146 mov edx, DATA32
1147 mov es, edx
1148 VBOXSF_FARPTR_2_FLAT 0eh, 2*4 ; pbData
1149 VBOXSF_PSFFSD_2_FLAT 12h, 1*4 ; psffsd
1150 VBOXSF_FARPTR_2_FLAT 16h, 0*4 ; psffsi
1151 call FS32_READ
1152
1153 les dx, [ebp + 0ah] ; *pcbData = cbDataTmp;
1154 movzx edx, dx
1155 mov cx, [esp + 5*4]
1156 mov [es:edx], cx
1157 mov edx, DATA32
1158 mov es, edx
1159
1160VBOXSF_TO_16 FS_READ
1161
1162 pop es
1163 retf 12h
1164VBOXSF_EP16_END FS_READ
1165
1166
1167;;
1168; @cproto int FS_RMDIR(PCDFSI pcdfsi, PVBOXSFCD pcdfsd, PCSZ pszName, USHORT iCurDirEnd);
1169;
1170VBOXSF_EP16_BEGIN FS_RMDIR, 'FS_RMDIR'
1171VBOXSF_TO_32 FS_RMDIR, 4*4
1172 movzx edx, word [ebp + 08h] ; iCurDirEnd
1173 mov [esp + 3*4], edx
1174 VBOXSF_FARPTR_2_FLAT 0ah, 2*4 ; pszName
1175 VBOXSF_PCDFSD_2_FLAT 0eh, 1*4 ; pcdfsd
1176 VBOXSF_FARPTR_2_FLAT 12h, 0*4 ; pcdfsi
1177 call NAME(FS32_RMDIR)
1178VBOXSF_TO_16 FS_RMDIR
1179 retf 14h
1180VBOXSF_EP16_END FS_RMDIR
1181
1182
1183;;
1184; @cproto int FS_SETSWAP(PSFFSI psffsi, PVBOXSFFSD psffsd);
1185;
1186VBOXSF_EP16_BEGIN FS_SETSWAP, 'FS_SETSWAP'
1187VBOXSF_TO_32 FS_SETSWAP, 2*4
1188 VBOXSF_PSFFSD_2_FLAT 08h, 1*4 ; psffsd
1189 VBOXSF_FARPTR_2_FLAT 0ch, 0*4 ; psffsi
1190 call NAME(FS32_SETSWAP)
1191VBOXSF_TO_16 FS_SETSWAP
1192 retf 8h
1193VBOXSF_EP16_END FS_SETSWAP
1194
1195
1196;;
1197; @cproto int FS_SHUTDOWN(USHORT type, ULONG reserved);
1198;
1199VBOXSF_EP16_BEGIN FS_SHUTDOWN, 'FS_SHUTDOWN'
1200VBOXSF_TO_32 FS_SHUTDOWN, 3*4
1201 mov ecx, [ebp + 08h] ; type
1202 mov [esp + 1*4], edx
1203 movzx edx, word [ebp + 0ah] ; reserved
1204 mov [esp], eax
1205 call NAME(FS32_SHUTDOWN)
1206VBOXSF_TO_16 FS_SHUTDOWN
1207 retf 6h
1208VBOXSF_EP16_END FS_SHUTDOWN
1209
1210
1211;;
1212; @cproto int FS_WRITE(PSFFSI psffsi, PVBOXSFFSD psffsd, PBYTE pbData, PUSHORT pcbData, USHORT IOflag)
1213VBOXSF_EP16_BEGIN FS_WRITE, 'FS_WRITE'
1214VBOXSF_TO_32 FS_WRITE, 6*4 ; extra local for ULONG cbDataTmp.
1215 movzx ecx, word [ebp + 08h] ; IOflag
1216 mov [esp + 4*4], ecx
1217 les dx, [ebp + 0ah] ; cbDataTmp = *pcbData;
1218 movzx edx, dx
1219 lea ecx, [esp + 5*4] ; pcbData = &cbDataTmp
1220 movzx eax, word [es:edx]
1221 mov [ecx], eax
1222 mov [esp + 3*4], ecx
1223 mov edx, DATA32
1224 mov es, edx
1225 VBOXSF_FARPTR_2_FLAT 0eh, 2*4 ; pbData
1226 VBOXSF_PSFFSD_2_FLAT 12h, 1*4 ; psffsd
1227 VBOXSF_FARPTR_2_FLAT 16h, 0*4 ; psffsi
1228 call FS32_WRITE
1229
1230 les dx, [ebp + 0ah] ; *pcbData = cbDataTmp;
1231 movzx edx, dx
1232 mov cx, [esp + 5*4]
1233 mov [es:edx], cx
1234 mov edx, DATA32
1235 mov es, edx
1236
1237VBOXSF_TO_16 FS_WRITE
1238
1239 pop es
1240 retf 12h
1241VBOXSF_EP16_END FS_WRITE
1242
1243
1244
1245
1246
1247
1248;
1249;
1250; Init code starts here
1251; Init code starts here
1252; Init code starts here
1253;
1254;
1255
1256
1257;;
1258; Ring-3 Init (16-bit).
1259;
1260; @param pMiniFS [bp + 08h] The mini-FSD. (NULL)
1261; @param fpfnDevHlp [bp + 0ch] The address of the DevHlp router.
1262; @param pszCmdLine [bp + 10h] The config.sys command line.
1263;
1264VBOXSF_EP16_BEGIN FS_INIT, 'FS_INIT'
1265; DEBUG_STR16 'VBoxSF: FS_INIT - enter'
1266 push ebp
1267 mov ebp, esp
1268 push ds ; bp - 02h
1269 push es ; bp - 04h
1270 push esi ; bp - 08h
1271 push edi ; bp - 0ch
1272
1273 mov ax, DATA16
1274 mov ds, ax
1275 mov es, ax
1276
1277 ;
1278 ; Save the device help entry point.
1279 ;
1280 mov eax, [bp + 0ch]
1281 mov [NAME(g_fpfnDevHlp)], eax
1282
1283 ;
1284 ; Parse the command line.
1285 ; Doing this in assembly is kind of ugly...
1286 ;
1287 cmp word [bp + 10h + 2], 3
1288 jbe near .no_command_line
1289 lds si, [bp + 10h] ; ds:si -> command line iterator.
1290.parse_next:
1291
1292 ; skip leading blanks.
1293.parse_next_char:
1294 mov di, si ; DI = start of argument.
1295 lodsb
1296 cmp al, ' '
1297 je .parse_next_char
1298 cmp al, 9 ; tab
1299 je .parse_next_char
1300 cmp al, 0
1301 je near .parse_done
1302
1303 ; check for '/' or '-'
1304 cmp al, '/'
1305 je .parse_switch
1306 cmp al, '-'
1307 je .parse_switch
1308 jmp .parse_error
1309
1310 ; parse switches.
1311.parse_switch:
1312 lodsb
1313 cmp al, 0
1314 je .parse_error
1315 and al, ~20h ; uppercase
1316
1317 cmp al, 'V' ; /V - verbose
1318 je .parse_verbose
1319 cmp al, 'Q' ; /Q - quiet.
1320 je .parse_quiet
1321 jmp .parse_error
1322
1323.parse_verbose:
1324 mov byte [es:NAME(g_fVerbose)], 1
1325 jmp .parse_next
1326
1327.parse_quiet:
1328 mov byte [es:NAME(g_fVerbose)], 0
1329 jmp .parse_next
1330
1331.parse_error:
1332segment DATA16
1333.szSyntaxError:
1334 db 0dh, 0ah, 'VBoxSF.ifs: command line parse error at: ', 0
1335.szNewLine:
1336 db 0dh, 0ah, 0dh, 0ah, 0
1337segment CODE16
1338 mov bx, .szSyntaxError
1339 call NAME(FS_INIT_FPUTS)
1340
1341 push es
1342 push ds
1343 pop es
1344 mov bx, di
1345 call NAME(FS_INIT_FPUTS)
1346 pop es
1347
1348 mov bx, .szNewLine
1349 call NAME(FS_INIT_FPUTS)
1350
1351 mov ax, ERROR_INVALID_PARAMETER
1352 jmp .done
1353
1354.parse_done:
1355 mov ax, DATA16
1356 mov ds, ax
1357.no_command_line:
1358
1359 ;
1360 ; Write our greeting to STDOUT.
1361 ; APIRET _Pascal DosWrite(HFILE hf, PVOID pvBuf, USHORT cbBuf, PUSHORT pcbBytesWritten);
1362 ;
1363 cmp byte [NAME(g_fVerbose)], 0
1364 je near .quiet
1365segment DATA16
1366.szMessage:
1367 db 'VirtualBox Guest Additions IFS for OS/2', 0dh, 0ah, 0
1368segment CODE16
1369 mov bx, .szMessage
1370 call NAME(FS_INIT_FPUTS)
1371.quiet:
1372
1373 ; return success.
1374 xor eax, eax
1375.done:
1376 lea sp, [bp - 0ch]
1377 pop edi
1378 pop esi
1379 pop es
1380 pop ds
1381 mov esp, ebp
1382 pop ebp
1383 DEBUG_STR16 'VBoxSF: FS_INIT - leave'
1384 retf 0ch
1385VBOXSF_EP16_END FS_INIT
1386
1387
1388;;
1389; Dos16Write wrapper.
1390;
1391; @param es:bx String to print. (zero terminated)
1392; @uses nothing.
1393GLOBALNAME FS_INIT_FPUTS
1394 push bp
1395 mov bp, sp
1396 push es ; bp - 02h
1397 push ds ; bp - 04h
1398 push ax ; bp - 06h
1399 push bx ; bp - 08h
1400 push cx ; bp - 0ah
1401 push dx ; bp - 0ch
1402 push si ; bp - 0eh
1403 push di ; bp - 10h
1404
1405 ; cx = strlen(es:bx)
1406 xor al, al
1407 mov di, bx
1408 mov cx, 0ffffh
1409 cld
1410 repne scasb
1411 not cx
1412 dec cx
1413
1414 ; APIRET _Pascal DosWrite(HFILE hf, PVOID pvBuf, USHORT cbBuf, PUSHORT pcbBytesWritten);
1415 push cx
1416 mov ax, sp ; cbBytesWritten
1417 push 1 ; STDOUT
1418 push es ; pvBuf
1419 push bx
1420 push cx ; cbBuf
1421 push ss ; pcbBytesWritten
1422 push ax
1423%if 0 ; wlink/nasm generates a non-aliased fixup here which results in 16-bit offset with the flat 32-bit selector.
1424 call far DOS16WRITE
1425%else
1426 ; convert flat pointer to a far pointer using the tiled algorithm.
1427 mov ax, DATA32 wrt FLAT
1428 mov ds, ax
1429 mov eax, g_pfnDos16Write wrt FLAT
1430 movzx eax, word [eax + 2] ; High word of the flat address (in DATA32).
1431 shl ax, 3
1432 or ax, 0007h
1433 mov dx, DATA16
1434 mov ds, dx
1435 mov [NAME(g_fpfnDos16Write) + 2], ax ; Update the selector (in DATA16).
1436 ; do the call
1437 call far [NAME(g_fpfnDos16Write)]
1438%endif
1439
1440 lea sp, [bp - 10h]
1441 pop di
1442 pop si
1443 pop dx
1444 pop cx
1445 pop bx
1446 pop ax
1447 pop ds
1448 pop es
1449 pop bp
1450 ret
1451ENDPROC FS_INIT_FPUTS
1452
1453
1454
1455;;
1456; 16-bit ring-0 init routine.
1457;
1458; Called from various entrypoints likely to be the first to be invoked.
1459;
1460GLOBALNAME VBoxSFR0Init16Bit
1461 DEBUG_STR16 'VBoxSF: VBoxSFR0Init16Bit - enter'
1462 push ds
1463 push es
1464 push fs
1465 push gs
1466 push esi
1467 push edi
1468 push ebp
1469 mov ebp, esp
1470 and sp, 0fffch
1471
1472 ;
1473 ; Only try once.
1474 ;
1475 mov ax, DATA16
1476 mov ds, ax
1477 mov byte [NAME(g_fDoneRing0)], 1
1478
1479 ;
1480 ; Try attach to the VBoxGuest driver.
1481 ;
1482 mov bx, NAME(g_szVBoxGuestName)
1483 mov di, NAME(g_VBoxGuestAttachDD)
1484 mov dl, DevHlp_AttachDD
1485 call far [NAME(g_fpfnDevHlp)]
1486 jc .attach_attempt_done
1487
1488 push seg NAME(g_VBoxGuestIDC)
1489 push NAME(g_VBoxGuestIDC)
1490 call far [NAME(g_VBoxGuestAttachDD) + 6]
1491.attach_attempt_done:
1492
1493%ifndef DONT_LOCK_SEGMENTS
1494 ;
1495 ; Lock the two 16-bit segments.
1496 ;
1497 push DATA16
1498 call far FSH_FORCENOSWAP
1499 push CODE16
1500 call far FSH_FORCENOSWAP
1501 ; Wonder if this'll work if wlink could mark the two segments as ALIASed...
1502 ;push DATA32
1503 ;call far FSH_FORCENOSWAP
1504 ;push TEXT32
1505 ;call far FSH_FORCENOSWAP
1506%endif
1507
1508 ;
1509 ; Do 32-bit ring-0 init.
1510 ;
1511 ;jmp far dword NAME(VBoxSFR0Init16Bit_32) wrt FLAT
1512 db 066h
1513 db 0eah
1514 dd NAME(VBoxSFR0Init16Bit_32) ;wrt FLAT
1515 dw TEXT32 wrt FLAT
1516segment TEXT32
1517GLOBALNAME VBoxSFR0Init16Bit_32
1518 mov ax, DATA32 wrt FLAT
1519 mov ds, ax
1520 mov es, ax
1521
1522 call KernThunkStackTo32
1523 call NAME(VBoxSFR0Init)
1524 call KernThunkStackTo16
1525
1526 ;jmp far dword NAME(VBoxSFR0Init16Bit_16) wrt CODE16
1527 db 066h
1528 db 0eah
1529 dw NAME(VBoxSFR0Init16Bit_16) wrt CODE16
1530 dw CODE16
1531segment CODE16
1532GLOBALNAME VBoxSFR0Init16Bit_16
1533
1534 mov esp, ebp
1535 pop ebp
1536 pop edi
1537 pop esi
1538 pop gs
1539 pop fs
1540 pop es
1541 pop ds
1542 DEBUG_STR16 'VBoxSF: VBoxSFR0Init16Bit - leave'
1543 ret
1544ENDPROC VBoxSFR0Init16Bit
1545
1546
1547%ifdef DEBUG
1548;;
1549; print the string which offset is in AX (it's in the data segment).
1550; @uses AX
1551;
1552GLOBALNAME dbgstr16
1553 push ds
1554 push ebx
1555 push edx
1556
1557 mov bx, ax
1558 mov dx, 0504h ; RTLOG_DEBUG_PORT
1559 mov ax, DATA16
1560 mov ds, ax
1561
1562.next:
1563 mov al, [bx]
1564 or al, al
1565 jz .done
1566 inc bx
1567 out dx, al
1568 jmp .next
1569
1570.done:
1571 pop edx
1572 pop ebx
1573 pop ds
1574 ret
1575ENDPROC dbgstr16
1576%endif
1577
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette