/**************************************************************** * * * MORROW 68K SYSTEM DMA I/O TEST REV 0. * * Dual SIO4 board tester. * * * initial coding: 5/3/84 -bjg- * * C translation LE * * *****************************************************************/ char * signon= "\nMorrow 68k system serial port test Version 0 \n" */ char *textbeg= "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOGS BACK 0123456789\r\n" /* ioaddr = $ff0000 * compupro i/o address space */ #define IOADDR 0xff0000 /******************** * SIO4 equates * ********************/ /* base = ioaddr+$20 * SIO4 base I/O address */ struct sio { char addr0, /* low byte dma address */ addr1, /* high byte dma address */ addr2, /* extended byte of dma address */ recntrl, /* receiver control port */ count0, /* low byte of dma count */ count1, /* high byte of dma count */ enable, /* start / stop enable */ dmacon, /* dma control and status */ sdata, /* uart data port */ sstatus, /* uart status port */ smode, /* uart mode register */ scommnd, /* uart command register */ fstatus, /* fifo status */ fdata, /* fifo data */ dmaglob, /* global dma status */ select; /* tty select port */ }; struct sio *sio = SIOBASE; /* control = $27 * normal async mode ttya = 0 * select byte for ttta ttyb = 1 * select byte for tttb ttyc = 2 * select byte for tttc ttyd = 3 * select byte for tttd divisor = $d * 9600 baud divisor done = $40 * DMA idle when port 27 = 40 kick = 1 * value to kick controller */ #define CONTROL 0x27 #define NORMAL 0x27 #define TTYA 0 #define TTYB 1 #define TTYC 2 #define TTYD 3 #define B9600 0xd #define DONE 0x40 #define KICK 1 /*************************** * miscellaneous equates * ***************************/ /* alf = $a * ascii line feed acr = $d * ascii carriage return asp = $20 * ascii space acs = $1a * ascii clear for ADM31 qpat = $AA55 * initial ram test pattern spat = $00ff * marching pattern stop = $F0000 * end of 2 Meg ramtest area page = 1024 * 2K X 8 ram chips image = 0 */ /* PRINT SIGNON */ /* init: bsr acrlf move.w #$09,d0 move.l #signon,d1 trap #$2 bsr acrlf bsr acrlf bsr sbaud */ init () { prs (signon); sbaud (); } /* main program loop main: bsr sendt * direct I/O bsr output * do the QBF bsr nout * do the barber pole bsr keybrd * check for console key pressed jmp main */ main () { for (;;) { sendt (); output (); nout (); keybrd (); } } /* routine sets all 4 ttys to 9600 baud sbaud: move.b #ttya,d2 * select uart 0 sbaud1: move.b d2,sselect * select the tty move.b scommnd,d0 * set up for uart mode reg. 1 move.b smode,d1 * read mode register 1 point to 2 move.b smode,d0 * read mode register 2 point to 1 move.b smode,d1 * read mode register 1 setup for 2 andi.b #$f0,d0 * strip baud rate off ori.b #divisor,d0 * lower 4 bits = 9600 baud move.b d0,smode * write register 2 move.b #control,scommnd * set it for normal async rs232 addq.b #1,d2 * next one cmpi.b #4,d2 bne sbaud1 rts */ sbaud () { char i, c, m1, m2; for (i = 0; i < 4; i++) { sio->select = i; c = sio->scommand; m1 = sio->smode; m2 = sio->smode; m2 &= 0xf0; m2 |= B9600; m1 = sio->smode; sio->mode = m2; sio->scommand = NORMAL; } } /* routine sends barber pole to each UART via direct I/O sendt: move.b #ttya,d2 * select uart 0 sendt1: move.b d2,sselect * write select port move.b #asp,d3 * start with a 'space' sendt2: andi.b #1,sstatus * check uart tbe flag beq sendt2 * loop till empty move.b d3,sdata * send the data addq.b #1,d3 * next character cmpi.b #$7f,d3 * check for last ascii character bne sendt2 * loop for whole set addq.b #1,d2 * repeat for next uart cmpi.b #4,d2 * last uart?? bne sendt1: rts */ sendt () { } * QUICK BROWN FOX - set up the dma and send buffer to each uart output: move.b #ttya,d2 * select uart 0 dmaset: move.b d2,sselect move.l #textbeg,d7 * set up dma address move.w #textsiz,d6 * byte count bsr idle * check for idle move.b d7,dmaddrl * output the low and high byte ror.l #8,d7 move.b d7,dmaddrh ror.l #8,d7 move.b d7,dmaddre move.b d6,lcount * buffer size ror.l #8,d6 move.b d6,hcount move.b #kick,dmacntl * kick the controller addq.b #1,d2 * increment for next channel cmpi.b #4,d2 bne dmaset rts * BARBER POLE - set up the dma and send buffer to each uart nout: move.b #ttya,d2 * select uart 0 nset: move.b d2,sselect move.w #2048,d6 * byte count--one screen move.l #textend,a1 * write barber pole to memory buffer nloop: move.b #asp,d0 nloop1: move.b d0,(a1)+ subq.w #1,d6 beq nchk addq.b #1,d0 * next ascii char cmpi.b #$7f,d0 * check for last ascii char bne nloop1 bra nloop nchk: move.b d2,sselect * next uart move.l #textend,d7 move.w #2048,d6 * byte count--one screen bsr idle * check for idle move.b d7,dmaddrl * output the low address ror.l #8,d7 move.b d7,dmaddrh * output high address ror.l #8,d7 move.b d7,dmaddre * output extended address move.b d6,lcount * buffer size lsb ror.l #8,d6 move.b d6,hcount * buffer size msb move.b #kick,dmacntl * kick the controller addq.b #1,d2 * increment for next channel cmpi.b #4,d2 bne nchk rts * delay loop dummy: move.l a5,-(a7) * save a5 move.l #-1,a5 dumb1: subq.l #1,a5 bne dumb1 move.l (a7)+,a5 * get it back rts * routine loops till dma channel is idle idle: move.l d5,-(a7) * save d5 idle1: move.b dmacntl,d3 * check for idle andi.b #done,d3 beq idle1 move.l (a7)+,d5 * restore d5 rts * PRINT A SPACE through CP/M aspace: move.w #$02,d0 move.w #asp,d1 trap #$2 * call bdos rts * PRINT A CARRIAGE RETURN / LINE FEED through CP/M acrlf: move.w #$02,d0 * bdos write char call move.w #acr,d1 trap #$2 * call bdos move.w #$02,d0 move.w #alf,d1 trap #$2 * call bdos rts /*keybrd: move.w #$b,d0 * bdos con stat call trap #2 * call bdos cmpi.w #0,d0 * was key pressed? beq leave addq.l #4,(a7) leave: rts */ keyboard () { if (__BDOS (CONSTAT)) exit (); }