Annotation of 42BSD/sys/mdec/mtboot.s, revision 1.1.1.1

1.1       root        1: /*     mtboot.s        6.1     83/07/29        */
                      2: 
                      3: /*
                      4:  * VAX tape boot block for distribution tapes
                      5:  * works on massbys tu78
                      6:  *
                      7:  * reads a program from a tp directory on a tape and executes it
                      8:  * program must be stripped of the header and is loaded ``bits as is''
                      9:  * you can return to this loader via ``ret'' as you are called ``calls $0,ent''
                     10:  *
                     11:  * Based on similar driver for tm03 formatter.
                     12:  * Local modifications by Jeffrey R. Schwab    June, 1982
                     13:  *                             Purdue University Computing Center
                     14:  */
                     15:        .set    RELOC,0x70000
                     16: /* a.out defines */
                     17:        .set    HDRSIZ,040      /* size of file header for VAX */
                     18:        .set    MAGIC,0410      /* file type id in header */
                     19:        .set    TSIZ,4          /* text size */
                     20:        .set    DSIZ,8          /* data size */
                     21:        .set    BSIZ,12         /* bss size */
                     22:        .set    TENT,024        /* task header entry loc */
                     23: /* tp directory definitions */
                     24:        .set    FILSIZ,38       /* tp direc offset for file size */
                     25:        .set    BNUM,44         /* tp dir offset for start block no. */
                     26:        .set    ENTSIZ,64       /* size of 1 TP dir entry, bytes */
                     27:        .set    PTHSIZ,32       /* size of TP path name, bytes */
                     28:        .set    BLKSIZ,512      /* tape block size, bytes */
                     29:        .set    NUMDIR,24       /* no. of dir blocks on tape */
                     30:        .set    ENTBLK,8        /* no. of dir entries per tape block */
                     31: /* processor registers and bits */
                     32:        .set    RXCS,32
                     33:        .set    RXDB,33
                     34:        .set    TXCS,34
                     35:        .set    TXDB,35
                     36:        .set    RXCS_DONE,0x80
                     37:        .set    TXCS_RDY,0x80
                     38:        .set    TXCS_pr,7       /* bit position of TXCS ready bit */
                     39:        .set    RXCS_pd,7       /* bit position of RXCS done bit */
                     40: /* MBA registers */
                     41:        .set    MBA_CSR,0       /* configuration and status register */
                     42:        .set    MBA_CR,4        /* MBA control reg */
                     43:        .set    MBA_SR,8        /* MBA status reg */
                     44:        .set    MBA_VAR,12      /* MBA virt addr reg */
                     45:        .set    MBA_BCR,16      /* MBA byte count reg */
                     46:        .set    MBA_MAP,0x800   /* start of MBA map reg's */
                     47:        .set    MRV,0x80000000
                     48:        .set    MBA_bsy,31      /* massbus busy */
                     49: /* TU78 mba registers */
                     50:        .set    MTCS,0          /* MT data transfer control reg */
                     51:        .set    MTER,4          /* data transfer error status reg */
                     52:        .set    MTRC,8          /* record count */
                     53:        .set    MTAS,16         /* attention summary */
                     54:        .set    MTBC,20         /* byte count */
                     55:        .set    MTNER,44        /* non data transfer error status reg */
                     56:        .set    MTNCS,48        /* non data transfer control reg */
                     57:        .set    MTID,68         /* internal data reg */
                     58: /* MT commands */
                     59:        .set    GO,1            /* GO bit */
                     60:        .set    MT_REW,6        /* rewind, on-line */
                     61:        .set    MT_RCOM,070     /* read forward */
                     62: /* MT bits */
                     63:        .set    MT_rdy,15       /* controller ready */
                     64:        .set    MT_rec,2        /* bit for single record count */
                     65:        .set    MT_rcnt,4       /* record count for single record (shifted) */
                     66:        .set    MT_erc,0xffffffc0       /* error code mask */
                     67:        .set    MT_done,1       /* proper completion code */
                     68: /* local stack variables */
                     69:        .set    tapa,-4         /* desired tape addr */
                     70:        .set    mtapa,-8        /* current tape addr */
                     71:        .set    name,-8-PTHSIZ  /* operator-typed file name */
                     72: /* register usage */
                     73:        .set    rMBA,r10
                     74:        .set    rMT,r11
                     75: 
                     76: /* initialization */
                     77: init:
                     78:        mull2   $0x80,%rMT
                     79:        addl2   $0x400,%rMT
                     80:        addl2   %rMBA,%rMT
                     81:        movl    $RELOC,fp       /* core loc to which to move this program */
                     82:        addl3   $name,fp,sp     /* set stack pointer, leaving room for locals */
                     83:        clrl    r0
                     84: 1:
                     85:        movc3   $end,(r0),(fp)  /* move boot up to relocated position */
                     86:        jmp     start+RELOC
                     87: start:
                     88:        movl    $1,MBA_CR(%rMBA)        /* MBA init */
                     89: 1:
                     90:        movl    MTID(%rMT),r2           /* wait for tape controller to ready */
                     91:        bbc     $MT_rdy,r2,1b           /* after massbus init */
                     92:        bsbw    rew                     /* rewind input tape */
                     93:        movab   name(fp),r4             /* start of filename storage */
                     94:        movzbl  $'=,r0                  /* prompt character */
                     95:        bsbw    putc                    /* output char to main console */
                     96: /* read in a file name */
                     97:        movl    r4,r1                   /* loc at which to store file name */
                     98: nxtc:
                     99:        bsbw    getc                    /* get input char's in file name */
                    100:        cmpb    r0,$012                 /* terminator ? */
                    101:        beql    nullc
                    102:        movb    r0,(r1)+
                    103:        brb     nxtc
                    104: nullc:
                    105:        subl3   r4,r1,r9                /* size of path name */
                    106:        beql    start                   /* dumb operator */
                    107:        clrb    (r1)+
                    108:        incl    r9
                    109: /* user-specified TP filename has been stored at name(fp) */
                    110: /* read in entire tp directory contents into low core */
                    111: dirred:
                    112:        movl    $8,tapa(fp)             /* tp directory starts at block 8 */
                    113:        movl    $(NUMDIR*BLKSIZ),r6     /* no. bytes in total dir */
                    114:        bsbw    taper                   /* read no. bytes indicated */
                    115: /* search entire directory for user-specified file name */
                    116:        clrl    r5                      /* dir buff loc = 0 */
                    117: nxtdir:
                    118:        cmpc3   r9,(r5),(r4)            /* see if dir entry matches filename */
                    119:        beql    fndfil                  /* found match */
                    120:        acbl    $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir
                    121:                                        /* see if done with tp dir */
                    122:        brw     start                   /* entry not in directory; start over */
                    123: /* found desired tp dir entry */
                    124: fndfil:
                    125:        movzwl  BNUM(r5),tapa(fp)       /* start block no., 2 bytes */
                    126:        addl2   $7,tapa(fp)             /* skip 7 boot blocks */
                    127:        movzwl  FILSIZ(r5),r6           /* low 2 bytes file size */
                    128:        insv    FILSIZ-1(r5),$16,$8,r6  /* file size, high byte */
                    129:        cmpl    r6,$RELOC-512           /* check if file fits below stack */
                    130:        blss    filok                   /* file o.k. */
                    131:        brw     start                   /* file too large */
                    132: /* time to read in desired file from tape */
                    133: filok:
                    134:        movl    r6,r7                   /* save r6 */
                    135:        bsbb    taper
                    136:        bsbw    rew
                    137: /* clear core */
                    138:        subl3   r7,$RELOC-4,r0          /* no. bytes to clear */
                    139: 1:
                    140:        clrb    (r7)+
                    141:        sobgtr  r0,1b
                    142: /* time to jump to start of file & execute */
                    143:        addl3   $20,fp,ap
                    144:        clrl    r5
                    145:        calls   $0,(r5)
                    146:        brw     start
                    147: /* taper: movcTAPE (r6),tapa(fp),0 */
                    148: rew2:
                    149:        bsbb    rew                     /* beginning of tape */
                    150: taper0:
                    151:        bsbb    rrec                    /* advance 1 block; never want blk0 */
                    152: taper:
                    153:        clrl    r0                      /* page no. */
                    154:        cmpl    mtapa(fp),tapa(fp)      /* current position .vs. desired */
                    155:        bgtr    rew2
                    156:        blss    taper0
                    157: 1:
                    158:        bsbb    rrec
                    159:        acbl    $1,$-BLKSIZ,r6,1b
                    160:        rsb
                    161: /* rew: rewind the tape */
                    162: rew:
                    163:        clrl    mtapa(fp)               /* current position */
                    164:        movl    MTNER(%rMT),r2          /* read non-data status */
                    165:        movl    MTAS(%rMT),MTAS(%rMT)   /* and clear any attention bits */
                    166:        movl    $MT_REW+GO,MTNCS(%rMT)  /* rewind command and go bit */
                    167: 1:
                    168:        movl    MTAS(%rMT),r2           /* check attention bits */
                    169:        beql    1b                      /* loop if attention not yet set */
                    170:        movl    MTNER(%rMT),r2          /* read non-data status */
                    171:        movl    MTAS(%rMT),MTAS(%rMT)   /* and clear any attention bits */
                    172:        bicl2   $MT_erc,r2              /* isolate error condition */
                    173:        subl2   $MT_done,r2             /* check with completion condition */
                    174:        bneq    1b                      /* wait for completion attention */
                    175:        rsb
                    176: /* rrec: read 1 block from mag tape into page (r0) */
                    177: rrec:
                    178:        /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */
                    179:        movl    MTNER(%rMT),r2          /* read non-data status */
                    180:        movl    MTAS(%rMT),MTAS(%rMT)   /* and clear any attention bits */
                    181:        movl    $-BLKSIZ,MBA_BCR(%rMBA)
                    182:        bisl3   $MRV,r0,MBA_MAP(%rMBA)
                    183:        clrl    MBA_VAR(%rMBA)
                    184:        movl    $BLKSIZ,MTBC(%rMT)      /* set byte count */
                    185:        bisl2   $MT_rcnt,MTRC(%rMT)     /* set record count */
                    186:        movl    $MT_RCOM+GO,MTCS(%rMT)  /* load read command */
                    187: 1:
                    188:        movl    MBA_SR(%rMBA),r2        /* load mba status reg */
                    189:        bbs     $MBA_bsy,r2,1b          /* wait for mba to go non-busy */
                    190:        movl    MTRC(%rMT),r2           /* fetch record count */
                    191:        bbs     $MT_rec,r2,rrec         /* retry read if we did not read a record */
                    192:        movl    MTER(%rMT),r2           /* load data transfer error status */
                    193:        bicl2   $MT_erc,r2              /* isolate status value */
                    194:        subl2   $MT_done,r2             /* compare with successful read */
                    195:        bneq    rrec                    /* load to try read again */
                    196: 
                    197:        incl    r0                      /* next page no. */
                    198:        incl    mtapa(fp)               /* mag tape block position */
                    199:        rsb
                    200: getc:
                    201:        mfpr    $RXCS,r0
                    202:        bbc     $RXCS_pd,r0,getc        /* receiver ready ? */
                    203:        mfpr    $RXDB,r0
                    204:        extzv   $0,$7,r0,r0
                    205:        cmpb    r0,$015
                    206:        bneq    putc
                    207:        bsbb    putc
                    208:        movb    $0,r0
                    209:        bsbb    putc
                    210:        movb    $012,r0
                    211: putc:
                    212:        mfpr    $TXCS,r2
                    213:        bbc     $TXCS_pr,r2,putc        /* transmitter ready ? */
                    214:        extzv   $0,$7,r0,r0
                    215:        mtpr    r0,$TXDB
                    216:        rsb
                    217: end:

unix.superglobalmegacorp.com

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