1*23149Smckusick /* 2*23149Smckusick * Copyright (c) 1980 Regents of the University of California. 3*23149Smckusick * All rights reserved. The Berkeley software License Agreement 4*23149Smckusick * specifies the terms and conditions for redistribution. 5*23149Smckusick */ 611095Ssam 7*23149Smckusick #ifndef lint 8*23149Smckusick _sccsid:.asciz "@(#)tmboot.c 6.2 (Berkeley) 06/08/85" 9*23149Smckusick #endif not lint 10*23149Smckusick 1111095Ssam /* 1211095Ssam * VAX tape boot block for distribution tapes 1311095Ssam * works on unibus tm03 1411095Ssam * 1511095Ssam * reads a program from a tp directory on a tape and executes it 1611095Ssam * program must be stripped of the header and is loaded ``bits as is'' 1711095Ssam * you can return to this loader via ``ret'' as you are called ``calls $0,ent'' 1811095Ssam */ 1911095Ssam .set RELOC,0x70000 2011095Ssam /* a.out defines */ 2111095Ssam .set HDRSIZ,040 /* size of file header for VAX */ 2211095Ssam .set MAGIC,0410 /* file type id in header */ 2311095Ssam .set TSIZ,4 /* text size */ 2411095Ssam .set DSIZ,8 /* data size */ 2511095Ssam .set BSIZ,12 /* bss size */ 2611095Ssam .set TENT,024 /* task header entry loc */ 2711095Ssam /* tp directory definitions */ 2811095Ssam .set FILSIZ,38 /* tp direc offset for file size */ 2911095Ssam .set BNUM,44 /* tp dir offset for start block no. */ 3011095Ssam .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 3111095Ssam .set PTHSIZ,32 /* size of TP path name, bytes */ 3211095Ssam .set BLKSIZ,512 /* tape block size, bytes */ 3311095Ssam .set NUMDIR,24 /* no. of dir blocks on tape */ 3411095Ssam .set ENTBLK,8 /* no. of dir entries per tape block */ 3511095Ssam /* processor registers and bits */ 3611095Ssam .set RXCS,32 3711095Ssam .set RXDB,33 3811095Ssam .set TXCS,34 3911095Ssam .set TXDB,35 4011095Ssam .set RXCS_DONE,0x80 4111095Ssam .set TXCS_RDY,0x80 4211095Ssam .set TXCS_pr,7 /* bit position of TXCS ready bit */ 4311095Ssam .set RXCS_pd,7 /* bit position of RXCS done bit */ 4411095Ssam /* UBA registers */ 4511095Ssam .set UBA_DPR1,68 4611095Ssam .set UBA_MAP,2048 4711095Ssam .set BNE,0x80000000 4811095Ssam .set MRV,0x80000000 4911095Ssam .set MR_BDP1,0x200000 5011095Ssam /* TM UBA registers */ 5111095Ssam .set TMER,0 5211095Ssam .set TMCS,2 5311095Ssam .set TMBC,4 5411095Ssam .set TMBA,6 5511095Ssam /* TM commands and bits */ 5611095Ssam .set GO,1 5711095Ssam .set TM_REW,016 5811095Ssam .set TM_RCOM,02 5911095Ssam .set TM_SREV,012 6011095Ssam .set TM_DCLR,010000 6111095Ssam .set TM_crdy,7 6211095Ssam .set TM_gapsd,3 6311095Ssam .set TMDENS,0 /* 1600 bpi */ 6411095Ssam /* local stack variables */ 6511095Ssam .set tapa,-4 /* desired tape addr */ 6611095Ssam .set mtapa,-8 /* current tape addr */ 6711095Ssam .set name,-8-PTHSIZ /* operator-typed file name */ 6811095Ssam /* register usage */ 6911095Ssam .set rUBA,r10 7011095Ssam .set rTM,r11 7111095Ssam /* ===== */ 7211095Ssam 7311095Ssam /* initialization */ 7411095Ssam init: 7511095Ssam movl $RELOC,fp /* core loc to which to move this program */ 7611095Ssam addl3 $name,fp,sp /* set stack pointer; leave room for locals */ 7711095Ssam clrl r0 7811095Ssam 1: 7911095Ssam movc3 $end,(r0),(fp) /* move boot up to relocated position */ 8011095Ssam jmp start+RELOC 8111095Ssam start: 8211095Ssam bsbw rew /* rewind input tape */ 8311095Ssam movab name(fp),r4 /* start of filename storage */ 8411095Ssam movzbl $'=,r0 /* prompt character */ 8511095Ssam bsbw putc /* output char to main console */ 8611095Ssam /* read in a file name */ 8711095Ssam movl r4,r1 /* loc at which to store file name */ 8811095Ssam nxtc: 8911095Ssam bsbw getc /* get input char's in file name */ 9011095Ssam cmpb r0,$012 /* terminator ? */ 9111095Ssam beql nullc 9211095Ssam movb r0,(r1)+ 9311095Ssam brb nxtc 9411095Ssam nullc: 9511095Ssam subl3 r4,r1,r9 /* size of path name */ 9611095Ssam beql start /* dumb operator */ 9711095Ssam clrb (r1)+ 9811095Ssam incl r9 9911095Ssam /* user-specified TP filename has been stored at name(fp) */ 10011095Ssam /* read in entire tp directory contents into low core */ 10111095Ssam dirred: 10211095Ssam movl $8,tapa(fp) /* tp directory starts at block 8 */ 10311095Ssam movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 10411095Ssam bsbw taper /* read no. bytes indicated */ 10511095Ssam /* search entire directory for user-specified file name */ 10611095Ssam clrl r5 /* dir buff loc = 0 */ 10711095Ssam nxtdir: 10811095Ssam cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 10911095Ssam beql fndfil /* found match */ 11011095Ssam acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 11111095Ssam /* see if done with tp dir */ 11211095Ssam brw start /* entry not in directory; start over */ 11311095Ssam /* found desired tp dir entry */ 11411095Ssam fndfil: 11511095Ssam movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 11611095Ssam addl2 $7,tapa(fp) /* skip 7 boot blocks */ 11711095Ssam movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 11811095Ssam insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 11911095Ssam cmpl r6,$RELOC-512 /* check if file fits below stack */ 12011095Ssam blss filok /* file o.k. */ 12111095Ssam brw start /* file too large */ 12211095Ssam /* time to read in desired file from tape */ 12311095Ssam filok: 12411095Ssam movl r6,r7 /* save r6 */ 12511095Ssam bsbb taper 12611095Ssam bsbw rew 12711095Ssam /* clear core */ 12811095Ssam subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 12911095Ssam 1: 13011095Ssam clrb (r7)+ 13111095Ssam sobgtr r0,1b 13211095Ssam /* time to jump to start of file & execute */ 13311095Ssam addl3 $20,fp,ap 13411095Ssam clrl r5 13511095Ssam calls $0,(r5) 13611095Ssam brw start 13711095Ssam /* taper: movcTAPE (r6),tapa(fp),0 */ 13811095Ssam rew2: 13911095Ssam bsbb rew /* beginning of tape */ 14011095Ssam taper0: 14111095Ssam bsbb rrec /* advance 1 block; never want blk 0 */ 14211095Ssam taper: 14311095Ssam clrl r0 /* page no. */ 14411095Ssam cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 14511095Ssam bgtr rew2 14611095Ssam blss taper0 14711095Ssam 1: 14811095Ssam bsbb rrec 14911095Ssam acbl $1,$-BLKSIZ,r6,1b 15011095Ssam rsb 15111095Ssam /* rew: rewind the tape */ 15211095Ssam rew: 15311095Ssam clrl mtapa(fp) /* current position */ 15411095Ssam movw $TM_REW+TMDENS+GO,TMCS(%rTM) 15511095Ssam rsb 15611095Ssam /* rrec: read 1 block from mag tape into page (r0) */ 15711095Ssam rrec: 15811095Ssam /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 15911095Ssam jsb tmquiet 16011095Ssam movw $-BLKSIZ,TMBC(%rTM) 16111095Ssam bisl3 $MRV|MR_BDP1,r0,UBA_MAP(%rUBA) 16211095Ssam movw $0,TMBA(%rTM) 16311095Ssam movw $TM_RCOM+TMDENS+GO,TMCS(%rTM) 16411095Ssam jsb tmquiet 16511095Ssam bisl2 $BNE,UBA_DPR1(%rUBA) 16611095Ssam tstw TMER(%rTM) 16711095Ssam jgeq 2f 16811095Ssam mnegw $1,TMBC(%rTM) 16911095Ssam movw $TM_SREV+TMDENS+GO,TMCS(%rTM) 17011095Ssam jmp rrec 17111095Ssam 2: 17211095Ssam incl r0 /* next page no. */ 17311095Ssam incl mtapa(fp) /* mag tape block position */ 17411095Ssam rsb 17511095Ssam getc: 17611095Ssam mfpr $RXCS,r0 17711095Ssam bbc $RXCS_pd,r0,getc /* receiver ready ? */ 17811095Ssam mfpr $RXDB,r0 17911095Ssam extzv $0,$7,r0,r0 18011095Ssam cmpb r0,$015 18111095Ssam bneq putc 18211095Ssam bsbb putc 18311095Ssam movb $0,r0 18411095Ssam bsbb putc 18511095Ssam movb $012,r0 18611095Ssam putc: 18711095Ssam mfpr $TXCS,r2 18811095Ssam bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 18911095Ssam extzv $0,$7,r0,r0 19011095Ssam mtpr r0,$TXDB 19111095Ssam rsb 19211095Ssam tmquiet: 19311095Ssam movw TMCS(%rTM),r2 19411095Ssam bbc $TM_crdy,r2,tmquiet 19511095Ssam 1: 19611095Ssam movw TMER(%rTM),r2 19711095Ssam blbc r2,1b /* low bit == TUR */ 19811095Ssam bbs $TM_gapsd,r2,1b 19911095Ssam rsb 20011095Ssam end: 201