1: MAJOR = 10. / major # from bdevsw[] 2: 3: / Fujitsu 160 on SI 9400 or Emulex SC01B Controller bootstrap 4: / Actually just a small modification of the RM02/03/05 bootstrap 5: / 6: / 1995/05/31 - The unit number needs to go in bits 3-5 of bootdev 7: / because the partition number now goes into bits 0-2. 8: / 9: / disk boot program to load and transfer 10: / to a unix entry. 11: / for use with 1 KB byte blocks, CLSIZE is 2. 12: / NDIRIN is the number of direct inode addresses (currently 4) 13: / assembled size must be <= 512; if > 494, the 16-byte a.out header 14: / must be removed 15: 16: / options: none. all options of reading an alternate name or echoing to 17: / the keyboard had to be removed to make room for the 18: / code which understands the new directory structure on disc 19: 20: / constants: 21: CLSIZE = 2. / physical disk blocks per logical block 22: CLSHFT = 1. / shift to multiply by CLSIZE 23: BSIZE = 512.*CLSIZE / logical block size 24: INOSIZ = 64. / size of inode in bytes 25: NDIRIN = 4. / number of direct inode addresses 26: ADDROFF = 12. / offset of first address in inode 27: INOPB = BSIZE\/INOSIZ / inodes per logical block 28: INOFF = 31. / inode offset = (INOPB * (SUPERB+1)) - 1 29: PBSHFT = -4 / shift to divide by inodes per block 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 for autobooting. 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: 48: nop / These two lines must be present or DEC 49: br start / boot ROMs will refuse to run boot block! 50: start: 51: mov r0,unit 52: mov r1,csr 53: mov $..,sp 54: mov sp,r1 55: clr r0 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: clr r0 65: / clear core to make things clean 66: 2: 67: clr (r0)+ 68: cmp r0,sp 69: blo 2b 70: 71: / initialize disk 72: mov csr,r1 73: mov unit,rmcs2(r1) 74: mov $preset+go,rmcs1(r1) 75: mov $fmt22,rmof(r1) 76: 77: mov $bootnm, r1 78: mov $2,r0 / ROOTINO 79: jsr pc,iget 80: clr r2 / offset 81: again: 82: jsr pc,readdir 83: beq restart / error - restart 84: mov 4(r0),r4 / dp->d_namlen 85: cmp r4,$bootlen / if (bootlen == dp->d_namlen) 86: bne again / nope, go try next entry 87: mov r0,r3 88: add $6,r3 / r3 = dp->d_name 89: mov r1,r5 / r5 = filename 90: 9: 91: cmpb (r3)+,(r5)+ 92: bne again / no match - go read next entry 93: sob r4,9b 94: mov (r0),r0 / r0 = dp->d_ino 95: jsr pc,iget / fetch boot's inode 96: br loadfile / 'boot'- go read it 97: 98: / get the inode specified in r0 99: iget: 100: add $INOFF,r0 101: mov r0,r5 102: ash $PBSHFT,r0 103: bic $!7777,r0 104: mov r0,dno 105: clr r0 106: jsr pc,rblk 107: bic $!17,r5 108: mov $INOSIZ,r0 109: mul r0,r5 110: add $buf,r5 111: mov $inod,r4 112: 1: 113: movb (r5)+,(r4)+ 114: sob r0,1b 115: rts pc 116: 117: readdir: 118: bit $BSIZE-1,r2 119: bne 1f 120: jsr pc,rmblk / read mapped block (bno) 121: br err / end of file branch 122: clr r2 / start at beginning of buf 123: 1: 124: mov $buf,r0 125: add r2,r0 / dp = buf+offset 126: add buf+2(r2),r2 / dp += dp->d_reclen 127: tst (r0) / dp->d_ino == 0? 128: beq readdir / yes - go look at next 129: rts pc / return with r0 = &dp->d_ino 130: err: 131: clr r0 / return with 132: rts pc / dp = NULL 133: 134: loadfile: 135: clr bno / start at block 0 of inode in 'inod' 136: / read file into core until 137: / a mapping error, (no disk address) 138: clr r1 139: 1: 140: jsr pc,rmblk 141: br 1f 142: mov $buf,r2 143: 2: 144: mov (r2)+,(r1)+ 145: cmp r2,$buf+BSIZE 146: blo 2b 147: br 1b 148: / relocate core around 149: / assembler header 150: 1: 151: clr r0 152: cmp (r0),$407 153: bne 2f 154: 1: 155: mov 20(r0),(r0)+ 156: cmp r0,sp 157: blo 1b 158: / enter program and 159: / restart if return 160: 2: 161: mov ENDCORE-BOOTOPTS, r4 162: mov unit,r3 163: ash $3,r3 / unit # in bits 3-5, partition # is 0 164: bis $MAJOR\<8.,r3 165: mov ENDCORE-CHECKWORD, r2 166: mov csr,r1 167: jsr pc,*$0 168: br restart 169: 170: / read a mapped block 171: / offset in file is in bno. 172: / skip if success, no skip if fail 173: / the algorithm only handles a single 174: / indirect block. that means that 175: / files longer than NDIRIN+256 blocks (260kb) cannot 176: / be loaded. 177: rmblk: 178: add $2,(sp) 179: mov bno,r0 180: cmp r0,$NDIRIN 181: blt 1f 182: mov $NDIRIN,r0 183: 1: 184: ash $2,r0 185: mov addr+2(r0),dno 186: mov addr(r0),r0 187: bne 1f 188: tst dno 189: beq 2f 190: 1: 191: jsr pc,rblk 192: mov bno,r0 193: inc bno 194: sub $NDIRIN,r0 195: blt 1f 196: ash $2,r0 197: mov buf+2(r0),dno 198: mov buf(r0),r0 199: bne rblk 200: tst dno 201: bne rblk 202: 2: 203: sub $2,(sp) 204: 1: 205: rts pc 206: 207: read = 70 208: preset = 20 209: go = 1 210: fmt22 = 10000 211: NSECT = 32. 212: NTRAK = 10. / SI 9400 with Fujitsu 160 213: 214: rmcs1 = 0 215: rmda = rmcs1+6 216: rmcs2 = rmcs1+10 217: rmds = rmcs1+12 218: rmof = rmcs1+32 219: rmca = rmcs1+34 220: 221: / rm02/3/5 disk driver. 222: / low order address in dno, 223: / high order in r0. 224: rblk: 225: mov r1,-(sp) 226: mov dno,r1 227: .if CLSIZE-1 228: ashc $CLSHFT,r0 / multiply by CLSIZE 229: .endif 230: div $NSECT*NTRAK,r0 231: mov csr,r3 232: mov r0,rmca(r3) 233: clr r0 234: div $NSECT,r0 235: swab r0 236: bis r1,r0 237: add $rmcs2,r3 238: mov unit,(r3) 239: mov r0,-(r3) 240: mov $buf,-(r3) 241: mov $WC,-(r3) 242: mov $read+go,-(r3) 243: 1: 244: tstb (r3) 245: bge 1b 246: mov (sp)+,r1 247: rts pc 248: 249: bootnm: <boot\0\0> 250: bootlen = 4 / strlen(bootnm) 251: unit: 0 252: csr: 0 253: end: 254: 255: inod = ..-512.-BSIZE / room for inod, buf, stack 256: addr = inod+ADDROFF / first address in inod 257: buf = inod+INOSIZ 258: bno = buf+BSIZE 259: dno = bno+2