2 * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <timestamp.h>
29 #if !defined(CONFIG_IDENT_STRING)
30 #define CONFIG_IDENT_STRING ""
33 #define STATUS_INIT 0x8600 /* IE=1, IPRI=2 */
35 /*************************************************************************
37 ************************************************************************/
47 /* GERMS -- The "standard-32" configuration GERMS monitor looks
48 * for the string "Nios" at flash_base + 0xc (actually it only
49 * tests for 'N', 'i'). You can leave support for this in place
50 * as it's only a few words.
58 * Early setup -- set cwp = HI_LIMIT, IPRI = 2, IE = 1 to
59 * enable underflow exceptions. Disable cache.
60 * NOTE: %o7 has return addr -- save in %g7 use later.
68 or %g0, %lo(STATUS_INIT)
69 wrctl %g0 /* update status */
75 pfx %hi(CONFIG_SYS_INIT_SP)
76 movi %sp, %lo(CONFIG_SYS_INIT_SP)
77 pfx %xhi(CONFIG_SYS_INIT_SP)
78 movhi %sp, %xlo(CONFIG_SYS_INIT_SP)
82 subi %sp, %lo(4*16) /* Space for reg window mgmt */
85 * RELOCATE -- %g7 has return addr from bsr at _start.
87 pfx %hi(__u_boot_cmd_end)
88 movi %g5, %lo(__u_boot_cmd_end)
89 pfx %xhi(__u_boot_cmd_end)
90 movhi %g5, %xlo(__u_boot_cmd_end) /* %g5 <- end address */
92 lsli %g7, 1 /* mem = retaddr << 1 */
94 subi %g6, 4 /* %g6 <- src addr */
95 ld %g7, [%g7] /* %g7 <- dst addr */
97 /* No need to move text sections if we're already located
98 * at the proper address.
111 addi %g6, 4 /* src++ */
113 addi %g7, 4 /* dst++ */
119 * Jump to relocation address
122 movi %g0, %lo(reloc@h)
124 movhi %g0, %xlo(reloc@h)
133 movi %g5, %lo(__bss_end)
135 movhi %g5, %xlo(__bss_end) /* %g5 <- end address */
137 movi %g7, %lo(__bss_start)
138 pfx %xhi(__bss_start)
139 movhi %g7, %xlo(__bss_start) /* %g7 <- end address */
148 addi %g7, 4 /* (delay slot) dst++ */
156 pfx %hi(CONFIG_SYS_VECT_BASE)
157 movi %g0, %lo(CONFIG_SYS_VECT_BASE)
158 pfx %xhi(CONFIG_SYS_VECT_BASE)
159 movhi %g0, %xlo(CONFIG_SYS_VECT_BASE) /* dst */
163 movi %g1, %lo(_vectors)
165 movhi %g1, %xlo(_vectors) /* src */
166 bgen %g2, 6 /* cnt = 64 */
168 ldp %g3, [%l0, 3] /* bkpt vector */
169 ldp %g4, [%l0, 4] /* single step vector */
172 addi %g1, 4 /* src++ */
174 addi %g0, 4 /* dst++ */
176 subi %g2, 1 /* cnt-- */
181 #if defined(CONFIG_ROM_STUBS)
182 /* Restore the breakpoint and single step exception
183 * vectors to their original values.
185 stp [%l0,3], %g3 /* breakpoint */
186 stp [%l0,4], %g4 /* single step */
189 /* For debug startup convenience ... software breakpoints
190 * set prior to this point may not succeed ;-)
196 * Call board_init -- never returns
198 pfx %hi(board_init@h)
199 movi %g1, %lo(board_init@h)
200 pfx %xhi(board_init@h)
201 movhi %g1, %xlo(board_init@h)
203 nop /* Delaly slot */
207 * dly_clks -- Nios doesn't have a time/clk reference for simple
208 * delay loops, so we do our best by counting instruction cycles.
209 * A control register that counts system clock cycles would be
210 * a handy feature -- hint for Altera ;-)
213 /* Each loop is 4 instructions as delay slot is always
214 * executed. Each instruction is approximately 4 clocks
215 * (according to some lame info from Altera). So ...
216 * ... each loop is about 16 clocks.
220 lsri %o0, 4 /* cnt/16 */
224 subi %o0, 1 /* cnt--, Delay slot */
233 .globl version_string
236 .ascii U_BOOT_VERSION
237 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
238 .ascii CONFIG_IDENT_STRING, "\0"