1/*
2 *  linux/arch/arm26/kernel/head.S
3 *
4 *  Copyright (C) 1994-2000 Russell King
5 *  Copyright (C) 2003 Ian Molton
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 *  26-bit kernel startup code
12 */
13#include <linux/linkage.h>
14#include <asm/mach-types.h>
15
16		.globl	swapper_pg_dir
17		.equ	swapper_pg_dir,	0x0207d000
18
19/*
20 * Entry point.
21 */
22		.section ".init.text",#alloc,#execinstr
23ENTRY(stext)
24
25__entry:
26		cmp	pc, #0x02000000
27		ldrlt	pc, LC0			@ if 0x01800000, call at 0x02080000
28		teq	r0, #0                  @ Check for old calling method
29		blne	oldparams		@ Move page if old
30
31		adr	r0, LC0
32		ldmib	r0, {r2-r5, sp}		@ Setup stack (and fetch other values)
33
34		mov	r0, #0			@ Clear BSS
351:		cmp	r2, r3
36		strcc	r0, [r2], #4
37		bcc	1b
38
39		bl	detect_proc_type
40		str	r0, [r4]
41		bl	detect_arch_type
42		str	r0, [r5]
43
44#ifdef CONFIG_XIP_KERNEL
45               ldr     r3, ETEXT                       @ data section copy
46               ldr     r4, SDATA
47               ldr     r5, EDATA
481:
49               ldr     r6, [r3], #4
50               str     r6, [r4], #4
51               cmp     r4, r5
52               blt     1b
53#endif
54		mov	fp, #0
55		b	start_kernel
56
57LC0:		.word	_stext
58		.word	__bss_start		@ r2
59		.word	_end			@ r3
60		.word	processor_id		@ r4
61		.word	__machine_arch_type	@ r5
62		.word	init_thread_union+8192	@ sp
63#ifdef CONFIG_XIP_KERNEL
64ETEXT:		.word   _endtext
65SDATA:		.word   _sdata
66EDATA:		.word   __bss_start
67#endif
68
69arm2_id:	.long	0x41560200  @ ARM2 and 250 dont have a CPUID
70arm250_id:	.long	0x41560250  @ So we create some after probing for them
71		.align
72
73oldparams:	mov     r4, #0x02000000
74		add	r3, r4, #0x00080000
75		add	r4, r4, #0x0007c000
761:		ldmia	r0!, {r5 - r12}
77		stmia	r4!, {r5 - r12}
78		cmp	r4, r3
79		blt	1b
80		mov	pc, lr
81
82/*
83 * We need some way to automatically detect the difference between
84 * these two machines.  Unfortunately, it is not possible to detect
85 * the presence of the SuperIO chip, because that will hang the old
86 * Archimedes machines solid.
87 */
88/* DAG: Outdated, these have been combined !!!!!!! */
89detect_arch_type:
90#if defined(CONFIG_ARCH_ARC)
91		mov	r0, #MACH_TYPE_ARCHIMEDES
92#elif defined(CONFIG_ARCH_A5K)
93		mov	r0, #MACH_TYPE_A5K
94#endif
95		mov	pc, lr
96
97detect_proc_type:
98		mov	ip, lr
99		mov	r2, #0xea000000		@ Point undef instr to continuation
100		adr	r0, continue - 12
101		orr	r0, r2, r0, lsr #2
102		mov	r1, #0
103		str	r0, [r1, #4]
104		ldr	r0, arm2_id
105		swp	r2, r2, [r1]		@ check for swp (ARM2 cant)
106		ldr	r0, arm250_id
107		mrc	15, 0, r3, c0, c0	@ check for CP#15 (ARM250 cant)
108		mov	r0, r3
109continue:	mov	r2, #0xeb000000		@ Make undef vector loop
110		sub	r2, r2, #2
111		str	r2, [r1, #4]
112		mov	pc, ip
113