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 / fsh32_dovolio.asm < prev    next >
Assembly Source File  |  1997-03-16  |  5KB  |  172 lines

  1. ;
  2. ; $Header: d:\\32bits\\ext2-os2\\fsh32\\rcs\\fsh32_dovolio.asm,v 1.3 1997/03/15 17:52:54 Willm Exp $
  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_DOSERRORS equ 1
  27.         include bseerr.inc
  28.         include devhlp.inc
  29.         include segdef.inc
  30.         include r0thunk.inc
  31.  
  32. CODE16 segment
  33.         ASSUME CS:CODE16, DS:FLAT
  34.  
  35.         extrn FSH_DOVOLIO : far
  36.  
  37.         public thunk16$fsh32_dovolio_1
  38.         public thunk16$fsh32_dovolio_2
  39.         public thunk16$fsh32_dovolio_3
  40.         public thunk16$fsh32_dovolio_4
  41.  
  42. thunk16$fsh32_dovolio_1:
  43.         call [DevHelp2]
  44. ;        jmp far ptr FLAT:thunk32$fsh32_dovolio_1
  45.         jmp32 thunk32$fsh32_dovolio_1
  46.  
  47. thunk16$fsh32_dovolio_2:
  48.         call [DevHelp2]
  49. ;        jmp far ptr FLAT:thunk32$fsh32_dovolio_2
  50.         jmp32 thunk32$fsh32_dovolio_2
  51.  
  52. thunk16$fsh32_dovolio_3:
  53.         call FSH_DOVOLIO
  54. ;        jmp far ptr FLAT:thunk32$fsh32_dovolio_3
  55.         jmp32 thunk32$fsh32_dovolio_3
  56.  
  57. thunk16$fsh32_dovolio_4:
  58.         call [DevHelp2]
  59. ;        jmp far ptr FLAT:thunk32$fsh32_dovolio_4
  60.         jmp32 thunk32$fsh32_dovolio_4
  61.  
  62. CODE16 ends
  63.  
  64. CODE32 segment
  65. ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING
  66.  
  67.         public         fsh32_dovolio
  68.         public thunk32$fsh32_dovolio_1
  69.         public thunk32$fsh32_dovolio_2
  70.         public thunk32$fsh32_dovolio_3
  71.         public thunk32$fsh32_dovolio_4
  72.  
  73. ;
  74. ; int fsh32_dovolio(
  75. ;                   int operation,              /* ebp + 8  */
  76. ;                   int fAllowed,               /* ebp + 12 */
  77. ;                   int hVPB,                   /* ebp + 16 */
  78. ;                   void *pData,                /* ebp + 20 */
  79. ;                   unsigned long *pcSec,       /* ebp + 24 */
  80. ;                   unsigned long  iSec         /* ebp + 28 */
  81. ;                  );
  82. ;
  83. fsh32_dovolio proc near
  84.         enter 12, 0
  85.         push es
  86.         push ebx
  87.         push esi
  88.         push edi
  89. ;
  90. ; ebp - 2 -> sel    (word) used to map pData to 16:16
  91. ; ebp - 4 -> *pcSec (word) local copy of *pcSec to get a 16:16 stack based address to it
  92. ; ebp - 6 -> rc     (word) used to store return codes
  93. ;
  94.  
  95.     ;
  96.     ; rc = 0
  97.     ;
  98.     mov [ebp - 6], 0
  99.  
  100.  
  101.         mov ax, ss
  102.         mov es, ax
  103.         lea edi, [ebp - 2]                      ; &sel in ES:DI
  104.         mov ecx, 1                              ; one selector
  105.         mov dl, DevHlp_AllocGDTSelector
  106.         jmp far ptr thunk16$fsh32_dovolio_1
  107. thunk32$fsh32_dovolio_1:
  108.         jc @@error
  109.  
  110.         mov ax, [ebp - 2]                       ; sel
  111.         mov ebx, dword ptr [ebp + 20]           ; lin
  112.     mov ecx, [ebp + 24]            ; pcSec 
  113.         movzx ecx, word ptr [ecx]                ; *pcSec (nr of sectors)
  114.     mov [ebp - 4], cx
  115.         shl ecx, 9                              ; 512 byte sector
  116.         mov dl, DevHlp_LinToGDTSelector
  117.         jmp far ptr thunk16$fsh32_dovolio_2
  118. thunk32$fsh32_dovolio_2:
  119.         mov [ebp - 6], ax                       ; rc
  120.         jc short @@error_2
  121.  
  122.  
  123.         sub esp, 18
  124.         mov eax, [ebp + 8]                      ; operation
  125.         mov [esp + 16], ax
  126.         mov eax, [ebp + 12]                     ; fAllowed
  127.         mov [esp + 14], ax
  128.         mov eax, [ebp + 16]                     ; hVPB
  129.         mov [esp + 12], ax
  130.         mov ax, [ebp - 2]                       ; sel
  131.         shl eax, 16
  132.         mov [esp + 8], eax                      ; pData
  133.         mov ax, ss
  134.         shl eax, 16
  135.         lea ebx, [ebp - 4]
  136.         mov ax, bx
  137.         mov [esp + 4], eax                      ; pcSec
  138.         mov eax, [ebp + 28]
  139.         mov [esp], eax                          ; iSec
  140.         jmp far ptr thunk16$fsh32_dovolio_3
  141. thunk32$fsh32_dovolio_3:
  142.         mov [ebp - 6], ax                       ; rc
  143.  
  144. @@error_2:
  145.         mov ax, [ebp - 2]
  146.         mov dl, DevHlp_FreeGDTSelector
  147.         jmp far ptr thunk16$fsh32_dovolio_4
  148. thunk32$fsh32_dovolio_4:
  149.         jc @@error
  150.  
  151.         mov ax, [ebp - 6]                    ; rc
  152.         cmp ax, 0
  153.         jnz @@error
  154.  
  155.         mov ebx, [ebp - 4]
  156.         movzx ebx, bx
  157.         mov edi, [ebp + 24]                     ;  pcSec
  158.         mov [edi], ebx                          ; *pcSec
  159. @@error:
  160.         movzx eax, ax
  161.         pop edi
  162.         pop esi
  163.         pop ebx
  164.         pop es
  165.         leave
  166.         ret
  167. fsh32_dovolio endp
  168.  
  169. CODE32  ends
  170.  
  171.         end
  172.