1: / RK05 bootstrap.
   2: /
   3: / disk boot program to load and transfer
   4: / to a unix entry.
   5: / for use with 1 KB byte blocks, CLSIZE is 2.
   6: / NDIRIN is the number of direct inode addresses (currently 4)
   7: / assembled size must be <= 512; if > 494, the 16-byte a.out header
   8: / must be removed
   9: 
  10: / options:
  11: nohead  = 0             / 0->normal, 1->this boot must have a.out
  12:                         /   header removed.  Saves 10 bytes.
  13: readname= 1             / 1->normal, if default not found, read name
  14:                         /   from console. 0->loop on failure, saves 36 bytes
  15: prompt  = 1             / 1->prompt ('>') before reading from console
  16:                         /   0-> no prompt, saves 8 bytes
  17: autoboot= 1             / 1->code for autoboot. 0->no autoboot, saves 12 bytes
  18: 
  19: / constants:
  20: CLSIZE  = 2.                    / physical disk blocks per logical block
  21: CLSHFT  = 1.                    / shift to multiply by CLSIZE
  22: BSIZE   = 512.*CLSIZE           / logical block size
  23: INOSIZ  = 64.                   / size of inode in bytes
  24: NDIRIN  = 4.                    / number of direct inode addresses
  25: ADDROFF = 12.                   / offset of first address in inode
  26: INOPB   = BSIZE\/INOSIZ         / inodes per logical block
  27: INOFF   = 31.                   / inode offset = (INOPB * (SUPERB+1)) - 1
  28: WC      = -256.*CLSIZE          / word count
  29: 
  30: /  The boot options and device are placed in the last SZFLAGS bytes
  31: /  at the end of core by the kernel if this is an autoboot.
  32: ENDCORE=        160000          / end of core, mem. management off
  33: SZFLAGS=        6               / size of boot flags
  34: BOOTOPTS=       2               / location of options, bytes below ENDCORE
  35: BOOTDEV=        4
  36: CHECKWORD=      6
  37: 
  38: .. = ENDCORE-512.-SZFLAGS       / save room for boot flags
  39: 
  40: / entry is made by jsr pc,*$0
  41: / so return can be rts pc
  42: 
  43: / establish sp, copy
  44: / program up to end of core.
  45: start:
  46:         mov     $..,sp
  47:         mov     sp,r1
  48:         clr     r0
  49: .if     nohead-1                        / if nohead == 1
  50:         cmp     (r0),$407
  51:         bne     1f
  52:         mov     $20,r0
  53: .endif
  54: 1:
  55:         mov     (r0)+,(r1)+
  56:         cmp     r1,$end
  57:         blo     1b
  58:         jmp     *$2f
  59: 
  60: / On error, restart from here.
  61: restart:
  62: 
  63: / clear core to make things clean
  64:         clr     r0
  65: 2:
  66:         clr     (r0)+
  67:         cmp     r0,sp
  68:         blo     2b
  69: 
  70: / initialize rk
  71:         mov     $reset+go,*$rkcs        / reset controller
  72: 
  73: / at origin, read pathname
  74: .if     prompt
  75:         mov     $'>, r0
  76:         jsr     pc, putc
  77: .endif
  78: 
  79: / spread out in array 'names', one
  80: / component every 14 bytes.
  81:         mov     $names,r1
  82: 1:
  83:         mov     r1,r2
  84: 2:
  85:         jsr     pc,getc
  86:         cmp     r0,$'\n
  87:         beq     1f
  88:         cmp     r0,$'/
  89:         beq     3f
  90:         movb    r0,(r2)+
  91:         br      2b
  92: 3:
  93:         cmp     r1,r2
  94:         beq     2b
  95:         add     $14.,r1
  96:         br      1b
  97: 
  98: / now start reading the inodes
  99: / starting at the root and
 100: / going through directories
 101: 1:
 102:         mov     $names,r1
 103:         mov     $2,r0
 104: 1:
 105:         clr     bno
 106:         jsr     pc,iget
 107:         tst     (r1)
 108:         beq     1f
 109: 2:
 110:         jsr     pc,rmblk
 111:                 br restart
 112:         mov     $buf,r2
 113: 3:
 114:         mov     r1,r3
 115:         mov     r2,r4
 116:         add     $16.,r2
 117:         tst     (r4)+
 118:         beq     5f
 119: 4:
 120:         cmpb    (r3)+,(r4)+
 121:         bne     5f
 122:         cmp     r4,r2
 123:         blo     4b
 124:         mov     -16.(r2),r0
 125:         add     $14.,r1
 126:         br      1b
 127: 5:
 128:         cmp     r2,$buf+BSIZE
 129:         blo     3b
 130:         br      2b
 131: 
 132: / read file into core until
 133: / a mapping error, (no disk address)
 134: 1:
 135:         clr     r1
 136: 1:
 137:         jsr     pc,rmblk
 138:                 br 1f
 139:         mov     $buf,r2
 140: 2:
 141:         mov     (r2)+,(r1)+
 142:         cmp     r2,$buf+BSIZE
 143:         blo     2b
 144:         br      1b
 145: / relocate core around
 146: / assembler header
 147: 1:
 148:         clr     r0
 149:         cmp     (r0),$407
 150:         bne     2f
 151: 1:
 152:         mov     20(r0),(r0)+
 153:         cmp     r0,sp
 154:         blo     1b
 155: / enter program and
 156: / restart if return
 157: 2:
 158: .if     autoboot
 159:         mov     ENDCORE-BOOTOPTS, r4
 160:         mov     ENDCORE-BOOTDEV, r3
 161:         mov     ENDCORE-CHECKWORD, r2
 162: .endif
 163:         jsr     pc,*$0
 164:         br      restart
 165: 
 166: / get the inode specified in r0
 167: iget:
 168:         add     $INOFF,r0
 169:         mov     r0,r5
 170:         ash     $-4.,r0
 171:         bic     $!7777,r0
 172:         mov     r0,dno
 173:         clr     r0
 174:         jsr     pc,rblk
 175:         bic     $!17,r5
 176:         mul     $INOSIZ,r5
 177:         add     $buf,r5
 178:         mov     $inod,r4
 179: 1:
 180:         mov     (r5)+,(r4)+
 181:         cmp     r4,$inod+INOSIZ
 182:         blo     1b
 183:         rts     pc
 184: 
 185: / read a mapped block
 186: / offset in file is in bno.
 187: / skip if success, no skip if fail
 188: / the algorithm only handles a single
 189: / indirect block. that means that
 190: / files longer than NDIRIN+128 blocks cannot
 191: / be loaded.
 192: rmblk:
 193:         add     $2,(sp)
 194:         mov     bno,r0
 195:         cmp     r0,$NDIRIN
 196:         blt     1f
 197:         mov     $NDIRIN,r0
 198: 1:
 199:         mov     r0,-(sp)
 200:         asl     r0
 201:         add     (sp)+,r0
 202:         add     $addr+1,r0
 203:         movb    (r0)+,dno
 204:         movb    (r0)+,dno+1
 205:         movb    -3(r0),r0
 206:         bne     1f
 207:         tst     dno
 208:         beq     2f
 209: 1:
 210:         jsr     pc,rblk
 211:         mov     bno,r0
 212:         inc     bno
 213:         sub     $NDIRIN,r0
 214:         blt     1f
 215:         ash     $2,r0
 216:         mov     buf+2(r0),dno
 217:         mov     buf(r0),r0
 218:         bne     rblk
 219:         tst     dno
 220:         bne     rblk
 221: 2:
 222:         sub     $2,(sp)
 223: 1:
 224:         rts     pc
 225: 
 226: read    = 4
 227: reset   = 0
 228: go      = 1
 229: 
 230: rkcs    = 177404
 231: rkda    = 177412
 232: rkwc    = 177406
 233: rkba    = 177410
 234: / rk05 disk driver.
 235: / low order address in dno,
 236: / high order in r0.
 237: rblk:
 238:         mov     r1,-(sp)
 239:         mov     dno,r1
 240: .if     CLSIZE-1
 241:         ashc    $CLSHFT,r0              / multiply by CLSIZE
 242: .endif
 243:         div     $12.,r0
 244:         ash     $4,r0
 245:         bis     r1,r0
 246:         mov     r0,*$rkda       / stuff disc address
 247:         mov     $buf,*$rkba     / where to put it.
 248:         mov     $WC,*$rkwc      / yes sir, yes sir, three bags full
 249:         mov     $read+go,*$rkcs / press the button
 250: 1:
 251:         tstb    *$rkcs
 252:         bge     1b
 253:         mov     (sp)+,r1
 254:         rts     pc
 255: 
 256: tks = 177560
 257: tkb = 177562
 258: / read and echo a teletype character
 259: / if *cp is nonzero, it is the next char to simulate typing
 260: / after the defnm is tried once, read a name from the console
 261: getc:
 262:         movb    *cp, r0
 263:         beq     2f
 264:         inc     cp
 265: .if     readname
 266:         br      putc
 267: 2:
 268:         mov     $tks,r0
 269:         inc     (r0)
 270: 1:
 271:         tstb    (r0)
 272:         bge     1b
 273:         mov     tkb,r0
 274:         bic     $!177,r0
 275:         cmp     r0,$'A
 276:         blo     2f
 277:         cmp     r0,$'Z
 278:         bhi     2f
 279:         add     $'a-'A,r0
 280: .endif
 281: 2:
 282: 
 283: tps = 177564
 284: tpb = 177566
 285: / print a teletype character
 286: putc:
 287:         tstb    *$tps
 288:         bge     putc
 289:         mov     r0,*$tpb
 290:         cmp     r0,$'\r
 291:         bne     1f
 292:         mov     $'\n,r0
 293:         br      putc
 294: 1:
 295:         rts     pc
 296: 
 297: cp:     defnm
 298: defnm:  <boot\r\0>
 299: end:
 300: 
 301: inod = ..-512.-BSIZE            / room for inod, buf, stack
 302: addr = inod+ADDROFF             / first address in inod
 303: buf = inod+INOSIZ
 304: bno = buf+BSIZE
 305: dno = bno+2
 306: names = dno+2

Defined functions

ADDROFF defined in line 25; used 1 times
BOOTDEV defined in line 35; used 1 times
BOOTOPTS defined in line 34; used 1 times
BSIZE defined in line 22; used 5 times
CHECKWORD defined in line 36; used 1 times
CLSHFT defined in line 21; used 1 times
CLSIZE defined in line 20; used 3 times
ENDCORE defined in line 32; used 4 times
INOFF defined in line 27; used 1 times
INOPB defined in line 26; never used
INOSIZ defined in line 23; used 4 times
NDIRIN defined in line 24; used 3 times
SZFLAGS defined in line 33; used 1 times
  • in line 38
WC defined in line 28; used 1 times
addr defined in line 302; used 1 times
autoboot defined in line 17; used 1 times
bno defined in line 304; used 5 times
buf defined in line 303; used 9 times
cp defined in line 297; used 2 times
defnm defined in line 298; used 1 times
dno defined in line 305; used 8 times
end defined in line 299; used 1 times
  • in line 56
getc defined in line 261; used 1 times
  • in line 85
go defined in line 228; used 2 times
iget defined in line 167; used 1 times
inod defined in line 301; used 4 times
names defined in line 306; used 2 times
nohead defined in line 11; used 1 times
  • in line 49
prompt defined in line 15; used 1 times
  • in line 74
putc defined in line 286; used 4 times
rblk defined in line 237; used 4 times
read defined in line 226; used 1 times
readname defined in line 13; used 1 times
restart defined in line 61; used 2 times
rkba defined in line 233; used 1 times
rkcs defined in line 230; used 3 times
rkda defined in line 231; used 1 times
rkwc defined in line 232; used 1 times
rmblk defined in line 192; used 2 times
start defined in line 45; never used
tkb defined in line 257; used 1 times
tks defined in line 256; used 1 times
tpb defined in line 284; used 1 times
tps defined in line 283; used 1 times
Last modified: 1983-03-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 526
Valid CSS Valid XHTML 1.0 Strict