home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / cyrix2.zip / CYRIX.ASM next >
Assembly Source File  |  1992-12-13  |  5KB  |  220 lines

  1.         page    50,132
  2.         .286
  3.  
  4.         .xlist
  5.         INCL_BASE  equ  1
  6.         include OS2.INC
  7.         .list
  8.  
  9.         public  header
  10.         public  devhlp
  11.         public  tInterrupt
  12.         public  fEnabled
  13.         public  strategy
  14.         public  init
  15.         public  enable
  16.         public  strategy9
  17.         public  dataPtr
  18.  
  19. DGROUP  group   _DATA
  20.  
  21. _DATA   segment word    public  'DATA'
  22. header  label   dword
  23.         dd      -1
  24.         dw      1000000010000000b       ; char device, OS/2 1.x level
  25.         dw      strategy
  26.         dw      0
  27.         db      'Cyrix$  '
  28.         db      8 dup (0)
  29.  
  30.         align   4
  31. devhlp  label   dword
  32.         dw      ?
  33.         dw      ?
  34.  
  35. fEnabled        label   byte
  36.         db      -1                      ; -1 => cache not enabled
  37.                                         ; 0 => cache enabled
  38.  
  39. end_resident    equ     this byte
  40.         
  41. _DATA   ends
  42.  
  43. _TEXT   segment word    public  'CODE'
  44.         assume  cs:_TEXT, ds:DGROUP, es:NOTHING
  45.  
  46. strategy        proc    far
  47. ;;;;        int 3
  48.         cmp     byte ptr es:[bx+2],0    ; init?
  49.         mov     ax,8103h                ; assume not
  50.         jne     strategy9
  51.  
  52.         call    init
  53.         mov     ax,0100h                ; no error, done
  54.  
  55. strategy9:
  56.         mov     word ptr es:[bx+3],ax
  57.         ret
  58. strategy        endp
  59.  
  60. enable  proc    near
  61.         .386p
  62.  
  63.         push    eax
  64.         push    ebx
  65.  
  66.         cli
  67.         jmp     $+2
  68.  
  69.         ; disable cache filling & flush cache
  70.         mov     eax,cr0
  71.         mov     ebx,eax         ; save copy cr0
  72.         or      eax,040000000h
  73.         mov     cr0,eax
  74.  
  75.         ; flush cache
  76.         db      00001111b, 00001000b    ; invalidate cache (invd)
  77.  
  78.         ; turn on NC0, NC1, & BARB
  79.         ; NC0
  80.         ; bit 0 = 1 inhibits caching  1st 64K bytes at each 1Mb boundary
  81.         ;
  82.         ; NC1
  83.         ; bit 1 = 1 inhibits caching of memory addresses 09ffffh to 0ffffffh
  84.         ; 
  85.         ; BARB
  86.         ; bit 5 = 1 forces cache to flush when HOLD state entered
  87.         ; (HOLD state entered when BUS master active (or DRAM refresh?)
  88.         ;
  89.         mov     al,0c0h
  90.         out     22h,al
  91.         mov     al,23h
  92.         out     23h,al
  93.  
  94.         ; set start address equal to 0 & block size to disabled for NCR1
  95.         mov     al,0c5h
  96.         out     22h,al
  97.         mov     al,0
  98.         out     23h,al
  99.         mov     al,0c6h
  100.         out     22h,al
  101.         mov     al,0
  102.         out     23h,al
  103.  
  104.         ; set start address to 0 & block size to disabled for NCR2
  105.         mov     al,0c8h
  106.         out     22h,al
  107.         mov     al,0
  108.         out     23h,al
  109.         mov     al,0c9h
  110.         out     22h,al
  111.         mov     al,0
  112.         out     23h,al
  113.  
  114.         ; set start address to 0 & block size to disabled for NCR3
  115.         mov     al,0cbh
  116.         out     22h,al
  117.         mov     al,0h
  118.         out     23h,al
  119.         mov     al,0cch
  120.         out     22h,al
  121.         mov     al,0h
  122.         out     23h,al
  123.  
  124.         ; set start address to 0 & block size to disabled for NCR4
  125.         mov     al,0ceh
  126.         out     22h,al
  127.         mov     al,0h
  128.         out     23h,al
  129.         mov     al,0cfh
  130.         out     22h,al
  131.         mov     al,0
  132.         out     23h,al
  133.  
  134.         ; enable cache filling
  135.         mov     eax,ebx         ; restore cr0
  136.         and     eax,09fffffffh
  137.         mov     cr0,eax
  138.  
  139.         pop     ebx
  140.         pop     eax
  141.  
  142.         sti
  143.  
  144.         .286
  145.         ret
  146. enable  endp
  147.  
  148.         align   4
  149. dataPtr label   word
  150.         dw      _DATA
  151.  
  152.         align   4
  153. tInterrupt      proc    far
  154.         ; must save used registers
  155.         push    cx
  156.         push    ds
  157.  
  158.         ;
  159.         ; point DS to local data
  160.         ;
  161.         mov     ds,cs:dataPtr
  162.  
  163.         ;
  164.         ; see if we been here before
  165.         ;
  166.         xor     cx,cx
  167.         xchg    cl,fEnabled
  168.         jcxz    tInterrupt9
  169.  
  170.         call    enable
  171.  
  172.         align   4
  173. tInterrupt9:
  174.         pop     ds
  175.         pop     cx
  176.         ret
  177. tInterrupt      endp
  178.  
  179.         ;
  180.         ; put all code to remain resident before init
  181.         ;
  182. init    proc    near
  183.         ;
  184.         ; save address of devhlp entry point
  185.         ;
  186.         mov     ax,es:[bx+14]
  187.         mov     word ptr devhlp+0,ax
  188.         mov     ax,es:[bx+16]
  189.         mov     word ptr devhlp+2,ax
  190.  
  191.         ;
  192.         ; add timer handler to list of timer handlers
  193.         ;
  194.         lea     ax,_TEXT:tInterrupt
  195.         mov     dl,29                   ; add timer function
  196.         call    devhlp
  197.         jnc     @F
  198.  
  199.         ;
  200.         ; call failed => don't install driver
  201.         ;
  202.         mov     word ptr es:[bx+14],0
  203.         mov     word ptr es:[bx+16],0
  204.         jmp     short init9
  205.  
  206. @@:
  207.         ;
  208.         ; tell kernel what to keep resident
  209.         ;
  210.         mov     word ptr es:[bx+14],offset CS:init
  211.         mov     word ptr es:[bx+16],offset DGROUP:end_resident
  212.  
  213. init9:
  214.         ret
  215. init    endp
  216.  
  217. _TEXT   ends
  218.  
  219.         end
  220.