home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CDOSDSK5.ZIP / CDOSDSK5.TD0 / XIOS / ROSIF.A86 < prev    next >
Encoding:
Text File  |  1989-01-26  |  5.0 KB  |  252 lines

  1. ; ROSIF.A86
  2. title 'IBM ROS Entry and Semaphores'
  3. pagesize 60+11
  4. ;****************************************
  5. ;*    IBM ROS ENTRY POINTS        *
  6. ;*    MUTUAL EXCLUSION SEMAPHORES    *
  7. ;*    CDOS 6,0 XIOS            *
  8. ;*    DRI OS ENGR, JMB        *
  9. ;****************************************
  10. ; Major mods:
  11. ; 6.0
  12. ; 21 Jul 88 -- intercept int 14 as well                    IJ
  13. ;  7 DEC 87 -- ROS equip_flag no longer changed for int 10h's        GS
  14. ; 17 JUL 87 -- converted XIOS to small model                JW
  15. ; 5.0
  16. ;  6 JAN 86 -- disable keyboard ROS MX control
  17. ; 12 DEC 85 -- don't rely on DS = SYSDAT
  18. ; 11 DEC 85 -- cli before entering ROS
  19. ;  1 JUL 85 -- initial creation
  20.  
  21. ; include COPYRITE.TXT
  22.  
  23. nolist
  24. include CDOS.EQU
  25. include PCHW.EQU
  26. include ROSDATA.EQU
  27. list
  28. ; These were included:
  29. ; include CDOS.EQU
  30. ; include PCHW.EQU
  31. ; include ROSDATA.EQU
  32.  
  33. CGROUP group    CODE,rosif
  34.  
  35. public    vector_table$
  36. public    int10_isr$
  37. public    int10_entry@,    int13_entry@,    int14_entry@
  38. public    int16_entry@,    int40_entry@
  39. public    NUM_VECTORS
  40.  
  41.     cseg
  42. extrn    supif@:near
  43. extrn    sysdat$:word
  44.  
  45. LOCKED    equ    0ffh
  46. FREE    equ    0
  47. eject
  48.  
  49.     cseg
  50.  
  51. ; These routines depend on XIOS INIT to initialize the ROS entry point
  52. ;  variables, and because they swap the actual int. vectors (int. 10 calls
  53. ;  itself), they rely on the fact that the interrupt vectors are part of the
  54. ;  context that gets saved for each process.
  55.  
  56. int10_entry@:                ; Entry point to ROS VIDEO driver
  57. ;------------
  58.     push    ax
  59.     call    get_ros_mx
  60.  
  61.     mov    ax,int10_isr$
  62.     mov    word ptr ros_entry,ax
  63.     mov    ax,int10_isr$+2
  64.     mov    word ptr ros_entry+2,ax
  65.     pop    ax                ; get back original
  66.     call    call_ros            ; alternate entry
  67.     mov    ros_mx,FREE
  68.     ret
  69. eject
  70.  
  71. int13_entry@:                ; Entry point to ROS DISKETTE driver
  72. ;------------
  73.     push    bx
  74.     mov    bx,offset int13_isr
  75.     jmps    common_code
  76.  
  77.  
  78. int14_entry@:                ; Entry point to ROS ASYNC driver
  79. ;------------
  80. ;    push    bx
  81. ;    mov    bx,offset int14_isr
  82. ;    jmps    common_code
  83.  
  84.     pushf
  85.     callf    dword ptr int14_isr
  86.     ret
  87.  
  88. int16_entry@:                ; Entry point to ROS KEYBOARD driver
  89. ;------------
  90. ;    push    bx
  91. ;    mov    bx,offset int16_isr
  92. ;    jmps    common_code
  93.  
  94.     pushf
  95.     callf    dword ptr int16_isr
  96.     ret
  97.  
  98. int40_entry@:                ; Entry point to ROS HD driver
  99. ;------------
  100.     push    bx
  101.     mov    bx,offset int40_isr
  102. ;    jmps    common_code
  103.  
  104.  
  105. common_code:
  106.     push    ax
  107.     call    get_ros_mx
  108.     mov    ax,cs:[bx]                ; offset
  109.     mov    word ptr ros_entry,ax
  110.     mov    ax,cs:2[bx]            ; segment
  111.     mov    word ptr ros_entry+2,ax  
  112.     pop    ax
  113.     pop    bx
  114.     call    call_ros
  115.     mov    ros_mx,FREE
  116.     ret
  117. eject
  118.  
  119. call_ros:
  120.     call    save_5                ; Save these 4 around the
  121.                         ; vector swap
  122.     sub    di,di
  123.     mov    es,di                ; point ES at int. vectors
  124.     mov    si,offset vector_table
  125.     mov    cx,NUM_VECTORS
  126.     cli ! cld
  127.  
  128. lp:
  129.     mov    di,cs:[si]            ; get vector address
  130.     inc si ! inc si                ; point to data
  131.     push    es:word ptr[di]            ; save current offset
  132.     lods cs:ax ! stosw            ;  and replace
  133.     push    es:word ptr[di]            ; save current segment
  134.     lods cs:ax ! stosw            ;  and replace
  135.     sti ! nop ! cli                ; let one in
  136.     loop    lp
  137.     sti
  138.  
  139. ; Now call ROS:
  140. ;  All registers should be correct...flags are the only ones that are dif.,
  141. ;  but flags are not part of the entry spec. for any of these calls.
  142.     call    restore_5            ; Restore the saved regs
  143.      pushf ! cli                ; fake the int.
  144.      callf    ros_entry
  145.  
  146.     pushf                    ; save the return flags
  147.     pop    flags_save            ;  around the vector restore
  148.  
  149.     call    save_5                ;  and these five, too.
  150. eject
  151.  
  152. ; Restore the vectors:
  153.     sub    si,si
  154.     mov    es,si                ; point to low mem.
  155.     mov    ds,sysdat$
  156.     mov    si,offset table_end
  157.     sub    si,6                ; point to vect. address
  158.     mov    cx,NUM_VECTORS
  159.     cli
  160. lp1:
  161.     mov    di,cs:[si]
  162.     sub    si,6
  163.     pop    es:word ptr 2[di]
  164.     pop    es:word ptr  [di]
  165.     sti ! nop ! cli                ; allow one
  166.     loop    lp1
  167.     sti
  168.  
  169. ; Restore the flags:
  170.     push    flags_save
  171.     popff    iret_op@
  172.     call    restore_5            ; as ROS left them.
  173.  
  174. ; And go home:
  175.     ret                    ; back to caller
  176.  
  177. eject
  178.  
  179. get_ros_mx:
  180. ; Uses ax.
  181.     mov    al,LOCKED            ; locked for us
  182.     xchg    al,ros_mx
  183.     inc    al                ; if already locked, set ZF
  184.      jnz    got_it                ; jump if not already locked
  185.  
  186.     push bx ! push cx ! push dx
  187.     push bp ! push di ! push si ! push es
  188.     mov    cl,P_DELAY
  189.     mov    dx,1                ; delay for one tick
  190.     call    supif@
  191.     pop es ! pop si ! pop di ! pop bp
  192.     pop dx ! pop cx ! pop bx
  193.  
  194.     jmps    get_ros_mx            ; try again
  195.  
  196. got_it:
  197.     ret
  198.  
  199.  
  200. save_5:
  201.     mov    es_save,es
  202.     mov    ds_save,ds
  203.     mov    si_save,si
  204.     mov    di_save,di
  205.     mov    cx_save,cx
  206.     mov    ax_save,ax
  207.     ret
  208.  
  209.  
  210. restore_5:
  211.     mov    es,es_save
  212.     mov    ds,ds_save
  213.     mov    si,si_save
  214.     mov    di,di_save
  215.     mov    cx,cx_save
  216.     mov    ax,ax_save
  217.     ret
  218. eject
  219. rosif    cseg
  220.  
  221. ros_entry    rd    1            ; space for current entry
  222.                         ;  address
  223. vector_table$    rw 0
  224.         dw    10h*4            ; video entry
  225. int10_isr$    dw    0,0
  226.         dw    13h*4            ; diskette entry
  227. int13_isr    dw    0,0
  228.         dw    14h*4            ; async entry
  229. int14_isr    dw    0,0
  230.         dw    16h*4            ; keyboard entry
  231. int16_isr    dw    0,0
  232.         dw    40h*4            ; hard-disk entry
  233. int40_isr    dw    0,0
  234.  
  235. table_end    rb    0
  236. NUM_VECTORS    equ    (offset $ - offset vector_table) / 6
  237.  
  238.  
  239. flags_save    rw    1
  240. es_save        rw    1
  241. ds_save        rw    1
  242. si_save        rw    1
  243. di_save        rw    1
  244. cx_save        rw    1
  245. ax_save        rw    1
  246.  
  247. ros_mx        db    FREE
  248.  
  249. end
  250.  
  251. ; END OF ROSIF.A86
  252.