home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kernex32.zip / mwdd_src.zip / 32bits / ext2-os2 / mwdd32 / mwdd32_pre_init_base.asm < prev    next >
Assembly Source File  |  1997-03-16  |  5KB  |  167 lines

  1. ;
  2. ; $Header: d:\\32bits\\ext2-os2\\mwdd32\\rcs\\mwdd32_pre_init_base.asm,v 1.2 1997/03/16 12:44:29 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 devcmd.inc
  30. ;        include devsym.inc
  31.         include segdef.inc
  32.     include r0thunk.inc
  33.  
  34. reqPacket       struc
  35. reqLenght       db ?
  36. reqUnit         db ?
  37. reqCommand      db ?
  38. reqStatus       dw ?
  39. reqFlags        db ?
  40.                 db 3 dup (?)    ; Reserved field
  41. reqLink         dd ?
  42. reqPacket       ends
  43.  
  44. rpInitIn        struc
  45. i_rph           db size reqPacket dup (?)
  46. i_unit          db ?
  47. i_devHelp       dd ?
  48. i_initArgs      dd ?
  49. i_driveNum      db ?
  50. rpInitIn        ends
  51.  
  52. DosTable2 struc
  53.         d2_ErrMap24                     dd ?
  54.         d2_MsgMap24                     dd ?
  55.         d2_Err_Table_24                 dd ?
  56.         d2_CDSAddr                      dd ?
  57.         d2_GDT_RDR1                     dd ?
  58.         d2_InterruptLevel               dd ?
  59.         d2__cInDos                      dd ?
  60.         d2_zero_1                       dd ?
  61.         d2_zero_2                       dd ?
  62.         d2_FlatCS                       dd ?
  63.         d2_FlatDS                       dd ?
  64.         d2__TKSSBase                    dd ?
  65.         d2_intSwitchStack               dd ?
  66.         d2_privateStack                 dd ?
  67.         d2_PhysDiskTablePtr             dd ?
  68.         d2_forceEMHandler               dd ?
  69.         d2_ReserveVM                    dd ?
  70.         d2_pgpPageDir                   dd ?
  71.         d2_unknown                      dd ?
  72. DosTable2 ends
  73.  
  74. DATA32 segment
  75.         extrn TKSSBase        : dword
  76. DATA32 ends
  77.  
  78. CODE16 segment
  79. ASSUME CS:CODE16, DS:FLAT
  80.  
  81.     public thunk16$mwdd32_pre_init_base
  82.  
  83. thunk16$mwdd32_pre_init_base:
  84.         call dword ptr [DevHelp2]
  85.         jmp far ptr FLAT:thunk32$mwdd32_pre_init_base
  86.  
  87. CODE16 ends
  88.  
  89. CODE32 segment
  90. ASSUME CS:FLAT, DS:FLAT, ES:FLAT
  91.  
  92.         public thunk32$mwdd32_pre_init_base
  93.         public         mwdd32_pre_init_base
  94.  
  95. ;
  96. ; int mwdd32_pre_init_base(
  97. ;                          PTR16 reqpkt      /* ebp + 8 */
  98. ;                         );
  99. ;
  100. mwdd32_pre_init_base proc near
  101.         push ebp
  102.         mov ebp, esp
  103.         push es
  104.         push ebx
  105.         push esi
  106.         push edi
  107.  
  108.         ;
  109.         ; Saves the DevHelp entry point
  110.         ;
  111.         les bx, dword ptr[ebp + 8]   ; es:bx points to the INIT request packet
  112.         movzx ebx, bx
  113.         mov ebx, es:[ebx].i_devHelp  ; Device Helper entry point
  114.         mov DevHelp2, ebx            ; saved into DevHelp2
  115.  
  116.         ;
  117.         ; Gets the TKSSBase pointer from DosTable. TKSSBase is used by
  118.         ; __StackToFlat() to convert a stack based address to a FLAT address
  119.         ; without the overhead of DevHlp_VirtToLin
  120.         ;
  121.         ; DosTable is obtained through GetDOSVar with undocumented index 9
  122.         ; The layout is :
  123.         ;     byte      count of following dword (n)
  124.         ;     dword 1   -+
  125.         ;       .        |
  126.         ;       .        | this is DosTable1
  127.         ;       .        |
  128.         ;     dword n   -+
  129.         ;     byte      count of following dword (p)
  130.         ;     dword 1   -+
  131.         ;       .        |
  132.         ;       .        | this is DosTable2
  133.         ;       .        |
  134.         ;     dword p   -+
  135.         ;
  136.         ; Flat CS  is dword number 10 in DosTable2
  137.         ; Flat DS  is dword number 11 in DosTable2
  138.         ; TKSSBase is dword number 12 in DosTable2
  139.         ;
  140.         mov eax, 9                       ; undocumented DosVar : DosTable pointer
  141.         xor ecx, ecx
  142.         mov edx, DevHlp_GetDOSVar
  143.         jmp far ptr thunk16$mwdd32_pre_init_base ; ax:bx points to DosTable
  144. thunk32$mwdd32_pre_init_base:
  145.         jc short mwdd32_pre_init_base_err
  146.         mov es, ax                       ; es:bx points to DosTable
  147.         movzx ebx, bx
  148.         movzx ecx, byte ptr es:[ebx]     ; count of dword in DosTable1
  149.         mov eax, es:[ebx + 4 * ecx + 2].d2__TKSSBase
  150.         mov TKSSBase, eax
  151.  
  152.         mov eax, NO_ERROR
  153. mwdd32_pre_init_base_err:
  154.         pop edi
  155.         pop esi
  156.         pop ebx
  157.         pop es
  158.         leave
  159.         ret
  160. mwdd32_pre_init_base endp
  161.  
  162. CODE32 ends
  163.  
  164.  
  165.  
  166.     end
  167.