xref: /netbsd/sys/arch/landisk/stand/boot/boot.S (revision 6550d01e)
1/*	$NetBSD: boot.S,v 1.1 2006/09/01 21:26:18 uwe Exp $	*/
2
3/*-
4 * Copyright (c) 2005 NONAKA Kimihiro
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <machine/asm.h>
30#include <sys/bootblock.h>
31
32ENTRY(boot_start)
33	bra	boot_start1
34	 nop
35	.balign 4
36ENTRY(boot_magic)
37	.long	LANDISK_BOOT_MAGIC_2
38ENTRY(boot_params)
39	.long	boot_start1 - boot_params
40#include <boot_params.S>
41
42	. = boot_start + 0x80
43boot_start1:
44	mov	r4, r0
45	add	#-4, r0
46	mov.l	@(0, r0), r0
47	mov.l	.L.boot_magic1, r1
48	cmp/eq	r0, r1
49	bf	2f
50	mov	r4, r0
51	mov.l	.L.boot_params_size, r3
52	mov.l	@r0, r2
53	mov.l	.L.boot_params, r1
54	cmp/hi	r3, r2
55	bf	1f
56	mov	r3, r2
571:	mov.b	@r0+, r3
58	mov.b	r3, @r1
59	dt	r2
60	bf/s	1b
61	 add	#1, r1
622:
63	mov.l	.L._end, r0		/* zero bss */
64	mov.l	.L.__bss_start, r1
65	sub	r1, r0
66	shlr2	r0			/* _end and __bss_start are aligned */
67	mov	#0, r2
681:	mov.l	r2, @r1
69	dt	r0
70	bf/s	1b
71	 add	#4, r1
72
73	mov.l	.L.boot2, r0
74	jsr	@r0
75	 mov	r5, r4
76
77boot_fail:
78	mov	r0, r1
79	mova	.L.errtxt, r0
80	mov	r0, r4
81	mov	#32, r0
82	trapa	#0x3f
83	mov	r1, r4
84	mov	#32, r0
85	trapa	#0x3f
86	mova	.L.crlf, r0
87	mov	r0, r4
88	mov	#32, r0
89	trapa	#0x3f
9099:	bra	99b
91	 nop
92
93
94ENTRY(halt)
95	mova	.L.pwrctl, r0
96	mov	#1, r1
97	mov.b	@r1, r0
98	rts
99	 nop
100
101ENTRY(reboot)
102ENTRY(_rtt)
103	mov	#1, r4			/* reboot */
104	mov	#11, r0
105	trapa	#0x3f
106	mov.l	.L.start, r0
107	jmp	@r0
108	 nop
109
110
111        .align  2
112.L.boot_magic1:
113	.long	LANDISK_BOOT_MAGIC_1
114.L.boot_params:
115	.long	boot_params
116.L.boot_params_size:
117	.long	boot_start1 - boot_params
118.L._end:
119	.long   _end
120.L.__bss_start:
121	.long   __bss_start
122.L.boot2:
123	.long   _C_LABEL(boot2)
124.L.start:
125	.long	0xc0000000
126.L.pwrctl:
127	.long	0xb0000003
128
129	.align	2
130.L.errtxt:	.asciz  "Boot2 failed: "
131	.align	2
132.L.crlf:	.asciz  "\r\n"
133