generalize uba code to handle Q bus more gracefully
[unix-history] / usr / src / sys / vax / mdec / rlboot.c
CommitLineData
cb1c44c2 1/*
0880b18e 2 * Copyright (c) 1980, 1986 Regents of the University of California.
cb1c44c2
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
0880b18e 7/* "@(#)rlboot.c 7.1 (Berkeley) %G%" */
a96c16a1
MK
8
9 .set MAJOR,14 /* major("/dev/rl0a") */
2639612e
SL
10
11/*
2e6422fd
SL
12 * RL02 1st level boot program: loads next 7.5Kbytes from
13 * boot sector of file system and sets it up to run.
2639612e 14 */
2e6422fd 15 .set BOOTSIZE,15 /* 15 ``sectors'' */
2639612e 16 .set RELOC,0x50000
2639612e 17/* UBA registers */
2e6422fd
SL
18 .set UBA_CNFGR,0 /* UBA configuration register */
19 .set UBA_CR,4 /* UBA control register offset */
20 .set UBA_MAP,0x800 /* UBA offset to map reg's */
2639612e 21/* RL11 registers and bits */
2e6422fd
SL
22 .set HL,0174400-0160000 /* address of RL11 */
23 .set HLBPSECT,512 /* sector size in bytes (kludge) */
24 .set HL_cs,HL+0 /* control and status */
25 .set HL_ba,HL+2 /* bus address */
26 .set HL_da,HL+4 /* disk address */
27 .set HL_wc,HL+6 /* word count */
a96c16a1 28 .set HL_RDY,0200 /* READY */
2e6422fd
SL
29 .set HL_RCOM,014 /* read command */
30 .set HL_SEEK,06 /* seek */
31 .set HL_RESET,013 /* reset drive */
32 .set HL_GSTAT,04 /* get status command */
33 .set HL_pRDY,7 /* position of ready bit */
34 .set HL_pERR,15 /* position of error bit */
2639612e
SL
35
36init:
37/* r9 UBA address */
a96c16a1 38/* r8 RL addr */
2e6422fd
SL
39 .word 0 /* entry mask for dec monitor */
40 nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */
2639612e 41 nop;nop;
a96c16a1
MK
42 movl $MAJOR,r10 /* major("/dev/xx0a") */
43 extzv $18,$1,r1,r9 /* get UBA number from R1 */
44 xorb2 $0x01,r9 /* complement bit */
45 insv r9,$24,$8,r10 /* set UBA number */
46 insv r3,$16,$8,r10 /* drive number */
47 extzv $12,$4,r5,r4 /* get partition from r5 */
48 bicw2 $0xf000,r5 /* remove from r5 */
49 insv r4,$8,$8,r10 /* set partition */
50 movl r5,r11 /* boot flags */
51 movl physUBA[r9],r9 /* UNIBUS adaptor address */
52 movl r2,r8 /* boot device CSR */
53 movl r3,r7 /* unit number */
54 ashl $8,r7,r7 /* shifted for HL_cs */
55
56/* init rl11, and drive, don't check for any errors now */
57 movw $HL_RESET,HL_da(r8)
58 bisw3 r7,$HL_GSTAT,HL_cs(r8)
2639612e
SL
59/* relocate to high core */
60start:
2e6422fd 61 movl r5,r11 /* save boot flags */
2639612e
SL
62 movl $RELOC,sp
63 moval init,r6
64 movc3 $end,(r6),(sp)
65 jmp *$RELOC+start2
66/* now running relocated */
2e6422fd
SL
67/* read in the boot program */
68 .set PROGSIZE,(BOOTSIZE*HLBPSECT)
2639612e 69start2:
a96c16a1
MK
70 movw $1,HL_da(r8) /* seek to cylinder 0 */
71 bisw3 r7,$HL_SEEK,HL_cs(r8)
2639612e 721:
a96c16a1 73 movw HL_cs(r8),r0
2e6422fd
SL
74 bbc $HL_pRDY,r0,1b
75 bbs $HL_pERR,r0,hlerr
05ec64d7 76 /* Rl has 256 byte sectors */
a96c16a1
MK
77 movw $2,HL_da(r8) /* read program */
78 movw $-PROGSIZE/2,HL_wc(r8)
2e6422fd 79 clrl r0
2639612e 801:
2e6422fd
SL
81 bisl3 $0x80000000,r0,UBA_MAP(r9)
82 addl2 $4,r9
83 aobleq $BOOTSIZE,r0,1b
a96c16a1
MK
84 clrw HL_ba(r8)
85 bisw3 r7,$HL_RCOM,HL_cs(r8)
2639612e 861:
a96c16a1 87 movw HL_cs(r8),r0
2e6422fd 88 bbc $HL_pRDY,r0,1b
a96c16a1 89 bbc $HL_pERR,r0,done
2639612e 90hlerr:
2e6422fd
SL
91 halt /* ungraceful */
92done:
93 movl $PROGSIZE,r3
94clrcor:
95 clrq (r3)
96 acbl $RELOC,$8,r3,clrcor
97/* run loaded program */
2e6422fd
SL
98 calls $0,*$0
99 brw start2
2639612e 100physUBA:
a96c16a1
MK
101 .long 0xf30000 /* uba0 */
102 .long 0xf32000 /* uba1 */
2639612e 103end: