home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Dev32 / lxdevhlp.asm < prev    next >
Assembly Source File  |  2002-04-27  |  5KB  |  158 lines

  1. ; $Id: lxdevhlp.asm,v 1.2 2002/04/26 23:08:55 smilcke Exp $
  2.  
  3. ; 32 bits OS/2 device driver and IFS support driver. Provides 32 bits kernel
  4. ; services (DevHelp) and utility functions to 32 bits OS/2 ring 0 code
  5. ; (device drivers and installable file system drivers).
  6. ; Copyright (C) 1995, 1996 Matthieu WILLM
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.     .386p
  23.  
  24.        include bseerr.inc
  25.        include devhlp.inc
  26.        include seg32.inc
  27.        include infoseg.inc
  28.  
  29. DosTable2 struc
  30.        d2_ErrMap24                     dd ?
  31.        d2_MsgMap24                     dd ?
  32.        d2_Err_Table_24                 dd ?
  33.        d2_CDSAddr                      dd ?
  34.        d2_GDT_RDR1                     dd ?
  35.        d2_InterruptLevel               dd ?
  36.        d2__cInDos                      dd ?
  37.        d2_zero_1                       dd ?
  38.        d2_zero_2                       dd ?
  39.        d2_FlatCS                       dd ?
  40.        d2_FlatDS                       dd ?
  41.        d2__TKSSBase                    dd ?
  42.        d2_intSwitchStack               dd ?
  43.        d2_privateStack                 dd ?
  44.        d2_PhysDiskTablePtr             dd ?
  45.        d2_forceEMHandler               dd ?
  46.        d2_ReserveVM                    dd ?
  47.        d2_pgpPageDir                   dd ?
  48.        d2_unknown                      dd ?
  49. DosTable2 ends
  50.  
  51.  
  52. DATA16 segment
  53.        public  LInfoSeg
  54. LInfoSeg       dd 0
  55. DATA16 ends
  56.  
  57. DATA32 segment
  58.        public DevHelp32
  59.        public TKSSBase
  60.  
  61. DevHelp32    dd 0
  62. TKSSBase    dd 0
  63.  
  64. DATA32 ends
  65.  
  66.  
  67. CODE32 segment
  68. ASSUME CS:FLAT, DS:FLAT, ES:FLAT
  69.  
  70.        public GetTKSSBase
  71.        public OS2_get_current_pid_
  72.        public iodelay32_
  73.        extrn  DevHlp : near
  74.        extrn  DOSIODELAYCNT : ABS
  75.  
  76.        ALIGN   4
  77. OS2_get_current_pid_ proc near
  78.        push    es
  79.        push    ebx
  80.  
  81.        movzx   eax,word ptr DATA16:LInfoSeg+2
  82.        mov     es,ax
  83.        movzx   ebx,word ptr DATA16:LInfoSeg
  84.        movzx   eax,word ptr es:[bx].LIS_CurProcID
  85.  
  86.        pop     ebx
  87.        pop     es
  88.        ret
  89. OS2_get_current_pid_ endp
  90.  
  91.        ALIGN   4
  92.  
  93. GetTKSSBase proc near
  94.        push    ebp
  95.        mov     ebp, esp
  96.        push    es
  97.        push    ebx
  98.      push    ecx
  99.     push    edx
  100.  
  101.        ;
  102.        ; Gets the TKSSBase pointer from DosTable. TKSSBase is used by
  103.        ; __StackToFlat() to convert a stack based address to a FLAT address
  104.        ; without the overhead of DevHlp_VirtToLin
  105.        ;
  106.        ; DosTable is obtained through GetDOSVar with undocumented index 9
  107.        ; The layout is :
  108.        ;     byte      count of following dword (n)
  109.        ;     dword 1   -+
  110.        ;       .        |
  111.        ;       .        | this is DosTable1
  112.        ;       .        |
  113.        ;     dword n   -+
  114.        ;     byte      count of following dword (p)
  115.        ;     dword 1   -+
  116.        ;       .        |
  117.        ;       .        | this is DosTable2
  118.        ;       .        |
  119.        ;     dword p   -+
  120.        ;
  121.        ; Flat CS  is dword number 10 in DosTable2
  122.        ; Flat DS  is dword number 11 in DosTable2
  123.        ; TKSSBase is dword number 12 in DosTable2
  124.        ;
  125.        mov     eax, 9                       ; undocumented DosVar : DosTable pointer
  126.        xor     ecx, ecx
  127.        mov     edx, DevHlp_GetDOSVar
  128.        call     DevHlp
  129.        jc     short GetTKSSBase_Err
  130.        mov     es, ax                       ; es:bx points to DosTable
  131.        movzx     ebx, bx
  132.        movzx     ecx, byte ptr es:[ebx]     ; count of dword in DosTable1
  133.        mov     eax, es:[ebx + 4 * ecx + 2].d2__TKSSBase
  134.        mov     TKSSBase, eax
  135.  
  136.        xor     eax, eax
  137. GetTKSSBase_Err:
  138.        pop     edx
  139.        pop     ecx
  140.        pop     ebx
  141.        pop     es
  142.        leave
  143.        ret
  144. GetTKSSBase endp
  145.  
  146. iodelay32_ proc near
  147.        mov   eax, DOSIODELAYCNT
  148.        align 4
  149. @@:    dec   eax
  150.        jnz   @b
  151.        loop  iodelay32_
  152.        ret
  153. iodelay32_ endp
  154.  
  155. CODE32 ends
  156.  
  157. end
  158.