Annotation of cci/d/ioex/u_ex.c, revision 1.1

1.1     ! root        1: #include "udc.h"
        !             2: #define SCRATCH                CMD_R
        !             3: #define TSTBLK         5010
        !             4: 
        !             5: extern long Probe, iob0, iob1, iob2, iob3, iob4;
        !             6: long u_err;
        !             7: 
        !             8: /*     Routine to exercise UDC
        !             9: */
        !            10: u_ex()
        !            11: {
        !            12:        Probe = 1;
        !            13:        u_probe(CMD_R);
        !            14:        u_probe(CMD_F);
        !            15:        Probe = 0;
        !            16:        u_ex1(1);
        !            17:        u_ex1(2);
        !            18:        u_ex1(3);
        !            19:        if (!u_err) writes("\nUDC passed..\n");
        !            20:                else  writes("\nUDC failed..\n");
        !            21: }
        !            22: 
        !            23: u_ex1(factor)
        !            24: long factor;
        !            25: {      register long ix, pat, *sptr, *dptr, blk, loop;
        !            26:        unsigned short *s, *d;
        !            27:        char sdev;
        !            28: 
        !            29:        sdev = SCRATCH;         /* Play on the removable */
        !            30:        blk = TSTBLK;           /* Read write test from block no. */
        !            31: 
        !            32:        pat = 0xababab00;       /* Pattern */
        !            33:        sptr = &iob0;           /* Source buffer */
        !            34:        dptr = &iob3;           /* Destination buffer */
        !            35: 
        !            36: for(u_err=loop=0;loop<40;loop++)
        !            37:        {
        !            38:        /* initialize pattern in source buffer */
        !            39:        for (ix=0; ix<(BLKSIZ/4)*factor; ix++) { 
        !            40:                sptr[ix] = pat + ix;    /* init. pattern in source buffer */
        !            41:                dptr[ix] = 0;           /* Clear destination buffer */
        !            42:                }
        !            43:        /* Write 1 block of data */
        !            44:        if (disk_rw(WRITE,sdev,blk,factor,&iob0)==0) { u_err=1; return(0); }
        !            45: 
        !            46:        /* Read 1 block of data */
        !            47:        if (disk_rw(READ,sdev,blk,factor,&iob3)==0) { u_err=1; return(0); }
        !            48: 
        !            49:        s = (unsigned short *)&iob0;            /* Source buffer */
        !            50:        d = (unsigned short *)&iob3;            /* Destination buffer */
        !            51:        for (ix=0; ix<(BLKSIZ/2)*factor; ix++) {
        !            52:                if (s[ix] != d[ix]) {
        !            53:                        writes("\nExpected ");
        !            54:                        writeh(s[ix] & 0xffff);
        !            55:                        writes(" , actual "); writeh(d[ix] & 0xffff);
        !            56:                        writes(", address "); writeh(&d[ix]);
        !            57:                        u_err = 1;
        !            58:                        }       
        !            59:                }
        !            60:        if (u_err) loop = 0;    /* If error then loop forever */
        !            61:        }
        !            62: }
        !            63: 
        !            64: 
        !            65: /*     routine to probe CMD disk 
        !            66: */
        !            67: u_probe(sdev)
        !            68: char sdev;
        !            69: {      register long *dptr, blk, inc;
        !            70: 
        !            71:        inc = 200;
        !            72:        blk = 0;
        !            73:        while (inc != 1) {
        !            74:                for(;;blk += inc)       {       /* Read 1 block (1K) of data */
        !            75:                        if (disk_rw(READ,sdev,blk,1,&iob0)==0) 
        !            76:                                { blk -= inc; break; }
        !            77:                        }
        !            78:                inc /= 2;
        !            79:                }
        !            80:        if (sdev == CMD_F) writes("\n** CMD fixed has ");
        !            81:                else  writes("\n** CMD removable has ");
        !            82:        writed(blk); writes(" Kbytes\n");
        !            83: 
        !            84: }

unix.superglobalmegacorp.com

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