187827dc2Smckusick /* 2*c3ae43a4Smckusick * Copyright (c) 1980, 1986 Regents of the University of California. 387827dc2Smckusick * All rights reserved. The Berkeley software License Agreement 487827dc2Smckusick * specifies the terms and conditions for redistribution. 587827dc2Smckusick */ 687827dc2Smckusick 7*c3ae43a4Smckusick /* "@(#)htboot.c 7.1 (Berkeley) 06/05/86" */ 887827dc2Smckusick 927c82199Ssam 1027c82199Ssam /* 1127c82199Ssam * VAX tape boot block for distribution tapes 1227c82199Ssam * works on massbus tu10/te16/tu45/tu77 1327c82199Ssam * 1427c82199Ssam * reads a program from a tp directory on a tape and executes it 1527c82199Ssam * program must be stripped of the header and is loaded ``bits as is'' 1627c82199Ssam * you can return to this loader via ``ret'' as you are called ``calls $0,ent'' 1727c82199Ssam */ 1827c82199Ssam .set RELOC,0x70000 1927c82199Ssam /* a.out defines */ 2027c82199Ssam .set HDRSIZ,040 /* size of file header for VAX */ 2127c82199Ssam .set MAGIC,0410 /* file type id in header */ 2227c82199Ssam .set TSIZ,4 /* text size */ 2327c82199Ssam .set DSIZ,8 /* data size */ 2427c82199Ssam .set BSIZ,12 /* bss size */ 2527c82199Ssam .set TENT,024 /* task header entry loc */ 2627c82199Ssam /* tp directory definitions */ 2727c82199Ssam .set FILSIZ,38 /* tp direc offset for file size */ 2827c82199Ssam .set BNUM,44 /* tp dir offset for start block no. */ 2927c82199Ssam .set ENTSIZ,64 /* size of 1 TP dir entry, bytes */ 3027c82199Ssam .set PTHSIZ,32 /* size of TP path name, bytes */ 3127c82199Ssam .set BLKSIZ,512 /* tape block size, bytes */ 3227c82199Ssam .set NUMDIR,24 /* no. of dir blocks on tape */ 3327c82199Ssam .set ENTBLK,8 /* no. of dir entries per tape block */ 3427c82199Ssam /* processor registers and bits */ 3527c82199Ssam .set RXCS,32 3627c82199Ssam .set RXDB,33 3727c82199Ssam .set TXCS,34 3827c82199Ssam .set TXDB,35 3927c82199Ssam .set RXCS_DONE,0x80 4027c82199Ssam .set TXCS_RDY,0x80 4127c82199Ssam .set TXCS_pr,7 /* bit position of TXCS ready bit */ 4227c82199Ssam .set RXCS_pd,7 /* bit position of RXCS done bit */ 4327c82199Ssam /* MBA registers */ 4427c82199Ssam .set MBA_CSR,0 /* configuration and status register */ 4527c82199Ssam .set MBA_CR,4 /* MBA control reg */ 4627c82199Ssam .set MBA_SR,8 /* MBA status reg */ 4727c82199Ssam .set MBA_VAR,12 /* MBA virt addr reg */ 4827c82199Ssam .set MBA_BCR,16 /* MBA byte count reg */ 4927c82199Ssam .set MBA_MAP,0x800 /* start of MBA map reg's */ 5027c82199Ssam .set MRV,0x80000000 5127c82199Ssam /* TE16/TU45/TU77 mba registers */ 5227c82199Ssam .set HTCS1,0 /* HT control 1 reg */ 5327c82199Ssam .set HTDS,4 /* status reg */ 5427c82199Ssam .set HTER,8 /* error reg */ 5527c82199Ssam .set HTAS,16 /* attention summary */ 5627c82199Ssam .set HTFC,20 /* frame count */ 5727c82199Ssam .set HTTC,36 /* HT tape control */ 5827c82199Ssam /* HT commands */ 5927c82199Ssam .set GO,1 /* GO bit */ 6027c82199Ssam .set HT_REW,6 /* rewind, on-line */ 6127c82199Ssam .set HT_DCLR,010 /* drive clear */ 6227c82199Ssam .set HT_SREV,032 /* space reverse */ 6327c82199Ssam .set HT_RCOM,070 /* read forward */ 6427c82199Ssam /* HT bits */ 6527c82199Ssam .set ERR,040000 /* composite error bit in status reg */ 6627c82199Ssam .set TCHAR,012300 /* unit 0, odd parity, PDP11, 1600 BPI NRZ, */ 6727c82199Ssam /* abort on error - for tape controller */ 6827c82199Ssam .set DRDY,0200 /* HT/drive ready in status reg */ 6927c82199Ssam .set HT_pd,7 /* bit position of HT DRDY bit */ 7027c82199Ssam .set HT_pe,14 /* bit position of HT ERROR bit */ 7127c82199Ssam /* local stack variables */ 7227c82199Ssam .set tapa,-4 /* desired tape addr */ 7327c82199Ssam .set mtapa,-8 /* current tape addr */ 7427c82199Ssam .set name,-8-PTHSIZ /* operator-typed file name */ 7527c82199Ssam /* register usage */ 7627c82199Ssam .set rMBA,r10 7727c82199Ssam .set rHT,r11 7827c82199Ssam 7927c82199Ssam /* initialization */ 8027c82199Ssam init: 8127c82199Ssam mull2 $0x80,%rHT 8227c82199Ssam addl2 $0x400,%rHT 8327c82199Ssam addl2 %rMBA,%rHT 8427c82199Ssam movl $RELOC,fp /* core loc to which to move this program */ 8527c82199Ssam addl3 $name,fp,sp /* set stack pointer, leaving room for locals */ 8627c82199Ssam clrl r0 8727c82199Ssam 1: 8827c82199Ssam movc3 $end,(r0),(fp) /* move boot up to relocated position */ 8927c82199Ssam jmp start+RELOC 9027c82199Ssam start: 9127c82199Ssam movl $1,MBA_CR(%rMBA) /* MBA init */ 9227c82199Ssam movl $TCHAR,HTTC(%rHT) /* drive no., etc. */ 9327c82199Ssam movl $HT_DCLR+GO,HTCS1(%rHT) /* drive clear */ 9427c82199Ssam bsbw rew /* rewind input tape */ 9527c82199Ssam movab name(fp),r4 /* start of filename storage */ 9627c82199Ssam movzbl $'=,r0 /* prompt character */ 9727c82199Ssam bsbw putc /* output char to main console */ 9827c82199Ssam /* read in a file name */ 9927c82199Ssam movl r4,r1 /* loc at which to store file name */ 10027c82199Ssam nxtc: 10127c82199Ssam bsbw getc /* get input char's in file name */ 10227c82199Ssam cmpb r0,$012 /* terminator ? */ 10327c82199Ssam beql nullc 10427c82199Ssam movb r0,(r1)+ 10527c82199Ssam brb nxtc 10627c82199Ssam nullc: 10727c82199Ssam subl3 r4,r1,r9 /* size of path name */ 10827c82199Ssam beql start /* dumb operator */ 10927c82199Ssam clrb (r1)+ 11027c82199Ssam incl r9 11127c82199Ssam /* user-specified TP filename has been stored at name(fp) */ 11227c82199Ssam /* read in entire tp directory contents into low core */ 11327c82199Ssam dirred: 11427c82199Ssam movl $8,tapa(fp) /* tp directory starts at block 8 */ 11527c82199Ssam movl $(NUMDIR*BLKSIZ),r6 /* no. bytes in total dir */ 11627c82199Ssam bsbw taper /* read no. bytes indicated */ 11727c82199Ssam /* search entire directory for user-specified file name */ 11827c82199Ssam clrl r5 /* dir buff loc = 0 */ 11927c82199Ssam nxtdir: 12027c82199Ssam cmpc3 r9,(r5),(r4) /* see if dir entry matches filename */ 12127c82199Ssam beql fndfil /* found match */ 12227c82199Ssam acbl $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir 12327c82199Ssam /* see if done with tp dir */ 12427c82199Ssam brw start /* entry not in directory; start over */ 12527c82199Ssam /* found desired tp dir entry */ 12627c82199Ssam fndfil: 12727c82199Ssam movzwl BNUM(r5),tapa(fp) /* start block no., 2 bytes */ 12827c82199Ssam addl2 $7,tapa(fp) /* skip 7 boot blocks */ 12927c82199Ssam movzwl FILSIZ(r5),r6 /* low 2 bytes file size */ 13027c82199Ssam insv FILSIZ-1(r5),$16,$8,r6 /* file size, high byte */ 13127c82199Ssam cmpl r6,$RELOC-512 /* check if file fits below stack */ 13227c82199Ssam blss filok /* file o.k. */ 13327c82199Ssam brw start /* file too large */ 13427c82199Ssam /* time to read in desired file from tape */ 13527c82199Ssam filok: 13627c82199Ssam movl r6,r7 /* save r6 */ 13727c82199Ssam bsbb taper 13827c82199Ssam bsbw rew 13927c82199Ssam /* clear core */ 14027c82199Ssam subl3 r7,$RELOC-4,r0 /* no. bytes to clear */ 14127c82199Ssam 1: 14227c82199Ssam clrb (r7)+ 14327c82199Ssam sobgtr r0,1b 14427c82199Ssam /* time to jump to start of file & execute */ 14527c82199Ssam addl3 $20,fp,ap 14627c82199Ssam clrl r5 14727c82199Ssam calls $0,(r5) 14827c82199Ssam brw start 14927c82199Ssam /* taper: movcTAPE (r6),tapa(fp),0 */ 15027c82199Ssam rew2: 15127c82199Ssam bsbb rew /* beginning of tape */ 15227c82199Ssam taper0: 15327c82199Ssam bsbb rrec /* advance 1 block; never want blk0 */ 15427c82199Ssam taper: 15527c82199Ssam clrl r0 /* page no. */ 15627c82199Ssam cmpl mtapa(fp),tapa(fp) /* current position .vs. desired */ 15727c82199Ssam bgtr rew2 15827c82199Ssam blss taper0 15927c82199Ssam 1: 16027c82199Ssam bsbb rrec 16127c82199Ssam acbl $1,$-BLKSIZ,r6,1b 16227c82199Ssam rsb 16327c82199Ssam /* rew: rewind the tape */ 16427c82199Ssam rew: 16527c82199Ssam clrl mtapa(fp) /* current position */ 16627c82199Ssam movl $HT_REW+GO,HTCS1(%rHT) /* rewind */ 16727c82199Ssam rsb 16827c82199Ssam /* rrec: read 1 block from mag tape into page (r0) */ 16927c82199Ssam rrec: 17027c82199Ssam /* pushl r0; movzbl $'r,r0; bsbw putc; movl (sp)+,r0; */ 17127c82199Ssam movl HTDS(%rHT),r2 17227c82199Ssam bbc $HT_pd,r2,rrec /* HT & drive ready ? */ 17327c82199Ssam movl $-BLKSIZ,MBA_BCR(%rMBA) 17427c82199Ssam bisl3 $MRV,r0,MBA_MAP(%rMBA) 17527c82199Ssam clrl MBA_VAR(%rMBA) 17627c82199Ssam movl $HT_RCOM+GO,HTCS1(%rHT) /* read forward */ 17727c82199Ssam 1: 17827c82199Ssam movl HTDS(%rHT),r2 17927c82199Ssam bbc $HT_pd,r2,1b 18027c82199Ssam movl HTER(%rHT),r2 18127c82199Ssam bbc $HT_pe,r2,2f /* any read errors ? */ 18227c82199Ssam clrl HTDS(%rHT) /* clear status - try to recover */ 18327c82199Ssam mnegl $1,HTFC(%rHT) /* frame count for backspace */ 18427c82199Ssam movl $HT_SREV+GO,HTCS1(%rHT) /* space reverse */ 18527c82199Ssam brb rrec 18627c82199Ssam 2: 18727c82199Ssam incl r0 /* next page no. */ 18827c82199Ssam incl mtapa(fp) /* mag tape block position */ 18927c82199Ssam rsb 19027c82199Ssam getc: 19127c82199Ssam mfpr $RXCS,r0 19227c82199Ssam bbc $RXCS_pd,r0,getc /* receiver ready ? */ 19327c82199Ssam mfpr $RXDB,r0 19427c82199Ssam extzv $0,$7,r0,r0 19527c82199Ssam cmpb r0,$015 19627c82199Ssam bneq putc 19727c82199Ssam bsbb putc 19827c82199Ssam movb $0,r0 19927c82199Ssam bsbb putc 20027c82199Ssam movb $012,r0 20127c82199Ssam putc: 20227c82199Ssam mfpr $TXCS,r2 20327c82199Ssam bbc $TXCS_pr,r2,putc /* transmitter ready ? */ 20427c82199Ssam extzv $0,$7,r0,r0 20527c82199Ssam mtpr r0,$TXDB 20627c82199Ssam rsb 20727c82199Ssam end: 208