blob: 06ba9c8e62bee5c020aaff14aba69b654b7fd818 [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>
Catalin Marinas55bdd692010-05-21 18:06:41 +010022#include <asm/v7m.h>
Hyok S. Choi75d90832006-03-27 14:58:25 +010023
Hyok S. Choi75d90832006-03-27 14:58:25 +010024/*
25 * Kernel startup entry point.
26 * ---------------------------
27 *
28 * This is normally called from the decompressor code. The requirements
29 * are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
30 * r1 = machine nr.
31 *
32 * See linux/arch/arm/tools/mach-types for the complete list of machine
33 * numbers for r1.
34 *
35 */
Dave Martin540b5732011-07-13 15:53:30 +010036
Tim Abbott2abc1c52009-10-02 16:32:46 -040037 __HEAD
Uwe Kleine-Königbc7dea02011-12-09 20:52:10 +010038
39#ifdef CONFIG_CPU_THUMBONLY
40 .thumb
41ENTRY(stext)
42#else
43 .arm
Hyok S. Choi75d90832006-03-27 14:58:25 +010044ENTRY(stext)
Dave Martin540b5732011-07-13 15:53:30 +010045
46 THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.
47 THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
48 THUMB( .thumb ) @ switch to Thumb now.
49 THUMB(1: )
Uwe Kleine-Königbc7dea02011-12-09 20:52:10 +010050#endif
Dave Martin540b5732011-07-13 15:53:30 +010051
Catalin Marinasb86040a2009-07-24 12:32:54 +010052 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
Hyok S. Choi75d90832006-03-27 14:58:25 +010053 @ and irqs disabled
Catalin Marinas55bdd692010-05-21 18:06:41 +010054#if defined(CONFIG_CPU_CP15)
Hyok S. Choi75d90832006-03-27 14:58:25 +010055 mrc p15, 0, r9, c0, c0 @ get processor id
Catalin Marinas55bdd692010-05-21 18:06:41 +010056#elif defined(CONFIG_CPU_V7M)
57 ldr r9, =BASEADDR_V7M_SCB
58 ldr r9, [r9, V7M_SCB_CPUID]
59#else
60 ldr r9, =CONFIG_PROCESSOR_ID
Hyok S. Choif12d0d72006-09-26 17:36:37 +090061#endif
Hyok S. Choi75d90832006-03-27 14:58:25 +010062 bl __lookup_processor_type @ r5=procinfo r9=cpuid
63 movs r10, r5 @ invalid processor (r5=0)?
64 beq __error_p @ yes, error 'p'
Hyok S. Choi75d90832006-03-27 14:58:25 +010065
Will Deacon01fafca2012-02-28 11:50:32 +000066 ldr r13, =__mmap_switched @ address to jump to after
67 @ initialising sctlr
68 adr lr, BSYM(1f) @ return (PIC) address
Catalin Marinasb86040a2009-07-24 12:32:54 +010069 ARM( add pc, r10, #PROCINFO_INITFUNC )
70 THUMB( add r12, r10, #PROCINFO_INITFUNC )
71 THUMB( mov pc, r12 )
Will Deacon01fafca2012-02-28 11:50:32 +000072 1: b __after_proc_init
Catalin Marinas93ed3972008-08-28 11:22:32 +010073ENDPROC(stext)
Hyok S. Choi75d90832006-03-27 14:58:25 +010074
Will Deacon01fafca2012-02-28 11:50:32 +000075#ifdef CONFIG_SMP
76 __CPUINIT
77ENTRY(secondary_startup)
78 /*
79 * Common entry point for secondary CPUs.
80 *
81 * Ensure that we're in SVC mode, and IRQs are disabled. Lookup
82 * the processor type - there is no need to check the machine type
83 * as it has already been validated by the primary processor.
84 */
85 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9
86#ifndef CONFIG_CPU_CP15
87 ldr r9, =CONFIG_PROCESSOR_ID
88#else
89 mrc p15, 0, r9, c0, c0 @ get processor id
90#endif
91 bl __lookup_processor_type @ r5=procinfo r9=cpuid
92 movs r10, r5 @ invalid processor?
93 beq __error_p @ yes, error 'p'
94
95 adr r4, __secondary_data
96 ldmia r4, {r7, r12}
97 adr lr, BSYM(__after_proc_init) @ return address
98 mov r13, r12 @ __secondary_switched address
99 ARM( add pc, r10, #PROCINFO_INITFUNC )
100 THUMB( add r12, r10, #PROCINFO_INITFUNC )
101 THUMB( mov pc, r12 )
102ENDPROC(secondary_startup)
103
104ENTRY(__secondary_switched)
105 ldr sp, [r7, #8] @ set up the stack pointer
106 mov fp, #0
107 b secondary_start_kernel
108ENDPROC(__secondary_switched)
109
110 .type __secondary_data, %object
111__secondary_data:
112 .long secondary_data
113 .long __secondary_switched
114#endif /* CONFIG_SMP */
115
Hyok S. Choi75d90832006-03-27 14:58:25 +0100116/*
117 * Set the Control Register and Read the process ID.
118 */
Hyok S. Choi75d90832006-03-27 14:58:25 +0100119__after_proc_init:
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900120#ifdef CONFIG_CPU_CP15
Catalin Marinas05efde92009-07-24 12:34:59 +0100121 /*
122 * CP15 system control register value returned in r0 from
123 * the CPU init function.
124 */
Armando Visconti76e09202012-12-04 10:34:39 +0100125#if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6
Hyok S. Choi75d90832006-03-27 14:58:25 +0100126 orr r0, r0, #CR_A
127#else
128 bic r0, r0, #CR_A
129#endif
130#ifdef CONFIG_CPU_DCACHE_DISABLE
131 bic r0, r0, #CR_C
132#endif
133#ifdef CONFIG_CPU_BPREDICT_DISABLE
134 bic r0, r0, #CR_Z
135#endif
136#ifdef CONFIG_CPU_ICACHE_DISABLE
137 bic r0, r0, #CR_I
138#endif
Hyok S. Choi6afd6fa2006-09-28 21:46:34 +0900139#ifdef CONFIG_CPU_HIGH_VECTOR
140 orr r0, r0, #CR_V
141#else
142 bic r0, r0, #CR_V
143#endif
Hyok S. Choi75d90832006-03-27 14:58:25 +0100144 mcr p15, 0, r0, c1, c0, 0 @ write control reg
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900145#endif /* CONFIG_CPU_CP15 */
Will Deacon01fafca2012-02-28 11:50:32 +0000146 mov pc, r13
Catalin Marinas93ed3972008-08-28 11:22:32 +0100147ENDPROC(__after_proc_init)
Hyok S. Choi3b920ce2006-04-24 09:45:35 +0100148 .ltorg
Hyok S. Choi75d90832006-03-27 14:58:25 +0100149
150#include "head-common.S"