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 /* "@(#)utboot.c 7.1 (Berkeley) 06/05/86" */ 8 9 /* 10 * VAX tape boot block for distribution tapes 11 * works on unibus tm03 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 .set RELOC,0x70000 18 /* a.out defines */ 19 .set HDRSIZ,040 /* size of file header for VAX */ 20 .set MAGIC,0410 /* file type id in header */ 21 .set TSIZ,4 /* text size */ 22 .set DSIZ,8 /* data size */ 23 .set BSIZ,12 /* bss size */ 24 .set TENT,024 /* task header entry loc */ 25 /* tp directory definitions */ 26 .set FILSIZ,38 /* tp direc offset for file size */ 27 .set BNUM,44 /* tp dir offset for start block no. */ 28 .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 29 .set PTHSIZ,32 /* size of TP path name, bytes */ 30 .set BLKSIZ,512 /* tape block size, bytes */ 31 .set NUMDIR,24 /* no. of dir blocks on tape */ 32 .set ENTBLK,8 /* no. of dir entries per tape block */ 33 /* processor registers and bits */ 34 .set RXCS,32 35 .set RXDB,33 36 .set TXCS,34 37 .set TXDB,35 38 .set RXCS_DONE,0x80 39 .set TXCS_RDY,0x80 40 .set TXCS_pr,7 /* bit position of TXCS ready bit */ 41 .set RXCS_pd,7 /* bit position of RXCS done bit */ 42 /* UBA registers */ 43 .set UBA_DPR1,68 44 .set UBA_MAP,2048 45 .set BNE,0x80000000 46 .set MRV,0x80000000 47 .set MR_BDP1,0x200000 48 49 /* UT UBA registers */ 50 .set UTCS1,0 51 .set UTWC,02 52 .set UTBA,04 53 .set UTFC,06 54 .set UTCS2,010 55 .set UTDS,012 56 .set UTER,014 57 .set UTAS,016 58 .set UTCC,020 59 .set UTDB,022 60 .set UTMR,024 61 .set UTDT,026 62 .set UTSN,030 63 .set UTTC,032 64 65 /* UT commands and bits */ 66 .set GO,01 67 .set UT_REW,0x6 68 .set UT_RCOM,0x38 69 .set UT_SREV,0x1a 70 .set UT_DCLR,0x8 71 .set UT_crdy,7 /* bit pos. */ 72 .set UT_gapsd,13 /* bit; aka "positioning in progress" */ 73 .set UTDENS,0x4c0 /* 1600 bpi, PDP-11 format */ 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 rUBA,r10 80 .set rUT,r11 81 /* ===== */ 82 83 /* initialization */ 84 init: 85 movl $RELOC,fp /* core loc to which to move this program */ 86 addl3 $name,fp,sp /* set stack pointer; leave room for locals */ 87 clrl r0 88 1: 89 movc3 $end,(r0),(fp) /* move boot up to relocated position */ 90 jmp start+RELOC 91 start: 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 blk 0 */ 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 movw $UTDENS,UTTC(%rUT) /* select drive */ 165 movw $UT_REW+GO,UTCS1(%rUT) 166 rsb 167 /* rrec: read 1 block from mag tape into page (r0) */ 168 rrec: 169 /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 170 jsb utquiet 171 movw $-BLKSIZ,UTFC(%rUT) 172 movw $-256,UTWC(%rUT) /* !!!!!!!!!!!!!! */ 173 bisl3 $MRV|MR_BDP1,r0,UBA_MAP(%rUBA) 174 movw $0,UTBA(%rUT) 175 movw $UTDENS,UTTC(%rUT) /* select drive */ 176 movw $UT_RCOM+GO,UTCS1(%rUT) 177 jsb utquiet 178 bisl2 $BNE,UBA_DPR1(%rUBA) 179 tstw UTER(%rUT) 180 jgeq 2f 181 mnegw $1,UTWC(%rUT) 182 movw $UTDENS,UTTC(%rUT) /* select drive */ 183 movw $UT_SREV+GO,UTCS1(%rUT) 184 jmp rrec 185 2: 186 incl r0 /* next page no. */ 187 incl mtapa(fp) /* mag tape block position */ 188 rsb 189 getc: 190 mfpr $RXCS,r0 191 bbc $RXCS_pd,r0,getc /* receiver ready ? */ 192 mfpr $RXDB,r0 193 extzv $0,$7,r0,r0 194 cmpb r0,$015 195 bneq putc 196 bsbb putc 197 movb $0,r0 198 bsbb putc 199 movb $012,r0 200 putc: 201 mfpr $TXCS,r2 202 bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 203 extzv $0,$7,r0,r0 204 mtpr r0,$TXDB 205 rsb 206 utquiet: 207 movw UTCS1(%rUT),r2 208 bbc $UT_crdy,r2,utquiet 209 1: 210 movw UTDS(%rUT),r2 211 bbs $UT_gapsd,r2,1b 212 rsb 213 end: 214