1: / RM02/03/05 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: RM05    = 0             / 0-> RM02/03, 1-> RM05
  11: drive   = 0             / unit to boot from
  12: cyl     = 0.            / cylinder offset of filesys to read from
  13: 
  14: / options:
  15: nohead  = 0             / 0->normal, 1->this boot must have a.out
  16:                         /   header removed.  Saves 10 bytes.
  17: readname= 1             / 1->normal, if default not found, read name
  18:                         /   from console. 0->loop on failure, saves 36 bytes
  19: prompt  = 1             / 1->prompt ('>') before reading from console
  20:                         /   0-> no prompt, saves 8 bytes
  21: autoboot= 1             / 1->code for autoboot. 0->no autoboot, saves 12 bytes
  22: 
  23: / constants:
  24: CLSIZE  = 2.                    / physical disk blocks per logical block
  25: CLSHFT  = 1.                    / shift to multiply by CLSIZE
  26: BSIZE   = 512.*CLSIZE           / logical block size
  27: INOSIZ  = 64.                   / size of inode in bytes
  28: NDIRIN  = 4.                    / number of direct inode addresses
  29: ADDROFF = 12.                   / offset of first address in inode
  30: INOPB   = BSIZE\/INOSIZ         / inodes per logical block
  31: INOFF   = 31.                   / inode offset = (INOPB * (SUPERB+1)) - 1
  32: WC      = -256.*CLSIZE          / word count
  33: 
  34: /  The boot options and device are placed in the last SZFLAGS bytes
  35: /  at the end of core by the kernel if this is an autoboot.
  36: ENDCORE=        160000          / end of core, mem. management off
  37: SZFLAGS=        6               / size of boot flags
  38: BOOTOPTS=       2               / location of options, bytes below ENDCORE
  39: BOOTDEV=        4
  40: CHECKWORD=      6
  41: 
  42: .. = ENDCORE-512.-SZFLAGS       / save room for boot flags
  43: 
  44: / entry is made by jsr pc,*$0
  45: / so return can be rts pc
  46: 
  47: / establish sp, copy
  48: / program up to end of core.
  49: start:
  50:         mov     $..,sp
  51:         mov     sp,r1
  52:         clr     r0
  53: .if     nohead-1                        / if nohead != 1
  54:         cmp     (r0),$407
  55:         bne     1f
  56:         mov     $20,r0
  57: .endif
  58: 1:
  59:         mov     (r0)+,(r1)+
  60:         cmp     r1,$end
  61:         blo     1b
  62:         jmp     *$2f
  63: 
  64: / On error, restart from here.
  65: restart:
  66: 
  67: / clear core to make things clean
  68:         clr     r0
  69: 2:
  70:         clr     (r0)+
  71:         cmp     r0,sp
  72:         blo     2b
  73: 
  74: / initialize disk
  75:         mov     $drive,*$rmcs2
  76:         mov     $preset+go,*$rmcs1
  77:         mov     $fmt22,*$rmof
  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: read    = 70
 233: preset  = 20
 234: go      = 1
 235: fmt22   = 10000
 236: NSECT   = 32.
 237: .if     RM05
 238: NTRAK   = 19.           / RM05
 239: .endif
 240: .if     RM05-1
 241: NTRAK   = 5.            / RM02/03
 242: .endif
 243: 
 244: rmcs1   = 176700
 245: rmda    = rmcs1+6
 246: rmcs2   = rmcs1+10
 247: rmds    = rmcs1+12
 248: rmof    = rmcs1+32
 249: rmca    = rmcs1+34
 250: 
 251: / rm02/3/5 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     $NSECT*NTRAK,r0
 261: .if     cyl
 262:         add     $cyl,r0
 263: .endif
 264:         mov     r0,*$rmca
 265:         clr     r0
 266:         div     $NSECT,r0
 267:         swab    r0
 268:         bis     r1,r0
 269:         mov     $rmda,r1
 270:         mov     r0,(r1)
 271:         mov     $buf,-(r1)
 272:         mov     $WC,-(r1)
 273:         mov     $read+go,-(r1)
 274: 1:
 275:         tstb    (r1)
 276:         bge     1b
 277:         mov     (sp)+,r1
 278:         rts     pc
 279: 
 280: tks = 177560
 281: tkb = 177562
 282: / read and echo a teletype character
 283: / if *cp is nonzero, it is the next char to simulate typing
 284: / after the defnm is tried once, read a name from the console
 285: getc:
 286:         movb    *cp, r0
 287:         beq     2f
 288:         inc     cp
 289: .if     readname
 290:         br      putc
 291: 2:
 292:         mov     $tks,r0
 293:         inc     (r0)
 294: 1:
 295:         tstb    (r0)
 296:         bge     1b
 297:         mov     tkb,r0
 298:         bic     $!177,r0
 299:         cmp     r0,$'A
 300:         blo     2f
 301:         cmp     r0,$'Z
 302:         bhi     2f
 303:         add     $'a-'A,r0
 304: .endif
 305: 2:
 306: 
 307: tps = 177564
 308: tpb = 177566
 309: / print a teletype character
 310: putc:
 311:         tstb    *$tps
 312:         bge     putc
 313:         mov     r0,*$tpb
 314:         cmp     r0,$'\r
 315:         bne     1f
 316:         mov     $'\n,r0
 317:         br      putc
 318: 1:
 319:         rts     pc
 320: 
 321: cp:     defnm
 322: defnm:  <boot\r\0>
 323: end:
 324: 
 325: inod = ..-512.-BSIZE            / room for inod, buf, stack
 326: addr = inod+ADDROFF             / first address in inod
 327: buf = inod+INOSIZ
 328: bno = buf+BSIZE
 329: dno = bno+2
 330: names = dno+2

Defined functions

ADDROFF defined in line 29; used 1 times
BOOTDEV defined in line 39; used 1 times
BOOTOPTS defined in line 38; used 1 times
BSIZE defined in line 26; used 5 times
CHECKWORD defined in line 40; used 1 times
CLSHFT defined in line 25; used 1 times
CLSIZE defined in line 24; used 3 times
ENDCORE defined in line 36; used 4 times
INOFF defined in line 31; used 1 times
INOPB defined in line 30; never used
INOSIZ defined in line 27; used 4 times
NDIRIN defined in line 28; used 3 times
NSECT defined in line 236; used 2 times
NTRAK defined in line 241; used 1 times
RM05 defined in line 10; used 2 times
SZFLAGS defined in line 37; used 1 times
  • in line 42
WC defined in line 32; used 1 times
addr defined in line 326; used 1 times
autoboot defined in line 21; used 1 times
bno defined in line 328; used 5 times
buf defined in line 327; used 9 times
cp defined in line 321; used 2 times
cyl defined in line 12; used 2 times
defnm defined in line 322; used 1 times
dno defined in line 329; used 8 times
drive defined in line 11; used 1 times
  • in line 75
end defined in line 323; used 1 times
  • in line 60
fmt22 defined in line 235; used 1 times
  • in line 77
getc defined in line 285; used 1 times
  • in line 91
go defined in line 234; used 2 times
iget defined in line 173; used 1 times
inod defined in line 325; used 4 times
names defined in line 330; used 2 times
nohead defined in line 15; used 1 times
  • in line 53
preset defined in line 233; used 1 times
  • in line 76
prompt defined in line 19; used 1 times
  • in line 80
putc defined in line 310; used 4 times
rblk defined in line 254; used 4 times
read defined in line 232; used 1 times
readname defined in line 17; used 1 times
restart defined in line 65; used 2 times
rmblk defined in line 198; used 2 times
rmca defined in line 249; used 1 times
rmcs1 defined in line 244; used 6 times
rmcs2 defined in line 246; used 1 times
  • in line 75
rmda defined in line 245; used 1 times
rmds defined in line 247; never used
rmof defined in line 248; used 1 times
  • in line 77
start defined in line 49; never used
tkb defined in line 281; used 1 times
tks defined in line 280; used 1 times
tpb defined in line 308; used 1 times
tps defined in line 307; used 1 times
Last modified: 1983-03-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 489
Valid CSS Valid XHTML 1.0 Strict