| 1 | /* |
| 2 | * Copyright (c) 1980 Regents of the University of California. |
| 3 | * All rights reserved. The Berkeley software License Agreement |
| 4 | * specifies the terms and conditions for redistribution. |
| 5 | */ |
| 6 | |
| 7 | #ifndef lint |
| 8 | _sccsid:.asciz "@(#)hkboot.c 6.2 (Berkeley) %G%" |
| 9 | #endif not lint |
| 10 | |
| 11 | |
| 12 | /* |
| 13 | * RK07 1st level boot program: loads next 7.5Kbytes from |
| 14 | * boot sector of file system and sets it up to run. |
| 15 | * Always reads from drive 0. |
| 16 | */ |
| 17 | .set RELOC,0x50000 |
| 18 | .set BOOTSIZE,15 /* size of boot in sectors */ |
| 19 | .set SID,62 /* system ID register */ |
| 20 | /* UBA registers */ |
| 21 | .set UBA_CNFGR,0 /* UBA configuration register */ |
| 22 | .set UBA_CR,4 /* UBA control register offset */ |
| 23 | .set UBA_MAP,0x800 /* UBA offset to map reg's */ |
| 24 | .set UBAinit,1 /* UBA init bit in UBA control reg */ |
| 25 | .set pUBIC,16 /* Unibus init complete */ |
| 26 | /* RK611 registers and bits */ |
| 27 | .set HK,0177440-0160000 /* address of RK611 */ |
| 28 | .set HK_cs1,HK+0 /* control and status */ |
| 29 | .set HK_wc,HK+2 /* word count */ |
| 30 | .set HK_ba,HK+4 /* bus address */ |
| 31 | .set HK_da,HK+6 /* disk address */ |
| 32 | .set HK_dc,HK+020 /* desired cylinder */ |
| 33 | .set HKBPSECT,512 /* bytes per sector */ |
| 34 | .set HK_GO,1 /* go bit */ |
| 35 | .set HK_PACK,2 /* pack acknowledge */ |
| 36 | .set HK_RCOM,020 /* read command */ |
| 37 | .set HK_SEL7,02000 /* select RK07 disk */ |
| 38 | .set HK_pRDY,7 /* position of ready bit */ |
| 39 | .set HK_pERR,15 /* position of error bit */ |
| 40 | |
| 41 | init: |
| 42 | /* r9 UBA address */ |
| 43 | /* r10 umem addr */ |
| 44 | .word 0 /* entry mask for dec monitor */ |
| 45 | nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */ |
| 46 | nop;nop; |
| 47 | /* get cpu type and find the first uba */ |
| 48 | mfpr $SID,r0 |
| 49 | extzv $24,$8,r0,r0 /* get cpu type */ |
| 50 | ashl $2,r0,r1 |
| 51 | movab physUBA,r2 /* get physUBA[cpu] */ |
| 52 | addl2 r1,r2 |
| 53 | movl (r2),r9 |
| 54 | movab physUMEM,r2 /* get physUMEM[cpu] */ |
| 55 | addl2 r1,r2 |
| 56 | movl (r2),r10 |
| 57 | /* if 780, init uba */ |
| 58 | cmpl r0,$1 |
| 59 | bneq 2f |
| 60 | movl $UBAinit,UBA_CR(r9) |
| 61 | 1: |
| 62 | bbc $pUBIC,UBA_CNFGR(r9),1b |
| 63 | 2: |
| 64 | /* init rk611, set vv in drive 0; if any errors, give up */ |
| 65 | movw $HK_SEL7+HK_GO,HK_cs1(r10) |
| 66 | 1: |
| 67 | movw HK_cs1(r10),r0 |
| 68 | bbc $HK_pRDY,r0,1b |
| 69 | bbs $HK_pERR,r0,9f |
| 70 | movw $HK_SEL7+HK_PACK+HK_GO,HK_cs1(r10) |
| 71 | 1: |
| 72 | movw HK_cs1(r10),r0 |
| 73 | bbc $HK_pRDY,r0,1b |
| 74 | bbc $HK_pERR,r0,start |
| 75 | 9: |
| 76 | halt |
| 77 | /* relocate to high core */ |
| 78 | start: |
| 79 | movl r5,r11 /* boot flags */ |
| 80 | movl $RELOC,sp |
| 81 | moval init,r6 |
| 82 | movc3 $end,(r6),(sp) |
| 83 | jmp *$RELOC+start2 |
| 84 | /* now running relocated */ |
| 85 | /* bring in the boot program */ |
| 86 | .set PROGSIZE,(BOOTSIZE*HKBPSECT) |
| 87 | start2: |
| 88 | movw $0,HK_dc(r10) |
| 89 | movw $1,HK_da(r10) |
| 90 | movw $-PROGSIZE/2,HK_wc(r10) |
| 91 | clrl r0 |
| 92 | 1: |
| 93 | bisl3 $0x80000000,r0,UBA_MAP(r9) |
| 94 | addl2 $4,r9 |
| 95 | aobleq $BOOTSIZE,r0,1b |
| 96 | clrw HK_ba(r10) |
| 97 | movw $HK_SEL7+HK_RCOM+HK_GO,HK_cs1(r10) |
| 98 | hkrdy: |
| 99 | movw HK_cs1(r10),r0 |
| 100 | bbc $HK_pRDY,r0,hkrdy |
| 101 | bbs $HK_pERR,r0,hkerr |
| 102 | brw done |
| 103 | hkerr: |
| 104 | halt /* ungraceful */ |
| 105 | done: |
| 106 | movl $PROGSIZE,r3 |
| 107 | clrcor: |
| 108 | clrq (r3) |
| 109 | acbl $RELOC,$8,r3,clrcor |
| 110 | /* start loaded program */ |
| 111 | movl $3,r10 /* major("/dev/hk0a") */ |
| 112 | calls $0,*$0 |
| 113 | brw start2 |
| 114 | physUBA: |
| 115 | .long 0 |
| 116 | .long 0x20006000 /* 11/780 */ |
| 117 | .long 0xf30000 /* 11/750 */ |
| 118 | .long 0xf26000 /* 11/730 */ |
| 119 | physUMEM: |
| 120 | .long 0 |
| 121 | .long 0x2013e000 /* 11/780 */ |
| 122 | .long 0xffe000 /* 11/750 */ |
| 123 | .long 0xffe000 /* 11/730 */ |
| 124 | end: |