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