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

Defined functions

dirred defined in line 117; never used
end defined in line 223; used 1 times
  • in line 91
filok defined in line 139; used 1 times
fndfil defined in line 130; used 1 times
getc defined in line 206; used 2 times
init defined in line 83; never used
nullc defined in line 110; used 1 times
nxtc defined in line 104; used 1 times
nxtdir defined in line 123; used 1 times
putc defined in line 217; used 5 times
rew defined in line 168; used 3 times
rew2 defined in line 154; used 1 times
rrec defined in line 183; used 4 times
start defined in line 93; used 5 times
taper defined in line 158; used 2 times
taper0 defined in line 156; used 1 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 717
Valid CSS Valid XHTML 1.0 Strict