Commit | Line | Data |
---|---|---|
cb1c44c2 KM |
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 | ||
c7a945fd | 7 | /* "@(#)rlboot.c 6.3 (Berkeley) %G%" */ |
2639612e SL |
8 | |
9 | /* | |
2e6422fd SL |
10 | * RL02 1st level boot program: loads next 7.5Kbytes from |
11 | * boot sector of file system and sets it up to run. | |
12 | * Always reads from drive 0. | |
13 | * UNTESTED | |
2639612e | 14 | */ |
2e6422fd | 15 | .set BOOTSIZE,15 /* 15 ``sectors'' */ |
2639612e | 16 | .set RELOC,0x50000 |
2e6422fd | 17 | .set SID,62 /* system ID register */ |
2639612e | 18 | /* UBA registers */ |
2e6422fd SL |
19 | .set UBA_CNFGR,0 /* UBA configuration register */ |
20 | .set UBA_CR,4 /* UBA control register offset */ | |
21 | .set UBA_MAP,0x800 /* UBA offset to map reg's */ | |
22 | .set UBAinit,1 /* UBA init bit in UBA control reg */ | |
23 | .set pUBIC,16 /* Unibus init complete */ | |
2639612e | 24 | /* RL11 registers and bits */ |
2e6422fd SL |
25 | .set HL,0174400-0160000 /* address of RL11 */ |
26 | .set HLBPSECT,512 /* sector size in bytes (kludge) */ | |
27 | .set HL_cs,HL+0 /* control and status */ | |
28 | .set HL_ba,HL+2 /* bus address */ | |
29 | .set HL_da,HL+4 /* disk address */ | |
30 | .set HL_wc,HL+6 /* word count */ | |
31 | .set HL_GO,0 /* go bit */ | |
32 | .set HL_RCOM,014 /* read command */ | |
33 | .set HL_SEEK,06 /* seek */ | |
34 | .set HL_RESET,013 /* reset drive */ | |
35 | .set HL_GSTAT,04 /* get status command */ | |
36 | .set HL_pRDY,7 /* position of ready bit */ | |
37 | .set HL_pERR,15 /* position of error bit */ | |
2639612e SL |
38 | |
39 | init: | |
40 | /* r9 UBA address */ | |
41 | /* r10 umem addr */ | |
2e6422fd SL |
42 | .word 0 /* entry mask for dec monitor */ |
43 | nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */ | |
2639612e SL |
44 | nop;nop; |
45 | /* get cpu type and find the first uba */ | |
46 | mfpr $SID,r0 | |
2e6422fd | 47 | extzv $24,$8,r0,r0 /* get cpu type */ |
2639612e | 48 | ashl $2,r0,r1 |
2e6422fd | 49 | movab physUBA,r2 /* get physUBA[cpu] */ |
2639612e SL |
50 | addl2 r1,r2 |
51 | movl (r2),r9 | |
2e6422fd | 52 | movab physUMEM,r2 /* get physUMEM[cpu] */ |
2639612e SL |
53 | addl2 r1,r2 |
54 | movl (r2),r10 | |
55 | /* if 780, init uba */ | |
56 | cmpl r0,$1 | |
57 | bneq 2f | |
58 | movl $UBAinit,UBA_CR(r9) | |
59 | 1: | |
60 | bbc $pUBIC,UBA_CNFGR(r9),1b | |
61 | 2: | |
62 | /* init rl11, and drive 0, don't check for any errors now */ | |
63 | movw $HL_RESET,HL_da(r10) | |
64 | movw $HL_GSTAT+HL_GO,HL_cs(r10) | |
2639612e SL |
65 | /* relocate to high core */ |
66 | start: | |
2e6422fd | 67 | movl r5,r11 /* save boot flags */ |
2639612e SL |
68 | movl $RELOC,sp |
69 | moval init,r6 | |
70 | movc3 $end,(r6),(sp) | |
71 | jmp *$RELOC+start2 | |
72 | /* now running relocated */ | |
2e6422fd SL |
73 | /* read in the boot program */ |
74 | .set PROGSIZE,(BOOTSIZE*HLBPSECT) | |
2639612e | 75 | start2: |
05ec64d7 SL |
76 | movw $1,HL_da(r10) /* seek to cylinder 0 */ |
77 | movw $HL_SEEK+HL_GO,HL_cs(r10) | |
2639612e | 78 | 1: |
2e6422fd SL |
79 | movw HL_cs(r10),r0 |
80 | bbc $HL_pRDY,r0,1b | |
81 | bbs $HL_pERR,r0,hlerr | |
05ec64d7 SL |
82 | /* Rl has 256 byte sectors */ |
83 | movw $2,HL_da(r10) /* read program */ | |
2e6422fd SL |
84 | movw $-PROGSIZE/2,HL_wc(r10) |
85 | clrl r0 | |
2639612e | 86 | 1: |
2e6422fd SL |
87 | bisl3 $0x80000000,r0,UBA_MAP(r9) |
88 | addl2 $4,r9 | |
89 | aobleq $BOOTSIZE,r0,1b | |
90 | clrw HL_ba(r10) | |
91 | movw $HL_RCOM+HL_GO,HL_cs(r10) | |
2639612e | 92 | 1: |
2639612e | 93 | movw HL_cs(r10),r0 |
2e6422fd | 94 | bbc $HL_pRDY,r0,1b |
2639612e | 95 | bbs $HL_pERR,r0,hlerr |
05ec64d7 | 96 | brw done |
2639612e | 97 | hlerr: |
2e6422fd SL |
98 | halt /* ungraceful */ |
99 | done: | |
100 | movl $PROGSIZE,r3 | |
101 | clrcor: | |
102 | clrq (r3) | |
103 | acbl $RELOC,$8,r3,clrcor | |
104 | /* run loaded program */ | |
05ec64d7 | 105 | movl $14,r10 /* major("/dev/hl0a") */ |
2e6422fd SL |
106 | calls $0,*$0 |
107 | brw start2 | |
2639612e SL |
108 | physUBA: |
109 | .long 0 | |
2e6422fd SL |
110 | .long 0x20006000 /* 11/780 */ |
111 | .long 0xf30000 /* 11/750 */ | |
112 | .long 0xf26000 /* 11/730 */ | |
2639612e SL |
113 | physUMEM: |
114 | .long 0 | |
2e6422fd SL |
115 | .long 0x2013e000 /* 11/780 */ |
116 | .long 0xffe000 /* 11/750 */ | |
117 | .long 0xffe000 /* 11/730 */ | |
2639612e | 118 | end: |