home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / DOOG / CTASK.ZIP / TSKBIOS.ASM < prev    next >
Assembly Source File  |  1989-12-20  |  5KB  |  280 lines

  1. ;
  2. ;    --- Version 2.0 89-12-13 17:56 ---
  3. ;
  4. ;    CTask - BIOS INT 15 interrupt handler (IBM AT specific)
  5. ;
  6. ;    Public Domain Software written by
  7. ;        Thomas Wagner
  8. ;        Patschkauer Weg 31
  9. ;        D-1000 Berlin 33
  10. ;        West Germany
  11. ;
  12. ;    NOTE:   Support for printer output busy has been dropped in
  13. ;        version 1.2. Depending on the speed of the driving
  14. ;        program, the old algorithm (which used a timed delay)
  15. ;        could cause the printer to slow down to an unbearable
  16. ;        crawl, and there is little chance for a clean solution
  17. ;        here, since there is not enough info on the printer
  18. ;        passed to INT 15.
  19. ;        Instead, an INT 17 replacement that schedules while 
  20. ;        waiting on the printer has been added (module tskint17.asm).
  21. ;
  22.     name    tskbios
  23.     .model    large,c
  24. ;
  25.     public    tsk_install_bios
  26.     public    tsk_remove_bios
  27. ;
  28.     include    tsk.mac
  29. ;
  30.     extrn    clear_flag_wait_set: far
  31.     extrn    set_flag: far
  32.         extrn   create_flag: far
  33.         extrn   delete_flag: far
  34.         extrn   t_delay: far
  35. ;
  36.     extrn    tsk_dgroup: word
  37. ;
  38. intseg    segment at 0
  39. ;
  40.         org    15h*4
  41. pintofs        dw    ?        ; interrupt entry
  42. pintseg        dw    ?
  43.  
  44. intseg    ends
  45. ;
  46. ;
  47.     .tsk_data
  48. ;
  49.     extrn    tsk_glob_rec: word    ; global_rec
  50. ;
  51. floppy  flag    <>
  52. fdisk   flag    <>
  53. kbd     flag    <>
  54. ;
  55. flag_tab    label    word
  56.     dw    offset fdisk
  57.     dw    offset floppy
  58.     dw    offset kbd
  59. ;
  60.     IF    TSK_NAMEPAR
  61. fflname    db    "WFLEXDSK",0
  62. ffdname    db    "WHARDDSK",0
  63. fkbname    db    "WKBDPOST",0
  64.     ENDIF
  65. ;
  66.     .tsk_edata
  67.     .tsk_code
  68. ;
  69.     extrn    tsk_switch_stack: near
  70. ;
  71. post_save    label    dword        ; in CSEG to allow addressing
  72. psofs        dw    ?
  73. psseg        dw    ?
  74. ;
  75. ;----------------------------------------------------------------------
  76. ;
  77. ;    interrupt handler
  78. ;
  79. bios_int    proc    far
  80.         pushf
  81.     sti
  82.         cmp     ah,90h            ; WAIT
  83.         jb      bios_pass
  84.         cmp     ah,91h            ; POST
  85.         ja    bios_pass
  86.     cmp    al,2            ; fdisk/floppy/keyboard
  87.         jbe    process_bios
  88.     cmp    al,0fdh            ; floppy motor
  89.         je    process_bios
  90. ;
  91. bios_pass:
  92.     popf
  93.     jmp    cs:post_save
  94. ;
  95. ;
  96. process_bios:
  97.     popf
  98.     call    tsk_switch_stack
  99.     stc_saved            ; Carry set on return
  100. ;
  101.     cmp    al,2
  102.     jbe    flag_ops
  103. ;
  104. ;    Wait for diskette motor start (1 sec.)
  105. ;
  106. wait_motor:
  107.     xor    ax,ax
  108.     push    ax
  109.     mov    ax,tsk_glob_rec.ticks_per_sec
  110.     push    ax
  111.     call    t_delay
  112.     add    sp,4
  113.     iret
  114. ;
  115. ;    Floppy/Fdisk/Keyboard wait/post
  116. ;
  117. flag_ops:
  118.     xor    bh,bh
  119.     mov    bl,al    
  120.     add    bx,bx
  121.     mov    bx,flag_tab[bx]        ; load appropriate flag
  122.     cmp    ah,90h
  123.     je    fl_wait            ; jump if wait op
  124.     push    ds
  125.     push    bx
  126.     call    set_flag        ; set flag: complete
  127.     add    sp,4
  128.     clc_saved            ; carry clear on return
  129.     iret
  130. ;
  131. fl_wait:
  132.     xor    dx,dx
  133.     cmp    al,2
  134.     je    fl_dowait        ; no timeout if AL=2 (Keyboard)
  135.     mov    dx,tsk_glob_rec.ticks_per_sec
  136.     add    dx,dx            ; two seconds
  137.     cmp    al,1
  138.     je    fl_dowait        ; 2 sec timeout if AL=1 (Diskette)
  139.     mov    cx,dx
  140.     add    dx,cx
  141.     add    dx,cx            ; 6 sec timeout for Harddisk
  142. fl_dowait:
  143.     xor    ax,ax
  144.     push    ax
  145.     push    dx
  146.     push    ds
  147.     push    bx
  148.     call    clear_flag_wait_set    ; Clear flag & wait for event
  149.     add    sp,8
  150.     or    ax,ax
  151.     jnz    flw_ret            ; keep carry set if timeout
  152.     clc_saved            ; else return with carry clear
  153. flw_ret:
  154.     iret
  155. ;
  156. bios_int       endp
  157. ;
  158. ;------------------------------------------------------------------------
  159. ;
  160. ;    void far tsk_remove_bios (void)
  161. ;
  162. ;    This routine un-installs the int handler.
  163. ;
  164. tsk_remove_bios    proc    near uses ds
  165. ;
  166.     mov    ds,cs:tsk_dgroup
  167. ;
  168.     push    es
  169.     xor    ax,ax
  170.     mov    es,ax
  171.     assume    es:intseg
  172.         cli
  173.     mov    ax,cs:psofs        ; restore vector
  174.     mov    pintofs,ax
  175.     mov    ax,cs:psseg
  176.     mov    pintseg,ax
  177.         sti
  178.     assume    es:nothing
  179.     pop    es
  180. ;
  181.         mov     ax,offset floppy
  182.         push    ds
  183.         push    ax
  184.         call    delete_flag
  185.         add     sp,4
  186. ;
  187.         mov     ax,offset fdisk
  188.         push    ds
  189.         push    ax
  190.         call    delete_flag
  191.         add     sp,4
  192. ;
  193.         mov     ax,offset kbd
  194.         push    ds
  195.         push    ax
  196.         call    delete_flag
  197.         add     sp,4
  198. ;
  199.         ret
  200. ;
  201. tsk_remove_bios    endp
  202. ;
  203. ;----------------------------------------------------------------------
  204. ;
  205. ;    void far tsk_install_bios (void)
  206. ;
  207. ;    This routine installs the int handler.
  208. ;
  209. tsk_install_bios    proc    near uses ds
  210. ;
  211.     mov    ds,cs:tsk_dgroup
  212. ;
  213.     IF    TSK_NAMEPAR
  214.     mov    ax,offset fflname
  215.     push    ds
  216.     push    ax
  217.     ENDIF
  218.         mov     ax,offset floppy
  219.         push    ds
  220.         push    ax
  221.         call    create_flag
  222.     IF    TSK_NAMEPAR
  223.     add    sp,8
  224.     ELSE
  225.         add     sp,4
  226.     ENDIF
  227. ;
  228.     IF    TSK_NAMEPAR
  229.     mov    ax,offset ffdname
  230.     push    ds
  231.     push    ax
  232.     ENDIF
  233.         mov     ax,offset fdisk
  234.         push    ds
  235.         push    ax
  236.         call    create_flag
  237.     IF    TSK_NAMEPAR
  238.     add    sp,8
  239.     ELSE
  240.         add     sp,4
  241.     ENDIF
  242. ;
  243.     IF    TSK_NAMEPAR
  244.     mov    ax,offset fkbname
  245.     push    ds
  246.     push    ax
  247.     ENDIF
  248.         mov     ax,offset kbd
  249.         push    ds
  250.         push    ax
  251.         call    create_flag
  252.     IF    TSK_NAMEPAR
  253.     add    sp,8
  254.     ELSE
  255.         add     sp,4
  256.     ENDIF
  257. ;
  258.         push    es
  259.     xor    ax,ax
  260.     mov    es,ax            ; establish addressing for intseg
  261.     assume    es:intseg
  262. ;
  263.     mov    ax,pintofs        ; save old timer int addr
  264.     mov    psofs,ax
  265.     mov    ax,pintseg
  266.     mov    psseg,ax
  267.     cli
  268.     mov    pintofs,offset bios_int ; set new timer int addr
  269.     mov    pintseg,cs
  270.     sti
  271.     assume    es:nothing
  272.         pop     es
  273.     ret
  274. ;
  275. tsk_install_bios    endp
  276. ;
  277.     .tsk_ecode
  278.     end
  279.  
  280.