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