# 2.11BSD#431 - /usr/src/sys/mdec/rkuboot.s

       1: MAJOR = 6                       / major # from bdevsw[]
       2:
       3: / RK05 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: / 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:         clr     r0
      64: / clear core to make things clean
      65: 2:
      66:         clr     (r0)+
      67:         cmp     r0,sp
      68:         blo     2b
      69:
      70: / initialize rk
      71:         mov     csr,r1
      72:         mov     $reset+go,rkcs(r1)      / reset controller
      73:
      74:         mov     $bootnm, r1
      75:         mov     $2,r0                   / ROOTINO
      76:         jsr     pc,iget
      77:         clr     r2                      / offset
      78: again:
      79:         jsr     pc,readdir
      80:         beq     restart                 / error - restart
      81:         mov     4(r0),r4                / dp->d_namlen
      82:         cmp     r4,$bootlen             / if (bootlen == dp->d_namlen)
      83:         bne     again                   /    nope, go try next entry
      84:         mov     r0,r3
      85:         add     $6,r3                   / r3 = dp->d_name
      86:         mov     r1,r5                   / r5 = filename
      87: 9:
      88:         cmpb    (r3)+,(r5)+
      89:         bne     again                   / no match - go read next entry
      90:         sob     r4,9b
      91:         mov     (r0),r0                 / r0 = dp->d_ino
      92:         jsr     pc,iget                 / fetch boot's inode
      93:         br      loadfile                / 'boot'- go read it
      94:
      95: / get the inode specified in r0
      96: iget:
      97:         add     $INOFF,r0
      98:         mov     r0,r5
      99:         ash     $PBSHFT,r0
     100:         bic     $!7777,r0
     101:         mov     r0,dno
     102:         clr     r0
     103:         jsr     pc,rblk
     104:         bic     $!17,r5
     105:         mov     $INOSIZ,r0
     106:         mul     r0,r5
     107:         add     $buf,r5
     108:         mov     $inod,r4
     109: 1:
     110:         movb    (r5)+,(r4)+
     111:         sob     r0,1b
     112:         rts     pc
     113:
     114: readdir:
     115:         bit     $BSIZE-1,r2
     116:         bne     1f
     117:         jsr     pc,rmblk                / read mapped block (bno)
     118:                 br err                  / end of file branch
     119:         clr     r2                      / start at beginning of buf
     120: 1:
     121:         mov     $buf,r0
     122:         add     r2,r0                   / dp = buf+offset
     123:         add     buf+2(r2),r2            / dp += dp->d_reclen
     124:         tst     (r0)                    / dp->d_ino == 0?
     125:         beq     readdir                 / yes - go look at next
     126:         rts     pc                      / return with r0 = &dp->d_ino
     127: err:
     128:         clr     r0                      / return with
     129:         rts     pc                      / dp = NULL
     130:
     131: loadfile:
     132:         clr     bno                     / start at block 0 of inode in 'inod'
     133: / read file into core until
     134: / a mapping error, (no disk address)
     135:         clr     r1
     136: 1:
     137:         jsr     pc,rmblk
     138:                 br 1f
     139:         mov     $buf,r2
     140: 2:
     141:         mov     (r2)+,(r1)+
     142:         cmp     r2,$buf+BSIZE
     143:         blo     2b
     144:         br      1b
     145: / relocate core around
     146: / assembler header
     147: 1:
     148:         clr     r0
     149:         cmp     (r0),$407
     150:         bne     2f
     151: 1:
     152:         mov     20(r0),(r0)+
     153:         cmp     r0,sp
     154:         blo     1b
     155: / enter program and
     156: / restart if return
     157: 2:
     158:         mov     ENDCORE-BOOTOPTS, r4
     159:         mov     unit,r3
     160:         ash     $3,r3                   / unit # in bits 3-5, partition # is 0
     161:         bis     $MAJOR\<8.,r3
     162:         mov     ENDCORE-CHECKWORD, r2
     163:         mov     csr,r1
     164:         jsr     pc,*$0
     165:         br      restart
     166:
     167: / read a mapped block
     168: / offset in file is in bno.
     169: / skip if success, no skip if fail
     170: / the algorithm only handles a single
     171: / indirect block. that means that
     172: / files longer than NDIRIN+256 blocks (260kb) cannot
     173: / be loaded.
     174: rmblk:
     175:         add     $2,(sp)
     176:         mov     bno,r0
     177:         cmp     r0,$NDIRIN
     178:         blt     1f
     179:         mov     $NDIRIN,r0
     180: 1:
     181:         ash     $2,r0
     182:         mov     addr+2(r0),dno
     183:         mov     addr(r0),r0
     184:         bne     1f
     185:         tst     dno
     186:         beq     2f
     187: 1:
     188:         jsr     pc,rblk
     189:         mov     bno,r0
     190:         inc     bno
     191:         sub     $NDIRIN,r0
     192:         blt     1f
     193:         ash     $2,r0
     194:         mov     buf+2(r0),dno
     195:         mov     buf(r0),r0
     196:         bne     rblk
     197:         tst     dno
     198:         bne     rblk
     199: 2:
     200:         sub     $2,(sp)
     201: 1:
     202:         rts     pc
     203:
     204: read    = 4
     205: reset   = 0
     206: go      = 1
     207:
     208: rkcs    = 0             / offset from base csr
     209: rkwc    = 2
     210: rkba    = 4
     211: rkda    = 6
     212: / rk05 disk driver.
     213: / low order address in dno,
     214: / high order in r0.
     215: rblk:
     216:         mov     r1,-(sp)
     217:         mov     dno,r1
     218: .if     CLSIZE-1
     219:         ashc    $CLSHFT,r0              / multiply by CLSIZE
     220: .endif
     221:         div     $12.,r0
     222:         ash     $4,r0
     223:         bis     r1,r0
     224:         mov     unit,r3
     225:         ash     $13.,r3
     226:         bis     r3,r0
     227:         mov     csr,r3
     228:         mov     r0,rkda(r3)     / stuff disc address
     229:         mov     $buf,rkba(r3)   / where to put it.
     230:         mov     $WC,rkwc(r3)    / yes sir, yes sir, three bags full
     231:         mov     $read+go,(r3)   / rkcs - press the button
     232: 1:
     233:         tstb    (r3)            / rkcs
     234:         bge     1b
     235:         mov     (sp)+,r1
     236:         rts     pc
     237:
     238: bootnm: <boot\0\0>
     239: bootlen = 4                     / strlen(bootnm)
     240: unit: 0
     241: csr: 0
     242: end:
     243:
     244: inod = ..-512.-BSIZE            / room for inod, buf, stack
     245: addr = inod+ADDROFF             / first address in inod
     246: buf = inod+INOSIZ
     247: bno = buf+BSIZE
     248: dno = bno+2

#### Defined functions

ADDROFF defined in line 25; used 1 times

- in line 245

BOOTDEV defined in line 36; never used
BOOTOPTS defined in line 35; used 1 times

- in line 158

BSIZE defined in line 22; used 5 times

- in line 26, 115, 142, 244-247(2)

CHECKWORD defined in line 37; used 1 times

- in line 162

CLSHFT defined in line 21; used 1 times

- in line 219

CLSIZE defined in line 20; used 3 times

- in line 22, 29, 218

ENDCORE defined in line 33; used 3 times

- in line 39, 158-162(2)

INOFF defined in line 27; used 1 times

- in line 97

INOPB defined in line 26; never used
INOSIZ defined in line 23; used 3 times

- in line 26, 105, 246

MAJOR defined in line 1; used 1 times

- in line 161

NDIRIN defined in line 24; used 3 times

- in line 177-179(2), 191

PBSHFT defined in line 28; used 1 times

- in line 99

SZFLAGS defined in line 34; used 1 times

- in line 39

WC defined in line 29; used 1 times

- in line 230

addr defined in line 245; used 2 times

- in line 182-183(2)

again defined in line 78; used 2 times

- in line 83, 89

bno defined in line 247; used 5 times

- in line 132, 176, 189-190(2), 248

bootlen defined in line 239; used 1 times

- in line 82

bootnm defined in line 238; used 1 times

- in line 74

buf defined in line 246; used 9 times

- in line 107, 121-123(2), 139-142(2), 194-195(2), 229, 247

csr defined in line 241; used 4 times

- in line 51, 71, 163, 227

dno defined in line 248; used 6 times

- in line 101, 182-185(2), 194-197(2), 217

end defined in line 242; used 1 times

- in line 57

err defined in line 127; used 1 times

- in line 118

go defined in line 206; used 2 times

- in line 72, 231

iget defined in line 96; used 2 times

- in line 76, 92

inod defined in line 244; used 3 times

- in line 108, 245-246(2)

loadfile defined in line 131; used 1 times

- in line 93

rblk defined in line 215; used 4 times

- in line 103, 188, 196-198(2)

read defined in line 204; used 1 times

- in line 231

readdir defined in line 114; used 2 times

- in line 79, 125

restart defined in line 62; used 2 times

- in line 80, 165

rkba defined in line 210; used 1 times

- in line 229

rkcs defined in line 208; used 1 times

- in line 72

rkda defined in line 211; used 1 times

- in line 228

rkwc defined in line 209; used 1 times

- in line 230

rmblk defined in line 174; used 2 times

- in line 117, 137

start defined in line 49; used 1 times

- in line 48

unit defined in line 240; used 3 times

- in line 50, 159, 224

Last modified: 1995-06-01 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 749 |