home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / KERNELS / LODLIN15.ZIP / LOADLIN / BIOSINTV.ASM next >
Encoding:
Assembly Source File  |  1994-04-17  |  4.6 KB  |  175 lines

  1. ;============================================================================
  2. ;   BIOSINTV v1.0 (C) 1994 Hans Lermen (lermen@elserv.ffm.fgan.de)
  3. ;   part of package
  4. ;   LOADLIN v1.4 (C) 1994 Hans Lermen (lermen@elserv.ffm.fgan.de)
  5. ;
  6. ;   This program is free software; you can redistribute it and/or modify
  7. ;   it under the terms of the GNU General Public License as published by
  8. ;   the Free Software Foundation; either version 2 of the License, or
  9. ;   (at your option) any later version.
  10. ;
  11. ;   This program is distributed in the hope that it will be useful,
  12. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;   GNU General Public License for more details.
  15. ;
  16. ;   You should have received a copy of the GNU General Public License
  17. ;   along with this program; if not, write to the Free Software
  18. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ;
  20. ;----------------------------------------------------------------------------
  21. ;   Comments and bug reports are welcome and may be sent to:
  22. ;   E-Mail:    lermen@elserv.ffm.fgan.de
  23. ;   SnailMail: Hans Lermen
  24. ;              Am Muehlenweg 38
  25. ;              D53424 REMAGEN-Unkelbach
  26. ;              GERMANY
  27. ;
  28. ;============================================================================
  29.           name  biosintv
  30.           .386
  31.           locals
  32.           jumps
  33.  
  34. code    segment para USE16
  35.         assume  cs:code,ds:nothing
  36.         org     0 ; NOTE: must really be 0
  37.  
  38.         dd     -1              ; chain pointer to next device header
  39.         dw     0c000h          ; character device (with ioctl support)
  40.         dw     strategyRoutine
  41.         dw     DevIntRoutine
  42.         db     '$BIOSINT'
  43.  
  44.  
  45. done          =    1         ; complete status, goes into highbyte
  46. inval_function=    8003h     ; invalid function code
  47.  
  48. current_header dd ?    ; this is the saved pointer from strategy call
  49. num_ints_to_save = 128
  50. intvectbuf     dd  num_ints_to_save dup(?)
  51.  
  52.  
  53. strategyRoutine proc far
  54.         mov     word ptr cs:current_header,bx
  55.         mov     word ptr cs:current_header+2,es
  56.         ret
  57. strategyRoutine endp
  58.  
  59.  
  60. DevIntRoutine proc far
  61. @@header struc
  62.            db 2 dup(?)
  63.   @@cmd    db ?
  64.   @@status dw ?
  65. @@header ends
  66.         push    ds
  67.         push    es
  68.         push    ax
  69.         push    bx
  70.         push    cx
  71.         push    dx
  72.         push    di
  73.         push    si
  74.         cld
  75.         lds     bx,cs:current_header
  76.  
  77.         movzx   ax,byte ptr ds:[bx].@@cmd
  78.         cmp     al,12
  79.         ja      @@ex_inval
  80.  
  81.         shl     ax,1
  82.         mov     di,ax
  83.         xor     ax,ax
  84.         push    offset @@ex_command         ; it's the return address of
  85.         jmp     word ptr cs:@@jumptable[di] ; a simulated call
  86.  
  87. @@jumptable label word
  88.            dw   init             ; 0, init-routine
  89.            dw   2 dup (@@nosupport)
  90.            dw   ioctl_in         ; 3
  91.            dw   8 dup (@@nosupport)
  92.            dw   ioctl_out        ; 12
  93.  
  94. @@nosupport:
  95.         add     sp,2             ; readjust stack
  96. @@ex_inval:
  97.         mov     ax,inval_function
  98.  
  99. @@ex_command:
  100.         lds     bx,cs:current_header
  101.         or      ah,done
  102.         mov     ds:[bx].@@status,ax
  103.         pop     si
  104.         pop     di
  105.         pop     dx
  106.         pop     cx
  107.         pop     bx
  108.         pop     ax
  109.         pop     es
  110.         pop     ds
  111.         ret
  112. DevIntRoutine endp
  113.  
  114.  
  115.  
  116. ioctl_in proc near
  117. @@header struc
  118.            db 14 dup(?);
  119.   @@bufptr dd ?
  120.   @@count  dw ?
  121. @@header ends
  122.         les     di,[bx].@@bufptr
  123.         mov     cx,[bx].@@count
  124.         cmp     cx,num_ints_to_save*4
  125.         jna     @@ok
  126.         mov     cx,num_ints_to_save*4
  127. @@ok:
  128.         mov     [bx].@@count,cx
  129.         shr     cx,2
  130.         push    ds
  131.         push    cs
  132.         pop     ds
  133.         lea     si,intvectbuf
  134.         cld
  135.         rep movsd
  136.         pop     ds
  137.         mov     ax,1            ; status ok
  138.         ret
  139. ioctl_in endp
  140.  
  141.  
  142. ioctl_out proc near
  143.         mov     ax,1            ; status ok
  144.         ret
  145. ioctl_out endp
  146.  
  147.  
  148. modulend equ    $+15
  149.  
  150.  
  151.  
  152. init proc near
  153. @@header struc
  154.            db 14 dup(?);
  155.   @@endptr dd ?
  156. @@header ends
  157.         mov     word ptr ds:[bx].@@endptr,offset modulend
  158.         mov     word ptr ds:[bx].@@endptr+2,cs
  159.         push    ds
  160.         xor     si,si
  161.         mov     ds,si
  162.         push    cs
  163.         pop     es
  164.         lea     di,intvectbuf
  165.         cld
  166.         mov     cx,num_ints_to_save
  167.         rep movsd
  168.         mov     ax,0
  169.         pop     ds
  170.         ret
  171. init endp
  172.  
  173. code    ends
  174.         end
  175.