xref: /original-bsd/sys/vax/mdec/raboot.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 /* "@(#)raboot.c	7.2 (Berkeley) 08/28/86" */
8 #include <sys/disklabel.h>
9 
10 	.set	MAJOR,9			/* major("/dev/ra0a") */
11 
12 /*
13  * 1st level boot program: loads next 7.5Kbytes from
14  * boot sector of file system and sets it up to run.
15  * Except for MAJOR definition above, should work
16  * with any disk using 750 boot rom.
17  */
18 	.set	RELOC,0x50000
19 	.set	BOOTLAST,15		/* last boot sector */
20 	.set	RABPSECT,512		/* bytes per sector */
21 
22 init:
23 	.word	0  			/* entry mask for dec monitor */
24 	nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */
25 	nop;nop;
26 start:
27 	movl	$MAJOR,r10		/* major("/dev/xx0a") */
28 	extzv	$18,$1,r1,r4		/* get UBA number from R1 */
29 	xorb2	$0x01,r4		/* complement bit */
30 	insv	r4,$24,$8,r10		/* set UBA number */
31 	insv	r3,$16,$8,r10		/* drive number */
32 	extzv	$12,$4,r5,r4		/* get partition from r5 */
33 	bicw2	$0xf000,r5		/* remove from r5 */
34 	insv	r4,$8,$8,r10		/* set partition */
35 	movl	r5,r11			/* boot flags */
36 	movl	r1,r9			/* UNIBUS I/O page address */
37 	movl	r2,r8			/* boot device CSR */
38 	movl	r3,r7			/* unit number */
39 	brw	start0
40 
41 /*
42  * Leave space for pack label.
43  */
44 pad:
45 	.space	LABELOFFSET - (pad - init)
46 packlabel:
47 	.space	d_end_
48 
49 start0:
50 	movl	$RELOC,sp
51 	moval	init,r4
52 	movc3	$end,(r4),(sp)
53 	movl	r9,r1			/* UNIBUS I/O page address */
54 	movl	r8,r2			/* boot device CSR */
55 	movl	r7,r3			/* unit number */
56 	jmp	*$RELOC+start2
57 /* now running relocated */
58 /* bring in the boot program */
59 start2:					/* running relocated */
60 	pushr	$0xffff			/* BEGIN FIREWALL */
61 	movl	$1,r4			/* first boot sector */
62 	clrl	r5			/* transfer address */
63 	clrl	-(sp)			/* transfer address */
64 1:
65 	movl	r4,r8			/* requested sector # */
66 	jsb	(r6)			/* call ROM-based driver */
67 	blbs	r0,2f
68 	halt				/* read error */
69 2:
70 	addl2	$RABPSECT,r5		/* bump address */
71 	movl	r5,(sp)
72 	aobleq	$BOOTLAST,r4,1b
73 
74 	.set	PROGSIZE,(BOOTLAST*RABPSECT)
75 done:
76 	tstl	(sp)+			/* pop address */
77 	popr	$0xffff			/* END FIREWALL */
78 	movl	$PROGSIZE,r4
79 clrcor:
80 	clrq	(r4)
81 	acbl	$RELOC,$8,r4,clrcor
82 /* start loaded program */
83 	calls	$0,*$0
84 	brw	start2
85 end:
86