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

Defined functions

ADDROFF defined in line 27; used 1 times
BOOTDEV defined in line 38; never used
BOOTOPTS defined in line 37; used 1 times
BSIZE defined in line 24; used 5 times
CHECKWORD defined in line 39; used 1 times
CLSHFT defined in line 23; used 1 times
CLSIZE defined in line 22; used 3 times
ENDCORE defined in line 35; used 3 times
INOFF defined in line 29; used 1 times
INOPB defined in line 28; never used
INOSIZ defined in line 25; used 3 times
MAJOR defined in line 1; used 1 times
NDIRIN defined in line 26; used 3 times
PBSHFT defined in line 30; used 1 times
RK07 defined in line 15; used 2 times
SZFLAGS defined in line 36; used 1 times
  • in line 41
WC defined in line 31; used 1 times
ack defined in line 226; used 1 times
  • in line 77
addr defined in line 267; used 2 times
again defined in line 86; used 2 times
bno defined in line 269; used 5 times
bootlen defined in line 261; used 1 times
  • in line 90
bootnm defined in line 260; used 1 times
  • in line 82
buf defined in line 268; used 9 times
clear defined in line 227; used 1 times
  • in line 75
csr defined in line 263; used 4 times
dno defined in line 270; used 6 times
end defined in line 264; used 1 times
  • in line 59
err defined in line 135; used 1 times
hkca defined in line 215; used 1 times
hkcs1 defined in line 212; used 2 times
hkcs2 defined in line 214; used 2 times
hkda defined in line 213; used 1 times
iget defined in line 104; used 2 times
inod defined in line 266; used 3 times
iocom defined in line 228; used 1 times
loadfile defined in line 139; used 1 times
rblk defined in line 234; used 4 times
readdir defined in line 122; used 2 times
restart defined in line 64; used 2 times
rmblk defined in line 182; used 2 times
start defined in line 51; used 1 times
  • in line 50
unit defined in line 262; used 4 times
Last modified: 1995-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2369
Valid CSS Valid XHTML 1.0 Strict