home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / disk.doc < prev    next >
Text File  |  1990-01-11  |  14KB  |  524 lines

  1.  
  2.         Fixed Disk System Trainning Course
  3.  
  4.  
  5. 1.    Introduction
  6.  
  7.  
  8.     1.1    Basic Function of Disk Controller
  9.  
  10.     1.2    Disk Interface Standard
  11.  
  12.         A.    ST-506/412 Winchester
  13.         B.    Enhanced Small Device Interface(ESDI)
  14.         C.    Storage Module Device(SMD)
  15.         D.    Enhanced SMD
  16.         E.    Small Computer Systems Interface(SCSI)
  17.         F.    Intelligent Peripheral Interface(IPI)
  18.         G.    AT-Bus
  19.  
  20.     1.3    Coding
  21.  
  22.         A.    Frequency Modulation(FM)
  23.         B.    Modified Frequency MOdulation(MFM)
  24.         C.    Run Length Limited(RLL)
  25.         D.    Group Code Recording(GCR)
  26.         E.    Zone Bit Recording(ZBR)*
  27.  
  28.     1.4    Data Format
  29.  
  30.     1.5    Sector Interleaving
  31.  
  32.     1.6    Disk Formatting
  33.  
  34.         A.    Physical Format
  35.         B.    Partitioning
  36.         C.    Logical Format
  37.  
  38.     1.7    Translative Versus Non-Translative Mode
  39.  
  40.  
  41. 2.    Winchester Disk Controller
  42.  
  43.  
  44.     2.1    System Configuration for Fixed Disk System
  45.  
  46. 3.    Programming Sequence in Fixed Disk Service Program
  47.  
  48. 4.    Q & A
  49.  
  50.  
  51.         1.    Introduction
  52.  
  53.  
  54. 1.1    Basic Function of a Disk Controller
  55.  
  56.  
  57.     1.    Write data to the disk
  58.     
  59.     2.    Read data from the disk
  60.  
  61.     3.    Serialize and de-serialize data
  62.  
  63.     4.    Control the disk drive(option)
  64.  
  65.     5.    Ensure data integrity
  66.  
  67.     6.    Provide reasonable system interface(option)
  68.  
  69.     7.    Buffer data to/from disk
  70.  
  71.  
  72.  
  73. 1.2    Disk Interface Standard
  74.  
  75.  
  76.  
  77.  
  78.       │
  79.     High  │
  80.       │
  81.       │
  82.       │                             . IPI
  83.       │
  84.       │              . SMD          . ESMD
  85.       │
  86.       │                          . SCSI
  87.  COST      │                   . ESDI
  88.       │
  89.       │
  90.       │
  91.       │            . ST-412HP
  92.       │
  93.       │         . ST-506/412     . AT Bus
  94.       │
  95.     Low      │   . 3.5 Floppy
  96.       │
  97.       └───────────────────────────────────────────────────────>
  98.         Low                           High
  99.                PERFORMANCE
  100.  
  101.     Fig 1 :    Fixed Disk Interface Versus Market
  102.  
  103.  
  104. A.    ST-506 412 Winchester Interface
  105.  
  106.  
  107.     1.    Industry standard since 1981
  108.  
  109.     2.    Low capacity Winchester(5 - 150 Mbytes)
  110.  
  111.     3.    small size
  112.  
  113.     4.    Serial data transfer rate of 5 Mbits/second
  114.  
  115.     5.    Cost(not performance) oriented
  116.  
  117.     6.    Simple disk interface(most effort is in the disk controller)
  118.  
  119.  
  120. B.    Enhanced Small Device Interface(ESDI)
  121.  
  122.     
  123.     1.    Substantial upgrade to ST-506/412 interface
  124.  
  125.     2.    Oriented towards high-capacity, high speed small winchesters
  126.  
  127.     3.    Also capable of handling magnetic tapes and optical disks
  128.  
  129.     4.    Serial transfer rate 10 Mbits/second
  130.  
  131.     5.    Controller complexity simpler
  132.  
  133.  
  134. C.    Storage Module Device(SMD)
  135.  
  136. D.    Enhanced SMD
  137.  
  138. E.    Small Computer Systems Interface(SCSI)
  139.  
  140.  
  141.     1.    ANSI defined intelligent, low-cost peripheral interface
  142.  
  143.     2.    Derived from SASI(Shgart Assoc. Systems Interface)
  144.  
  145.     3.    8-bit parallel data transfer, 1.5 to 4 Mbytes/second
  146.  
  147.     4.    Provides device independent software
  148.  
  149.     5.     Function more as a computer interface than a disk interface
  150.  
  151.     6.    Requires lots of intelligence in the peripheral
  152.     
  153.  
  154. F.    Intelligent Peripheral Interface(IPI)
  155.  
  156. G.    AT-Bus
  157.  
  158.  
  159.     1.    Cost dowm
  160.  
  161.     2.    Data transfer rate
  162.  
  163.     3.    An I/O slot more for another add on card
  164.  
  165.     4.    The fixed disk controller is no longer required
  166.  
  167.  
  168. 1.3    Coding
  169.  
  170.         There are 4 different ways of improving the storage capacity of
  171.     disk drives:
  172.     
  173.         1)    Added more platters
  174.         2)    Added more tracks per platter
  175.         3)    Increase BPI(Bit Per Inch)
  176.         4)    Use better encoding methods
  177.     
  178.         For method 1, it will increase manufacture cost for extra platter
  179.     and extra read/write head set.
  180.  
  181.         For method 2, it will increase control logic complexity for write
  182.     current precompensation and interfere.
  183.  
  184.         For method 3, it will use better read/write set to shorten the
  185.     length between read/write head and platter.
  186.  
  187.         For method 4, it will increase the encoding/decoding complexity.
  188.  
  189.  
  190. A.    Frequency Modulation(FM)
  191.  
  192.  
  193.                    1 bit cell
  194.                 │<----->│
  195.         ┌───────┐       ┌───────┐                ┌───────┐
  196.         │   1   │   0   │   1   │    0       0       0  │   1   │  0
  197.   NRZ Data    ──┘       └───────┘       └───────────────────────┘       └────
  198.  
  199.  
  200.          c   d     c     c   d     c     c     c     c   d     c
  201.         ┌─┐ ┌─┐    ┌─┐     ┌─┐ ┌─┐ ┌─┐     ┌─┐     ┌─┐     ┌─┐ ┌─┐ ┌─┐ 
  202.         │ │ │ │    │ │     │ │ │ │ │ │     │ │     │ │     │ │ │ │ │ │
  203.   FM Data     ──┘ └─┘ └─┘ └─────┘ └─┘ └─┘ └─────┘ └─────┘ └─────┘ └─┘ └─┘ └─
  204.  
  205.  
  206.  
  207.         ┌───┐   ┌───────┐   ┌───┐       ┌───────┐       ┌───┐   ┌───
  208.   Disk Flux       │   │   │       │   │   │       │       │       │   │   │
  209.   Transitions ──┘   └───┘       └───┘   └───────┘       └───────┘   └───┘  
  210.   
  211.  
  212.  
  213.     FM Encoding Rules :
  214.  
  215.     1.    Insert clock pulse for each bit cell
  216.     2.    Insert data pulse when NRZ data is "1"
  217.  
  218.  
  219.  
  220. B.    Modified Frequency Modulation(MFM)
  221.  
  222.  
  223.                    1 bit cell
  224.                 │<----->│
  225.         ┌───────┐       ┌───────┐                ┌───────┐
  226.         │   1   │   0   │   1   │    0       0       0  │   1   │  0
  227.   NRZ Data    ──┘       └───────┘       └───────────────────────┘       └────
  228.  
  229.                         ┌─┐    ┌─┐
  230.                         │ │    │ │
  231.   Clock          ──────────────────────────────────┘ └─────┘ └──────────────
  232.  
  233.             ┌─┐            ┌─┐                    ┌─┐
  234.             │ │            │ │                    │ │
  235.   Data          ──────┘ └─────────────┘ └─────────────────────────────┘ └────
  236.  
  237.              d               d           c     c         d      
  238.             ┌─┐                ┌─┐         ┌─┐     ┌─┐         ┌─┐     
  239.             │ │                │ │         │ │     │ │         │ │    
  240.   MFM Data    ──────┘ └─────────────┘ └─────────┘ └─────┘ └─────────┘ └────
  241.  
  242.  
  243.             ┌───────────────┐           ┌───────┐           ┌─────
  244.   Disk Flux          │               │           │       │           │           
  245.   Transitions ──────┘               └───────────┘       └───────────┘      
  246.   
  247.  
  248.  
  249.     MFM Encoding Rules :
  250.  
  251.     1.    Insert clock in pulse at the beginning of a bit cell only
  252.         if NRZ data = 0 for two consecutive bits
  253.     2.    If data bit = 1, insert data pulse in the middle of the bit
  254.         cell.
  255.     3.    If data bit = 0, no insertion of data pulses in the bit cell
  256.  
  257.  
  258. C.    Run Length Limited(RLL)
  259.  
  260.  
  261.     RLL 2,7 Encoding Rules :
  262.  
  263.     According to following table to encoding/decoding :
  264.  
  265.     ┌─────────┬────┬────┬──────┬──────┬────────┬────────┬────────┐
  266.     │ NRZ Data│10  │11  │000   │010   │011     │0010    │0011    │
  267.     ├─────────┼────┼────┼──────┼──────┼────────┼────────┼────────┤
  268.     │ RLL 2,7 │1000│0100│100100│001000│000100  │00001000│00100100│
  269.     └─────────┴────┴────┴──────┴──────┴────────┴────────┴────────┘
  270.  
  271.  
  272. D.    Group Code Recording(GCR)
  273.  
  274.     4,5 GCR Encoding Rules :
  275.  
  276.     According to following table to encoding/decoding :
  277.  
  278.     ┌─────────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
  279.     │ NRZ Data│0000 │000 1│0010 │0011 │0100 │0101 │0110 │0111 │
  280.     ├─────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
  281.     │ 4,5 GCR │11001│11011│10010│10011│11101│10101│10110│10111│
  282.     └─────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
  283.  
  284.     ┌─────────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
  285.     │ NRZ Data│1000 │1001 │1010 │1011 │1100 │1101 │1110 │1111 │
  286.     ├─────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
  287.     │ 4,5 GCR │11010│01001│01010│01011│11110│01101│01110│01111│
  288.     └─────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
  289.  
  290.  
  291.  
  292. E.    Zone Bit Recording(ZBR)
  293.  
  294.     
  295.         According to track no, the fixed disk drive is divided into serval
  296.     zones. The tracks in the same zone have the same format, but the tracks
  297.     in different zone may have different format.
  298.         
  299.  
  300. 1.4    Data Format
  301.  
  302.  
  303.      ┌─┐                                           ┌─┐
  304.      │ │                                                          │ │
  305.   Index    ─┘ └──────────────────────────────────────────────────────────┘ └────
  306.  
  307.  
  308.          ┌───────────┬──────┬──────┬────────────────┬──────┬──────┬─────┐
  309.      │Index delay│Sector│Sector│    . . . .     │Sector│Sector│Final│
  310.      │  Field    │  0   │  1   │    . . . .     │  N-1 │  N   │ Gap    │
  311.      └───────────┴──────┴──────┴────────────────┴──────┴──────┴─────┘
  312.  
  313.              │        │
  314.      ┌───────────┘        └─────────────────────────────────────────────┐
  315.          ┌───────────┬───────┬────────┬───┬───────────┬──────┬────────────┐
  316.      │Preamble 1 │Address│ I.D.   │EDC│Postamble 1│Sector│Inter sector│
  317.      │(Synch 1)  │ Mark  │(Header)│ECC│           │Data  │     Gap    │
  318.      └───────────┴───────┴────────┴───┴───────────┴──────┴────────────┘
  319.  
  320.                      │          │              │         │
  321.      ┌───────────────────┘          └─────┐          │         │
  322.          ┌─────┬─────┬─────┬────┬──────┬────┐          │         │
  323.      │ID AM│Track│Track│Head│Sector│ ID │          │         │
  324.      │     │(MSD)│(LSD)│ #  │  #   │Flag│          │         │
  325.      └─────┴─────┴─────┴────┴──────┴────┘          │         │
  326.                               │         │
  327.                                               │         │
  328.                       ┌───────────────────────────┘         └────────────┐
  329.                           ┌───────────┬───────┬────┬──────┬───┬───────────┐
  330.                       │Preamble 2 │Address│Data│ Data │EDC│Postamble 2│
  331.                       │(Synch 2)  │ Mark  │Mark│Record│ECC│           │
  332.                       └───────────┴───────┴────┴──────┴───┴───────────┘
  333.  
  334.  
  335. 1.5    Sector Interleaving
  336.  
  337.         The initial formatting of a disk determines where sectors are
  338.     located within a track. It is not necessary to allocate sectors
  339.     sequentially around the track. The Technique known as sector inter-
  340.     leaving optimizes access times when, although sectors are accessed
  341.     sequentially, a small amount of processing must be performed between
  342.     sector read/write.
  343.  
  344.  
  345.     interleave factor = 3
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.     interleave factor = 2
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378. 1.6    Disk Formatting
  379.  
  380.  
  381.     A.    Physical Format(initialization)
  382.  
  383.         Initializes the fixed disk with sectors and address so that
  384.         data can be access
  385.  
  386.     B.    Partitioning
  387.  
  388.         Assign a partical amount of disk space to DOS
  389.  
  390.     C.    Logical Format
  391.  
  392.         Verify that the initialization of fixed disk drive was 
  393.         successfully completed
  394.  
  395.  
  396. 1.7    Translative Versus Non-Translative Mode
  397.  
  398.  
  399.        Owing to using advanced technique, the new WDD contain more
  400.     cylinders, more heads, and more sectors in a track. But due to
  401.     DOS limitation, some DOS  software can't access the extra disk
  402.     space. So some WDD manufacturer  support "Translative mode" to
  403.     translate the extra disk space into DOS disk space.
  404.  
  405.     Example 1 :
  406.  
  407.        Assume WDD have 1033 cylinders, 2 heads, 33  sectors/track in 
  408.     non-translative mode, but it can have 1002 cylinders, 4 heads, and
  409.     17 sectors/track in translative mode.
  410.  
  411.       1033 * 2 * 33 = 68178 sectors/drive in non-translative mode
  412.       1002 * 4 * 17 = 68136 sectors/drive in translative mode
  413.  
  414.        So it will loss 42 sectors in translative mode.
  415.  
  416.  
  417.         2.    Winchester Disk Controller
  418.  
  419.  
  420. 2.1    System Configuration for Fixed Disk System
  421.  
  422.  
  423.           ┌────────┐                                  
  424.      ┌────────────┤        │<───────────┐                                  
  425.      │              │ 8259A  │        │
  426.      │         ┌───>│        │           │                         
  427.      │         │      └────────┘            │                 ┌────────┐
  428.      │ ┌─────┴──┐                   ┌───┴────┐      ┌---->│ WDD 0  │
  429.      │ │  CPU   ├──────────────────>│        │<─────|──┬─>│        │
  430.      │ │ INT 13H│<----┬-------------│  WDC   │      |  │  └────────┘
  431.      │ │ -------│     |             │        │<-----|  │  ┌────────┐
  432.      └>│ INT 0EH│     |             └────────┘        |  └─>│ WDD 1  │
  433.        └────────┘     |               ^           └---->│        │
  434.                   |               |                 └────────┘
  435.               |                    |                          
  436.           ┌───┴────┐            |                         
  437.                   │ DRAM   │<-----------┘                            
  438.                   └────────┘                                     
  439.  
  440.  
  441.      Command/Control  ────────
  442.  
  443.      Data/Status      --------
  444.  
  445.  
  446.   Fig :    System Configuration for Fixed Disk System
  447.  
  448.  
  449.     3.    Programming Sequence in Fixed Disk Service Program
  450.  
  451. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  452. ;Module_Name: read_sector_hd
  453. ;Calling Sequence:
  454. ;
  455. ;        Input :   AH = 02h
  456. ;                  AH(in stack) = no_error
  457. ;                  DL = drive no.(not value check)
  458. ;                  DH = head no.
  459. ;                  CH = cylinder low
  460. ;                  CL =  bit 7-6  -- cylinder high
  461. ;                        bit 5-0  -- sector no.(1 base)
  462. ;                  AL = no. of sectors to be read
  463. ;        output :  AH(in stack) = status of operation
  464. ;
  465. ;PDL:    IF WDC valid THEN
  466. ;           prepare task file
  467. ;           IF WDC ready THEN
  468. ;              write READ command to WDC
  469. ;           ENDIF
  470. ;           IF interrupt occurred THEN
  471. ;              read one sector from data register
  472. ;              get result back
  473. ;           ELSE
  474. ;        ELSE
  475. ;           return error code = 01H(invalid function call)
  476. ;        ENDIF
  477. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  478. page
  479.  
  480. f02_00:  ; check valid_WDC
  481.  
  482.          call      valid_wdc            ; check valid_wdc
  483.          jc        f02_60               ; goto f02_40 if error occurred
  484.  
  485. ;        send read command block to WDC
  486.  
  487.          call      write_data           ; Send command
  488.          mov       ah, 021h             ; BX = 021h for read command
  489.          call      out_com              ; out command byte to WDC
  490.          jc        f02_60               ; goto f02_60 if WDC not ready
  491.          mov       di, [bp-4]           ; DI = offset of transfer address
  492.          call      wait_drq             ;
  493.          jc        f02_60               ;
  494.  
  495. f02_20:  ; wait DRQ and test 64K boundary
  496.  
  497.          cmp       di, 0fe00h           ; if in 64K boundary
  498.          jb        f02_30               ; goto f02_30 if no boundary error
  499.          mov       ax, es               ;
  500.          add       ax, 20h              ;
  501.          mov       es, ax               ; adjust ES
  502.          sub       di, 200h             ; adjust DI
  503. f02_30:
  504.          call      wait_int             ; wait_interrupt
  505.          jc        f02_60               ; goto f02_60 if time out
  506.          mov       dx, hd_port0         ; data register
  507.          mov       cx, 100h             ; count = 256 words
  508.      cld                ;
  509.      cli                ;
  510.      rep       insw            ;
  511.      sti                ;
  512.  
  513. ;        get result back
  514.  
  515.          call      get_result           ; get result byte into AL
  516.          jc        f02_60               ;
  517.          dec       byte ptr [bp-2]      ;
  518.          jnz       f02_20        ;
  519. f02_60:
  520.          jmp       disk_end
  521.  
  522.  
  523.     4.    Q & A
  524.