blob: 6a2e09c952c715862cb32907af2438e39d5b9788 [file] [log] [blame]
Hyok S. Choi75d90832006-03-27 14:58:25 +01001/*
2 * linux/arch/arm/kernel/head-nommu.S
3 *
4 * Copyright (C) 1994-2002 Russell King
5 * Copyright (C) 2003-2006 Hyok S. Choi
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Common kernel startup code (non-paged MM)
Hyok S. Choi75d90832006-03-27 14:58:25 +010012 *
13 */
Hyok S. Choi75d90832006-03-27 14:58:25 +010014#include <linux/linkage.h>
15#include <linux/init.h>
16
17#include <asm/assembler.h>
Hyok S. Choi75d90832006-03-27 14:58:25 +010018#include <asm/ptrace.h>
Uwe Zeisberger2eb9d312006-05-05 15:11:14 +010019#include <asm/asm-offsets.h>
Russell King15d07dc2012-03-28 18:30:01 +010020#include <asm/cp15.h>
Hyok S. Choi3b920ce2006-04-24 09:45:35 +010021#include <asm/thread_info.h>
Hyok S. Choi75d90832006-03-27 14:58:25 +010022
Hyok S. Choi75d90832006-03-27 14:58:25 +010023/*
24 * Kernel startup entry point.
25 * ---------------------------
26 *
27 * This is normally called from the decompressor code. The requirements
28 * are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
29 * r1 = machine nr.
30 *
31 * See linux/arch/arm/tools/mach-types for the complete list of machine
32 * numbers for r1.
33 *
34 */
Dave Martin540b5732011-07-13 15:53:30 +010035
Tim Abbott2abc1c52009-10-02 16:32:46 -040036 __HEAD
Uwe Kleine-Königbc7dea02011-12-09 20:52:10 +010037
38#ifdef CONFIG_CPU_THUMBONLY
39 .thumb
40ENTRY(stext)
41#else
42 .arm
Hyok S. Choi75d90832006-03-27 14:58:25 +010043ENTRY(stext)
Dave Martin540b5732011-07-13 15:53:30 +010044
45 THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.
46 THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
47 THUMB( .thumb ) @ switch to Thumb now.
48 THUMB(1: )
Uwe Kleine-Königbc7dea02011-12-09 20:52:10 +010049#endif
Dave Martin540b5732011-07-13 15:53:30 +010050
Catalin Marinasb86040a2009-07-24 12:32:54 +010051 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
Hyok S. Choi75d90832006-03-27 14:58:25 +010052 @ and irqs disabled
Hyok S. Choif12d0d72006-09-26 17:36:37 +090053#ifndef CONFIG_CPU_CP15
54 ldr r9, =CONFIG_PROCESSOR_ID
55#else
Hyok S. Choi75d90832006-03-27 14:58:25 +010056 mrc p15, 0, r9, c0, c0 @ get processor id
Hyok S. Choif12d0d72006-09-26 17:36:37 +090057#endif
Hyok S. Choi75d90832006-03-27 14:58:25 +010058 bl __lookup_processor_type @ r5=procinfo r9=cpuid
59 movs r10, r5 @ invalid processor (r5=0)?
60 beq __error_p @ yes, error 'p'
Hyok S. Choi75d90832006-03-27 14:58:25 +010061
Catalin Marinasb86040a2009-07-24 12:32:54 +010062 adr lr, BSYM(__after_proc_init) @ return (PIC) address
63 ARM( add pc, r10, #PROCINFO_INITFUNC )
64 THUMB( add r12, r10, #PROCINFO_INITFUNC )
65 THUMB( mov pc, r12 )
Catalin Marinas93ed3972008-08-28 11:22:32 +010066ENDPROC(stext)
Hyok S. Choi75d90832006-03-27 14:58:25 +010067
68/*
69 * Set the Control Register and Read the process ID.
70 */
Hyok S. Choi75d90832006-03-27 14:58:25 +010071__after_proc_init:
Hyok S. Choif12d0d72006-09-26 17:36:37 +090072#ifdef CONFIG_CPU_CP15
Catalin Marinas05efde92009-07-24 12:34:59 +010073 /*
74 * CP15 system control register value returned in r0 from
75 * the CPU init function.
76 */
Armando Visconti76e09202012-12-04 10:34:39 +010077#if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
Hyok S. Choi75d90832006-03-27 14:58:25 +010078 orr r0, r0, #CR_A
79#else
80 bic r0, r0, #CR_A
81#endif
82#ifdef CONFIG_CPU_DCACHE_DISABLE
83 bic r0, r0, #CR_C
84#endif
85#ifdef CONFIG_CPU_BPREDICT_DISABLE
86 bic r0, r0, #CR_Z
87#endif
88#ifdef CONFIG_CPU_ICACHE_DISABLE
89 bic r0, r0, #CR_I
90#endif
Hyok S. Choi6afd6fa2006-09-28 21:46:34 +090091#ifdef CONFIG_CPU_HIGH_VECTOR
92 orr r0, r0, #CR_V
93#else
94 bic r0, r0, #CR_V
95#endif
Hyok S. Choi75d90832006-03-27 14:58:25 +010096 mcr p15, 0, r0, c1, c0, 0 @ write control reg
Hyok S. Choif12d0d72006-09-26 17:36:37 +090097#endif /* CONFIG_CPU_CP15 */
Hyok S. Choi75d90832006-03-27 14:58:25 +010098
Russell Kingf131a082010-10-01 15:42:02 +010099 b __mmap_switched @ clear the BSS and jump
Hyok S. Choi75d90832006-03-27 14:58:25 +0100100 @ to start_kernel
Catalin Marinas93ed3972008-08-28 11:22:32 +0100101ENDPROC(__after_proc_init)
Hyok S. Choi3b920ce2006-04-24 09:45:35 +0100102 .ltorg
Hyok S. Choi75d90832006-03-27 14:58:25 +0100103
104#include "head-common.S"