Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 1 | /* |
| 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. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 12 | * |
| 13 | */ |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 14 | #include <linux/linkage.h> |
| 15 | #include <linux/init.h> |
| 16 | |
| 17 | #include <asm/assembler.h> |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 18 | #include <asm/ptrace.h> |
Uwe Zeisberger | 2eb9d31 | 2006-05-05 15:11:14 +0100 | [diff] [blame] | 19 | #include <asm/asm-offsets.h> |
Russell King | 15d07dc | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 20 | #include <asm/cp15.h> |
Hyok S. Choi | 3b920ce | 2006-04-24 09:45:35 +0100 | [diff] [blame] | 21 | #include <asm/thread_info.h> |
Catalin Marinas | 55bdd69 | 2010-05-21 18:06:41 +0100 | [diff] [blame^] | 22 | #include <asm/v7m.h> |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 23 | |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 24 | /* |
| 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 Martin | 540b573 | 2011-07-13 15:53:30 +0100 | [diff] [blame] | 36 | |
Tim Abbott | 2abc1c5 | 2009-10-02 16:32:46 -0400 | [diff] [blame] | 37 | __HEAD |
Uwe Kleine-König | bc7dea0 | 2011-12-09 20:52:10 +0100 | [diff] [blame] | 38 | |
| 39 | #ifdef CONFIG_CPU_THUMBONLY |
| 40 | .thumb |
| 41 | ENTRY(stext) |
| 42 | #else |
| 43 | .arm |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 44 | ENTRY(stext) |
Dave Martin | 540b573 | 2011-07-13 15:53:30 +0100 | [diff] [blame] | 45 | |
| 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önig | bc7dea0 | 2011-12-09 20:52:10 +0100 | [diff] [blame] | 50 | #endif |
Dave Martin | 540b573 | 2011-07-13 15:53:30 +0100 | [diff] [blame] | 51 | |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 52 | setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 53 | @ and irqs disabled |
Catalin Marinas | 55bdd69 | 2010-05-21 18:06:41 +0100 | [diff] [blame^] | 54 | #if defined(CONFIG_CPU_CP15) |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 55 | mrc p15, 0, r9, c0, c0 @ get processor id |
Catalin Marinas | 55bdd69 | 2010-05-21 18:06:41 +0100 | [diff] [blame^] | 56 | #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. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 61 | #endif |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 62 | 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. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 65 | |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 66 | adr lr, BSYM(__after_proc_init) @ return (PIC) address |
| 67 | ARM( add pc, r10, #PROCINFO_INITFUNC ) |
| 68 | THUMB( add r12, r10, #PROCINFO_INITFUNC ) |
| 69 | THUMB( mov pc, r12 ) |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 70 | ENDPROC(stext) |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * Set the Control Register and Read the process ID. |
| 74 | */ |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 75 | __after_proc_init: |
Hyok S. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 76 | #ifdef CONFIG_CPU_CP15 |
Catalin Marinas | 05efde9 | 2009-07-24 12:34:59 +0100 | [diff] [blame] | 77 | /* |
| 78 | * CP15 system control register value returned in r0 from |
| 79 | * the CPU init function. |
| 80 | */ |
Armando Visconti | 76e0920 | 2012-12-04 10:34:39 +0100 | [diff] [blame] | 81 | #if defined(CONFIG_ALIGNMENT_TRAP) && __LINUX_ARM_ARCH__ < 6 |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 82 | orr r0, r0, #CR_A |
| 83 | #else |
| 84 | bic r0, r0, #CR_A |
| 85 | #endif |
| 86 | #ifdef CONFIG_CPU_DCACHE_DISABLE |
| 87 | bic r0, r0, #CR_C |
| 88 | #endif |
| 89 | #ifdef CONFIG_CPU_BPREDICT_DISABLE |
| 90 | bic r0, r0, #CR_Z |
| 91 | #endif |
| 92 | #ifdef CONFIG_CPU_ICACHE_DISABLE |
| 93 | bic r0, r0, #CR_I |
| 94 | #endif |
Hyok S. Choi | 6afd6fa | 2006-09-28 21:46:34 +0900 | [diff] [blame] | 95 | #ifdef CONFIG_CPU_HIGH_VECTOR |
| 96 | orr r0, r0, #CR_V |
| 97 | #else |
| 98 | bic r0, r0, #CR_V |
| 99 | #endif |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 100 | mcr p15, 0, r0, c1, c0, 0 @ write control reg |
Hyok S. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 101 | #endif /* CONFIG_CPU_CP15 */ |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 102 | |
Russell King | f131a08 | 2010-10-01 15:42:02 +0100 | [diff] [blame] | 103 | b __mmap_switched @ clear the BSS and jump |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 104 | @ to start_kernel |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 105 | ENDPROC(__after_proc_init) |
Hyok S. Choi | 3b920ce | 2006-04-24 09:45:35 +0100 | [diff] [blame] | 106 | .ltorg |
Hyok S. Choi | 75d9083 | 2006-03-27 14:58:25 +0100 | [diff] [blame] | 107 | |
| 108 | #include "head-common.S" |