1 /* 2 * Copyright (c) 1980 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 #ifndef lint 8 _sccsid:.asciz "@(#)tsboot.c 6.2 (Berkeley) 06/08/85" 9 #endif not lint 10 11 /* 12 * VAX tape boot block for distribution tapes 13 * works on unibus ts11 14 * 15 * reads a program from a tp directory on a tape and executes it 16 * program must be stripped of the header and is loaded ``bits as is'' 17 * you can return to this loader via ``ret'' as you are called ``calls $0,ent'' 18 */ 19 .set RELOC,0x70000 20 /* a.out defines */ 21 .set HDRSIZ,040 /* size of file header for VAX */ 22 .set MAGIC,0410 /* file type id in header */ 23 .set TSIZ,4 /* text size */ 24 .set DSIZ,8 /* data size */ 25 .set BSIZ,12 /* bss size */ 26 .set TENT,024 /* task header entry loc */ 27 /* tp directory definitions */ 28 .set FILSIZ,38 /* tp direc offset for file size */ 29 .set BNUM,44 /* tp dir offset for start block no. */ 30 .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 31 .set PTHSIZ,32 /* size of TP path name, bytes */ 32 .set BLKSIZ,512 /* tape block size, bytes */ 33 .set NUMDIR,24 /* no. of dir blocks on tape */ 34 .set ENTBLK,8 /* no. of dir entries per tape block */ 35 /* processor registers and bits */ 36 .set RXCS,32 37 .set RXDB,33 38 .set TXCS,34 39 .set TXDB,35 40 .set RXCS_DONE,0x80 41 .set TXCS_RDY,0x80 42 .set TXCS_pr,7 /* bit position of TXCS ready bit */ 43 .set RXCS_pd,7 /* bit position of RXCS done bit */ 44 /* UBA registers */ 45 .set UBA_DPR1,68 46 .set UBA_MAP,2048 47 .set BNE,0x80000000 48 .set MRV,0x80000000 49 .set MR_BDP1,0x200000 50 /* TS UBA registers */ 51 .set TSDB,0 52 .set TSSR,2 53 /* TS commands and bits */ 54 .set TSA,0x200 /* page 1, ts command buffer relocation */ 55 .set TS_ACK,0100000 /* ack packet */ 56 .set TS_CVC,040000 /* clear volume check */ 57 .set TS_SETCHR,4 /* set characteristics */ 58 .set TS_READ,1 /* read */ 59 .set TS_RETRY,01000 /* retry, or with read */ 60 .set TS_REWIND,02010 61 /* local stack variables */ 62 .set tapa,-4 /* desired tape addr */ 63 .set mtapa,-8 /* current tape addr */ 64 .set name,-8-PTHSIZ /* operator-typed file name */ 65 /* register usage */ 66 .set rUBA,r10 67 .set rTS,r11 68 /* ===== */ 69 70 /* initialization */ 71 init: 72 movl $RELOC,fp /* core loc to which to move this program */ 73 addl3 $name,fp,sp /* set stack pointer; leave room for locals */ 74 clrl r0 75 1: 76 movc3 $end,(r0),(fp) /* move boot up to relocated position */ 77 jmp start+RELOC 78 start: 79 ashl $-9,$RELOC,r0 80 bisl3 $MRV,r0,UBA_MAP+4(%rUBA) 81 clrw TSSR(%rTS) 82 bsbw tsquiet 83 movw $TSA+setchr,TSDB(%rTS) 84 bsbw tsquiet 85 bsbw rew /* rewind input tape */ 86 movab name(fp),r4 /* start of filename storage */ 87 movzbl $'=,r0 /* prompt character */ 88 bsbw putc /* output char to main console */ 89 /* read in a file name */ 90 movl r4,r1 /* loc at which to store file name */ 91 nxtc: 92 bsbw getc /* get input char's in file name */ 93 cmpb r0,$012 /* terminator ? */ 94 beql nullc 95 movb r0,(r1)+ 96 brb nxtc 97 nullc: 98 subl3 r4,r1,r9 /* size of path name */ 99 beql start /* dumb operator */ 100 clrb (r1)+ 101 incl r9 102 /* user-specified TP filename has been stored at name(fp) */ 103 /* read in entire tp directory contents into low core */ 104 dirred: 105 movl $8,tapa(fp) /* tp directory starts at block 8 */ 106 movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 107 bsbw taper /* read no. bytes indicated */ 108 /* search entire directory for user-specified file name */ 109 clrl r5 /* dir buff loc = 0 */ 110 nxtdir: 111 cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 112 beql fndfil /* found match */ 113 acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 114 /* see if done with tp dir */ 115 brw start /* entry not in directory; start over */ 116 /* found desired tp dir entry */ 117 fndfil: 118 movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 119 addl2 $7,tapa(fp) /* skip 7 boot blocks */ 120 movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 121 insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 122 cmpl r6,$RELOC-512 /* check if file fits below stack */ 123 blss filok /* file o.k. */ 124 brw start /* file too large */ 125 /* time to read in desired file from tape */ 126 filok: 127 movl r6,r7 /* save r6 */ 128 bsbb taper 129 bsbw rew 130 /* clear core */ 131 subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 132 1: 133 clrb (r7)+ 134 sobgtr r0,1b 135 /* time to jump to start of file & execute */ 136 addl3 $20,fp,ap 137 clrl r5 138 calls $0,(r5) 139 brw start 140 /* taper: movcTAPE (r6),tapa(fp),0 */ 141 rew2: 142 bsbb rew /* beginning of tape */ 143 taper0: 144 bsbb rrec /* advance 1 block; never want blk 0 */ 145 taper: 146 clrl r0 /* page no. */ 147 cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 148 bgtr rew2 149 blss taper0 150 1: 151 bsbb rrec 152 acbl $1,$-BLKSIZ,r6,1b 153 rsb 154 /* rew: rewind the tape */ 155 rew: 156 clrl mtapa(fp) /* current position */ 157 movw $TSA+rewind,TSDB(%rTS) 158 bsbb tsquiet 159 rsb 160 /* rrec: read 1 block from mag tape into page (r0) */ 161 rrec: 162 /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 163 bisl3 $MRV,r0,UBA_MAP(%rUBA) 164 movw $TS_ACK|TS_CVC|TS_READ,tsread 165 1: 166 movw $TSA+tsread,TSDB(%rTS) 167 bsbb tsquiet 168 /* bisl2 $BNE,UBA_DPR1(%rUBA) */ 169 tstw TSSR(%rTS) 170 bgeq 2f 171 bisw2 $TS_RETRY,tsread 172 brb 1b 173 2: 174 incl r0 /* next page no. */ 175 incl mtapa(fp) /* mag tape block position */ 176 rsb 177 tsquiet: 178 tstb TSSR(%rTS) 179 bgeq tsquiet 180 rsb 181 getc: 182 mfpr $RXCS,r0 183 bbc $RXCS_pd,r0,getc /* receiver ready ? */ 184 mfpr $RXDB,r0 185 extzv $0,$7,r0,r0 186 cmpb r0,$015 187 bneq putc 188 bsbb putc 189 movb $0,r0 190 bsbb putc 191 movb $012,r0 192 putc: 193 mfpr $TXCS,r2 194 bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 195 extzv $0,$7,r0,r0 196 mtpr r0,$TXDB 197 rsb 198 .align 2 199 setchr: 200 .word TS_ACK|TS_CVC|TS_SETCHR 201 .long TSA+char 202 .word 0xe 203 char: 204 .long TSA+tsstat 205 .word 0xe 206 .word 0 207 tsread: 208 .word TS_ACK|TS_CVC|TS_READ 209 .long 0 210 .word BLKSIZ 211 rewind: 212 .word TS_ACK|TS_CVC|TS_REWIND 213 .long 0 214 .word 0 215 tsstat: 216 .space 7*2 217 end: 218