home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / MIDI.ZIP / MIDIDRV.ASM < prev    next >
Assembly Source File  |  1991-10-27  |  4KB  |  172 lines

  1. ;
  2. ; Musical Instrument Digital Interface
  3. ; Assembler routines for an OS/2 Device
  4. ; Driver written in C.
  5. ;
  6. ; Copyright Carl M. Benda 1991
  7.  
  8.         EXTRN   _main:near
  9.         EXTRN   _DevHlp:dword
  10.         EXTRN   _interrupt_handler:near
  11.         PUBLIC  _STRAT
  12.         PUBLIC  _INT_HNDLR
  13.         PUBLIC  _SetIRQ
  14.         PUBLIC  _ReadBytes
  15.         PUBLIC  _WriteBytes
  16.         PUBLIC  _int3
  17.         PUBLIC  __acrtused
  18.  
  19. _DATA   segment word public 'DATA'
  20. _DATA   ends
  21.  
  22. CONST   segment word public 'CONST'
  23. CONST   ends
  24.  
  25. _BSS    segment word public 'BSS'
  26. _BSS    ends
  27.  
  28. DGROUP  group   CONST, _BSS, _DATA
  29.  
  30. _TEXT   segment word public 'CODE'
  31.  
  32. ASSUME  cs:_TEXT, ds:DGROUP, es:NOTHING, ss:NOTHING
  33.  
  34.  
  35.  
  36.  
  37. .286P
  38.  
  39. ;
  40. ;       C startup routine for mididrv.c
  41. ;       _Strat is called by OS/2 during
  42. ;       boot time.
  43. ;
  44.  
  45. _STRAT  proc    far
  46. __acrtused:             ;prevent startup C
  47.         push    0       ;used as the dev value
  48.         push    es      ;send request packet address
  49.         push    bx
  50.         call    _main   ;call driver main function
  51.         pop     bx      ;restore bx
  52.         pop     es      ;restore es
  53.         add     sp,2    ;get rid of pushed 0
  54.         retf
  55.  
  56. _STRAT  endp
  57.  
  58.  
  59. _INT_HNDLR proc far
  60.         pusha           ;save registers
  61.         push    ds
  62.         push    es
  63.         call    _interrupt_handler  ;handle interrupts
  64.         mov     al,9h   ;int value  ;interrupt number.
  65.         mov     dl,31h  ;devhlp EOI ;DevHlp End of int
  66.         call    [_DevHlp]           ;call DevHlp entry
  67.         pop     es
  68.         pop     ds
  69.         popa            ;restore everything
  70.         retf            ;return to C function.
  71.  
  72. _INT_HNDLR endp
  73.  
  74. ;
  75. ; These next routines are used by the C code
  76. ; because these procedures need to call special
  77. ; device driver helper routines requiring
  78. ; hardware registers of specific values.
  79. ;
  80.  
  81. _SetIRQ   proc  near
  82.         push    bp
  83.         mov     bp,sp
  84. ;       flag    located at bp + 8
  85. ;       fnc     located at bp + 6
  86. ;       irq     irq number at + 4
  87.  
  88.         mov     bx,WORD PTR [bp+4]      ;irq number
  89.         mov     ax,WORD PTR [bp+6]      ;fnc entry
  90.         mov     dh,BYTE PTR [bp+8]      ;share flag
  91.         mov     dl,1Bh                  ;SetIRQ DevHlp
  92.         call    [_DevHlp]
  93.         leave
  94.         ret
  95.  
  96. _SetIRQ ENDP
  97.  
  98. _ReadBytes proc near
  99.         push    bp
  100.         mov     bp,sp
  101.         pusha
  102.         push    es
  103.         push    ds
  104.  
  105. ;       Physical Offset  =  4
  106. ;       Physical Segment =  6
  107. ;       Device   Driver  =  8
  108. ;       count            = 12
  109.  
  110.         mov     ax,WORD PTR [bp+6]
  111.         mov     bx,WORD PTR [bp+4]
  112.         mov     dl,15h                  ;PhysToVirt
  113.         mov     dh,01h                  ;result in es:di
  114.         call    [_DevHlp]               ;useable addr.
  115.  
  116.         lds     si,DWORD PTR [bp+ 8]    ;source
  117.         mov     cx, WORD PTR [bp+12]    ;bytes to move
  118.         rep     movsb                   ;copy data!
  119.  
  120.         mov     dl,32h                  ;Must UnPhys!
  121.         call    [_DevHlp]
  122.  
  123.         pop     ds
  124.         pop     es
  125.         popa
  126.         leave
  127.         ret
  128.  
  129. _ReadBytes ENDP
  130.  
  131. _WriteBytes proc near
  132.         push    bp
  133.         mov     bp,sp
  134.         pusha
  135.         push    es
  136.         push    ds
  137.  
  138. ;       Physical Offset  =  4
  139. ;       Physical Segment =  6
  140. ;       Device   Driver  =  8
  141. ;       count            = 12
  142.  
  143.         mov     ax,WORD PTR [bp+6]
  144.         mov     bx,WORD PTR [bp+4]
  145.         mov     dl,15h                  ;PhysToVirt
  146.         mov     dh,00h                  ;result in ds:si
  147.         call    [_DevHlp]               ;useable addr.
  148.  
  149.         les     di,DWORD PTR [bp+ 8]    ;source
  150.         mov     cx, WORD PTR [bp+12]    ;bytes to move
  151.         rep     movsb                   ;copy data!
  152.  
  153.         mov     dl,32h                  ;Must UnPhys!
  154.         call    [_DevHlp]
  155.  
  156.         pop     ds
  157.         pop     es
  158.         popa
  159.         leave
  160.         ret
  161.  
  162. _WriteBytes ENDP
  163.  
  164. _int3   proc    near
  165.         int     3
  166.         ret
  167. _int3   endp
  168.  
  169. _TEXT   ends
  170.         end
  171.  
  172.