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