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 "@(#)utboot.c 6.3 (Berkeley) 06/08/85" 9 #endif not lint 10 11 /* 12 * VAX tape boot block for distribution tapes 13 * works on unibus tm03 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 51 /* UT UBA registers */ 52 .set UTCS1,0 53 .set UTWC,02 54 .set UTBA,04 55 .set UTFC,06 56 .set UTCS2,010 57 .set UTDS,012 58 .set UTER,014 59 .set UTAS,016 60 .set UTCC,020 61 .set UTDB,022 62 .set UTMR,024 63 .set UTDT,026 64 .set UTSN,030 65 .set UTTC,032 66 67 /* UT commands and bits */ 68 .set GO,01 69 .set UT_REW,0x6 70 .set UT_RCOM,0x38 71 .set UT_SREV,0x1a 72 .set UT_DCLR,0x8 73 .set UT_crdy,7 /* bit pos. */ 74 .set UT_gapsd,13 /* bit; aka "positioning in progress" */ 75 .set UTDENS,0x4c0 /* 1600 bpi, PDP-11 format */ 76 /* local stack variables */ 77 .set tapa,-4 /* desired tape addr */ 78 .set mtapa,-8 /* current tape addr */ 79 .set name,-8-PTHSIZ /* operator-typed file name */ 80 /* register usage */ 81 .set rUBA,r10 82 .set rUT,r11 83 /* ===== */ 84 85 /* initialization */ 86 init: 87 movl $RELOC,fp /* core loc to which to move this program */ 88 addl3 $name,fp,sp /* set stack pointer; leave 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 bsbw rew /* rewind input tape */ 95 movab name(fp),r4 /* start of filename storage */ 96 movzbl $'=,r0 /* prompt character */ 97 bsbw putc /* output char to main console */ 98 /* read in a file name */ 99 movl r4,r1 /* loc at which to store file name */ 100 nxtc: 101 bsbw getc /* get input char's in file name */ 102 cmpb r0,$012 /* terminator ? */ 103 beql nullc 104 movb r0,(r1)+ 105 brb nxtc 106 nullc: 107 subl3 r4,r1,r9 /* size of path name */ 108 beql start /* dumb operator */ 109 clrb (r1)+ 110 incl r9 111 /* user-specified TP filename has been stored at name(fp) */ 112 /* read in entire tp directory contents into low core */ 113 dirred: 114 movl $8,tapa(fp) /* tp directory starts at block 8 */ 115 movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 116 bsbw taper /* read no. bytes indicated */ 117 /* search entire directory for user-specified file name */ 118 clrl r5 /* dir buff loc = 0 */ 119 nxtdir: 120 cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 121 beql fndfil /* found match */ 122 acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 123 /* see if done with tp dir */ 124 brw start /* entry not in directory; start over */ 125 /* found desired tp dir entry */ 126 fndfil: 127 movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 128 addl2 $7,tapa(fp) /* skip 7 boot blocks */ 129 movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 130 insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 131 cmpl r6,$RELOC-512 /* check if file fits below stack */ 132 blss filok /* file o.k. */ 133 brw start /* file too large */ 134 /* time to read in desired file from tape */ 135 filok: 136 movl r6,r7 /* save r6 */ 137 bsbb taper 138 bsbw rew 139 /* clear core */ 140 subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 141 1: 142 clrb (r7)+ 143 sobgtr r0,1b 144 /* time to jump to start of file & execute */ 145 addl3 $20,fp,ap 146 clrl r5 147 calls $0,(r5) 148 brw start 149 /* taper: movcTAPE (r6),tapa(fp),0 */ 150 rew2: 151 bsbb rew /* beginning of tape */ 152 taper0: 153 bsbb rrec /* advance 1 block; never want blk 0 */ 154 taper: 155 clrl r0 /* page no. */ 156 cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 157 bgtr rew2 158 blss taper0 159 1: 160 bsbb rrec 161 acbl $1,$-BLKSIZ,r6,1b 162 rsb 163 /* rew: rewind the tape */ 164 rew: 165 clrl mtapa(fp) /* current position */ 166 movw $UTDENS,UTTC(%rUT) /* select drive */ 167 movw $UT_REW+GO,UTCS1(%rUT) 168 rsb 169 /* rrec: read 1 block from mag tape into page (r0) */ 170 rrec: 171 /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 172 jsb utquiet 173 movw $-BLKSIZ,UTFC(%rUT) 174 movw $-256,UTWC(%rUT) /* !!!!!!!!!!!!!! */ 175 bisl3 $MRV|MR_BDP1,r0,UBA_MAP(%rUBA) 176 movw $0,UTBA(%rUT) 177 movw $UTDENS,UTTC(%rUT) /* select drive */ 178 movw $UT_RCOM+GO,UTCS1(%rUT) 179 jsb utquiet 180 bisl2 $BNE,UBA_DPR1(%rUBA) 181 tstw UTER(%rUT) 182 jgeq 2f 183 mnegw $1,UTWC(%rUT) 184 movw $UTDENS,UTTC(%rUT) /* select drive */ 185 movw $UT_SREV+GO,UTCS1(%rUT) 186 jmp rrec 187 2: 188 incl r0 /* next page no. */ 189 incl mtapa(fp) /* mag tape block position */ 190 rsb 191 getc: 192 mfpr $RXCS,r0 193 bbc $RXCS_pd,r0,getc /* receiver ready ? */ 194 mfpr $RXDB,r0 195 extzv $0,$7,r0,r0 196 cmpb r0,$015 197 bneq putc 198 bsbb putc 199 movb $0,r0 200 bsbb putc 201 movb $012,r0 202 putc: 203 mfpr $TXCS,r2 204 bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 205 extzv $0,$7,r0,r0 206 mtpr r0,$TXDB 207 rsb 208 utquiet: 209 movw UTCS1(%rUT),r2 210 bbc $UT_crdy,r2,utquiet 211 1: 212 movw UTDS(%rUT),r2 213 bbs $UT_gapsd,r2,1b 214 rsb 215 end: 216