home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / assembly / hdw3_s / hdw3.lst < prev    next >
Encoding:
File List  |  1991-09-26  |  21.4 KB  |  347 lines

  1. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   1
  2. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  3.  
  4.    1                                        TTL    "$Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $"
  5.    2                                    *
  6.    3                                    * Wait for hard disk to spin up
  7.    4                                    *
  8.    5                                    * $Log: hdw3.s,v $
  9.    6                                    * Revision 1.3  1991/09/18  14:35:10  mario
  10.    7                                    * Added return code at program exit.
  11.    8                                    *
  12.    9                                    * Revision 1.2  1991/09/17  15:12:12  mario
  13.   10                                    * Let the header be done by the assembler.
  14.   11                                    *
  15.   12                                    * Revision 1.1  1991/09/17  09:42:38  mario
  16.   13                                    * Initial revision
  17.   14                                    *
  18.   15                                    * Author: mario@tisu1.ti.informatik.uni-frankfurt.de Schulz
  19.   16                                    *        inspired by Jelske kloppenburg@gmd.de
  20.   17                                    *
  21.   18                                    * Send test_unit_ready SCSI command to every target at ACSI.
  22.   19                                    *
  23.   20                                    * timeout receiving command == target unavailable
  24.   21                                    * timeout receiving status == non-standard SCSI (i.e. MegafileXX)
  25.   22                                    *    wait for status to come with long timeout
  26.   23                                    * return status check -> rerun test_unit_ready until it succeeds or
  27.   24                                    *    maximum retry count it reached
  28.   25                                    *
  29.   26                                    * To be done:
  30.   27                                    *     If the device returns the check flag, a request_sense should
  31.   28                                    *    be done to check what it really does.
  32.   29                                    *
  33.   30                                    * Turn on progress messages with debug not equal to 0
  34.   31                                    *
  35.   32 00000001                           debug        equ    1
  36.   33 00000000                           extended_debug    equ    0
  37.   34                                    *
  38.   35                                    * Tuneable parameters section
  39.   36                                    *
  40.   37 00000032                           IWait        equ    50    ; Initial delay time 250ms
  41.   38 00000000                           HighTarg    equ    0    ; Highest target to be tested (max. 7)
  42.   39                                    *
  43.   40 00000050                           ToCycle        equ    80    ; Cycles for status timeout (for M60)
  44.   41 00000028                           ToWait        equ    40    ; Cycle time for status timeout 200ms
  45.   42                                    *
  46.   43                                    * Do not tweak to often, this might delay the work done for spin-up
  47.   44 00000014                           BusyCycle    equ    20    ; Cycles for busy indication
  48.   45 000000C8                           BusyWait    equ    200    ; Cycle time for busy indication 1000ms
  49.   46                                    *
  50.   47                                    * Long command waits give delays for unavailable devices, but if some
  51.   48                                    * device is pretty busy, you might loose synchronisation for the
  52.   49                                    * command bytes, you had to issue the (unavailable) software reset
  53.   50                                    * for the SCSI bus. 100ms for an Atari device should be enough!
  54.   51                                    * Some SCSI device may need 500ms - if the tests for device
  55.   52                                    * presence take too long, simply turn them off via "HighTarg".
  56.   53 00000032                           CmdWait        equ    50    ; Time for cmd ack 250ms
  57.   54 00000064                           StatWait    equ    100    ; Time for status byte 500ms
  58.   55                                    *
  59. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   2
  60. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  61.  
  62.   56 FFFFFA01                           gpip        equ    $FFFFFA01    ; MFP[GPIP]
  63.   57 FFFF8604                           diskctrl    equ    $FFFF8604    ; Controller access reg
  64.   58 FFFF8606                           dmamode        equ    $FFFF8606    ; DMA Mode Reg
  65.   59 0000043E                           flock        equ    $43E        ; DMA lock
  66.   60 000004BA                           _hz_200        equ    $4BA        ; 200hz counter
  67.   61                                    *
  68.   62 00000000'                              ORG    $0    ; Start of bootsector
  69.   63 00000000' 601C                         bra.b    entry
  70.   64 00000002' 686477616974                 dc.b    "hdwait"
  71.   65                                    *
  72.   66 00000008'                              ORG    $1e    ; Bootsector program strarts at 0x1e
  73.   67 0000001E' 48E77FFC                 entry:    movem.l    d1-a5,-(sp)
  74.   68 00000022' 4E56 FFFE                    link    a6,#-2
  75.   69 00000026' 487A 0160                    pea    WaitMes(PC)
  76.   70 0000002A' 3F3C 0009                    move.w    #9,-(a7)    ; ConWS
  77.   71 0000002E' 4E41                         trap    #1
  78.   72 00000030' 5C8F                         addq.l    #6,a7
  79.   73                                    *
  80.   74                                    * Initial Delay
  81.   75                                    *
  82.   76 00000032' 7032!                        move.l    #IWait,d0        ; Initial delay
  83.   77 00000034' 6100 00CA                    bsr    Wait
  84.   78                                    *
  85.   79                                    * Start checks
  86.   80                                    *
  87.   81 00000038' 50F8 043E                    st    flock        ; lock VBL interrupts
  88.   82 0000003C' 4245                         clr.w    d5        ; Start with target 0
  89.   83 0000003E' 426E FFFE                Chk:    clr.w    -2(a6)        ; n = 0
  90.   84 00000042' 617E                     SamChk:    bsr    TstTarg        ; expect status in d0
  91.   85                                        IF    debug
  92.   86 00000044' 6100 00E2                    bsr    DispRes        ; Show result on screen
  93.   87                                        ENDIF
  94.   88 00000048' 0C40 FFFF                    cmpi.w    #-1,d0        ; Target did not respond
  95.   89 0000004C' 660A                         bne    Case2
  96.   90                                    *
  97.   91 0000004E' 5245!                    NxtChk:    addi.w    #1,d5        ; next target
  98.   92 00000050' 4A45!                        cmpi.w    #HighTarg,d5    ; last one
  99.   93 00000052' 6200 0120                    bhi    Exit
  100.   94 00000056' 60E6                         bt    Chk
  101.   95                                    *
  102.   96                                    * This might be a MEGAFILE spinning up, so wait for status to show up
  103.   97                                    *
  104.   98 00000058' 0C40 FFFE                Case2:    cmpi.w    #-2,d0        ; Target timeout sending status
  105.   99 0000005C' 661A                         bne    Case3
  106.  100 0000005E' 6130                     Case2a:    bsr    IncPg
  107.  101 00000060' 0C6E 0050FFFE                cmpi.w    #ToCycle,-2(a6)    ; status timeout cycles
  108.  102 00000066' 67E6                         beq    NxtChk
  109.  103 00000068' 7028!                        move.l    #ToWait,d0    ; status timeout time
  110.  104 0000006A' 6100 00A0                    bsr    IntW
  111.  105 0000006E' 66EE                         bne    Case2a        ; still timeout
  112.  106 00000070' 426E FFFE                    clr.w    -2(a6)
  113.  107 00000074' 3038 8604                    move.w    diskctrl,d0    ; fall to case3 with valid status
  114.  108                                    *
  115.  109                                    * Now we have got a valid status byte
  116.  110                                    *
  117. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   3
  118. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  119.  
  120.  111 00000078' 4A00!                    Case3:    cmpi.b    #0,d0        ; Target responded with ready
  121.  112 0000007A' 67D2                         beq     NxtChk
  122.  113 0000007C' 6112                         bsr    IncPg        ; Target not ready (usually check cond)
  123.  114 0000007E' 0C6E 0014FFFE                cmpi.w    #BusyCycle,-2(a6)
  124.  115 00000084' 67C8                         beq    NxtChk        ; Number of busy cycles
  125.  116 00000086' 203C 000000C8                move.l    #BusyWait,d0    ; Wait time
  126.  117 0000008C' 6172                         bsr    Wait
  127.  118 0000008E' 60B2                         bt    SamChk        ; Check same target again
  128.  119                                    *
  129.  120                                    * Increment progress message on screen
  130.  121                                    *
  131.  122 00000090' 526E FFFE                IncPg:    addq.w    #1,-2(a6)    ; n++
  132.  123 00000094' 382E FFFE                    move.w    -2(a6),d4
  133.  124 00000098' 48C4                         ext.l    d4
  134.  125 0000009A' 88FC 000A                    divu    #10,d4        ; n /= 10
  135.  126 0000009E' 163C 0030                    move.b    #'0',d3
  136.  127 000000A2' D803                         add.b    d3,d4        ; high digit
  137.  128 000000A4' 49FA 00ED                    lea    WaitMesZ(pc),a4
  138.  129 000000A8' 1884                         move.b    d4,(a4)        ; to message
  139.  130 000000AA' 4844                         swap    d4        ; n %= 10
  140.  131 000000AC' D803                         add.b    d3,d4        ; low digit
  141.  132 000000AE' 49FA 00E4                    lea    WaitMesE(pc),a4
  142.  133 000000B2' 1884                         move.b    d4,(a4)        ; to message
  143.  134 000000B4' 487A 00D2                    pea    WaitMes(pc)
  144.  135 000000B8' 3F3C 0009                    move.w    #9,-(a7)    ; ConWs
  145.  136 000000BC' 4E41                         trap    #1
  146.  137 000000BE' 5C8F                         addq.l    #6,a7
  147.  138 000000C0' 4E75                         rts
  148.  139                                    *
  149.  140                                    * Test target device
  150.  141                                    *
  151.  142 000000C2' 4244                     TstTarg:clr.w    d4        ; cmd word counter
  152.  143 000000C4' 3C05                         move.w    d5,d6
  153.  144 000000C6' EB46                         asl.w    #5,d6        ; First command byte Target,Test Unit Ready
  154.  145 000000C8' 4846                         swap    d6
  155.  146 000000CA' 3C3C 008A                    move.w    #$8a,d6
  156.  147 000000CE' 31FC 00888606                move.w    #$88,dmamode    ; Command to come
  157.  148 000000D4' 5244!                    NxtWd:    addi.w    #1,d4
  158.  149 000000D6' 21C6 8604                    move.l    d6,diskctrl
  159.  150 000000DA' 0C44 0006                    cmpi.w    #6,d4
  160.  151 000000DE' 670E                         beq    CmdSucc
  161.  152 000000E0' 48C6                         ext.l    d6        ; Clear for next word
  162.  153 000000E2' 7032!                        move.l    #CmdWait,d0    ; wait time for command ack
  163.  154 000000E4' 6126                         bsr    IntW        ; Expect result in zero flag
  164.  155 000000E6' 67EC                         beq    NxtWd
  165.  156 000000E8' 303C FFFF                    move.w    #-1,d0        ; Timeout sending command bytes
  166.  157 000000EC' 4E75                         rts
  167.  158                                    * Status byte after last command takes more time
  168.  159 000000EE' 7064!                    CmdSucc:move.l    #StatWait,d0    ; wait time for status byte
  169.  160 000000F0' 611A                         bsr    IntW
  170.  161 000000F2' 6706                         beq    EndTst
  171.  162 000000F4' 303C FFFE                    move.w    #-2,d0        ; Timeout getting status byte
  172.  163 000000F8' 4E75                         rts
  173.  164 000000FA' 3038 8604                EndTst:    move.w    diskctrl,d0    ; return status byte
  174.  165 000000FE' 4E75                         rts
  175. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   4
  176. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  177.  
  178.  166                                    *
  179.  167                                    * Wait short amount of time given in d0.l
  180.  168                                    *
  181.  169 00000100' D0B8 04BA                Wait:    add.l    _hz_200,d0
  182.  170 00000104' B0B8 04BA                WLoop:    cmp.l    _hz_200,d0
  183.  171 00000108' 62FA                         bhi    WLoop
  184.  172 0000010A' 4E75                         rts
  185.  173                                    *
  186.  174                                    * Wait for interrupt or timeout
  187.  175                                    * Supply timeout time in d0 (0.005secs)
  188.  176                                    *
  189.  177 0000010C' D0B8 04BA                IntW:    add.l    _hz_200,d0
  190.  178 00000110' 0838 0005FA01            MFPTst:    btst    #$5,gpip
  191.  179 00000116' 6604                         bne    ctime
  192.  180 00000118' 4240                         clr.w    d0        ; return true for interrupt
  193.  181 0000011A' 4E75                         rts
  194.  182 0000011C' B0B8 04BA                ctime:    cmp.l    _hz_200,d0
  195.  183 00000120' 62EE                         bhi    MFPTst
  196.  184 00000122' 303C FFFF                    move.w    #-1,d0        ; return false for timeout
  197.  185 00000126' 4E75                         rts
  198.  186                                    *
  199.  187                                    * Display result message for debug purposes
  200.  188                                    * Status to be displayed in d0
  201.  189                                    *
  202.  190                                        IF    debug
  203.  191 00000128' 48E7FFFE                 DispRes:movem.l    d0-a6,-(sp)
  204.  192 0000012C' 183C 0030                    move.b    #'0',d4
  205.  193 00000130' D805                         add.b    d5,d4
  206.  194 00000132' 49FA 006F                    lea    TNo(pc),a4
  207.  195 00000136' 1884                         move.b    d4,(a4)
  208.  196 00000138' 49FA 0072                    lea    TSt(pc),a4
  209.  197 0000013C' 0C40 FFFF                    cmpi.w    #-1,d0
  210.  198 00000140' 6606                         bne    DCase2
  211.  199 00000142' 18BC 004E                    move.b    #'N',(a4)    ; N: Not available
  212.  200 00000146' 601A                         bt    DoDisp
  213.  201 00000148' 0C40 FFFE                DCase2:    cmpi.w    #-2,d0
  214.  202 0000014C' 6606                         bne    DCase3
  215.  203 0000014E' 18BC 0054                    move.b    #'T',(a4)    ; T: Status byte timeout
  216.  204 00000152' 600E                         bt    DoDisp
  217.  205 00000154' 4A00!                    DCase3:    cmpi.b    #0,d0
  218.  206 00000156' 6606                         bne    DCase4
  219.  207 00000158' 18BC 0030                    move.b    #'0',(a4)    ; 0: Status OK
  220.  208 0000015C' 6004                         bt    DoDisp
  221.  209 0000015E' 18BC 0042                DCase4:    move.b    #'B',(a4)    ; B: Busy
  222.  210                                    *
  223.  211 00000162'                          DoDisp:
  224.  212                                        IF    extended_debug
  225.  213                                        lea    ExtSt(pc),a4
  226.  214                                        move.w    #7,d1
  227.  215                                    zz:    btst    d1,d0
  228.  216                                        bne    z1
  229.  217                                        move.b    #'0',(a4)+
  230.  218                                        bt    z0
  231.  219                                    z1:    move.b    #'1',(a4)+
  232.  220                                    z0:    subq.w    #1,d1
  233. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   5
  234. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  235.  
  236.  221                                        bcc    zz
  237.  222                                        ENDIF
  238.  223 00000162' 487A 0034                    pea    Progr(pc)
  239.  224 00000166' 3F3C 0009                    move.w    #9,-(a7)
  240.  225 0000016A' 4E41                         trap    #1
  241.  226 0000016C' 5C8F                         addq.l    #6,a7
  242.  227 0000016E' 4CDF7FFF                     movem.l    (sp)+,d0-a6
  243.  228 00000172' 4E75                         rts
  244.  229                                        ENDIF
  245.  230                                    *
  246.  231                                    * End program
  247.  232                                    *
  248.  233 00000174' 31FC 00808606            Exit:    move.w    #$80,dmamode    ; Revert to FDC
  249.  234 0000017A' 51F8 043E                    sf    flock        ; enable VBL interrupts
  250.  235 0000017E' 4E5E                         unlk    a6
  251.  236 00000180' 4CDF3FFE                     movem.l    (sp)+,d1-a5
  252.  237 00000184' 4240                         clr.w    d0        ; Return Zero
  253.  238 00000186' 4E75                         rts
  254.  239                                    *
  255.  240 00000188'                              EVEN    ;          Row  Column
  256.  241 00000188'                          WaitMes:
  257.  242                                        IFF    extended_debug
  258.  243 00000188' 1B592223                     dc.b    $1B,'Y',32+2,32+3
  259.  244                                        ENDIF
  260.  245 0000018C' 68647761697420               dc.b    "hdwait "
  261.  246 00000193' 20                       WaitMesZ:dc.b    ' '
  262.  247 00000194' 200D0A00                 WaitMesE:dc.b    ' ',$0D,$0A,0
  263.  248                                        IF    debug
  264.  249 00000198'                              EVEN    ;          Row  Column
  265.  250 00000198'                          Progr:
  266.  251                                        IFF    extended_debug
  267.  252 00000198' 1B592423                     dc.b    $1b,'Y',32+4,32+3
  268.  253                                        ENDIF
  269.  254 0000019C' 54617267657420               dc.b    "Target "
  270.  255 000001A3' 3F                       TNo:    dc.b    '?'
  271.  256 000001A4' 2053746174757320             dc.b    " Status "
  272.  257 000001AC' 3F                       TSt:    dc.b    '?'
  273.  258                                        IF    extended_debug
  274.  259                                        dc.b    ' '
  275.  260                                    ExtSt:    dc.b    "LLLLLLLL"
  276.  261                                        ENDIF
  277.  262 000001AD' 0D0A00                       dc.b    $0d,$0a,0
  278.  263                                        ENDIF
  279.  264                                    *
  280.  265 000001B0'                              END
  281.  266                                    
  282. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   6
  283. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  284.  
  285.  
  286. S y m b o l   T a b l e
  287.  
  288. Name        Value        Type        Local to        References
  289.  
  290. BusyCycle   00000014        Absolute                           44*  114 
  291. BusyWait    000000C8        Absolute                           45*  116 
  292. Case2       00000058        Text                               89    98*
  293. Case2a      0000005E        Text                              100*  105 
  294. Case3       00000078        Text                               99   111*
  295. Chk         0000003E        Text                               83*   94 
  296. CmdSucc     000000EE        Text                              151   159*
  297. CmdWait     00000032        Absolute                           53*  153 
  298. DCase2      00000148        Text                              198   201*
  299. DCase3      00000154        Text                              202   205*
  300. DCase4      0000015E        Text                              206   209*
  301. DispRes     00000128        Text                               86   191*
  302. DoDisp      00000162        Text                              200   204   208 
  303.                                                               211*
  304. EndTst      000000FA        Text                              161   164*
  305. Exit        00000174        Text                               93   233*
  306. HighTarg    00000000        Absolute                           38*   92 
  307. IWait       00000032        Absolute                           37*   76 
  308. IncPg       00000090        Text                              100   113   122*
  309. IntW        0000010C        Text                              104   154   160 
  310.                                                               177*
  311. MFPTst      00000110        Text                              178*  183 
  312. NxtChk      0000004E        Text                               91*  102   112 
  313.                                                               115 
  314. NxtWd       000000D4        Text                              148*  155 
  315. Progr       00000198        Text                              223   250*
  316. SamChk      00000042        Text                               84*  118 
  317. StatWait    00000064        Absolute                           54*  159 
  318. TNo         000001A3        Text                              194   255*
  319. TSt         000001AC        Text                              196   257*
  320. ToCycle     00000050        Absolute                           40*  101 
  321. ToWait      00000028        Absolute                           41*  103 
  322. TstTarg     000000C2        Text                               84   142*
  323. WLoop       00000104        Text                              170*  171 
  324. Wait        00000100        Text                               77   117   169*
  325. WaitMes     00000188        Text                               69   134   241*
  326. WaitMesE    00000194        Text                              132   247*
  327. WaitMesZ    00000193        Text                              128   246*
  328. _hz_200     000004BA        Absolute                           60*  169   170 
  329.                                                               177   182 
  330. ctime       0000011C        Text                              179   182*
  331. debug       00000001        Absolute                           32*   85   190 
  332.                                                               248 
  333. diskctrl    FFFF8604        Absolute                           57*  107   149 
  334.                                                               164 
  335. dmamode     FFFF8606        Absolute                           58*  147   233 
  336. entry       0000001E        Text                               63    67*
  337. extended_debug
  338.         00000000        Absolute                           33*  212   242 
  339.                                                               251   258 
  340. flock       0000043E        Absolute                           59*   81   234 
  341. MAS-68K 68030 Macro Assembler  Release 19  (C) 88 - 90 SoftDesign Muenchen            Page   7
  342. $Id: hdw3.s,v 1.3 1991/09/18 14:35:10 mario Exp $
  343.  
  344. gpip        FFFFFA01        Absolute                           56*  178 
  345.  
  346.  
  347.