home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / latrobe / b / biodif.arc / HDISKDRV.DIF < prev    next >
Text File  |  1987-06-20  |  24KB  |  950 lines

  1.  
  2. ----------HDISKDRV.OLD
  3. ;            HREAD    --  Read sector(s)
  4. ;            HWRITE    --  Write sector(s)
  5. ;            HWRITEV    --  Write sectos(s) with verify
  6. ;            HFORMAT    --  Format track(s)
  7. ;            HINIT    --  Init hard disk drive
  8. ;            HMCHK    --  Media check
  9. ;            HVDISK    --  Verify disk
  10. ;            INTHDL    --  Hard disk interrupt handler
  11. ;
  12.  
  13. ----------HDISKDRV.ASM
  14. ;            HREAD        --  Read sector(s)
  15. ;            HWRITE        --  Write sector(s)
  16. ;            HWRITEV        --  Write sectos(s) with verify
  17. ;            HREAD_PHYS    --  Read physical sector(s)    ;RGT
  18. ;            HWRITE_PHYS    --  Write physical sector(s)    ;RGT
  19. ;            HWRITEV_PHYS    --  Write physical sectos(s) with verify;RGT
  20. ;            HFORMAT        --  Format track(s)
  21. ;            HINIT        --  Init hard disk drive
  22. ;            HMCHK        --  Media check
  23. ;            HVDISK        --  Verify disk
  24. ;            INTHDL        --  Hard disk interrupt handler
  25. ;
  26.  
  27. -----------------------------------------------
  28.  
  29. ----------HDISKDRV.OLD
  30. ;            RETRY    --  Error recovery after a read
  31. ;            HOMET    --  Restore head
  32. ;            MOVEMX    --  Move head to maximum track
  33. ;            MOVEH    --  Move head
  34. ;            LDTSKF    --  Load hard disk task file
  35. ;            OUTCMD    --  Output command and wait for cmd completion
  36. ;            ADVTNS    --  Advance to next logical sector (OS dependent)
  37. ;            ADVTNT    --  Advance to next logical track
  38. ;            DELAY    --  Delay for 0.5 milliseconds
  39. ;
  40.  
  41. ----------HDISKDRV.ASM
  42. ;            HREAD_ONE_SECTOR    --  Read one physical sector;RGT
  43. ;            HWRITE_ONE_SECTOR    --  Write one physical sector;RGT
  44. ;            RETRY        --  Error recovery after a read
  45. ;            HOMET        --  Restore head
  46. ;            MOVEMX        --  Move head to maximum track
  47. ;            MOVEH        --  Move head
  48. ;            LDTSKF        --  Load hard disk task file
  49. ;            OUTCMD        --  Output cmd and wait for completion
  50. ;            ADVTNT        --  Advance to next logical track
  51. ;            DELAY        --  Delay for 0.5 milliseconds
  52. ;
  53.  
  54. -----------------------------------------------
  55.  
  56. ----------HDISKDRV.OLD
  57. ;
  58.  
  59. ----------HDISKDRV.ASM
  60. ;    RGT    8 Feb 1987    Added routines to call cache control.
  61. ;
  62.  
  63. -----------------------------------------------
  64.  
  65. ----------HDISKDRV.OLD
  66.     PUBLIC    HFORMAT            ;Format track(s)
  67.  
  68. ----------HDISKDRV.ASM
  69.     PUBLIC    HREAD_PHYS        ;Read physical sector(s)    ;RGT
  70.     PUBLIC    HWRITE_PHYS        ;Write physical sector(s)    ;RGT
  71.     PUBLIC    HWRITEV_PHYS        ;Write physical sector(s) with verify;RGT
  72.     PUBLIC    HFORMAT            ;Format track(s)
  73.  
  74. -----------------------------------------------
  75.  
  76. ----------HDISKDRV.OLD
  77. ;
  78.  
  79. ----------HDISKDRV.ASM
  80.     EXTRN    TEMP_TRK:WORD, TEMP_SEC:BYTE                ;RGT
  81.     EXTRN    GETFTN:NEAR                        ;RGT
  82. ;                                    ;RGT
  83. ;   Define the entry points for the disk cache routines            ;RGT
  84. ;                                    ;RGT
  85.     EXTRN    READ_BLOCK_FROM_CACHE:NEAR    ;Routine to read cache    ;RGT
  86.     EXTRN    WRITE_BLOCK_TO_CACHE:NEAR    ;Routine to write cache    ;RGT
  87.     EXTRN    INVALIDATE_DISK_CACHE:NEAR    ;Routine to invalidate    ;RGT
  88.                         ;specific disk in cache    ;RGT
  89.     EXTRN    INVALIDATE_HARD_DISK_CACHE:NEAR    ;Routine to invalidate    ;RGT
  90.                         ;hard disk in cache    ;RGT
  91. ;
  92.  
  93. -----------------------------------------------
  94.  
  95. ----------HDISKDRV.OLD
  96. ;    Reg BH        --  Surface/drive number
  97.  
  98. ----------HDISKDRV.ASM
  99. ;    Reg AL        --  Unit code                    ;RGT
  100. ;    Reg CX        --  Sector count
  101. ;    Reg DX        --  Logical sector number            ;RGT
  102. ;    Reg ES:DI    --  Buffer start address
  103. ;
  104. ;   Exit Parameters:
  105. ;
  106. ;    Z-flag is clear if error (return Zero for no error)
  107. ;    Reg AX    --  Error status
  108. ;            Reg AL    = 0    --  no error
  109. ;                = 1    --  error
  110. ;                = 3    --  Drive defective
  111. ;                = 5    --  Disk defective
  112. ;                = 0DH    --  Write verify error
  113. ;                = 0FH    --  Soft error
  114. ;            Reg AH    Bit 0    --  DAM not found
  115. ;                Bit 1    --  Track 0 error
  116. ;                Bit 2    --  Aborted command
  117. ;                Bit 4    --  ID not found
  118. ;                Bit 6    --  CRC error in data field
  119. ;                Bit 7    --  Bad block detect
  120. ;    (RETNS)    --  Number of sectors performed the retry
  121. ;
  122. ;   Registers Changed:    All
  123. ;
  124. ;--
  125. ;
  126. HREAD:
  127.     CLD                ;Set forward flag
  128.     MOV    BYTE PTR RETNS,0    ;No sector did retry yet
  129.     MOV    BX,AX            ;Move disk code to reg BX
  130. ;
  131. ;   Read sector(s) loop
  132. ;
  133. HREAD5:
  134. ;                                    ;RGT
  135. ;   First, try to read the block from the disk cache            ;RGT
  136. ;                                    ;RGT
  137.     CALL    READ_BLOCK_FROM_CACHE    ;Read block from disk cache    ;RGT
  138.     JNC    HREAD_NEXT        ;If found in cache, do not read    ;RGT
  139. ;                                    ;RGT
  140. ;   Disk block not in cache  --  read the block from the disk        ;RGT
  141. ;                                    ;RGT
  142.     PUSH    BX            ;Save logical code of disk    ;RGT
  143.     PUSH    DX            ;Save logical sector of disk    ;RGT
  144.     PUSH    DI            ;Save address of buffer        ;RGT
  145.     CALL    SETPAR            ;Set up the disk parameters    ;RGT
  146.     CALL    HREAD_ONE_SECTOR    ;Read in the hard disk sector    ;RGT
  147.     POP    SI            ;Restor adr of buffer in reg SI    ;RGT
  148.     POP    DX            ;Restore logical sector of disk    ;RGT
  149.     POP    BX            ;Restore logical code of disk    ;RGT
  150.     JNZ    HREAD2            ;If error, just return        ;RGT
  151. ;                                    ;RGT
  152. ;   Disk block has been read  --  now write it to the disk cache    ;RGT
  153. ;                                    ;RGT
  154.     XCHG    SI,DI            ;Store new buffer address    ;RGT
  155.                     ;and get old one        ;RGT
  156.     MOV    AX,BX            ;Move logical disk code to AX    ;RGT
  157.     CALL    WRITE_BLOCK_TO_CACHE    ;Write block to disk cache    ;RGT
  158.     XCHG    SI,DI            ;Restore new buffer address    ;RGT
  159. ;
  160. ;   Done with this read  --  read next sector
  161. ;
  162. HREAD_NEXT:
  163.     INC    DX            ;Inc to next logical sector    ;RGT
  164.     LOOP    HREAD5            ;Loop for multi-sector read
  165. ;
  166. ;   Read completed  --  clear error and return
  167. ;
  168.     XOR    AX,AX            ;Assume no error
  169.     TEST    BYTE PTR RETNS,0FFH    ;Retry before?
  170.     JZ    HREAD2            ;If not, then just exit
  171.     MOV    AL,SERR            ;Otherwise, set soft error
  172. ;
  173. ;   Done with the read  --  turn the LED off on the disk drive
  174. ;
  175. HREAD2:
  176.     JMP    LED_OFF            ;Deselect device and return
  177. ;
  178.  
  179. ;++                                    ;RGT
  180. ;                                    ;RGT
  181. ;   Function:    HREAD_PHYS                        ;RGT
  182. ;
  183. ;   Abstract:
  184. ;
  185. ;    Read physical sector or sectors from the hard disk.        ;RGT
  186. ;
  187. ;   Entry Parameters:
  188. ;
  189. ;    Reg BH        --  Surface/drive number
  190.  
  191. -----------------------------------------------
  192.  
  193. ----------HDISKDRV.OLD
  194. ;    Z-flag is set if error
  195. ;    Reg AX    --  Error status
  196.  
  197. ----------HDISKDRV.ASM
  198. ;    Z-flag is clear if error (Zero indicates no error)
  199. ;    Reg AX    --  Error status
  200.  
  201. -----------------------------------------------
  202.  
  203. ----------HDISKDRV.OLD
  204. HREAD:
  205.     CLD                ;Set forward flag
  206.  
  207. ----------HDISKDRV.ASM
  208. HREAD_PHYS:                                ;RGT
  209.     CLD                ;Set forward flag
  210.  
  211. -----------------------------------------------
  212.  
  213. ----------HDISKDRV.OLD
  214. HREAD5:
  215.     CALL    LDTSKF            ;Load task file for winchester
  216.     JNZ    HREAD2            ;Error if past limit
  217.     MOV    AL,RDREAD+ATRETRY    ;Load read command
  218.  
  219. ----------HDISKDRV.ASM
  220. HREAD_PHYS5:                                ;RGT
  221.     CALL    HREAD_ONE_SECTOR    ;Read in the hard disk sector    ;RGT
  222.     JNZ    HREAD_PHYS2        ;If error, just return        ;RGT
  223. ;
  224. ;   Done with this read  --  read next sector
  225. ;
  226.     CALL    ADVTNS            ;Advance to next sector
  227.     LOOP    HREAD_PHYS5        ;Loop for multi-sector read
  228. ;
  229. ;   Read completed  --  clear error and return
  230. ;
  231.     XOR    AX,AX            ;Assume no error
  232.     TEST    BYTE PTR RETNS,0FFH    ;Retry before?
  233.     JZ    HREAD_PHYS2        ;If not, then just exit
  234.     MOV    AL,SERR            ;Otherwise, set soft error
  235. ;
  236. ;   Done with the read  --  turn the LED off on the disk drive
  237. ;
  238. HREAD_PHYS2:
  239.     JMP    LED_OFF            ;Deselect device
  240. ;
  241.  
  242. ;++
  243. ;
  244. ;   Function:    HREAD_ONE_SECTOR                    ;RGT
  245. ;
  246. ;   Abstract:
  247. ;
  248. ;    Read in one physical sector from the hard disk.
  249. ;
  250. ;   Entry Parameters:
  251. ;
  252. ;    Reg BH        --  Surface/drive number
  253. ;                Bits 0-3 - surface number
  254. ;                Bits 4-7 - drive number
  255. ;    Reg BL        --  Sector number
  256. ;    Reg CX        --  Sector count
  257. ;    Reg DX        --  Cylinder number
  258. ;    Reg ES:DI    --  Buffer start address
  259. ;
  260. ;   Exit Parameters:
  261. ;
  262. ;    Z-flag is clear if error (Zero indicates no error)
  263. ;    Reg AX    --  Error status
  264. ;            Reg AL    = 0    --  no error
  265. ;                = 1    --  error
  266. ;                = 3    --  Drive defective
  267. ;                = 5    --  Disk defective
  268. ;                = 0DH    --  Write verify error
  269. ;                = 0FH    --  Soft error
  270. ;            Reg AH    Bit 0    --  DAM not found
  271. ;                Bit 1    --  Track 0 error
  272. ;                Bit 2    --  Aborted command
  273. ;                Bit 4    --  ID not found
  274. ;                Bit 6    --  CRC error in data field
  275. ;                Bit 7    --  Bad block detect
  276. ;    (RETNS)    --  Number of sectors performed the retry
  277. ;
  278. ;   Registers Changed:    All
  279. ;
  280. ;--
  281. ;
  282. HREAD_ONE_SECTOR:                            ;RGT
  283.     CALL    LDTSKF            ;Load task file for winchester
  284.     JNZ    HREAD_ONE_SECT_RET    ;Error if past limit        ;RGT
  285.     MOV    AL,RDREAD+ATRETRY    ;Load read command
  286.  
  287. -----------------------------------------------
  288.  
  289. ----------HDISKDRV.OLD
  290. HREAD10:
  291.     OR    AL,AL            ;Check for error
  292.     JZ    HREAD3            ;Skip if no error
  293. ;
  294.  
  295. ----------HDISKDRV.ASM
  296. HREAD_ONE_SECT10:                            ;RGT
  297.     OR    AL,AL            ;Check for error
  298.     JZ    HREAD_ONE_SECT3        ;Skip if no error        ;RGT
  299. ;
  300.  
  301. -----------------------------------------------
  302.  
  303. ----------HDISKDRV.OLD
  304.     JNZ    HREAD2            ;If so, then abort command
  305. ;
  306.  
  307. ----------HDISKDRV.ASM
  308.     JNZ    HREAD_ONE_SECT_RET    ;If so, then abort command    ;RGT
  309. ;
  310.  
  311. -----------------------------------------------
  312.  
  313. ----------HDISKDRV.OLD
  314. HREAD3:
  315.     PUSH    DX            ;Save cylinder number
  316.  
  317. ----------HDISKDRV.ASM
  318. HREAD_ONE_SECT3:                            ;RGT
  319.     PUSH    DX            ;Save cylinder number
  320.  
  321. -----------------------------------------------
  322.  
  323. ----------HDISKDRV.OLD
  324. HREAD1:
  325.     IN    AL,DX            ;Get data byte
  326.  
  327. ----------HDISKDRV.ASM
  328. HREAD_ONE_SECT1:                            ;RGT
  329.     IN    AL,DX            ;Get data byte
  330.  
  331. -----------------------------------------------
  332.  
  333. ----------HDISKDRV.OLD
  334.     LOOP    HREAD1            ;Loop for all words in buffer
  335. ;
  336.  
  337. ----------HDISKDRV.ASM
  338.     LOOP    HREAD_ONE_SECT1        ;Loop for all words in buffer    ;RGT
  339. ;
  340.  
  341. -----------------------------------------------
  342.  
  343. ----------HDISKDRV.OLD
  344. ;   Done with this read  --  read next sector
  345. ;
  346.     CALL    ADVTNS            ;Advance to next sector
  347.     LOOP    HREAD5            ;Loop for multi-sector read
  348. ;
  349. ;   Read completed  --  clear error and return
  350. ;
  351.     XOR    AX,AX            ;Assume no error
  352.     TEST    BYTE PTR RETNS,0FFH    ;Retry before?
  353.     JZ    HREAD2            ;If not, then just exit
  354.     MOV    AL,SERR            ;Otherwise, set soft error
  355. ;
  356. ;   Done with the read  --  turn the LED off on the disk drive
  357. ;
  358. HREAD2:
  359.     JMP    LED_OFF            ;Deselect device
  360.     RET                ;Return (Do not know why this is here)
  361.  
  362.  
  363.  
  364. ----------HDISKDRV.ASM
  365. ;   Clear reg AX to indicate success
  366. ;
  367.     XOR    AX,AX            ;Clear reg AX for no error
  368. ;
  369. ;   Done with this read  --  return to caller                ;RGT
  370. ;
  371. HREAD_ONE_SECT_RET:                            ;RGT
  372.     RET                ;And return to caller        ;RGT
  373. ;
  374.  
  375.  
  376. -----------------------------------------------
  377.  
  378. ----------HDISKDRV.OLD
  379. ;    Reg BH        --  Surface/drive number
  380.  
  381. ----------HDISKDRV.ASM
  382. ;    Reg AL        --  Unit code                    ;RGT
  383. ;    Reg CX        --  Sector count
  384. ;    Reg DX        --  Logical sector number            ;RGT
  385. ;    Reg ES:DI    --  Buffer start address
  386. ;
  387. ;   Exit Parameters:
  388. ;
  389. ;    Z-flag is clear if error (Zero indicates no error)
  390. ;    Reg AX    --  Error status
  391. ;            Reg AL    = 0    --  no error
  392. ;                = 1    --  error
  393. ;                = 3    --  Drive defective
  394. ;                = 5    --  Disk defective
  395. ;                = 0DH    --  Write verify error
  396. ;                = 0FH    --  Soft error
  397. ;            Reg AH    Bit 0    --  DAM not found
  398. ;                Bit 1    --  Track 0 error
  399. ;                Bit 2    --  Aborted command
  400. ;                Bit 4    --  ID not found
  401. ;                Bit 6    --  CRC error in data field
  402. ;                Bit 7    --  Bad block detect
  403. ;
  404. ;   Registers Changed:    All
  405. ;
  406. ;--
  407. ;
  408. HWRITEV:
  409.     MOV    BYTE PTR WRTWVF,1    ;Set write with verify flag
  410.     JMP    SHORT HWRITE1        ;And perform write
  411. HWRITE:
  412.     MOV    BYTE PTR WRTWVF,0    ;Clear write with verify flag
  413. HWRITE1:
  414.     CLD                ;Set forward flag
  415.     MOV    SI,DI            ;Set SI to buffer address
  416.     MOV    BX,AX            ;Move disk code to reg BX
  417. ;
  418. ;   Write sector loop
  419. ;
  420. HWRITE5:
  421.     MOV    AX,BX            ;Move logical disk code to AX    ;RGT
  422.     CALL    WRITE_BLOCK_TO_CACHE    ;Write block to disk cache    ;RGT
  423.     PUSH    BX            ;Save logical code of disk    ;RGT
  424.     PUSH    DX            ;Save logical sector of disk    ;RGT
  425.     PUSH    SI            ;Save buffer address        ;RGT
  426.     CALL    SETPAR            ;Set up the disk parameters    ;RGT
  427.     POP    SI            ;Restore buffer address        ;RGT
  428.     CALL    HWRITE_ONE_SECTOR    ;Write sector to disk        ;RGT
  429.     POP    DX            ;Restore logical sector of disk    ;RGT
  430.     POP    BX            ;Restore logical code of disk    ;RGT
  431.     JNZ    HWRITE2            ;If error, just return        ;RGT
  432. ;
  433. ;   Write complete  --  advance to next sector
  434. ;
  435.     INC    DX            ;Inc to next logical sector    ;RGT
  436.     LOOP    HWRITE5            ;And perform multi-sector write
  437. ;
  438. ;   Done with write  --  clear error status
  439. ;
  440.     XOR    AX,AX            ;Clear error status
  441. ;
  442. ;   Done with the write  --  turn the LED off on the disk drive
  443. ;
  444. HWRITE2:
  445.     JMP    LED_OFF            ;Deselect device
  446. ;
  447.  
  448. ;++
  449. ;
  450. ;   Function:    HWRITE_PHYS and HWRITEV_PHYS                ;RGT
  451. ;
  452. ;   Abstract:
  453. ;
  454. ;    Write physical hard disk sector with and without verify        ;RGT
  455. ;
  456. ;   Entry Parameters:
  457. ;
  458. ;    Reg BH        --  Surface/drive number
  459.  
  460. -----------------------------------------------
  461.  
  462. ----------HDISKDRV.OLD
  463. ;    Z-flag is set if error
  464. ;    Reg AX    --  Error status
  465.  
  466. ----------HDISKDRV.ASM
  467. ;    Z-flag is clear if error (Zero indicates no error)
  468. ;    Reg AX    --  Error status
  469.  
  470. -----------------------------------------------
  471.  
  472. ----------HDISKDRV.OLD
  473. HWRITEV:
  474.     MOV    BYTE PTR WRTWVF,1    ;Set write with verify flag
  475.     JMP    SHORT HWRITE1        ;And perform write
  476. HWRITE:
  477.     MOV    BYTE PTR WRTWVF,0    ;Clear write with verify flag
  478. HWRITE1:
  479.     CLD                ;Set forward flag
  480.     MOV    SI,DI            ;Set SI to buffer address
  481. ;
  482.  
  483. ----------HDISKDRV.ASM
  484. HWRITEV_PHYS:                                ;RGT
  485.     MOV    BYTE PTR WRTWVF,1    ;Set write with verify flag
  486.     JMP    SHORT HWRITE_PHYS1    ;And perform write        ;RGT
  487. HWRITE_PHYS:                                ;RGT
  488.     MOV    BYTE PTR WRTWVF,0    ;Clear write with verify flag
  489. HWRITE_PHYS1:                                ;RGT
  490.     CLD                ;Set forward flag
  491.     MOV    SI,DI            ;Set SI to buffer address
  492.     CALL    HWRITE_ONE_SECTOR    ;Write sector to disk        ;RGT
  493.     JNZ    HWRITE_PHYS2        ;If error, just return        ;RGT
  494. ;
  495.  
  496. -----------------------------------------------
  497.  
  498. ----------HDISKDRV.OLD
  499. HWRITE5:
  500.     MOV    DI,SI            ;Set DI to buffer address
  501.     CALL    LDTSKF            ;Load task file
  502.     JNZ    HWRITE2            ;Error if past limit
  503.     MOV    AL,RDWRITE+ATRETRY    ;Load the write command
  504.  
  505. ----------HDISKDRV.ASM
  506. HWRITE_PHYS5:                                ;RGT
  507.     MOV    DI,SI            ;Set DI to buffer address
  508. ;
  509. ;   Write complete  --  advance to next sector
  510. ;
  511.     CALL    ADVTNS            ;Advance to next sector
  512.     LOOP    HWRITE_PHYS5        ;And perform multi-sector write
  513. ;
  514. ;   Done with write  --  clear error status
  515. ;
  516.     XOR    AX,AX            ;Clear error status
  517. ;
  518. ;   Done with the write  --  turn the LED off on the disk drive
  519. ;
  520. HWRITE_PHYS2:
  521.     JMP    LED_OFF            ;Deselect device
  522. ;
  523.  
  524. ;++                                    ;RGT
  525. ;
  526. ;   Function:    HWRITE_ONE_SECTOR                    ;RGT
  527. ;
  528. ;   Abstract:
  529. ;
  530. ;    Write one hard disk sector with and without verify        ;RGT
  531. ;
  532. ;   Entry Parameters:
  533. ;
  534. ;    Reg BH        --  Surface/drive number
  535. ;                Bits 0-3 - surface number
  536. ;                Bits 4-7 - drive number
  537. ;    Reg BL        --  Sector number
  538. ;    Reg CX        --  Sector count
  539. ;    Reg DX        --  Cylinder number
  540. ;    Reg ES:SI    --  Buffer start address
  541. ;
  542. ;   Exit Parameters:
  543. ;
  544. ;    Z-flag is clear if error (Zero indicates no error)
  545. ;    Reg AX    --  Error status
  546. ;            Reg AL    = 0    --  no error
  547. ;                = 1    --  error
  548. ;                = 3    --  Drive defective
  549. ;                = 5    --  Disk defective
  550. ;                = 0DH    --  Write verify error
  551. ;                = 0FH    --  Soft error
  552. ;            Reg AH    Bit 0    --  DAM not found
  553. ;                Bit 1    --  Track 0 error
  554. ;                Bit 2    --  Aborted command
  555. ;                Bit 4    --  ID not found
  556. ;                Bit 6    --  CRC error in data field
  557. ;                Bit 7    --  Bad block detect
  558. ;
  559. ;   Registers Changed:    All
  560. ;
  561. ;--
  562. ;
  563. HWRITE_ONE_SECTOR:                            ;RGT
  564.     CALL    LDTSKF            ;Load task file
  565.     JNZ    HWRITE_ONE_SECT_RET    ;Error if past limit        ;RGT
  566.     MOV    AL,RDWRITE+ATRETRY    ;Load the write command
  567.  
  568. -----------------------------------------------
  569.  
  570. ----------HDISKDRV.OLD
  571.     JNZ    HWRITE2            ;If so, abort
  572. ;
  573.  
  574. ----------HDISKDRV.ASM
  575.     JNZ    HWRITE_ONE_SECT_RET    ;If so, abort            ;RGT
  576. ;
  577.  
  578. -----------------------------------------------
  579.  
  580. ----------HDISKDRV.OLD
  581. HWRITE21:
  582.     LODSW                ;Get word of data from buffer
  583.  
  584. ----------HDISKDRV.ASM
  585. HWRITE_ONE_SECT21:                            ;RGT
  586.     LODSW                ;Get word of data from buffer
  587.  
  588. -----------------------------------------------
  589.  
  590. ----------HDISKDRV.OLD
  591.     LOOP    HWRITE21        ;Loop for all bytes of sector
  592. ;
  593.  
  594. ----------HDISKDRV.ASM
  595.     LOOP    HWRITE_ONE_SECT21    ;Loop for all bytes of sector
  596. ;
  597.  
  598. -----------------------------------------------
  599.  
  600. ----------HDISKDRV.OLD
  601.     JNZ    HWRITE2            ;If error, then abort
  602. ;
  603.  
  604. ----------HDISKDRV.ASM
  605.     JNZ    HWRITE_ONE_SECT_RET    ;If error, then abort
  606. ;
  607.  
  608. -----------------------------------------------
  609.  
  610. ----------HDISKDRV.OLD
  611.     JZ    HWRITE11        ;If none, then advance to next sector
  612. ;
  613.  
  614. ----------HDISKDRV.ASM
  615.     JZ    HWRITE_ONE_SECT11    ;If none, then advance to next sector
  616. ;
  617.  
  618. -----------------------------------------------
  619.  
  620. ----------HDISKDRV.OLD
  621.     JNZ    HWRITE2            ;If error, then abort
  622.     PUSH    CX            ;Save sector count
  623.     MOV    CX,SECSIZE        ;Get sector size
  624. HWRITE15:
  625.     IN    AL,DATA            ;Read byte from disk
  626.     SCASB                ;Compare to original data
  627.     JNZ    HWRITE16        ;If not equal, then  exit with error
  628.     LOOP    HWRITE15        ;Otherwise, continue for all bytes
  629. ;
  630.  
  631. ----------HDISKDRV.ASM
  632.     JNZ    HWRITE_ONE_SECT_RET    ;If error, then abort
  633.     PUSH    CX            ;Save sector count
  634.     MOV    CX,SECSIZE        ;Get sector size
  635. HWRITE_ONE_SECT15:                            ;RGT
  636.     IN    AL,DATA            ;Read byte from disk
  637.     SCASB                ;Compare to original data
  638.     JNZ    HWRITE_ONE_SECT16    ;If not equal, then  exit with error;RGT
  639.     LOOP    HWRITE_ONE_SECT15    ;Otherwise, continue for all bytes;RGT
  640. ;
  641.  
  642. -----------------------------------------------
  643.  
  644. ----------HDISKDRV.OLD
  645. HWRITE16:
  646.     POP    CX            ;Restore sector count
  647.  
  648. ----------HDISKDRV.ASM
  649. HWRITE_ONE_SECT16:                            ;RGT
  650.     POP    CX            ;Restore sector count
  651.  
  652. -----------------------------------------------
  653.  
  654. ----------HDISKDRV.OLD
  655. ;   Write complete  --  advance to next sector
  656. ;
  657. HWRITE11:
  658.     CALL    ADVTNS            ;Advance to next sector
  659.     LOOP    HWRITE5            ;And perform multi-sector write
  660. ;
  661. ;   Done with write  --  clear error status
  662. ;
  663.     XOR    AX,AX            ;Clear error status
  664. ;
  665. ;   Done with the write  --  turn the LED off on the disk drive
  666. ;
  667. HWRITE2:
  668. ;    CALL    LED_OFF            ;Deselect device
  669. ;    RET                ;Return to caller
  670.  
  671.  
  672. ----------HDISKDRV.ASM
  673. ;   Write complete  --  return to caller                ;RGT
  674. ;
  675. HWRITE_ONE_SECT11:                            ;RGT
  676.     XOR    AX,AX            ;Clear error status
  677. HWRITE_ONE_SECT_RET:
  678.     RET                ;Return to caller
  679.  
  680.  
  681. -----------------------------------------------
  682.  
  683. ----------HDISKDRV.OLD
  684. ;   Registers Changed:    All
  685. ;
  686.  
  687. ----------HDISKDRV.ASM
  688. ;   Registers Changed:    AX
  689. ;
  690.  
  691. -----------------------------------------------
  692.  
  693. ----------HDISKDRV.OLD
  694.  
  695.  
  696. ;++
  697. ;
  698. ;   Function:    ADVTNS
  699. ;
  700. ;   Abstract:
  701. ;
  702. ;    Advance to next logical sector on disk.
  703. ;
  704. ;    NOTE:
  705. ;
  706. ;    1)    This routine is operating system dependent
  707. ;
  708. ;    2)    (XLT_F) must be set before entering this routine.
  709. ;        This flag will fix the logical/not logical and
  710. ;        physical/not physical problem.
  711. ;        Actually, only routines HREAD, HWRITE, and HWRITEV
  712. ;        call this routine.
  713. ;
  714. ;   Entry Parameters:
  715. ;
  716. ;    Reg BH        --  Surface/drive number
  717. ;                Bits 0-3 - surface number
  718. ;                Bits 4-7 - drive number
  719. ;    Reg BL        --  Sector number
  720. ;    Reg DX        --  Cylinder number
  721. ;    RDXLT        --  Address of sector translation table
  722. ;    (XLT_F)        --  Translation flag (0 if no translation
  723. ;                should be done)
  724. ;
  725. ;   Exit Parameters:
  726. ;
  727. ;    None
  728. ;
  729. ;   Registers Changed:    AX
  730. ;
  731. ;
  732. ;--
  733. ;
  734. ADVTNS:
  735.     TEST    BYTE PTR XLT_F,0FFH    ;Check if using translation table
  736.     JNZ    ADVTNS3            ;If so, then translate
  737.     INC    BL            ;Otherwise, just set to next sector no.
  738.     CMP    BL,SECPTRK        ;See if past end of track
  739.     JLE    ADVT1            ;If not, then just return
  740.     MOV    BL,1            ;Otherwise, reset sector number to first
  741.     JMP    SHORT ADVTNT        ;And update surface/cylinder number
  742. ;
  743. ;   Sectors are being translated  --  translate them
  744. ;
  745. ADVTNS3:
  746.     PUSH    CX            ;Save registers used
  747.     PUSH    DI
  748.     PUSH    ES
  749. ;
  750. ;   Set reg ES to this code segment
  751. ;
  752.     PUSH    CS            ;Set ES to CS
  753.     POP    ES
  754. ;
  755. ;   Get address of translation table
  756. ;
  757.     MOV    DI,OFFSET RDXLT        ;Get address of translation table
  758.     MOV    CX,SECPTRK        ;Set count to no. of sectors per track
  759.     MOV    AL,BL            ;Get sector number
  760.     REPNZ    SCASB            ;Search for sector in table
  761.     MOV    BL,BYTE PTR [DI]    ;Get next sector number
  762.     POP    ES            ;Restore registers saved
  763.     POP    DI
  764.     JCXZ    ADVT2            ;If not in table, set to first
  765.     POP    CX            ;Restore register CX
  766.     RET                ;And return to caller
  767. ;
  768. ;   Sector was not in translation table  --  set to first sector number
  769. ;
  770. ADVT2:
  771.     POP    CX            ;Restore reg CX
  772.     MOV    BL,RDXLT        ;Set to first sector
  773. ;    JMP    ADVTNT            ;Advance to next track
  774.  
  775.  
  776.  
  777. ----------HDISKDRV.ASM
  778. ;
  779.  
  780.  
  781. -----------------------------------------------
  782.  
  783. ----------HDISKDRV.OLD
  784. ;   Function:    ADVTNT
  785.  
  786. ----------HDISKDRV.ASM
  787. ;   Function:    ADVTNS
  788. ;
  789. ;   Abstract:
  790. ;
  791. ;    Advance to next logical sector on disk.
  792. ;
  793. ;    NOTE:
  794. ;
  795. ;    1)    This routine is operating system dependent
  796. ;
  797. ;    2)    (XLT_F) must be set before entering this routine.
  798. ;        This flag will fix the logical/not logical and
  799. ;        physical/not physical problem.
  800. ;        Actually, only routines HREAD, HWRITE, and HWRITEV
  801. ;        call this routine.
  802. ;
  803. ;   Entry Parameters:
  804. ;
  805. ;    Reg BH        --  Surface/drive number
  806. ;                Bits 0-3 - surface number
  807. ;                Bits 4-7 - drive number
  808. ;    Reg BL        --  Sector number
  809. ;    Reg DX        --  Cylinder number
  810. ;    RDXLT        --  Address of sector translation table
  811. ;    (XLT_F)        --  Translation flag (0 if no translation
  812. ;                should be done)
  813. ;
  814. ;   Exit Parameters:
  815. ;
  816. ;    None
  817. ;
  818. ;   Registers Changed:    AX
  819. ;
  820. ;
  821. ;--
  822. ;
  823. ADVTNS:
  824.     TEST    BYTE PTR XLT_F,0FFH    ;Check if using translation table
  825.     JNZ    ADVTNS3            ;If so, then translate
  826.     INC    BL            ;Otherwise, just set to next sector no.
  827.     CMP    BL,SECPTRK        ;See if past end of track
  828.     JLE    ADVT1            ;If not, then just return
  829.     MOV    BL,1            ;Otherwise, reset sector number to first
  830.     JMP    SHORT ADVTNT        ;And update surface/cylinder number
  831. ;
  832. ;   Sectors are being translated  --  translate them
  833. ;
  834. ADVTNS3:
  835.     PUSH    CX            ;Save registers used
  836.     PUSH    DI
  837.     PUSH    ES
  838. ;
  839. ;   Set reg ES to this code segment
  840. ;
  841.     PUSH    CS            ;Set ES to CS
  842.     POP    ES
  843. ;
  844. ;   Get address of translation table
  845. ;
  846.     MOV    DI,OFFSET RDXLT        ;Get address of translation table
  847.     MOV    CX,SECPTRK        ;Set count to no. of sectors per track
  848.     MOV    AL,BL            ;Get sector number
  849.     REPNZ    SCASB            ;Search for sector in table
  850.     MOV    BL,BYTE PTR [DI]    ;Get next sector number
  851.     POP    ES            ;Restore registers saved
  852.     POP    DI
  853.     JCXZ    ADVT2            ;If not in table, set to first
  854.     POP    CX            ;Restore register CX
  855.     RET                ;And return to caller
  856. ;
  857. ;   Sector was not in translation table  --  set to first sector number
  858. ;
  859. ADVT2:
  860.     POP    CX            ;Restore reg CX
  861.     MOV    BL,RDXLT        ;Set to first sector
  862. ;    JMP    ADVTNT            ;Advance to next track
  863.  
  864.  
  865. ;++
  866. ;
  867. ;   Function:    ADVTNT
  868.  
  869. -----------------------------------------------
  870.  
  871. ----------HDISKDRV.OLD
  872. ;   Function:    CLTPN
  873.  
  874. ----------HDISKDRV.ASM
  875. ;   Function:    SETPAR
  876. ;
  877. ;   Abstract:
  878. ;
  879. ;    Set up disk interface parameters.
  880. ;
  881. ;   Entry Parameters:
  882. ;
  883. ;    Reg AL    --  Unit code
  884. ;    Reg DX    --  Logical sector number
  885. ;
  886. ;   Exit Parameters:
  887. ;
  888. ;    Reg BL    --  Sector number
  889. ;    Reg BH    --  Surface number
  890. ;    Reg DX    --  Cylinder number
  891. ;    (XLT_F)    --  Logical/Physical flag
  892. ;
  893. ;   Registers Changed:    All, except reg DI
  894. ;
  895. ;
  896. ;--
  897. ;
  898. SETPAR:
  899.     MOV    BYTE PTR XLT_F,1    ;Assume using translation table
  900.     MOV    SI,DX            ;Save logical sector number
  901.     CALL    GETFTN            ;Get partition first track
  902.     MOV    AX,SI            ;Get logical sector number
  903.     AND    SI,0FH            ;Form logical sector number
  904.     MOV    BL,BYTE PTR RDXLT[SI]    ;Get sector from translation table
  905.     SHR    AX,1            ;Shift to track offset
  906.     SHR    AX,1
  907.     SHR    AX,1
  908.     SHR    AX,1
  909.     CMP    AX,2            ;Check if tracks 0 or 1
  910.     JGE    SETPAR1            ;If so, use translation table
  911.     MOV    BX,SI            ;Otherwise, do not skew first 2 tracks
  912.     INC    BL            ;Sector number is based at 1
  913.     MOV    BYTE PTR XLT_F,0    ;Do not use translation table
  914. SETPAR1:
  915.     ADD    DX,AX            ;Add partition offset
  916.     MOV    TEMP_TRK,DX        ;Save track no. in case of error
  917.     MOV    TEMP_SEC,BL        ;Save sector no. in case of error
  918. ;                                    ;RGT
  919. ;   Fall through to CLTPN to convert to physical            ;RGT
  920. ;                                    ;RGT
  921. ;    JMP    CLTPN            ;Convert logical track no. to
  922.                     ;physical surface/cylinder number
  923. ;
  924.  
  925. ;++
  926. ;
  927. ;   Function:    CLTPN
  928.  
  929. -----------------------------------------------
  930.  
  931. ----------HDISKDRV.OLD
  932.     PUSH    BX            ;Save register used
  933.     MOV    AX,DX            ;Get cylinder number in DX:AX
  934.     MUL    WORD PTR NUMSURF    ;Divide by number of surfaces
  935.     XOR    DX,DX            ;Clear upper word
  936.     MOV    DL,BH            ;Get surface number
  937.     ADD    DX,AX            ;Add in logical track number
  938.     POP    BX            ;Restore register used
  939.     RET                ;Return to caller
  940.  
  941. ----------HDISKDRV.ASM
  942.     MOV    AX,DX            ;Get cylinder number in reg AX
  943.     MUL    WORD PTR NUMSURF    ;Multiply by number of surfaces
  944.     XOR    DX,DX            ;Clear upper byte
  945.     MOV    DL,BH            ;Get surface number
  946.     ADD    DX,AX            ;Add in logical track number
  947.     RET                ;Return to caller
  948.  
  949. -----------------------------------------------
  950.