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