source: mainline/boot/arch/mips32/src/asm.S@ 46757a6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 46757a6 was 4872160, checked in by Martin Decky <martin@…>, 15 years ago

new boot infrastructure

  • more code and metadata unification
  • import of up-to-date implementations from the kernel
  • the boot loaders should behave more similarly on all platforms
  • support for deflate compressed (LZ77) boot components
    • this again allows feasible boot images to be created on mips32
  • IA64 is still not booting
    • the broken forked GNU EFI library has been removed, a replacement of the functionality is on its way
  • Property mode set to 100644
File size: 3.8 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29#include <arch/arch.h>
30#include <arch/regname.h>
31
32.set noat
33.set noreorder
34.set nomacro
35
36.global start
37.global halt
38.global memcpy
39.global jump_to_kernel
40
41.section BOOTSTRAP
42
43start:
44 /* Setup CPU map (on msim this code
45 is executed in parallel on all CPUs,
46 but it not an issue) */
47 la $a0, PA2KA(CPUMAP_OFFSET)
48
49 sw $zero, 0($a0)
50 sw $zero, 4($a0)
51 sw $zero, 8($a0)
52 sw $zero, 12($a0)
53
54 sw $zero, 16($a0)
55 sw $zero, 20($a0)
56 sw $zero, 24($a0)
57 sw $zero, 28($a0)
58
59 sw $zero, 32($a0)
60 sw $zero, 36($a0)
61 sw $zero, 40($a0)
62 sw $zero, 44($a0)
63
64 sw $zero, 48($a0)
65 sw $zero, 52($a0)
66 sw $zero, 56($a0)
67 sw $zero, 60($a0)
68
69 sw $zero, 64($a0)
70 sw $zero, 68($a0)
71 sw $zero, 72($a0)
72 sw $zero, 76($a0)
73
74 sw $zero, 80($a0)
75 sw $zero, 84($a0)
76 sw $zero, 88($a0)
77 sw $zero, 92($a0)
78
79 sw $zero, 96($a0)
80 sw $zero, 100($a0)
81 sw $zero, 104($a0)
82 sw $zero, 108($a0)
83
84 sw $zero, 112($a0)
85 sw $zero, 116($a0)
86 sw $zero, 120($a0)
87 sw $zero, 124($a0)
88
89 lui $a1, 1
90
91#ifdef MACHINE_msim
92
93 /* Read dorder value */
94 la $k0, MSIM_DORDER_ADDRESS
95 lw $k1, ($k0)
96
97 /* If we are not running on BSP
98 then end in an infinite loop */
99 beq $k1, $zero, bsp
100 nop
101
102 /* Record CPU presence */
103 sll $a2, $k1, 2
104 addu $a2, $a2, $a0
105 sw $a1, ($a2)
106
107 loop:
108 j loop
109 nop
110
111#endif
112
113 bsp:
114 /* Record CPU presence */
115 sw $a1, ($a0)
116
117 /* Setup initial stack */
118 la $sp, PA2KA(STACK_OFFSET)
119
120 j bootstrap
121 nop
122
123.text
124
125halt:
126 j halt
127 nop
128
129memcpy:
130 addiu $v0, $a1, 3
131 li $v1, -4
132 and $v0, $v0, $v1
133 beq $a1, $v0, 3f
134 move $t0, $a0
135 move $t2, $a0
136
137 0:
138 beq $a2, $zero, 2f
139 move $a3, $zero
140
141 1:
142 addu $v0, $a1, $a3
143 lbu $a0, 0($v0)
144 addu $v1, $t0, $a3
145 addiu $a3, $a3, 1
146 bne $a3, $a2, 1b
147 sb $a0, 0($v1)
148
149 2:
150 jr $ra
151 move $v0, $t2
152
153 3:
154 addiu $v0, $a0, 3
155 and $v0, $v0, $v1
156 bne $a0, $v0, 0b
157 srl $t1, $a2, 2
158
159 beq $t1, $zero, 5f
160 move $a3, $zero
161
162 move $a3, $zero
163 move $a0, $zero
164
165 4:
166 addu $v0, $a1, $a0
167 lw $v1, 0($v0)
168 addiu $a3, $a3, 1
169 addu $v0, $t0, $a0
170 sw $v1, 0($v0)
171 bne $a3, $t1, 4b
172 addiu $a0, $a0, 4
173
174 5:
175 andi $a2, $a2, 0x3
176 beq $a2, $zero, 2b
177 nop
178
179 sll $v0, $a3, 2
180 addu $t1, $v0, $t0
181 move $a3, $zero
182 addu $t0, $v0, $a1
183
184 6:
185 addu $v0, $t0, $a3
186 lbu $a0, 0($v0)
187 addu $v1, $t1, $a3
188 addiu $a3, $a3, 1
189 bne $a3, $a2, 6b
190 sb $a0, 0($v1)
191
192 jr $ra
193 move $v0, $t2
194
195jump_to_kernel:
196 #
197 # TODO:
198 # Make sure that the I-cache, D-cache and memory are mutually coherent
199 # before passing control to the copied code.
200 #
201 j $a0
202 nop
Note: See TracBrowser for help on using the repository browser.