1: MAJOR = 10.                     / major # from bdevsw[]
   2: 
   3: / Bootstrap for Diva Comp. IV controller (33 sectors)
   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: / options: none.  all options of reading an alternate name or echoing to
  16: /		  the keyboard had to be removed to make room for the
  17: /		  code which understands the new directory structure on disc
  18: 
  19: / constants:
  20: CLSIZE  = 2.                    / physical disk blocks per logical block
  21: CLSHFT  = 1.                    / shift to multiply by CLSIZE
  22: BSIZE   = 512.*CLSIZE           / logical block size
  23: INOSIZ  = 64.                   / size of inode in bytes
  24: NDIRIN  = 4.                    / number of direct inode addresses
  25: ADDROFF = 12.                   / offset of first address in inode
  26: INOPB   = BSIZE\/INOSIZ         / inodes per logical block
  27: INOFF   = 31.                   / inode offset = (INOPB * (SUPERB+1)) - 1
  28: PBSHFT  = -4                    / shift to divide by inodes per block
  29: WC      = -256.*CLSIZE          / word count
  30: 
  31: /  The boot options and device are placed in the last SZFLAGS bytes
  32: /  at the end of core by the kernel for autobooting.
  33: ENDCORE=        160000          / end of core, mem. management off
  34: SZFLAGS=        6               / size of boot flags
  35: BOOTOPTS=       2               / location of options, bytes below ENDCORE
  36: BOOTDEV=        4
  37: CHECKWORD=      6
  38: 
  39: .. = ENDCORE-512.-SZFLAGS       / save room for boot flags
  40: 
  41: / entry is made by jsr pc,*$0
  42: / so return can be rts pc
  43: 
  44: / establish sp, copy
  45: / program up to end of core.
  46: 
  47:         nop                     / These two lines must be present or DEC
  48:         br      start           / boot ROMs will refuse to run boot block!
  49: start:
  50:         mov     r0,unit
  51:         mov     r1,csr
  52:         mov     $..,sp
  53:         mov     sp,r1
  54:         clr     r0
  55: 1:
  56:         mov     (r0)+,(r1)+
  57:         cmp     r1,$end
  58:         blo     1b
  59:         jmp     *$2f
  60: 
  61: / On error, restart from here.
  62: restart:
  63: 
  64: / clear core to make things clean
  65:         clr     r0
  66: 2:
  67:         clr     (r0)+
  68:         cmp     r0,sp
  69:         blo     2b
  70: 
  71: / initialize disk
  72:         mov     csr,r1
  73:         mov     unit,hpcs2(r1)
  74:         mov     $preset+go,hpcs1(r1)
  75:         mov     $fmt22,hpof(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: 
 212: hpcs1   = 0             / offset from base csr
 213: hpda    = hpcs1+6
 214: hpcs2   = hpcs1+10
 215: hpds    = hpcs1+12
 216: hpof    = hpcs1+32
 217: hpca    = hpcs1+34
 218: 
 219: / rp0456 disk driver.
 220: / low order address in dno,
 221: / high order in r0.
 222: rblk:
 223:         mov     r1,-(sp)
 224:         mov     dno,r1
 225: .if     CLSIZE-1
 226:         ashc    $CLSHFT,r0              / multiply by CLSIZE
 227: .endif
 228:         div     $33.*19.,r0
 229:         mov     csr,r3
 230:         mov     r0,hpca(r3)
 231:         clr     r0
 232:         div     $33.,r0
 233:         swab    r0
 234:         bis     r1,r0
 235:         add     $hpcs2,r3
 236:         mov     unit,(r3)
 237:         mov     r0,-(r3)
 238:         mov     $buf,-(r3)
 239:         mov     $WC,-(r3)
 240:         mov     $read+go,-(r3)
 241: 1:
 242:         tstb    (r3)
 243:         bge     1b
 244:         mov     (sp)+,r1
 245:         rts     pc
 246: 
 247: bootnm: <boot\0\0>
 248: bootlen = 4                     / strlen(bootnm)
 249: unit: 0
 250: csr: 0
 251: end:
 252: 
 253: inod = ..-512.-BSIZE            / room for inod, buf, stack
 254: addr = inod+ADDROFF             / first address in inod
 255: buf = inod+INOSIZ
 256: bno = buf+BSIZE
 257: dno = bno+2

Defined functions

ADDROFF defined in line 25; used 1 times
BOOTDEV defined in line 36; never used
BOOTOPTS defined in line 35; used 1 times
BSIZE defined in line 22; used 5 times
CHECKWORD defined in line 37; used 1 times
CLSHFT defined in line 21; used 1 times
CLSIZE defined in line 20; used 3 times
ENDCORE defined in line 33; used 3 times
INOFF defined in line 27; used 1 times
INOPB defined in line 26; never used
INOSIZ defined in line 23; used 3 times
MAJOR defined in line 1; used 1 times
NDIRIN defined in line 24; used 3 times
PBSHFT defined in line 28; used 1 times
SZFLAGS defined in line 34; used 1 times
  • in line 39
WC defined in line 29; used 1 times
addr defined in line 254; used 2 times
again defined in line 81; used 2 times
bno defined in line 256; used 5 times
bootlen defined in line 248; used 1 times
  • in line 85
bootnm defined in line 247; used 1 times
  • in line 77
buf defined in line 255; used 9 times
csr defined in line 250; used 4 times
dno defined in line 257; used 6 times
end defined in line 251; used 1 times
  • in line 57
err defined in line 130; used 1 times
fmt22 defined in line 210; used 1 times
  • in line 75
go defined in line 209; used 2 times
hpca defined in line 217; used 1 times
hpcs1 defined in line 212; used 6 times
hpcs2 defined in line 214; used 2 times
hpda defined in line 213; never used
hpds defined in line 215; never used
hpof defined in line 216; used 1 times
  • in line 75
iget defined in line 99; used 2 times
inod defined in line 253; used 3 times
loadfile defined in line 134; used 1 times
  • in line 96
preset defined in line 208; used 1 times
  • in line 74
rblk defined in line 222; used 4 times
read defined in line 207; used 1 times
readdir defined in line 117; used 2 times
restart defined in line 62; used 2 times
rmblk defined in line 177; used 2 times
start defined in line 49; used 1 times
  • in line 48
unit defined in line 249; used 4 times
Last modified: 1995-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2394
Valid CSS Valid XHTML 1.0 Strict