xref: /original-bsd/sys/vax/mdec/rlboot.c (revision 8f26171a)
1 /*
2  * Copyright (c) 1980, 1986 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 /* "@(#)rlboot.c	7.2 (Berkeley) 08/28/86" */
8 #include <sys/disklabel.h>
9 
10 	.set	MAJOR,14		/* major("/dev/rl0a") */
11 
12 /*
13  * RL02 1st level boot program: loads next 7.5Kbytes from
14  * boot sector of file system and sets it up to run.
15  */
16 	.set	BOOTSIZE,15		/* 15 ``sectors'' */
17         .set    RELOC,0x50000
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 */
22 /* RL11 registers and bits */
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 */
29         .set    HL_RDY,0200		/* READY  */
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 */
36 
37 init:
38 /* r9   UBA address */
39 /* r8	RL addr */
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;
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 */
52 	brw	start0
53 
54 /*
55  * Leave space for pack label.
56  */
57 pad:
58 	.space	LABELOFFSET - (pad - init)
59 packlabel:
60 	.space	d_end_
61 
62 start0:
63 	movl	physUBA[r9],r9		/* UNIBUS adaptor address */
64 	movl	r2,r8			/* boot device CSR */
65 	movl	r3,r7			/* unit number */
66 	ashl	$8,r7,r7		/* shifted for HL_cs */
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)
71 /* relocate to high core */
72 start:
73         movl    r5,r11			/* save boot flags */
74         movl    $RELOC,sp
75         moval   init,r6
76         movc3   $end,(r6),(sp)
77         jmp     *$RELOC+start2
78 /* now running relocated */
79 /* read in the boot program */
80 	.set	PROGSIZE,(BOOTSIZE*HLBPSECT)
81 start2:
82 	movw	$1,HL_da(r8)			/* seek to cylinder 0 */
83 	bisw3	r7,$HL_SEEK,HL_cs(r8)
84 1:
85         movw    HL_cs(r8),r0
86         bbc     $HL_pRDY,r0,1b
87         bbs     $HL_pERR,r0,hlerr
88 	/* Rl has 256 byte sectors */
89 	movw	$2,HL_da(r8)			/* read program */
90 	movw	$-PROGSIZE/2,HL_wc(r8)
91 	clrl	r0
92 1:
93 	bisl3	$0x80000000,r0,UBA_MAP(r9)
94 	addl2	$4,r9
95 	aobleq	$BOOTSIZE,r0,1b
96 	clrw	HL_ba(r8)
97 	bisw3	r7,$HL_RCOM,HL_cs(r8)
98 1:
99         movw    HL_cs(r8),r0
100         bbc     $HL_pRDY,r0,1b
101         bbc     $HL_pERR,r0,done
102 hlerr:
103         halt				/* ungraceful */
104 done:
105         movl    $PROGSIZE,r3
106 clrcor:
107         clrq    (r3)
108         acbl    $RELOC,$8,r3,clrcor
109 /* run loaded program */
110         calls   $0,*$0
111         brw     start2
112 physUBA:
113 	.long	0xf30000		/* uba0 */
114 	.long	0xf32000		/* uba1 */
115 end:
116