Annotation of nono/exp/rtldma1.has, revision 1.1.1.1

1.1       root        1: ;
                      2: ; nono
                      3: ; Copyright (C) 2022 nono project
                      4: ;
                      5: ; Redistribution and use in source and binary forms, with or without
                      6: ; modification, are permitted provided that the following conditions
                      7: ; are met:
                      8: ; 1. Redistributions of source code must retain the above copyright
                      9: ;    notice, this list of conditions and the following disclaimer.
                     10: ; 2. Redistributions in binary form must reproduce the above copyright
                     11: ;    notice, this list of conditions and the following disclaimer in the
                     12: ;    documentation and/or other materials provided with the distribution.
                     13: ;
                     14: ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     15: ; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     16: ; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     17: ; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     18: ; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
                     19: ; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
                     20: ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
                     21: ; AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
                     22: ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     23: ; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     24: ; SUCH DAMAGE.
                     25: 
                     26: ; RTL8019AS の DMA 転送の挙動を調べる。
                     27: ; DCR.WTS (転送サイズ) と実際の DMA ポートのアクセス幅が異なる場合や
                     28: ; RSAR が奇数アドレスから始まる場合にどうなるかとか。
                     29: ; PROM 領域と RAM 領域ではサイズによる挙動が違うのでそれぞれ調べる。
                     30: ; ただしその境界 ($3fff-$4001) で奇数だったら、については調べてない。
                     31: ;
                     32: ; WTS はアクセス後の、アドレスのインクリメントと残り転送バイト数の
                     33: ; デクリメントを1回やるか2回やるかの切り替えのようだ。
                     34: ; ここには書いてないが、ワード転送で RBCR=7 (奇数) にしても 8バイト
                     35: ; (4ワード) 読み込める。
                     36: ;
                     37: ; これ実行後はネットワークが使えなくなるので Human68k を再起動すること。
                     38: 
                     39:                .include        doscall.mac
                     40:                .include        iocscall.mac
                     41:                .xref   hexstr_word
                     42:                .xref   hexstr_byte
                     43: 
                     44: RTL_BASE       .equ    0xece300
                     45: CR             .equ    0x00
                     46: RSAR0          .equ    0x10
                     47: RSAR1          .equ    0x12
                     48: RBCR0          .equ    0x14
                     49: RBCR1          .equ    0x16
                     50: DCR            .equ    0x1c
                     51: DMA            .equ    0x20
                     52: 
                     53: CR_RD          .equ    0x09
                     54: CR_WR          .equ    0x11
                     55: 
                     56: DCR_B          .equ    0x08
                     57: DCR_W          .equ    0x09
                     58: 
                     59: DMA_B          .equ    0
                     60: DMA_W          .equ    1
                     61: 
                     62: PRINT          .macro  str
                     63:                pea             str
                     64:                DOS             _PRINT
                     65:                addq.l  #4,sp
                     66:                .endm
                     67: 
                     68:                .cpu    68030
                     69:                .list
                     70:                .text
                     71:                .even
                     72: start:
                     73:                clr.l   -(sp)
                     74:                DOS     _SUPER
                     75:                addq.l  #4,sp
                     76: 
                     77:                clr.l   a4
                     78:                lea.l   RTL_BASE(a4),a4
                     79: 
                     80:                bsr     read_macaddr
                     81: 
                     82:                lea.l   testdata(pc),a2
                     83: mainloop:
                     84:                move.w  (a2)+,d3        ; d3: start addr
                     85:                bmi     done            ; If addr < 0, goto done.
                     86: 
                     87:                lea.l   dmabuf(pc),a0   ; Clear dmabuf
                     88:                moveq.l #0,d0
                     89:                move.l  d0,(a0)+
                     90:                move.l  d0,(a0)+
                     91:                move.l  d0,(a0)+
                     92:                move.l  d0,(a0)+
                     93: 
                     94:                lea.l   buf(pc),a0      ; Display test parameters
                     95:                move.w  d3,d0
                     96:                swap    d0
                     97:                bsr     hexstr_word
                     98:                move.b  #'/',(a0)+
                     99: 
                    100:                move.w  (a2)+,d2        ; d2: DCR
                    101:                move.w  d2,d0
                    102:                ror.l   #8,d0
                    103:                bsr     hexstr_byte
                    104:                move.b  #'/',(a0)+
                    105: 
                    106:                move.l  #(('D'<<24)|('M'<<16)|('A'<<8)|'_'),(a0)+
                    107:                move.w  (a2)+,d1        ; d1: DMASizeIndex
                    108:                bne     @f
                    109:                move.b  #'B',(a0)+
                    110:                bra     @@f
                    111: @@:
                    112:                move.b  #'W',(a0)+
                    113: @@:
                    114:                clr.b   (a0)
                    115: 
                    116:                PRINT   buf(pc)
                    117: 
                    118:                move.w  d3,d0
                    119:                lsr.w   #8,d0           ; if (start_addr >> 8 == 00)
                    120:                beq     @f              ;  src is PROM, skip init_ram.
                    121:                bsr     init_ram
                    122: @@:
                    123:                lea.l   dmabuf(pc),a0
                    124:                move.b  d3,RSAR0(a4)    ; Set registers
                    125:                move.b  d0,RSAR1(a4)
                    126:                move.b  #$10,RBCR0(a4)
                    127:                move.b  #$00,RBCR1(a4)
                    128:                move.b  d2,DCR(a4)
                    129:                move.b  #CR_RD,CR(a4)   ; Issue Read command
                    130: 
                    131:                tst.b   d1              ; DMASizeIndex
                    132:                bne     dma_word
                    133: dma_byte:
                    134:                moveq.l #$10-1,d3
                    135: @@:
                    136:                move.b  DMA(a4),(a0)+
                    137:                dbra    d3,@b
                    138:                bra     verify
                    139: 
                    140: dma_word:
                    141:                moveq.l #8-1,d3
                    142: @@:
                    143:                move.w  DMA(a4),(a0)+
                    144:                dbra    d3,@b
                    145: 
                    146: verify:
                    147:                lea.l   expected(pc),a1
                    148:                bsr     read_expected
                    149: 
                    150:                lea.l   dmabuf(pc),a0
                    151:                moveq.l #16-1,d3
                    152: verify_byte:
                    153:                move.b  (a1)+,d0
                    154:                cmpi.b  #$fe,d0         ; If expected==$fe, no check this byte
                    155:                beq     @f
                    156:                cmp.b   (a0),d0
                    157:                bne     fail
                    158: @@:
                    159:                adda.l  #1,a0
                    160:                dbra    d3,verify_byte
                    161: 
                    162:                ; success
                    163:                PRINT   msg_ok(pc)
                    164:                bra     mainloop
                    165: 
                    166: fail:
                    167:                ; At this point, a2 points begin of next testdata.
                    168:                PRINT   msg_fail(pc)
                    169:                lea.l   buf(pc),a0
                    170:                lea.l   expected(pc),a1
                    171:                moveq.l #16-1,d3
                    172: @@:
                    173:                move.b  (a1)+,d0
                    174:                ror.l   #8,d0
                    175:                bsr     hexstr_byte
                    176:                dbra    d3,@b
                    177:                clr.b   (a0)
                    178:                PRINT   buf(pc)
                    179: 
                    180:                PRINT   msg_actual
                    181:                lea.l   buf(pc),a0
                    182:                lea.l   dmabuf(pc),a1
                    183:                moveq.l #16-1,d3
                    184: @@:
                    185:                move.b  (a1)+,d0
                    186:                ror.l   #8,d0
                    187:                bsr     hexstr_byte
                    188:                dbra    d3,@b
                    189:                clr.b   (a0)
                    190:                PRINT   buf(pc)
                    191: 
                    192:                PRINT   msg_crlf
                    193:                bra     mainloop
                    194: 
                    195: done:
                    196:                DOS     _EXIT
                    197: 
                    198: 
                    199: read_macaddr:
                    200:                ; Read MAC addr using correct way.
                    201:                moveq.l #0,d0
                    202:                move.b  d0,RSAR0(a4)
                    203:                move.b  d0,RSAR1(a4)
                    204:                move.b  #12,RBCR0(a4)
                    205:                move.b  d0,RBCR1(a4)
                    206:                move.b  #DCR_W,DCR(a4)
                    207:                move.b  #CR_RD,CR(a4)
                    208: 
                    209:                moveq.l #6-1,d3
                    210:                lea.l   macaddr(pc),a0
                    211: @@:
                    212:                move.w  DMA(a4),d0
                    213:                ror.w   #8,d0
                    214:                move.b  d0,(a0)+
                    215:                dbra    d3,@b
                    216:                rts
                    217: 
                    218: init_ram:
                    219:                movem.l d0/d3,-(sp)
                    220:                move.b  #$00,RSAR0(a4)
                    221:                move.b  #$40,RSAR1(a4)
                    222:                move.b  #$20,RBCR0(a4)
                    223:                move.b  #$00,RBCR1(a4)
                    224:                move.b  #DCR_W,DCR(a4)
                    225:                move.b  #CR_WR,CR(a4)
                    226:                move.w  #$1011,d0
                    227:                moveq.l #16-1,d3
                    228: @@:
                    229:                move.w  d0,DMA(a4)
                    230:                addi.w  #$0202,d0
                    231:                dbra    d3,@b
                    232:                movem.l (sp)+,d0/d3
                    233:                rts
                    234: 
                    235: ; IN a1: destination buffer (expected), don't change a1
                    236: ;    a2: source buffer, don't save a2
                    237: read_expected:
                    238:                movem.l d0/d3/a0-a1/a3,-(sp)
                    239:                lea.l   macaddr(pc),a3
                    240:                moveq.l #0,d0
                    241:                moveq.l #16-1,d3
                    242: @@:
                    243:                move.b  (a2)+,d0
                    244:                cmpi.w  #$fe,d0
                    245:                bge     @f
                    246:                cmpi.w  #$f0,d0
                    247:                blt     @f
                    248:                ; If $f0 <= d0 < $fe, replace them to mac addr
                    249:                subi.b  #$f0,d0
                    250:                ;move.b 0(a3,d0.b*1),d0
                    251:                movea.l a3,a0
                    252:                add.l   d0,a0
                    253:                move.b  (a0),d0
                    254: @@:
                    255:                move.b  d0,(a1)+
                    256:                dbra    d3,@@b
                    257:                movem.l (sp)+,d0/d3/a0-a1/a3
                    258:                rts
                    259: 
                    260: 
                    261: testdata:
                    262:  ;     RSAR   DCR    DMA    Expected($f0-$f5: MACaddr, $fe: ignore)
                    263:  .dc.w $0000, DCR_W, DMA_W, $f0ff,$f1ff,$f2ff,$f3ff, $f4ff,$f5ff,$ffff,$ffff
                    264:  .dc.w $0001, DCR_W, DMA_W, $f0ff,$f1ff,$f2ff,$f3ff, $f4ff,$f5ff,$ffff,$ffff
                    265:  .dc.w $4000, DCR_W, DMA_W, $1011,$1213,$1415,$1617, $1819,$1a1b,$1c1d,$1e1f
                    266:  .dc.w $4001, DCR_W, DMA_W, $1011,$1213,$1415,$1617, $1819,$1a1b,$1c1d,$1e1f
                    267: 
                    268:  .dc.w $0000, DCR_B, DMA_W, $f0ff,$f0ff,$f1ff,$f1ff, $f2ff,$f2ff,$f3ff,$f3ff
                    269:  .dc.w $0001, DCR_B, DMA_W, $f0ff,$f1ff,$f1ff,$f2ff, $f2ff,$f3ff,$f3ff,$f4ff
                    270:  .dc.w $4000, DCR_B, DMA_W, $1011,$fefe,$1213,$fefe, $1415,$fefe,$1617,$fefe
                    271:  .dc.w $4001, DCR_B, DMA_W, $fefe,$1213,$fefe,$1415, $fefe,$1617,$fefe,$1819
                    272: 
                    273:  ; XXX +7バイト目から不定($22 が読める)になるのが謎
                    274:  .dc.w $0000, DCR_W, DMA_B, $f0f1,$f2f3,$f4f5,$fffe, $fefe,$fefe,$fefe,$fefe
                    275:  .dc.w $0001, DCR_W, DMA_B, $f0f1,$f2f3,$f4f5,$ffff, $fefe,$fefe,$fefe,$fefe
                    276:  .dc.w $4000, DCR_W, DMA_B, $1012,$1416,$181a,$1c1e, $2020,$2020,$2020,$2020
                    277:  .dc.w $4001, DCR_W, DMA_B, $1012,$1416,$181a,$1c1e, $2020,$2020,$2020,$2020
                    278: 
                    279:  .dc.w $0000, DCR_B, DMA_B, $f0f0,$f1f1,$f2f2,$f3f3, $f4f4,$f5f5,$ffff,$ffff
                    280:  .dc.w $0001, DCR_B, DMA_B, $f0f1,$f1f2,$f2f3,$f3f4, $f4f5,$f5ff,$ffff,$ffff
                    281:  .dc.w $4000, DCR_B, DMA_B, $10fe,$12fe,$14fe,$16fe, $18fe,$1afe,$1cfe,$1efe
                    282:  .dc.w $4001, DCR_B, DMA_B, $fe12,$fe14,$fe16,$fe18, $fe1a,$fe1c,$fe1e,$fe20
                    283: 
                    284:  .dc.w $ffff   ; Sentinel
                    285: 
                    286: msg_fail:      .dc.b   " failed",$d,$a
                    287:                .dc.b   " Expected ",0
                    288: msg_actual:    .dc.b   $d,$a," Actual   ",0
                    289: msg_ok:                .dc.b   " OK",$d,$a,0
                    290: msg_crlf:      .dc.b   $d,$a,0
                    291: 
                    292:                .even
                    293: macaddr:       .ds.b   6
                    294:                .align  4
                    295: expected:      .ds.b   16
                    296: dmabuf:                .ds.b   32
                    297: 
                    298: buf:           .ds.b   64
                    299: 
                    300:                .end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.