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.
14 <<<<<<< HEAD:arch/arm/kernel/head-common.S
16 #define ATAG_CORE 0x54410001
17 #define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
19 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/kernel/head-common.S
20 .type __switch_data, %object
24 .long __data_start @ r5
25 .long __bss_start @ r6
27 .long processor_id @ r4
28 .long __machine_arch_type @ r5
29 .long __atags_pointer @ r6
30 .long cr_alignment @ r7
31 .long init_thread_union + THREAD_START_SP @ sp
34 * The following fragment of code is executed with the MMU on in MMU mode,
35 * and uses absolute addresses; this is not position independent.
37 * r0 = cp#15 control register
42 .type __mmap_switched, %function
44 adr r3, __switch_data + 4
46 ldmia r3!, {r4, r5, r6, r7}
47 cmp r4, r5 @ Copy data segment if needed
53 mov fp, #0 @ Clear BSS (and zero fp)
58 ldmia r3, {r4, r5, r6, r7, sp}
59 str r9, [r4] @ Save processor ID
60 str r1, [r5] @ Save machine type
61 str r2, [r6] @ Save atags pointer
62 bic r4, r0, #CR_A @ Clear 'A' bit
63 stmia r7, {r0, r4} @ Save control register values
67 * Exception handling. Something went wrong and we can't proceed. We
68 * ought to tell the user, but since we don't have any guarantee that
69 * we're even running on the right architecture, we do virtually nothing.
71 * If CONFIG_DEBUG_LL is set we try to print out something about the error
72 * and hope for the best (useful if bootloader fails to pass a proper
73 * machine ID for example).
76 .type __error_p, %function
78 #ifdef CONFIG_DEBUG_LL
82 str_p1: .asciz "\nError: unrecognized/unsupported processor variant.\n"
86 .type __error_a, %function
88 #ifdef CONFIG_DEBUG_LL
89 mov r4, r1 @ preserve machine ID
97 ldmia r3, {r4, r5, r6} @ get machine desc list
98 sub r4, r3, r4 @ get offset between virt&phys
99 add r5, r5, r4 @ convert virt addresses to
100 add r6, r6, r4 @ physical address space
101 1: ldr r0, [r5, #MACHINFO_TYPE] @ get machine type
105 ldr r0, [r5, #MACHINFO_NAME] @ get machine name
110 add r5, r5, #SIZEOF_MACHINE_DESC @ next machine_desc
116 str_a1: .asciz "\nError: unrecognized/unsupported machine ID (r1 = 0x"
117 str_a2: .asciz ").\n\nAvailable machine support:\n\nID (hex)\tNAME\n"
118 str_a3: .asciz "\nPlease check your kernel config and/or bootloader.\n"
122 .type __error, %function
124 #ifdef CONFIG_ARCH_RPC
126 * Turn the screen red on a error - RiscPC only.
130 orr r3, r3, r3, lsl #8
131 orr r3, r3, r3, lsl #16
142 * Read processor ID register (CP#15, CR0), and look up in the linker-built
143 * supported processor list. Note that we can't use the absolute addresses
144 * for the __proc_info lists since we aren't running with the MMU on
145 * (and therefore, we are not in the correct address space). We have to
146 * calculate the offset.
150 * r3, r4, r6 corrupted
151 * r5 = proc_info pointer in physical address space
152 * r9 = cpuid (preserved)
154 .type __lookup_processor_type, %function
155 __lookup_processor_type:
158 sub r3, r3, r7 @ get offset between virt&phys
159 add r5, r5, r3 @ convert virt addresses to
160 add r6, r6, r3 @ physical address space
161 1: ldmia r5, {r3, r4} @ value, mask
162 and r4, r4, r9 @ mask wanted bits
165 add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)
168 mov r5, #0 @ unknown processor
172 * This provides a C-API version of the above function.
174 ENTRY(lookup_processor_type)
175 stmfd sp!, {r4 - r7, r9, lr}
177 bl __lookup_processor_type
179 ldmfd sp!, {r4 - r7, r9, pc}
182 * Look in include/asm-arm/procinfo.h and arch/arm/kernel/arch.[ch] for
183 * more information about the __proc_info and __arch_info structures.
185 .long __proc_info_begin
186 .long __proc_info_end
188 .long __arch_info_begin
189 .long __arch_info_end
192 * Lookup machine architecture in the linker-build list of architectures.
193 * Note that we can't use the absolute addresses for the __arch_info
194 * lists since we aren't running with the MMU on (and therefore, we are
195 * not in the correct address space). We have to calculate the offset.
197 * r1 = machine architecture number
199 * r3, r4, r6 corrupted
200 * r5 = mach_info pointer in physical address space
202 .type __lookup_machine_type, %function
203 __lookup_machine_type:
205 ldmia r3, {r4, r5, r6}
206 sub r3, r3, r4 @ get offset between virt&phys
207 add r5, r5, r3 @ convert virt addresses to
208 add r6, r6, r3 @ physical address space
209 1: ldr r3, [r5, #MACHINFO_TYPE] @ get machine type
210 teq r3, r1 @ matches loader number?
212 add r5, r5, #SIZEOF_MACHINE_DESC @ next machine_desc
215 mov r5, #0 @ unknown machine
219 * This provides a C-API version of the above function.
221 ENTRY(lookup_machine_type)
222 stmfd sp!, {r4 - r6, lr}
224 bl __lookup_machine_type
226 ldmfd sp!, {r4 - r6, pc}
228 /* Determine validity of the r2 atags pointer. The heuristic requires
229 * that the pointer be aligned, in the first 16k of physical RAM and
230 * that the ATAG_CORE marker is first and present. Future revisions
231 * of this function may be more lenient with the physical address and
232 * may also be able to move the ATAGS block if necessary.
237 * r2 either valid atags pointer, or zero
241 .type __vet_atags, %function
243 tst r2, #0x3 @ aligned?
246 ldr r5, [r2, #0] @ is first tag ATAG_CORE?
247 subs r5, r5, #ATAG_CORE_SIZE
254 mov pc, lr @ atag pointer is ok