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

Defined functions

ADDROFF defined in line 27; used 1 times
BOOTDEV defined in line 37; used 1 times
BOOTOPTS defined in line 36; used 1 times
BSIZE defined in line 24; used 5 times
CHECKWORD defined in line 38; used 1 times
CLSHFT defined in line 23; used 1 times
CLSIZE defined in line 22; used 3 times
ENDCORE defined in line 34; used 4 times
INOFF defined in line 29; used 1 times
INOPB defined in line 28; never used
INOSIZ defined in line 25; used 4 times
NDIRIN defined in line 26; used 3 times
RK07 defined in line 10; used 2 times
SZFLAGS defined in line 35; used 1 times
  • in line 40
WC defined in line 30; used 1 times
ack defined in line 246; used 1 times
  • in line 74
addr defined in line 324; used 1 times
autoboot defined in line 19; used 1 times
bno defined in line 326; used 5 times
buf defined in line 325; used 9 times
clear defined in line 247; used 1 times
  • in line 73
cp defined in line 319; used 2 times
defnm defined in line 320; used 1 times
dno defined in line 327; used 8 times
end defined in line 321; used 1 times
  • in line 58
getc defined in line 283; used 1 times
  • in line 91
hkca defined in line 235; used 1 times
hkcs1 defined in line 232; used 2 times
hkcs2 defined in line 234; used 1 times
  • in line 73
hkda defined in line 233; used 1 times
iget defined in line 173; used 1 times
inod defined in line 323; used 4 times
iocom defined in line 248; used 1 times
names defined in line 328; used 2 times
nohead defined in line 13; used 1 times
  • in line 51
prompt defined in line 17; used 1 times
  • in line 80
putc defined in line 308; used 4 times
rblk defined in line 254; used 4 times
readname defined in line 15; used 1 times
restart defined in line 63; used 2 times
rmblk defined in line 198; used 2 times
start defined in line 47; never used
tkb defined in line 279; used 1 times
tks defined in line 278; used 1 times
tpb defined in line 306; used 1 times
tps defined in line 305; used 1 times
Last modified: 1983-03-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 480
Valid CSS Valid XHTML 1.0 Strict