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,
28 #if !defined(CONFIG_IDENT_STRING)
29 #define CONFIG_IDENT_STRING ""
32 #define STATUS_INIT 0x8600 /* IE=1, IPRI=2 */
34 /*************************************************************************
36 ************************************************************************/
46 /* GERMS -- The "standard-32" configuration GERMS monitor looks
47 * for the string "Nios" at flash_base + 0xc (actually it only
48 * tests for 'N', 'i'). You can leave support for this in place
49 * as it's only a few words.
57 * Early setup -- set cwp = HI_LIMIT, IPRI = 2, IE = 1 to
58 * enable underflow exceptions. Disable cache.
59 * NOTE: %o7 has return addr -- save in %g7 use later.
67 or %g0, %lo(STATUS_INIT)
68 wrctl %g0 /* update status */
74 pfx %hi(CONFIG_SYS_INIT_SP)
75 movi %sp, %lo(CONFIG_SYS_INIT_SP)
76 pfx %xhi(CONFIG_SYS_INIT_SP)
77 movhi %sp, %xlo(CONFIG_SYS_INIT_SP)
81 subi %sp, %lo(4*16) /* Space for reg window mgmt */
84 * RELOCATE -- %g7 has return addr from bsr at _start.
86 pfx %hi(__u_boot_cmd_end)
87 movi %g5, %lo(__u_boot_cmd_end)
88 pfx %xhi(__u_boot_cmd_end)
89 movhi %g5, %xlo(__u_boot_cmd_end) /* %g5 <- end address */
91 lsli %g7, 1 /* mem = retaddr << 1 */
93 subi %g6, 4 /* %g6 <- src addr */
94 ld %g7, [%g7] /* %g7 <- dst addr */
96 /* No need to move text sections if we're already located
97 * at the proper address.
110 addi %g6, 4 /* src++ */
112 addi %g7, 4 /* dst++ */
118 * Jump to relocation address
121 movi %g0, %lo(reloc@h)
123 movhi %g0, %xlo(reloc@h)
132 movi %g5, %lo(__bss_end)
134 movhi %g5, %xlo(__bss_end) /* %g5 <- end address */
136 movi %g7, %lo(__bss_start)
137 pfx %xhi(__bss_start)
138 movhi %g7, %xlo(__bss_start) /* %g7 <- end address */
147 addi %g7, 4 /* (delay slot) dst++ */
155 pfx %hi(CONFIG_SYS_VECT_BASE)
156 movi %g0, %lo(CONFIG_SYS_VECT_BASE)
157 pfx %xhi(CONFIG_SYS_VECT_BASE)
158 movhi %g0, %xlo(CONFIG_SYS_VECT_BASE) /* dst */
162 movi %g1, %lo(_vectors)
164 movhi %g1, %xlo(_vectors) /* src */
165 bgen %g2, 6 /* cnt = 64 */
167 ldp %g3, [%l0, 3] /* bkpt vector */
168 ldp %g4, [%l0, 4] /* single step vector */
171 addi %g1, 4 /* src++ */
173 addi %g0, 4 /* dst++ */
175 subi %g2, 1 /* cnt-- */
180 #if defined(CONFIG_ROM_STUBS)
181 /* Restore the breakpoint and single step exception
182 * vectors to their original values.
184 stp [%l0,3], %g3 /* breakpoint */
185 stp [%l0,4], %g4 /* single step */
188 /* For debug startup convenience ... software breakpoints
189 * set prior to this point may not succeed ;-)
195 * Call board_init -- never returns
197 pfx %hi(board_init@h)
198 movi %g1, %lo(board_init@h)
199 pfx %xhi(board_init@h)
200 movhi %g1, %xlo(board_init@h)
202 nop /* Delaly slot */
206 * dly_clks -- Nios doesn't have a time/clk reference for simple
207 * delay loops, so we do our best by counting instruction cycles.
208 * A control register that counts system clock cycles would be
209 * a handy feature -- hint for Altera ;-)
212 /* Each loop is 4 instructions as delay slot is always
213 * executed. Each instruction is approximately 4 clocks
214 * (according to some lame info from Altera). So ...
215 * ... each loop is about 16 clocks.
219 lsri %o0, 4 /* cnt/16 */
223 subi %o0, 1 /* cnt--, Delay slot */
232 .globl version_string
235 .ascii U_BOOT_VERSION
236 .ascii " (", __DATE__, " - ", __TIME__, ")"
237 .ascii CONFIG_IDENT_STRING, "\0"