changes for pack labels; use cpp, now are *.c
[unix-history] / usr / src / sys / vax / mdec / hkboot.c
CommitLineData
b1078c35 1/*
0880b18e 2 * Copyright (c) 1980, 1986 Regents of the University of California.
b1078c35
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
70385c9b
MK
7/* @(#)hkboot.c 7.2 (Berkeley) %G% */
8#include <sys/disklabel.h>
a96c16a1
MK
9
10 .set MAJOR,3 /* major("/dev/hk0a") */
405a2f58
SL
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.
405a2f58
SL
15 */
16 .set RELOC,0x50000
17 .set BOOTSIZE,15 /* size of boot in sectors */
405a2f58
SL
18/* UBA registers */
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 */
405a2f58 22/* RK611 registers and bits */
a96c16a1
MK
23 .set HK_cs1,0 /* control and status */
24 .set HK_wc,2 /* word count */
25 .set HK_ba,4 /* bus address */
26 .set HK_da,6 /* disk address */
27 .set HK_cs2,8 /* control and status */
28 .set HK_dc,020 /* desired cylinder */
405a2f58
SL
29 .set HKBPSECT,512 /* bytes per sector */
30 .set HK_GO,1 /* go bit */
31 .set HK_PACK,2 /* pack acknowledge */
32 .set HK_RCOM,020 /* read command */
33 .set HK_SEL7,02000 /* select RK07 disk */
34 .set HK_pRDY,7 /* position of ready bit */
35 .set HK_pERR,15 /* position of error bit */
36
37init:
38/* r9 UBA address */
a96c16a1 39/* r8 HK addr */
405a2f58
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 */
42 nop;nop;
a96c16a1
MK
43 movl $MAJOR,r10 /* major("/dev/xx0a") */
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 */
70385c9b
MK
52 brw start0
53
54/*
55 * Leave space for pack label.
56 */
57pad:
58 .space LABELOFFSET - (pad - init)
59packlabel:
60 .space d_end_
61
62start0:
a96c16a1
MK
63 movl physUBA[r9],r9 /* UNIBUS adaptor address */
64 movl r2,r8 /* boot device CSR */
65 movl r3,r7 /* unit number */
66
67/* select unit, init rk611, set vv in drive; if any errors, give up */
68 movw r7,HK_cs2(r8)
69 movw $HK_SEL7+HK_GO,HK_cs1(r8)
405a2f58 701:
a96c16a1 71 movw HK_cs1(r8),r0
405a2f58
SL
72 bbc $HK_pRDY,r0,1b
73 bbs $HK_pERR,r0,9f
a96c16a1 74 movw $HK_SEL7+HK_PACK+HK_GO,HK_cs1(r8)
405a2f58 751:
a96c16a1 76 movw HK_cs1(r8),r0
405a2f58
SL
77 bbc $HK_pRDY,r0,1b
78 bbc $HK_pERR,r0,start
799:
80 halt
81/* relocate to high core */
82start:
83 movl r5,r11 /* boot flags */
84 movl $RELOC,sp
85 moval init,r6
86 movc3 $end,(r6),(sp)
87 jmp *$RELOC+start2
88/* now running relocated */
89/* bring in the boot program */
90 .set PROGSIZE,(BOOTSIZE*HKBPSECT)
91start2:
a96c16a1
MK
92 movw $0,HK_dc(r8)
93 movw $1,HK_da(r8)
94 movw $-PROGSIZE/2,HK_wc(r8)
405a2f58
SL
95 clrl r0
961:
70385c9b
MK
97/* bisl3 $0x80000000,r0,UBA_MAP(r9) */
98/* addl2 $4,r9 */
99/* aobleq $BOOTSIZE,r0,1b */
a96c16a1
MK
100 clrw HK_ba(r8)
101 movw $HK_SEL7+HK_RCOM+HK_GO,HK_cs1(r8)
405a2f58 102hkrdy:
a96c16a1 103 movw HK_cs1(r8),r0
405a2f58
SL
104 bbc $HK_pRDY,r0,hkrdy
105 bbs $HK_pERR,r0,hkerr
106 brw done
107hkerr:
108 halt /* ungraceful */
109done:
110 movl $PROGSIZE,r3
111clrcor:
112 clrq (r3)
113 acbl $RELOC,$8,r3,clrcor
114/* start loaded program */
405a2f58
SL
115 calls $0,*$0
116 brw start2
117physUBA:
a96c16a1
MK
118 .long 0xf30000 /* uba0 */
119 .long 0xf32000 /* uba1 */
405a2f58 120end: