2 * arch/xtensa/kernel/head.S
4 * Xtensa Processor startup code.
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 * Copyright (C) 2001 - 2008 Tensilica Inc.
12 * Chris Zankel <chris@zankel.net>
13 * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
14 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
18 #include <asm/processor.h>
20 #include <asm/cacheasm.h>
21 #include <asm/initialize_mmu.h>
22 #include <asm/mxregs.h>
24 #include <linux/init.h>
25 #include <linux/linkage.h>
28 * This module contains the entry code for kernel images. It performs the
29 * minimal setup needed to call the generic C routines.
33 * - The kernel image has been loaded to the actual address where it was
35 * - a2 contains either 0 or a pointer to a list of boot parameters.
36 * (see setup.c for more details)
43 * The bootloader passes a pointer to a list of boot parameters in a2.
46 /* The first bytes of the kernel image must be an instruction, so we
47 * manually allocate and define the literal constant we need for a jx
52 .begin no-absolute-literals
56 /* Preserve the pointer to the boot parameter list in EXCSAVE_1 */
68 * Initialize WB, WS, and clear PS.EXCM (to allow loop instructions).
69 * Set Interrupt Level just below XCHAL_DEBUGLEVEL to allow
70 * xt-gdb to single step via DEBUG exceptions received directly
85 Offset = _SetupMMU - _start
87 #ifdef CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
89 #if defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
99 .end no-absolute-literals
111 /* Set a0 to 0 for the remaining initialization. */
115 #if XCHAL_HAVE_VECBASE
116 movi a2, VECBASE_RESET_VADDR
120 /* Clear debugging registers. */
123 #if XCHAL_NUM_IBREAK > 0
131 .rept XCHAL_NUM_DBREAK - 1
132 wsr a0, SREG_DBREAKC + _index
133 .set _index, _index + 1
137 /* Clear CCOUNT (not really necessary, but nice) */
139 wsr a0, ccount # not really necessary, but nice
141 /* Disable zero-loops. */
147 /* Disable all timers. */
150 .rept XCHAL_NUM_TIMERS
151 wsr a0, SREG_CCOMPARE + _index
152 .set _index, _index + 1
155 /* Interrupt initialization. */
157 movi a2, XCHAL_INTTYPE_MASK_SOFTWARE | XCHAL_INTTYPE_MASK_EXTERN_EDGE
161 /* Disable coprocessors. */
167 /* Initialize the caches.
168 * a2, a3 are just working registers (clobbered).
171 #if XCHAL_DCACHE_LINE_LOCKABLE
172 ___unlock_dcache_all a2 a3
175 #if XCHAL_ICACHE_LINE_LOCKABLE
176 ___unlock_icache_all a2 a3
179 ___invalidate_dcache_all a2 a3
180 ___invalidate_icache_all a2 a3
184 #ifdef CONFIG_HAVE_SMP
185 movi a2, CCON # MX External Register to Configure Cache
190 /* Setup stack and enable window exceptions (keep irqs disabled) */
195 movi a2, (1 << PS_WOE_BIT) | LOCKLEVEL
196 # WOE=1, INTLEVEL=LOCKLEVEL, UM=0
197 wsr a2, ps # (enable reg-windows; progmode stack)
200 /* Set up EXCSAVE[DEBUGLEVEL] to point to the Debug Exception Handler.*/
202 movi a2, debug_exception
203 wsr a2, SREG_EXCSAVE + XCHAL_DEBUGLEVEL
207 * Notice that we assume with SMP that cores have PRID
208 * supported by the cores.
211 bnez a2, .Lboot_secondary
213 #endif /* CONFIG_SMP */
215 /* Unpack data sections
217 * The linker script used to build the Linux kernel image
218 * creates a table located at __boot_reloc_table_start
219 * that contans the information what data needs to be unpacked.
224 movi a2, __boot_reloc_table_start
225 movi a3, __boot_reloc_table_end
227 1: beq a2, a3, 3f # no more entries?
228 l32i a4, a2, 0 # start destination (in RAM)
229 l32i a5, a2, 4 # end desination (in RAM)
230 l32i a6, a2, 8 # start source (in ROM)
231 addi a2, a2, 12 # next entry
232 beq a4, a5, 1b # skip, empty entry
233 beq a4, a6, 1b # skip, source and dest. are the same
235 2: l32i a7, a6, 0 # load word
237 s32i a7, a4, 0 # store word
243 /* All code and initialized data segments have been copied.
244 * Now clear the BSS segment.
247 movi a2, __bss_start # start of BSS
248 movi a3, __bss_stop # end of BSS
250 __loopt a2, a3, a4, 2
254 #if XCHAL_DCACHE_IS_WRITEBACK
256 /* After unpacking, flush the writeback cache to memory so the
257 * instructions/data are available.
260 ___flush_dcache_all a2 a3
264 ___invalidate_icache_all a2 a3
270 /* init_arch kick-starts the linux kernel */
275 movi a4, start_kernel
279 j should_never_return
284 movi a2, cpu_start_ccount
302 movi a4, secondary_start_kernel
304 j should_never_return
306 #endif /* CONFIG_SMP */
310 #ifdef CONFIG_HOTPLUG_CPU
314 #if XCHAL_DCACHE_IS_WRITEBACK
315 ___flush_invalidate_dcache_all a2 a3
317 ___invalidate_dcache_all a2 a3
320 movi a2, CCON # MX External Register to Configure Cache
327 movi a3, cpu_start_id
329 #if XCHAL_DCACHE_IS_WRITEBACK
338 * Initialize WB, WS, and clear PS.EXCM (to allow loop instructions).
339 * Set Interrupt Level just below XCHAL_DEBUGLEVEL to allow
340 * xt-gdb to single step via DEBUG exceptions received directly
357 #endif /* CONFIG_HOTPLUG_CPU */
363 .section ".data.init.refok"
366 .long init_thread_union + KERNEL_STACK_SIZE
374 ENTRY(swapper_pg_dir)
375 .fill PAGE_SIZE, 1, 0
378 ENTRY(empty_zero_page)
379 .fill PAGE_SIZE, 1, 0