2 * linux/arch/arm/kernel/head-common.S
4 * Copyright (C) 1994-2002 Russell King
5 * Copyright (c) 2003 ARM Limited
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <asm/assembler.h>
15 #define ATAG_CORE 0x54410001
16 #define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
17 #define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)
19 #ifdef CONFIG_CPU_BIG_ENDIAN
20 #define OF_DT_MAGIC 0xd00dfeed
22 #define OF_DT_MAGIC 0xedfe0dd0 /* 0xd00dfeed in big-endian */
26 * Exception handling. Something went wrong and we can't proceed. We
27 * ought to tell the user, but since we don't have any guarantee that
28 * we're even running on the right architecture, we do virtually nothing.
30 * If CONFIG_DEBUG_LL is set we try to print out something about the error
31 * and hope for the best (useful if bootloader fails to pass a proper
32 * machine ID for example).
36 /* Determine validity of the r2 atags pointer. The heuristic requires
37 * that the pointer be aligned, in the first 16k of physical RAM and
38 * that the ATAG_CORE marker is first and present. If CONFIG_OF_FLATTREE
39 * is selected, then it will also accept a dtb pointer. Future revisions
40 * of this function may be more lenient with the physical address and
41 * may also be able to move the ATAGS block if necessary.
44 * r2 either valid atags pointer, valid dtb pointer, or zero
48 tst r2, #0x3 @ aligned?
52 #ifdef CONFIG_OF_FLATTREE
53 ldr r6, =OF_DT_MAGIC @ is it a DTB?
57 cmp r5, #ATAG_CORE_SIZE @ is first tag ATAG_CORE?
58 cmpne r5, #ATAG_CORE_SIZE_EMPTY
65 2: ret lr @ atag/dtb pointer is ok
72 * The following fragment of code is executed with the MMU on in MMU mode,
73 * and uses absolute addresses; this is not position independent.
75 * r0 = cp#15 control register
77 * r2 = atags/dtb pointer
82 adr r3, __mmap_switched_data
84 ldmia r3!, {r4, r5, r6, r7}
85 cmp r4, r5 @ Copy data segment if needed
91 mov fp, #0 @ Clear BSS (and zero fp)
96 ARM( ldmia r3, {r4, r5, r6, r7, sp})
97 THUMB( ldmia r3, {r4, r5, r6, r7} )
98 THUMB( ldr sp, [r3, #16] )
99 str r9, [r4] @ Save processor ID
100 str r1, [r5] @ Save machine type
101 str r2, [r6] @ Save atags pointer
103 strne r0, [r7] @ Save control register values
106 ENDPROC(__mmap_switched)
109 .type __mmap_switched_data, %object
110 __mmap_switched_data:
111 .long __data_loc @ r4
113 .long __bss_start @ r6
115 .long processor_id @ r4
116 .long __machine_arch_type @ r5
117 .long __atags_pointer @ r6
118 #ifdef CONFIG_CPU_CP15
119 .long cr_alignment @ r7
123 .long init_thread_union + THREAD_START_SP @ sp
124 .size __mmap_switched_data, . - __mmap_switched_data
130 * This provides a C-API version of __lookup_processor_type
132 ENTRY(lookup_processor_type)
133 stmfd sp!, {r4 - r6, r9, lr}
135 bl __lookup_processor_type
137 ldmfd sp!, {r4 - r6, r9, pc}
138 ENDPROC(lookup_processor_type)
141 * Read processor ID register (CP#15, CR0), and look up in the linker-built
142 * supported processor list. Note that we can't use the absolute addresses
143 * for the __proc_info lists since we aren't running with the MMU on
144 * (and therefore, we are not in the correct address space). We have to
145 * calculate the offset.
149 * r3, r4, r6 corrupted
150 * r5 = proc_info pointer in physical address space
151 * r9 = cpuid (preserved)
153 __lookup_processor_type:
154 adr r3, __lookup_processor_type_data
156 sub r3, r3, r4 @ get offset between virt&phys
157 add r5, r5, r3 @ convert virt addresses to
158 add r6, r6, r3 @ physical address space
159 1: ldmia r5, {r3, r4} @ value, mask
160 and r4, r4, r9 @ mask wanted bits
163 add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)
166 mov r5, #0 @ unknown processor
168 ENDPROC(__lookup_processor_type)
171 * Look in <asm/procinfo.h> for information about the __proc_info structure.
174 .type __lookup_processor_type_data, %object
175 __lookup_processor_type_data:
177 .long __proc_info_begin
178 .long __proc_info_end
179 .size __lookup_processor_type_data, . - __lookup_processor_type_data
182 #ifdef CONFIG_DEBUG_LL
186 str_lpae: .asciz "\nError: Kernel with LPAE support, but CPU does not support LPAE.\n"
191 ENDPROC(__error_lpae)
194 #ifdef CONFIG_DEBUG_LL
202 str_p1: .asciz "\nError: unrecognized/unsupported processor variant (0x"
203 str_p2: .asciz ").\n"
209 #ifdef CONFIG_ARCH_RPC
211 * Turn the screen red on a error - RiscPC only.
215 orr r3, r3, r3, lsl #8
216 orr r3, r3, r3, lsl #16