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