/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 1994, 1995 Waldorf Electronics6* Written by Ralf Baechle and Andreas Busse7* Copyright (C) 1994 - 99, 2003, 06 Ralf Baechle8* Copyright (C) 1996 Paul M. Antoine9* Modified for DECStation and hence R3000 support by Paul M. Antoine10* Further modifications by David S. Miller and Harald Koerfgen11* Copyright (C) 1999 Silicon Graphics, Inc.12* Kevin Kissell, [email protected] and Carsten Langgaard, [email protected]13* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.14*/15#include <linux/init.h>16#include <linux/threads.h>1718#include <asm/addrspace.h>19#include <asm/asm.h>20#include <asm/asmmacro.h>21#include <asm/irqflags.h>22#include <asm/regdef.h>23#include <asm/mipsregs.h>24#include <asm/stackframe.h>2526#include <kernel-entry-init.h>2728/*29* For the moment disable interrupts, mark the kernel mode and30* set ST0_KX so that the CPU does not spit fire when using31* 64-bit addresses. A full initialization of the CPU's status32* register is done later in per_cpu_trap_init().33*/34.macro setup_c0_status set clr35.set push36mfc0 t0, CP0_STATUS37or t0, ST0_KERNEL_CUMASK|\set|0x1f|\clr38xor t0, 0x1f|\clr39mtc0 t0, CP0_STATUS40.set noreorder41sll zero,3 # ehb42.set pop43.endm4445.macro setup_c0_status_pri46#ifdef CONFIG_64BIT47setup_c0_status ST0_KX 048#else49setup_c0_status 0 050#endif51.endm5253.macro setup_c0_status_sec54#ifdef CONFIG_64BIT55setup_c0_status ST0_KX ST0_BEV56#else57setup_c0_status 0 ST0_BEV58#endif59.endm6061__HEAD6263#ifndef CONFIG_NO_EXCEPT_FILL64/*65* Reserved space for exception handlers.66* Necessary for machines which link their kernels at KSEG0.67*/68.fill 0x40069#endif7071EXPORT(_stext)7273#ifdef CONFIG_BOOT_RAW74/*75* Give us a fighting chance of running if execution beings at the76* kernel load address. This is needed because this platform does77* not have a ELF loader yet.78*/79FEXPORT(__kernel_entry)80j kernel_entry81#endif /* CONFIG_BOOT_RAW */8283__REF8485NESTED(kernel_entry, 16, sp) # kernel entry point8687kernel_entry_setup # cpu specific setup8889setup_c0_status_pri9091/* We might not get launched at the address the kernel is linked to,92so we jump there. */93PTR_LA t0, 0f94jr t0950:9697PTR_LA t0, __bss_start # clear .bss98LONG_S zero, (t0)99PTR_LA t1, __bss_stop - LONGSIZE1001:101PTR_ADDIU t0, LONGSIZE102LONG_S zero, (t0)103bne t0, t1, 1b104105LONG_S a0, fw_arg0 # firmware arguments106LONG_S a1, fw_arg1107LONG_S a2, fw_arg2108LONG_S a3, fw_arg3109110MTC0 zero, CP0_CONTEXT # clear context register111#ifdef CONFIG_64BIT112MTC0 zero, CP0_XCONTEXT113#endif114PTR_LA $28, init_thread_union115/* Set the SP after an empty pt_regs. */116PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE117PTR_ADDU sp, $28118back_to_back_c0_hazard119set_saved_sp sp, t0, t1120PTR_SUBU sp, 4 * SZREG # init stack pointer121122#ifdef CONFIG_RELOCATABLE123/* Copy kernel and apply the relocations */124jal relocate_kernel125126/* Repoint the sp into the new kernel image */127PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE128PTR_ADDU sp, $28129set_saved_sp sp, t0, t1130PTR_SUBU sp, 4 * SZREG # init stack pointer131132/*133* relocate_kernel returns the entry point either134* in the relocated kernel or the original if for135* some reason relocation failed - jump there now136* with instruction hazard barrier because of the137* newly sync'd icache.138*/139jr.hb v0140#else /* !CONFIG_RELOCATABLE */141j start_kernel142#endif /* !CONFIG_RELOCATABLE */143END(kernel_entry)144145#ifdef CONFIG_SMP146/*147* SMP slave cpus entry point. Board specific code for bootstrap calls this148* function after setting up the stack and gp registers.149*/150NESTED(smp_bootstrap, 16, sp)151smp_slave_setup152setup_c0_status_sec153j start_secondary154END(smp_bootstrap)155#endif /* CONFIG_SMP */156157158