126b4c79bSmckusick /* 2*db43d8d8Smckusick * Copyright (c) 1980, 1986 Regents of the University of California. 326b4c79bSmckusick * All rights reserved. The Berkeley software License Agreement 426b4c79bSmckusick * specifies the terms and conditions for redistribution. 526b4c79bSmckusick */ 626b4c79bSmckusick 7*db43d8d8Smckusick /* "@(#)tmboot.c 7.1 (Berkeley) 06/05/86" */ 855dbbc69Ssam 955dbbc69Ssam /* 1055dbbc69Ssam * VAX tape boot block for distribution tapes 1155dbbc69Ssam * works on unibus tm03 1255dbbc69Ssam * 1355dbbc69Ssam * reads a program from a tp directory on a tape and executes it 1455dbbc69Ssam * program must be stripped of the header and is loaded ``bits as is'' 1555dbbc69Ssam * you can return to this loader via ``ret'' as you are called ``calls $0,ent'' 1655dbbc69Ssam */ 1755dbbc69Ssam .set RELOC,0x70000 1855dbbc69Ssam /* a.out defines */ 1955dbbc69Ssam .set HDRSIZ,040 /* size of file header for VAX */ 2055dbbc69Ssam .set MAGIC,0410 /* file type id in header */ 2155dbbc69Ssam .set TSIZ,4 /* text size */ 2255dbbc69Ssam .set DSIZ,8 /* data size */ 2355dbbc69Ssam .set BSIZ,12 /* bss size */ 2455dbbc69Ssam .set TENT,024 /* task header entry loc */ 2555dbbc69Ssam /* tp directory definitions */ 2655dbbc69Ssam .set FILSIZ,38 /* tp direc offset for file size */ 2755dbbc69Ssam .set BNUM,44 /* tp dir offset for start block no. */ 2855dbbc69Ssam .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 2955dbbc69Ssam .set PTHSIZ,32 /* size of TP path name, bytes */ 3055dbbc69Ssam .set BLKSIZ,512 /* tape block size, bytes */ 3155dbbc69Ssam .set NUMDIR,24 /* no. of dir blocks on tape */ 3255dbbc69Ssam .set ENTBLK,8 /* no. of dir entries per tape block */ 3355dbbc69Ssam /* processor registers and bits */ 3455dbbc69Ssam .set RXCS,32 3555dbbc69Ssam .set RXDB,33 3655dbbc69Ssam .set TXCS,34 3755dbbc69Ssam .set TXDB,35 3855dbbc69Ssam .set RXCS_DONE,0x80 3955dbbc69Ssam .set TXCS_RDY,0x80 4055dbbc69Ssam .set TXCS_pr,7 /* bit position of TXCS ready bit */ 4155dbbc69Ssam .set RXCS_pd,7 /* bit position of RXCS done bit */ 4255dbbc69Ssam /* UBA registers */ 4355dbbc69Ssam .set UBA_DPR1,68 4455dbbc69Ssam .set UBA_MAP,2048 4555dbbc69Ssam .set BNE,0x80000000 4655dbbc69Ssam .set MRV,0x80000000 4755dbbc69Ssam .set MR_BDP1,0x200000 4855dbbc69Ssam /* TM UBA registers */ 4955dbbc69Ssam .set TMER,0 5055dbbc69Ssam .set TMCS,2 5155dbbc69Ssam .set TMBC,4 5255dbbc69Ssam .set TMBA,6 5355dbbc69Ssam /* TM commands and bits */ 5455dbbc69Ssam .set GO,1 5555dbbc69Ssam .set TM_REW,016 5655dbbc69Ssam .set TM_RCOM,02 5755dbbc69Ssam .set TM_SREV,012 5855dbbc69Ssam .set TM_DCLR,010000 5955dbbc69Ssam .set TM_crdy,7 6055dbbc69Ssam .set TM_gapsd,3 6155dbbc69Ssam .set TMDENS,0 /* 1600 bpi */ 6255dbbc69Ssam /* local stack variables */ 6355dbbc69Ssam .set tapa,-4 /* desired tape addr */ 6455dbbc69Ssam .set mtapa,-8 /* current tape addr */ 6555dbbc69Ssam .set name,-8-PTHSIZ /* operator-typed file name */ 6655dbbc69Ssam /* register usage */ 6755dbbc69Ssam .set rUBA,r10 6855dbbc69Ssam .set rTM,r11 6955dbbc69Ssam /* ===== */ 7055dbbc69Ssam 7155dbbc69Ssam /* initialization */ 7255dbbc69Ssam init: 7355dbbc69Ssam movl $RELOC,fp /* core loc to which to move this program */ 7455dbbc69Ssam addl3 $name,fp,sp /* set stack pointer; leave room for locals */ 7555dbbc69Ssam clrl r0 7655dbbc69Ssam 1: 7755dbbc69Ssam movc3 $end,(r0),(fp) /* move boot up to relocated position */ 7855dbbc69Ssam jmp start+RELOC 7955dbbc69Ssam start: 8055dbbc69Ssam bsbw rew /* rewind input tape */ 8155dbbc69Ssam movab name(fp),r4 /* start of filename storage */ 8255dbbc69Ssam movzbl $'=,r0 /* prompt character */ 8355dbbc69Ssam bsbw putc /* output char to main console */ 8455dbbc69Ssam /* read in a file name */ 8555dbbc69Ssam movl r4,r1 /* loc at which to store file name */ 8655dbbc69Ssam nxtc: 8755dbbc69Ssam bsbw getc /* get input char's in file name */ 8855dbbc69Ssam cmpb r0,$012 /* terminator ? */ 8955dbbc69Ssam beql nullc 9055dbbc69Ssam movb r0,(r1)+ 9155dbbc69Ssam brb nxtc 9255dbbc69Ssam nullc: 9355dbbc69Ssam subl3 r4,r1,r9 /* size of path name */ 9455dbbc69Ssam beql start /* dumb operator */ 9555dbbc69Ssam clrb (r1)+ 9655dbbc69Ssam incl r9 9755dbbc69Ssam /* user-specified TP filename has been stored at name(fp) */ 9855dbbc69Ssam /* read in entire tp directory contents into low core */ 9955dbbc69Ssam dirred: 10055dbbc69Ssam movl $8,tapa(fp) /* tp directory starts at block 8 */ 10155dbbc69Ssam movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 10255dbbc69Ssam bsbw taper /* read no. bytes indicated */ 10355dbbc69Ssam /* search entire directory for user-specified file name */ 10455dbbc69Ssam clrl r5 /* dir buff loc = 0 */ 10555dbbc69Ssam nxtdir: 10655dbbc69Ssam cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 10755dbbc69Ssam beql fndfil /* found match */ 10855dbbc69Ssam acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 10955dbbc69Ssam /* see if done with tp dir */ 11055dbbc69Ssam brw start /* entry not in directory; start over */ 11155dbbc69Ssam /* found desired tp dir entry */ 11255dbbc69Ssam fndfil: 11355dbbc69Ssam movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 11455dbbc69Ssam addl2 $7,tapa(fp) /* skip 7 boot blocks */ 11555dbbc69Ssam movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 11655dbbc69Ssam insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 11755dbbc69Ssam cmpl r6,$RELOC-512 /* check if file fits below stack */ 11855dbbc69Ssam blss filok /* file o.k. */ 11955dbbc69Ssam brw start /* file too large */ 12055dbbc69Ssam /* time to read in desired file from tape */ 12155dbbc69Ssam filok: 12255dbbc69Ssam movl r6,r7 /* save r6 */ 12355dbbc69Ssam bsbb taper 12455dbbc69Ssam bsbw rew 12555dbbc69Ssam /* clear core */ 12655dbbc69Ssam subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 12755dbbc69Ssam 1: 12855dbbc69Ssam clrb (r7)+ 12955dbbc69Ssam sobgtr r0,1b 13055dbbc69Ssam /* time to jump to start of file & execute */ 13155dbbc69Ssam addl3 $20,fp,ap 13255dbbc69Ssam clrl r5 13355dbbc69Ssam calls $0,(r5) 13455dbbc69Ssam brw start 13555dbbc69Ssam /* taper: movcTAPE (r6),tapa(fp),0 */ 13655dbbc69Ssam rew2: 13755dbbc69Ssam bsbb rew /* beginning of tape */ 13855dbbc69Ssam taper0: 13955dbbc69Ssam bsbb rrec /* advance 1 block; never want blk 0 */ 14055dbbc69Ssam taper: 14155dbbc69Ssam clrl r0 /* page no. */ 14255dbbc69Ssam cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 14355dbbc69Ssam bgtr rew2 14455dbbc69Ssam blss taper0 14555dbbc69Ssam 1: 14655dbbc69Ssam bsbb rrec 14755dbbc69Ssam acbl $1,$-BLKSIZ,r6,1b 14855dbbc69Ssam rsb 14955dbbc69Ssam /* rew: rewind the tape */ 15055dbbc69Ssam rew: 15155dbbc69Ssam clrl mtapa(fp) /* current position */ 15255dbbc69Ssam movw $TM_REW+TMDENS+GO,TMCS(%rTM) 15355dbbc69Ssam rsb 15455dbbc69Ssam /* rrec: read 1 block from mag tape into page (r0) */ 15555dbbc69Ssam rrec: 15655dbbc69Ssam /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 15755dbbc69Ssam jsb tmquiet 15855dbbc69Ssam movw $-BLKSIZ,TMBC(%rTM) 15955dbbc69Ssam bisl3 $MRV|MR_BDP1,r0,UBA_MAP(%rUBA) 16055dbbc69Ssam movw $0,TMBA(%rTM) 16155dbbc69Ssam movw $TM_RCOM+TMDENS+GO,TMCS(%rTM) 16255dbbc69Ssam jsb tmquiet 16355dbbc69Ssam bisl2 $BNE,UBA_DPR1(%rUBA) 16455dbbc69Ssam tstw TMER(%rTM) 16555dbbc69Ssam jgeq 2f 16655dbbc69Ssam mnegw $1,TMBC(%rTM) 16755dbbc69Ssam movw $TM_SREV+TMDENS+GO,TMCS(%rTM) 16855dbbc69Ssam jmp rrec 16955dbbc69Ssam 2: 17055dbbc69Ssam incl r0 /* next page no. */ 17155dbbc69Ssam incl mtapa(fp) /* mag tape block position */ 17255dbbc69Ssam rsb 17355dbbc69Ssam getc: 17455dbbc69Ssam mfpr $RXCS,r0 17555dbbc69Ssam bbc $RXCS_pd,r0,getc /* receiver ready ? */ 17655dbbc69Ssam mfpr $RXDB,r0 17755dbbc69Ssam extzv $0,$7,r0,r0 17855dbbc69Ssam cmpb r0,$015 17955dbbc69Ssam bneq putc 18055dbbc69Ssam bsbb putc 18155dbbc69Ssam movb $0,r0 18255dbbc69Ssam bsbb putc 18355dbbc69Ssam movb $012,r0 18455dbbc69Ssam putc: 18555dbbc69Ssam mfpr $TXCS,r2 18655dbbc69Ssam bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 18755dbbc69Ssam extzv $0,$7,r0,r0 18855dbbc69Ssam mtpr r0,$TXDB 18955dbbc69Ssam rsb 19055dbbc69Ssam tmquiet: 19155dbbc69Ssam movw TMCS(%rTM),r2 19255dbbc69Ssam bbc $TM_crdy,r2,tmquiet 19355dbbc69Ssam 1: 19455dbbc69Ssam movw TMER(%rTM),r2 19555dbbc69Ssam blbc r2,1b /* low bit == TUR */ 19655dbbc69Ssam bbs $TM_gapsd,r2,1b 19755dbbc69Ssam rsb 19855dbbc69Ssam end: 199