home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / SCSIDRV.ZIP / UNITS.ASM < prev   
Encoding:
Assembly Source File  |  1991-11-06  |  3.9 KB  |  205 lines

  1. ;
  2. ; target information/control structures
  3. ;
  4.         even
  5. unit0        db    size unit dup (-1)
  6.         even
  7. unit1        db    size unit dup (-1)
  8.         even
  9. unit2        db    size unit dup (-1)
  10.         even
  11. unit3        db    size unit dup (-1)
  12.         even
  13. unit4        db    size unit dup (-1)
  14.         even
  15. unit5        db    size unit dup (-1)
  16.         even
  17. unit6        db    size unit dup (-1)
  18.         ife reserve_addr
  19.         even
  20. unit7        db    size unit dup (-1)
  21.         endif
  22.  
  23. ;
  24. ; basic BPB array
  25. ;
  26.         even
  27. bpb0        db    size bpb dup (-1)
  28.         even
  29. bpb1        db    size bpb dup (-1)
  30.         even
  31. bpb2        db    size bpb dup (-1)
  32.         even
  33. bpb3        db    size bpb dup (-1)
  34.         even
  35. bpb4        db    size bpb dup (-1)
  36.         even
  37. bpb5        db    size bpb dup (-1)
  38.         even
  39. bpb6        db    size bpb dup (-1)
  40.         even
  41. bpb7        db    size bpb dup (-1)
  42.  
  43. ;
  44. ; Additional entries if needed
  45. ;
  46.         ife large_drives
  47.         even
  48. bpb8        db    size bpb dup (-1)
  49.         even
  50. bpb9        db    size bpb dup (-1)
  51.         even
  52. bpbA        db    size bpb dup (-1)
  53.         even
  54. bpbB        db    size bpb dup (-1)
  55.         even
  56. bpbC        db    size bpb dup (-1)
  57.         even
  58. bpbD        db    size bpb dup (-1)
  59.         even
  60. bpbE        db    size bpb dup (-1)
  61.         even
  62. bpbF        db    size bpb dup (-1)
  63.         endif
  64.  
  65.         even
  66. unit_array    dw    unit0
  67.         dw    unit1
  68.         dw    unit2
  69.         dw    unit3
  70.         dw    unit4
  71.         dw    unit5
  72.         dw    unit6
  73.         ife reserve_addr
  74.         dw    unit7
  75.         endif
  76.  
  77.         even
  78. bpb_array    dw    bpb0        ;BPB Array for DOS
  79.         dw    bpb1
  80.         dw    bpb2
  81.         dw    bpb3
  82.         dw    bpb4
  83.         dw    bpb5
  84.         dw    bpb6
  85.         dw    bpb7
  86.         ife large_drives
  87.         dw    bpb8
  88.         dw    bpb9
  89.         dw    bpbA
  90.         dw    bpbB
  91.         dw    bpbC
  92.         dw    bpbD
  93.         dw    bpbE
  94.         dw    bpbF
  95.         endif
  96. bpb_hw_mark    dw    bpb_array
  97.  
  98. tape_unit    dw    -1
  99. cur_unit    dw    unit0
  100. cur_bpb        dw    bpb0
  101.  
  102. ;
  103. ; Given the request header in es:bx
  104. ; Return a pointer in ds:di to the unit entry
  105. ; or 'C' if no such unit exists.
  106. ;
  107. ; Do not destroy es:bx !!!
  108. ;
  109. find_unit    proc    near
  110.         pusha
  111.         mov    ah,es:[bx].rh_unit    ;What drive did they want
  112.         lea    di,unit_array
  113.         lea    si,bpb_array
  114.         mov    cx,MAXUNIT        ;How many to search
  115. find_loop:    mov    bx,[di]            ;Point at a unit    
  116.         mov    al,[bx].unit_num_drv    ;Does this SCSI device
  117.         or    al,al            ;Have any Drives Defined?
  118.         jz    find_next
  119.         mov    dh,[bx].unit_1st_drv    ;Get First Drive Number
  120. find_unit_loop:    cmp    ah,dh            ;Is this the correct drive?
  121.         jz    find_match
  122.         inc    si            ;Bump to next BPB
  123.         inc    si
  124.         ife large_drives
  125.         inc    dh            ;Bump Drive Number
  126.         dec    al            ;Dec Drive count
  127.         jnz    find_unit_loop        ;Try next Drive
  128.         endif
  129.         jmp    short find_next        ;Try next SCSI device
  130. find_match:    mov    cur_unit,bx        ;Found a match
  131.         mov    ax,[si]
  132.         mov    cur_bpb,ax
  133.         clc
  134.         jmp    find_exit
  135. find_next:    inc    di
  136.         inc    di
  137.         loop    find_loop
  138.         stc                ;No More units, Error
  139. find_exit:    popa
  140.         ret
  141. find_unit    endp
  142.  
  143. ;
  144. ; Given the data in a unit entry,
  145. ; create the bpb for the unit.
  146. ;
  147. make_bpb    proc    near
  148.         mov    di,cur_bpb        ;Get the current BPB
  149.         mov    bx,cur_unit        ;Get the current Unit
  150. ;
  151. ; First the basic stuff
  152. ;
  153.         mov    [di].bpb_ss,P_SECT
  154.         mov    [di].bpb_au,CLUSTSIZE
  155.         mov    [di].bpb_rs,1
  156.         mov    [di].bpb_nf,2
  157.         mov    [di].bpb_de,512
  158.         mov    [di].bpb_st,SECT_TRACK
  159.         mov    [di].bpb_nh,1
  160.         mov    [di].bpb_hs_lsw,0
  161.         mov    [di].bpb_hs_msw,0
  162.         mov    [di].bpb_md,0F8h
  163. ;
  164. ; then the size and fat sectors
  165. ;
  166.         mov    dh,[bx].unit_cap_buf.cap_sectors_b3
  167.         mov    dl,[bx].unit_cap_buf.cap_sectors_b2
  168.         mov    ah,[bx].unit_cap_buf.cap_sectors_b1
  169.         mov    al,[bx].unit_cap_buf.cap_sectors_b0
  170.         if large_drives
  171.         mov    [di].bpb_ts,0        ;(32 bit size)
  172.         and    ax,ROUND_CYL        ;Round to nearest Cyl
  173.         mov    [di].bpb_ts_lsw,ax
  174.         mov    [di].bpb_ts_msw,dx
  175.         sub    [di].bpb_ts_lsw,1    ;Make it zero relative
  176.         sbb    [di].bpb_ts_msw,0
  177.         mov    bx,P_SECT        ;Figure out how many
  178.         div    bx            ;sectors it will take
  179.         mov    dx,0            ;to hold the FAT for
  180.         mov    bx,CLUSTSIZE        ;this drive.
  181.         div    bx
  182.         mov    dx,0
  183.         mov    bx,2
  184.         mul    bx
  185.         else
  186.         or    dx,dx
  187.         jz    make_bpb_last        ;Use up the last few sectors
  188.         dec    dx            ;Use up 65536 Sectors
  189.         mov    [bx].unit_cap_buf.cap_sectors_b3,dh
  190.         mov    [bx].unit_cap_buf.cap_sectors_b2,dl
  191.         mov    dx,0            ;Max of 32 Meg
  192.         mov    ax,65535
  193.         jmp    short make_bpb_ts
  194. make_bpb_last:    mov    [bx].unit_cap_buf.cap_sectors_b1,0
  195.         mov    [bx].unit_cap_buf.cap_sectors_b0,0
  196.         and    ax,ROUND_CYL        ;Round to nearest Cyl
  197.         dec    ax            ;Make it zero relative
  198. make_bpb_ts:    mov    [di].bpb_ts,ax
  199.         shr    ax,SECT_2_FS
  200.         endif
  201.         inc    ax            ;Allow for round-off
  202.         mov    [di].bpb_fs,ax
  203.         ret
  204. make_bpb    endp
  205.