home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kernex32.zip / mwdd_src.zip / 32bits / ext2-os2 / fsh32 / fs_init.asm next >
Assembly Source File  |  1997-03-22  |  5KB  |  164 lines

  1. ;
  2. ; $Header: D:/32bits/ext2-os2/fsh32/rcs/fs_init.asm,v 1.4 1997/03/15 17:52:54 Willm Exp Willm $
  3. ;
  4.  
  5. ; 32 bits OS/2 device driver and IFS support. Provides 32 bits kernel 
  6. ; services (DevHelp) and utility functions to 32 bits OS/2 ring 0 code 
  7. ; (device drivers and installable file system drivers).
  8. ; Copyright (C) 1995, 1996, 1997  Matthieu WILLM (willm@ibm.net)
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ;
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ; GNU General Public License for more details.
  19. ;
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.         .386p
  25.  
  26.         INCL_DOS        equ 1
  27.         INCL_DOSERRORS  equ 1
  28.         include os2.inc
  29.         include devhlp.inc
  30.  
  31.         include segdef.inc
  32.         include r0thunk.inc
  33.         include fsd.inc
  34.         include mwdd32_ioctl.inc
  35.  
  36.  
  37. DATA32 segment
  38. ;        public TKSSBase
  39.         extrn DevHelp32 : dword
  40.         extrn TKSSBase : dword
  41.  
  42. ;        TKSSBase dd (?)
  43. DATA32 ends
  44.  
  45. CODE16 segment
  46.         assume CS:CODE16
  47.  
  48.         public FS_INIT
  49.  
  50.         extrn DOS16OPEN       : far
  51.         extrn DOS16DEVIOCTL   : far
  52.         extrn DOS16CLOSE      : far
  53.         extrn DOS16PUTMESSAGE : far
  54.  
  55.         FileName db "mwdd32$", 0
  56.  
  57.  
  58.  
  59. ;
  60. ;int far pascal FS_INIT(
  61. ;                       char far * cmdline,
  62. ;                       unsigned long DevHelp,
  63. ;                       unsigned long far * pMiniFSD
  64. ;                      );
  65. ;
  66. FS_INIT proc far
  67.         enter 24, 0
  68.         push si
  69.         push di
  70.         ;
  71.         ; bp + 14 -> cmdline
  72.         ; bp + 10 -> DevHelp
  73.         ; bp + 6  -> pMiniFSD
  74.         ; bp + 2  -> FS_INIT
  75.         ; bp      ->  old bp
  76.         ; bp - 2  -> FileHandle
  77.         ; bp - 4  -> ActionTaken
  78.         ; bp - 8  -> IOCTL parm (4 bytes)  : union mwdd32_ioctl_int_fsd_parm
  79.         ; bp - 24 -> IOCTL data (16 bytes) : union mwdd32_ioctl_int_fsd_data
  80.  
  81.         ;
  82.         ; Opens mwdd32$
  83.         ;
  84.         push seg CODE16                 ; seg  FileName
  85.         push offset CODE16:FileName     ; ofs  FileName
  86.         push ss                         ; seg &FileHandle
  87.         lea ax, [bp - 2]
  88.         push ax                         ; ofs &FileHandle
  89.         push ss                         ; seg &ActionTaken
  90.         lea ax, [bp - 4]
  91.         push ax                         ; ofs &ActionTaken
  92.         push dword ptr 0                ; file size
  93.         push 0                          ; file attributes
  94.         push OPEN_ACTION_FAIL_IF_NEW + OPEN_ACTION_OPEN_IF_EXISTS
  95.         push OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY
  96.         push dword ptr 0                ; reserved
  97.         call DOS16OPEN
  98.         cmp ax, NO_ERROR
  99.         jnz short fs_init_out
  100.  
  101.  
  102. ;APIRET  APIENTRY DosDevIOCtl2(PVOID pData, USHORT cbData, PVOID pParm,
  103. ;                             USHORT cbParm, USHORT usFun, USHORT usCategory,
  104. ;                             HFILE hDev);
  105.  
  106.         lea si, [bp - 8]                ; parm
  107.         lea di, [bp - 24]               ; data
  108.         mov dword ptr [bp - 8].magic, INIT_FSD_MAGIC_IN                ; parm->input.magic_in
  109.         mov dword ptr [bp - 24].fs32_init_ptr , offset FLAT:fs32_init      ; data->input.fs32_init
  110.         lea ax, [bp + 6]
  111.         mov [bp - 24].fs32_init_parms_ofs , ax   ; data->input.fs32_init_parms (ofs)
  112.         mov ax, ss
  113.         mov [bp - 24].fs32_init_parms_seg , ax   ; data->input.fs32_init_parms (seg)
  114.         mov dword ptr [bp - 24].pTKSSBase, offset FLAT:TKSSBase
  115.         mov dword ptr [bp - 24].pDevHelp32, offset FLAT:DevHelp32
  116.         push ss                         ; seg pData
  117.         push di                         ; ofs pData
  118. ;        push word ptr 8                        ; cbData
  119.         push ss                         ; seg pParm
  120.         push si                         ; ofs pParm
  121. ;       push word ptr 4                 ; cbParm
  122.         push word ptr 041h              ; func
  123.         push word ptr 0f0h              ; cat
  124.         push word ptr [bp - 2]          ; FileHandle
  125.         call DOS16DEVIOCTL
  126.         cmp ax, NO_ERROR
  127.         jnz short fs_init_out
  128.  
  129.  
  130.         ;
  131.         ; Closes mwdd32$
  132.         ;
  133.         push word ptr [bp - 2]                   ; FileHandle
  134.         call DOS16CLOSE
  135.         cmp ax, NO_ERROR
  136.         jnz short fs_init_out
  137.  
  138.  
  139.         ;
  140.         ; Tests magic number in answer from mwdd32.sys
  141.         ;
  142.         cmp dword ptr [bp - 8].magic, INIT_FSD_MAGIC_OUT
  143.         jne       not_ok
  144.  
  145.         ;
  146.         ; Retrieves fs32_init's return code from mwdd32.sys answer
  147.         ;
  148.         mov ax, word ptr [bp - 24].fs32_init_rc     ; rc from fs32_init
  149.         jmp short fs_init_out
  150.  
  151. not_ok:
  152.         mov ax, ERROR_INVALID_PARAMETER
  153.  
  154. fs_init_out:
  155.         pop di
  156.         pop si
  157.         leave
  158.         retf 12
  159. FS_INIT endp
  160. CODE16 ends
  161.  
  162.  
  163.         end
  164.