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

       1: MAJOR = 11.                     / major # from bdevsw[]
       2:
       3: / BR bootstrap. supports the 32 sec/trk, 19 trk/cyl EATON 1537/1711
       4: /	Controller and 1538A/B/C/D drive.
       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:         clr     r0              / XXX - for Rome 11/70, boot card doesn't work
      52:         mov     $176714,r1      / XXX - for Rome 11/70, boot card doesn't work
      53:         movb    r0,unit+1       / save the unit in high byte (for brcs)
      54:         mov     r1,csr          /  and csr from the ROMs (not base addr!)
      55:         mov     $..,sp
      56:         mov     sp,r1
      57:         clr     r0
      58: 1:
      59:         mov     (r0)+,(r1)+
      60:         cmp     r1,$end
      61:         blo     1b
      62:         jmp     *$2f
      63:
      64: / On error, restart from here.
      65: restart:
      66:         clr     r0
      67: / clear core to make things clean
      68: 2:
      69:         clr     (r0)+
      70:         cmp     r0,sp
      71:         blo     2b
      72:
      73: / initialize controller
      74:         mov     csr,r1
      75:         mov     unit,brcs(r1)           / clr addr extension bits, select unit
      76:         mov     $32.,r0                 / default # of sec/track
      77:         bit     $2400,brae(r1)          / is this a 22 sec/track drive
      78:         beq     9f
      79:         mov     $22.,r0
      80: 9:
      81:         mov     $19.,r5                 / default # of tracks/cyl
      82:         bit     $1400,brae(r1)          / is this a 5 tr/cy drive?
      83:         beq     9f                      / no - br
      84:         mov     $5,r5
      85: 9:
      86:         mov     r0,sectors
      87:         mul     r0,r5                   / sectors/cyl
      88:         mov     r5,seccyl
      89:
      90:         mov     $bootnm, r1
      91:         mov     $2,r0                   / ROOTINO
      92:         jsr     pc,iget
      93:         clr     r2                      / offset
      94: again:
      95:         jsr     pc,readdir
      96:         beq     restart                 / error - restart
      97:         mov     4(r0),r4                / dp->d_namlen
      98:         cmp     r4,$bootlen             / if (bootlen == dp->d_namlen)
      99:         bne     again                   /    nope, go try next entry
     100:         mov     r0,r3
     101:         add     $6,r3                   / r3 = dp->d_name
     102:         mov     r1,r5                   / r5 = filename
     103: 9:
     104:         cmpb    (r3)+,(r5)+
     105:         bne     again                   / no match - go read next entry
     106:         sob     r4,9b
     107:         mov     (r0),r0                 / r0 = dp->d_ino
     108:         jsr     pc,iget                 / fetch boot's inode
     109:         br      loadfile                / 'boot'- go read it
     110:
     111: / get the inode specified in r0
     112: iget:
     113:         add     $INOFF,r0
     114:         mov     r0,r5
     115:         ash     $PBSHFT,r0
     116:         bic     $!7777,r0
     117:         mov     r0,dno
     118:         clr     r0
     119:         jsr     pc,rblk
     120:         bic     $!17,r5
     121:         mov     $INOSIZ,r0
     122:         mul     r0,r5
     123:         add     $buf,r5
     124:         mov     $inod,r4
     125: 1:
     126:         movb    (r5)+,(r4)+
     127:         sob     r0,1b
     128:         rts     pc
     129:
     130: readdir:
     131:         bit     $BSIZE-1,r2
     132:         bne     1f
     133:         jsr     pc,rmblk                / read mapped block (bno)
     134:                 br err                  / end of file branch
     135:         clr     r2                      / start at beginning of buf
     136: 1:
     137:         mov     $buf,r0
     138:         add     r2,r0                   / dp = buf+offset
     139:         add     buf+2(r2),r2            / dp += dp->d_reclen
     140:         tst     (r0)                    / dp->d_ino == 0?
     141:         beq     readdir                 / yes - go look at next
     142:         rts     pc                      / return with r0 = &dp->d_ino
     143: err:
     144:         clr     r0                      / return with
     145:         rts     pc                      / dp = NULL
     146:
     147: loadfile:
     148:         clr     bno                     / start at block 0 of inode in 'inod'
     149: / read file into core until
     150: / a mapping error, (no disk address)
     151:         clr     r1
     152: 1:
     153:         jsr     pc,rmblk
     154:                 br 1f
     155:         mov     $buf,r2
     156: 2:
     157:         mov     (r2)+,(r1)+
     158:         cmp     r2,$buf+BSIZE
     159:         blo     2b
     160:         br      1b
     161: / relocate core around
     162: / assembler header
     163: 1:
     164:         clr     r0
     165:         cmp     (r0),$407
     166:         bne     2f
     167: 1:
     168:         mov     20(r0),(r0)+
     169:         cmp     r0,sp
     170:         blo     1b
     171: / enter program and
     172: / restart if return
     173: 2:
     174:         mov     ENDCORE-BOOTOPTS, r4
     175:         movb    unit+1,r3
     176:         ash     $3,r3                   / unit # in bits 3-5, partition # is 0
     177:         bis     $MAJOR\<8.,r3
     178:         mov     ENDCORE-CHECKWORD, r2
     179:         mov     csr,r1
     180:         jsr     pc,*$0
     181:         jmp     restart
     182:
     183: / read a mapped block
     184: / offset in file is in bno.
     185: / skip if success, no skip if fail
     186: / the algorithm only handles a single
     187: / indirect block. that means that
     188: / files longer than NDIRIN+256 blocks (260kb) cannot
     189: / be loaded.
     190: rmblk:
     191:         add     $2,(sp)
     192:         mov     bno,r0
     193:         cmp     r0,$NDIRIN
     194:         blt     1f
     195:         mov     $NDIRIN,r0
     196: 1:
     197:         ash     $2,r0
     198:         mov     addr+2(r0),dno
     199:         mov     addr(r0),r0
     200:         bne     1f
     201:         tst     dno
     202:         beq     2f
     203: 1:
     204:         jsr     pc,rblk
     205:         mov     bno,r0
     206:         inc     bno
     207:         sub     $NDIRIN,r0
     208:         blt     1f
     209:         ash     $2,r0
     210:         mov     buf+2(r0),dno
     211:         mov     buf(r0),r0
     212:         bne     rblk
     213:         tst     dno
     214:         bne     rblk
     215: 2:
     216:         sub     $2,(sp)
     217: 1:
     218:         rts     pc
     219:
     220: read    = 4
     221: go      = 1
     222:
     223: brds    = -4
     224: brer    = -2
     225: brcs    = 0             / offset from base csr passed by ROMs
     226: brwc    = 2
     227: brba    = 4
     228: brca    = 6
     229: brda    = 10
     230: brae    = 12
     231: / br 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     seccyl,r0
     241:         mov     csr,r3
     242:         mov     r0,brca(r3)
     243:         clr     r0
     244:         div     sectors,r0
     245:         swab    r0
     246:         bis     r1,r0
     247:         mov     r0,brda(r3)
     248:         mov     $buf,brba(r3)
     249:         mov     $WC,brwc(r3)
     250:         mov     unit,r0
     251:         bis     $read+go,r0
     252:         mov     r0,(r3)         / brcs
     253: 1:
     254:         tstb    (r3)            / brcs
     255:         bge     1b
     256:         mov     (sp)+,r1
     257:         rts     pc
     258:
     259: bootnm: <boot\0\0>
     260: bootlen = 4             / strlen(bootnm)
     261: unit: 0
     262: csr: 0
     263: seccyl: 0
     264: sectors: 0
     265: end:
     266:
     267: inod = ..-512.-BSIZE            / room for inod, buf, stack
     268: addr = inod+ADDROFF             / first address in inod
     269: buf = inod+INOSIZ
     270: bno = buf+BSIZE
     271: dno = bno+2

#### Defined functions

ADDROFF defined in line 26; used 1 times

- in line 268

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

- in line 174

BSIZE defined in line 23; used 5 times

- in line 27, 131, 158, 267-270(2)

CHECKWORD defined in line 38; used 1 times

- in line 178

CLSHFT defined in line 22; used 1 times

- in line 238

CLSIZE defined in line 21; used 3 times

- in line 23, 30, 237

ENDCORE defined in line 34; used 3 times

- in line 40, 174-178(2)

INOFF defined in line 28; used 1 times

- in line 113

INOPB defined in line 27; never used
INOSIZ defined in line 24; used 3 times

- in line 27, 121, 269

MAJOR defined in line 1; used 1 times

- in line 177

NDIRIN defined in line 25; used 3 times

- in line 193-195(2), 207

PBSHFT defined in line 29; used 1 times

- in line 115

SZFLAGS defined in line 35; used 1 times

- in line 40

WC defined in line 30; used 1 times

- in line 249

addr defined in line 268; used 2 times

- in line 198-199(2)

again defined in line 94; used 2 times

- in line 99, 105

bno defined in line 270; used 5 times

- in line 148, 192, 205-206(2), 271

bootlen defined in line 260; used 1 times

- in line 98

bootnm defined in line 259; used 1 times

- in line 90

brae defined in line 230; used 2 times

- in line 77-82(2)

brba defined in line 227; used 1 times

- in line 248

brca defined in line 228; used 1 times

- in line 242

brcs defined in line 225; used 1 times

- in line 75

brda defined in line 229; used 1 times

- in line 247

brds defined in line 223; never used
brer defined in line 224; never used
brwc defined in line 226; used 1 times

- in line 249

buf defined in line 269; used 9 times

- in line 123, 137-139(2), 155-158(2), 210-211(2), 248, 270

csr defined in line 262; used 4 times

- in line 54, 74, 179, 241

dno defined in line 271; used 6 times

- in line 117, 198-201(2), 210-213(2), 236

end defined in line 265; used 1 times

- in line 60

err defined in line 143; used 1 times

- in line 134

go defined in line 221; used 1 times

- in line 251

iget defined in line 112; used 2 times

- in line 92, 108

inod defined in line 267; used 3 times

- in line 124, 268-269(2)

loadfile defined in line 147; used 1 times

- in line 109

rblk defined in line 234; used 4 times

- in line 119, 204, 212-214(2)

read defined in line 220; used 1 times

- in line 251

readdir defined in line 130; used 2 times

- in line 95, 141

restart defined in line 65; used 2 times

- in line 96, 181

rmblk defined in line 190; used 2 times

- in line 133, 153

seccyl defined in line 263; used 2 times

- in line 88, 240

sectors defined in line 264; used 2 times

- in line 86, 244

start defined in line 50; used 1 times

- in line 49

unit defined in line 261; used 4 times

- in line 53, 75, 175, 250

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