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 "@(#)htboot.c 6.2 (Berkeley) 06/08/85" 9 #endif not lint 10 11 12 /* 13 * VAX tape boot block for distribution tapes 14 * works on massbus tu10/te16/tu45/tu77 15 * 16 * reads a program from a tp directory on a tape and executes it 17 * program must be stripped of the header and is loaded ``bits as is'' 18 * you can return to this loader via ``ret'' as you are called ``calls $0,ent'' 19 */ 20 .set RELOC,0x70000 21 /* a.out defines */ 22 .set HDRSIZ,040 /* size of file header for VAX */ 23 .set MAGIC,0410 /* file type id in header */ 24 .set TSIZ,4 /* text size */ 25 .set DSIZ,8 /* data size */ 26 .set BSIZ,12 /* bss size */ 27 .set TENT,024 /* task header entry loc */ 28 /* tp directory definitions */ 29 .set FILSIZ,38 /* tp direc offset for file size */ 30 .set BNUM,44 /* tp dir offset for start block no. */ 31 .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 32 .set PTHSIZ,32 /* size of TP path name, bytes */ 33 .set BLKSIZ,512 /* tape block size, bytes */ 34 .set NUMDIR,24 /* no. of dir blocks on tape */ 35 .set ENTBLK,8 /* no. of dir entries per tape block */ 36 /* processor registers and bits */ 37 .set RXCS,32 38 .set RXDB,33 39 .set TXCS,34 40 .set TXDB,35 41 .set RXCS_DONE,0x80 42 .set TXCS_RDY,0x80 43 .set TXCS_pr,7 /* bit position of TXCS ready bit */ 44 .set RXCS_pd,7 /* bit position of RXCS done bit */ 45 /* MBA registers */ 46 .set MBA_CSR,0 /* configuration and status register */ 47 .set MBA_CR,4 /* MBA control reg */ 48 .set MBA_SR,8 /* MBA status reg */ 49 .set MBA_VAR,12 /* MBA virt addr reg */ 50 .set MBA_BCR,16 /* MBA byte count reg */ 51 .set MBA_MAP,0x800 /* start of MBA map reg's */ 52 .set MRV,0x80000000 53 /* TE16/TU45/TU77 mba registers */ 54 .set HTCS1,0 /* HT control 1 reg */ 55 .set HTDS,4 /* status reg */ 56 .set HTER,8 /* error reg */ 57 .set HTAS,16 /* attention summary */ 58 .set HTFC,20 /* frame count */ 59 .set HTTC,36 /* HT tape control */ 60 /* HT commands */ 61 .set GO,1 /* GO bit */ 62 .set HT_REW,6 /* rewind, on-line */ 63 .set HT_DCLR,010 /* drive clear */ 64 .set HT_SREV,032 /* space reverse */ 65 .set HT_RCOM,070 /* read forward */ 66 /* HT bits */ 67 .set ERR,040000 /* composite error bit in status reg */ 68 .set TCHAR,012300 /* unit 0, odd parity, PDP11, 1600 BPI NRZ, */ 69 /* abort on error - for tape controller */ 70 .set DRDY,0200 /* HT/drive ready in status reg */ 71 .set HT_pd,7 /* bit position of HT DRDY bit */ 72 .set HT_pe,14 /* bit position of HT ERROR bit */ 73 /* local stack variables */ 74 .set tapa,-4 /* desired tape addr */ 75 .set mtapa,-8 /* current tape addr */ 76 .set name,-8-PTHSIZ /* operator-typed file name */ 77 /* register usage */ 78 .set rMBA,r10 79 .set rHT,r11 80 81 /* initialization */ 82 init: 83 mull2 $0x80,%rHT 84 addl2 $0x400,%rHT 85 addl2 %rMBA,%rHT 86 movl $RELOC,fp /* core loc to which to move this program */ 87 addl3 $name,fp,sp /* set stack pointer, leaving room for locals */ 88 clrl r0 89 1: 90 movc3 $end,(r0),(fp) /* move boot up to relocated position */ 91 jmp start+RELOC 92 start: 93 movl $1,MBA_CR(%rMBA) /* MBA init */ 94 movl $TCHAR,HTTC(%rHT) /* drive no., etc. */ 95 movl $HT_DCLR+GO,HTCS1(%rHT) /* drive clear */ 96 bsbw rew /* rewind input tape */ 97 movab name(fp),r4 /* start of filename storage */ 98 movzbl $'=,r0 /* prompt character */ 99 bsbw putc /* output char to main console */ 100 /* read in a file name */ 101 movl r4,r1 /* loc at which to store file name */ 102 nxtc: 103 bsbw getc /* get input char's in file name */ 104 cmpb r0,$012 /* terminator ? */ 105 beql nullc 106 movb r0,(r1)+ 107 brb nxtc 108 nullc: 109 subl3 r4,r1,r9 /* size of path name */ 110 beql start /* dumb operator */ 111 clrb (r1)+ 112 incl r9 113 /* user-specified TP filename has been stored at name(fp) */ 114 /* read in entire tp directory contents into low core */ 115 dirred: 116 movl $8,tapa(fp) /* tp directory starts at block 8 */ 117 movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 118 bsbw taper /* read no. bytes indicated */ 119 /* search entire directory for user-specified file name */ 120 clrl r5 /* dir buff loc = 0 */ 121 nxtdir: 122 cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 123 beql fndfil /* found match */ 124 acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 125 /* see if done with tp dir */ 126 brw start /* entry not in directory; start over */ 127 /* found desired tp dir entry */ 128 fndfil: 129 movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 130 addl2 $7,tapa(fp) /* skip 7 boot blocks */ 131 movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 132 insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 133 cmpl r6,$RELOC-512 /* check if file fits below stack */ 134 blss filok /* file o.k. */ 135 brw start /* file too large */ 136 /* time to read in desired file from tape */ 137 filok: 138 movl r6,r7 /* save r6 */ 139 bsbb taper 140 bsbw rew 141 /* clear core */ 142 subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 143 1: 144 clrb (r7)+ 145 sobgtr r0,1b 146 /* time to jump to start of file & execute */ 147 addl3 $20,fp,ap 148 clrl r5 149 calls $0,(r5) 150 brw start 151 /* taper: movcTAPE (r6),tapa(fp),0 */ 152 rew2: 153 bsbb rew /* beginning of tape */ 154 taper0: 155 bsbb rrec /* advance 1 block; never want blk0 */ 156 taper: 157 clrl r0 /* page no. */ 158 cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 159 bgtr rew2 160 blss taper0 161 1: 162 bsbb rrec 163 acbl $1,$-BLKSIZ,r6,1b 164 rsb 165 /* rew: rewind the tape */ 166 rew: 167 clrl mtapa(fp) /* current position */ 168 movl $HT_REW+GO,HTCS1(%rHT) /* rewind */ 169 rsb 170 /* rrec: read 1 block from mag tape into page (r0) */ 171 rrec: 172 /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 173 movl HTDS(%rHT),r2 174 bbc $HT_pd,r2,rrec /* HT & drive ready ? */ 175 movl $-BLKSIZ,MBA_BCR(%rMBA) 176 bisl3 $MRV,r0,MBA_MAP(%rMBA) 177 clrl MBA_VAR(%rMBA) 178 movl $HT_RCOM+GO,HTCS1(%rHT) /* read forward */ 179 1: 180 movl HTDS(%rHT),r2 181 bbc $HT_pd,r2,1b 182 movl HTER(%rHT),r2 183 bbc $HT_pe,r2,2f /* any read errors ? */ 184 clrl HTDS(%rHT) /* clear status - try to recover */ 185 mnegl $1,HTFC(%rHT) /* frame count for backspace */ 186 movl $HT_SREV+GO,HTCS1(%rHT) /* space reverse */ 187 brb rrec 188 2: 189 incl r0 /* next page no. */ 190 incl mtapa(fp) /* mag tape block position */ 191 rsb 192 getc: 193 mfpr $RXCS,r0 194 bbc $RXCS_pd,r0,getc /* receiver ready ? */ 195 mfpr $RXDB,r0 196 extzv $0,$7,r0,r0 197 cmpb r0,$015 198 bneq putc 199 bsbb putc 200 movb $0,r0 201 bsbb putc 202 movb $012,r0 203 putc: 204 mfpr $TXCS,r2 205 bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 206 extzv $0,$7,r0,r0 207 mtpr r0,$TXDB 208 rsb 209 end: 210