new template, cleanup; mostly from Chris Torek
[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
e86f39b7 7/* "@(#)rlboot.c 7.3 (Berkeley) %G%" */
70385c9b 8#include <sys/disklabel.h>
a96c16a1
MK
9
10 .set MAJOR,14 /* major("/dev/rl0a") */
2639612e
SL
11
12/*
2e6422fd
SL
13 * RL02 1st level boot program: loads next 7.5Kbytes from
14 * boot sector of file system and sets it up to run.
2639612e 15 */
2e6422fd 16 .set BOOTSIZE,15 /* 15 ``sectors'' */
2639612e 17 .set RELOC,0x50000
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 */
2639612e 22/* RL11 registers and bits */
2e6422fd
SL
23 .set HL,0174400-0160000 /* address of RL11 */
24 .set HLBPSECT,512 /* sector size in bytes (kludge) */
25 .set HL_cs,HL+0 /* control and status */
26 .set HL_ba,HL+2 /* bus address */
27 .set HL_da,HL+4 /* disk address */
28 .set HL_wc,HL+6 /* word count */
a96c16a1 29 .set HL_RDY,0200 /* READY */
2e6422fd
SL
30 .set HL_RCOM,014 /* read command */
31 .set HL_SEEK,06 /* seek */
32 .set HL_RESET,013 /* reset drive */
33 .set HL_GSTAT,04 /* get status command */
34 .set HL_pRDY,7 /* position of ready bit */
35 .set HL_pERR,15 /* position of error bit */
2639612e
SL
36
37init:
38/* r9 UBA address */
a96c16a1 39/* r8 RL addr */
2e6422fd
SL
40 .word 0 /* entry mask for dec monitor */
41 nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */
2639612e 42 nop;nop;
e86f39b7 43 cvtbl $MAJOR,r10 /* major("/dev/xx0a") */
a96c16a1
MK
44 extzv $18,$1,r1,r9 /* get UBA number from R1 */
45 xorb2 $0x01,r9 /* complement bit */
46 insv r9,$24,$8,r10 /* set UBA number */
47 insv r3,$16,$8,r10 /* drive number */
48 extzv $12,$4,r5,r4 /* get partition from r5 */
49 bicw2 $0xf000,r5 /* remove from r5 */
50 insv r4,$8,$8,r10 /* set partition */
51 movl r5,r11 /* boot flags */
e86f39b7
MK
52
53 movl r2,r8 /* boot device CSR */
70385c9b
MK
54 brw start0
55
56/*
57 * Leave space for pack label.
58 */
59pad:
60 .space LABELOFFSET - (pad - init)
61packlabel:
62 .space d_end_
63
64start0:
a96c16a1 65 movl physUBA[r9],r9 /* UNIBUS adaptor address */
e86f39b7 66 ashl $8,r3,r7 /* unit number, shifted for HL_cs */
a96c16a1
MK
67
68/* init rl11, and drive, don't check for any errors now */
69 movw $HL_RESET,HL_da(r8)
70 bisw3 r7,$HL_GSTAT,HL_cs(r8)
2639612e
SL
71/* relocate to high core */
72start:
2639612e
SL
73 movl $RELOC,sp
74 moval init,r6
75 movc3 $end,(r6),(sp)
76 jmp *$RELOC+start2
77/* now running relocated */
2e6422fd
SL
78/* read in the boot program */
79 .set PROGSIZE,(BOOTSIZE*HLBPSECT)
2639612e 80start2:
a96c16a1
MK
81 movw $1,HL_da(r8) /* seek to cylinder 0 */
82 bisw3 r7,$HL_SEEK,HL_cs(r8)
2639612e 831:
a96c16a1 84 movw HL_cs(r8),r0
2e6422fd
SL
85 bbc $HL_pRDY,r0,1b
86 bbs $HL_pERR,r0,hlerr
05ec64d7 87 /* Rl has 256 byte sectors */
a96c16a1
MK
88 movw $2,HL_da(r8) /* read program */
89 movw $-PROGSIZE/2,HL_wc(r8)
2e6422fd 90 clrl r0
2639612e 911:
2e6422fd
SL
92 bisl3 $0x80000000,r0,UBA_MAP(r9)
93 addl2 $4,r9
94 aobleq $BOOTSIZE,r0,1b
a96c16a1
MK
95 clrw HL_ba(r8)
96 bisw3 r7,$HL_RCOM,HL_cs(r8)
2639612e 971:
a96c16a1 98 movw HL_cs(r8),r0
2e6422fd 99 bbc $HL_pRDY,r0,1b
a96c16a1 100 bbc $HL_pERR,r0,done
2639612e 101hlerr:
2e6422fd
SL
102 halt /* ungraceful */
103done:
104 movl $PROGSIZE,r3
105clrcor:
106 clrq (r3)
107 acbl $RELOC,$8,r3,clrcor
108/* run loaded program */
2e6422fd
SL
109 calls $0,*$0
110 brw start2
2639612e 111physUBA:
a96c16a1
MK
112 .long 0xf30000 /* uba0 */
113 .long 0xf32000 /* uba1 */
2639612e 114end: