home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / sysutl / aux2.arc / AUX2.ASM < prev    next >
Assembly Source File  |  1987-03-20  |  4KB  |  214 lines

  1.     title    aux2 - com2 AUX driver
  2. ;
  3. ; This program will make the AUX driver talk to the COM2 port so that Windows
  4. ; can have it's debugging terminal on COM2.
  5. ;
  6. ;    Copyright (c) Steve Brozosky, 1987
  7. ;
  8. ;        Steve Brozosky
  9. ;        2555 Raven Road
  10. ;        Pleasanton, CA  94566
  11. ;
  12. ;
  13. ;    This program is available for the Public Domain.
  14. ;
  15. ;
  16. ;    Version 1.00   January 19, 1987
  17. ;
  18. ;
  19. ;    To use, add the following line to your CONFIG.SYS:
  20. ;
  21. ;        device=aux2.sys
  22. ;
  23. ;
  24. ;    To Build this program:
  25. ;
  26. ;        masm aux2;
  27. ;        link aux2;
  28. ;        exe2bin aux2 aux2.sys
  29. Cseg    segment para public 'code'
  30.  
  31.  
  32. Request       equ    es:[bx]        ;pointer to request header
  33.  
  34. RequestH   Struc          ;Request header structure
  35.         db    ?         ;length of Request Header (including data)
  36.         db    ?         ;unit code 
  37. Command    db    ?         ;command code
  38. Status       dw    ?         ;status
  39.         dq    ?         ;reserved for DOS
  40. Media       db    ?        ;media descriptor byte
  41. AddrOff       dw    ?        ;transfer address
  42. AddrSeg       dw    ?    
  43. Count       dw     ?        ;byte/sector count value
  44. Sector       dw    ?        ;starting sector value
  45. RequestH   Ends
  46.  
  47.  
  48. Aux2        proc    far
  49.  
  50.         assume    cs:Cseg, ds:nothing, es:nothing
  51. begin:
  52.  
  53. NextDev     dd    -1            ;no more devices
  54. Attribute    dw    1000100000000000b    ;char device, supports open
  55. Strategy    dw    AuxStrategy        ;ptr to device strategy code
  56. Interrupt    dw    AuxInt            ;ptr of drive interrupt code    
  57. devName     db    'AUX     '        ;logical name
  58.  
  59. RequestOff    dw    ?
  60. RequestSeg    dw    ?
  61.  
  62. ;
  63. ;    function table
  64. ;
  65. funTab        label    word
  66.         dw    Init            ;Initialization
  67.         dw    MediaCheck        ;Media check 
  68.         dw    BuildBpb        ;Build BIOS parm block
  69.         dw    IoCtlIn            ;I/O control read
  70.         dw    Read            ;Read
  71.         dw    NdRead            ;Nondestructive read
  72.         dw    InStat            ;Input status
  73.         dw    InFlush            ;Flush input buffers
  74.         dw    Write            ;Write
  75.         dw    WriteVerify        ;Write with verify
  76.         dw    OutStat            ;Output statuc
  77.         dw    OutFlush        ;Flush output buffers
  78.         dw    IoCtlOut        ;I/O control write
  79.         dw    Open            ;Open
  80.         dw    Close            ;Close
  81.  
  82. ;
  83. ;    Strategy Routine.
  84. ;
  85. ;    Input:
  86. ;      es:bx         Address of Request Header
  87. ;
  88. AuxStrategy:
  89.     mov    cs:RequestSeg,es    ;save segment of request header
  90.     mov    cs:RequestOff,bx    ;save offset of request header
  91.     ret                ;and just return
  92.  
  93. ;
  94. ;    Interrupt Routine.
  95. ;
  96. ;    Will process the previous request header.
  97. ;
  98. AuxInt:
  99.     pushf                ;save everything first
  100.     push    ds
  101.     push    es
  102.     push    ax
  103.     push    bx
  104.     push    cx
  105.     push    dx
  106.     push    di
  107.     push    si
  108.     cld
  109.  
  110.     les    bx,dword ptr cs:RequestOff ;point to request header
  111.     mov    al,Request.Command    ;get command code
  112.     shl    al,1            ;make into 16 bit offset
  113.     xor    ah,ah            ;clear high bits
  114.     lea    di,funTab        ;get address of function table
  115.     add    di,ax            ;now point to appropriate routine
  116.     jmp    word ptr [di]        ;and go to it
  117.  
  118. ;
  119. ;    Output Routines.
  120. ;
  121. Write:
  122. WriteVerify:
  123.     mov    cx, Request.Count    ;get number of bytes to write
  124.     lds    si,dword ptr Request.AddrOff    ;point to data
  125. ;
  126. OLoop:
  127.     lodsb                ;get byte to output
  128.     mov    ah,1            ;transmit character
  129.     mov    dx,1            ;go to com2
  130.     int    14h            ;call BIOS comm output routine
  131.                     ;no error checking is done here
  132.     loop    OLoop            ;send out whole string
  133.  
  134.     jmp    done            ;and exit driver
  135. ;
  136. ;
  137. ;    Input Routine  (Read 1 byte)
  138. ;
  139. Read:
  140.     les    di,dword ptr Request.AddrOff    ;point to buffer
  141. ;
  142.     mov    dx,1            ;go to com2
  143.     mov    ah,2            ;receive char from comm port
  144.     int    14h            ;call BIOS routine
  145. ;
  146.     stosb                ;put byte into buffer
  147. ;
  148.     jmp    done            ;all done, exit driver
  149.  
  150. ;
  151. ;    These routines are not supported and should just return
  152. ;    with done flag set.
  153. ;
  154. MediaCheck:
  155. BuildBpb:
  156. IoCtlIn:
  157. IoCtlOut:
  158. NdRead:
  159. InStat:
  160. InFlush:
  161. OutStat:
  162. OutFlush:
  163. Open:
  164. Close:
  165.  
  166. done:
  167.     or    Request.Status,0100h        ;set done flag in header
  168. ;
  169.     pop    si                ;and restore registers
  170.     pop    di
  171.     pop    dx
  172.     pop    cx
  173.     pop    bx
  174.     pop    ax
  175.     pop    es
  176.     pop    ds
  177.     popf
  178.     ret
  179. ;
  180. ;    Initialization routine.  Will display message and tell caller
  181. ;    where end of driver is.  This init code will then be discarded.
  182. ;
  183.  
  184. Init:
  185.     mov    ah,9                ;print to console
  186.     mov    dx,offset SignOn        ;print signon
  187.     int    21h                ;call DOS
  188. ;
  189.     mov    Request.AddrSeg, cs        ;put last address in header
  190.     mov    Request.AddrOff, offset Init
  191.  
  192.     jmp    done                ;and return from driver
  193. ;
  194. ;
  195. ;    Signon information
  196. ;
  197. SignOn:
  198.     db    13,10
  199.     db    'AUX2.SYS  Version 1.00  Steve Brozosky',13,10
  200.     db    'AUX Port Now Redirected to COM2.',13,10,13,10,'$'
  201. ;
  202. ;
  203. ;    Copyright information
  204. ;
  205.     db    'Copyright (c) Steve Brozosky, Pleasanton, California, 1987'
  206. ;
  207. Aux2    endP
  208.  
  209. Cseg    endS
  210.  
  211.     end
  212.  
  213.