blob: 3338239717f108f2d03f4779eecd7e9ed865ebe3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: head.S,v 1.7 2003/09/01 17:58:19 lethal Exp $
2 *
3 * arch/sh/kernel/head.S
4 *
5 * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * Head.S contains the SH exception handlers and startup code.
12 */
13#include <linux/linkage.h>
Paul Mundtd153ea82006-09-27 18:20:16 +090014#include <asm/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Paul Mundtb7e108e2006-09-27 15:00:04 +090016#ifdef CONFIG_CPU_SH4A
17#define SYNCO() synco
18
19#define PREFI(label, reg) \
20 mov.l label, reg; \
21 prefi @reg
22#else
23#define SYNCO()
24#define PREFI(label, reg)
25#endif
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 .section .empty_zero_page, "aw"
28ENTRY(empty_zero_page)
29 .long 1 /* MOUNT_ROOT_RDONLY */
30 .long 0 /* RAMDISK_FLAGS */
31 .long 0x0200 /* ORIG_ROOT_DEV */
32 .long 1 /* LOADER_TYPE */
33 .long 0x00360000 /* INITRD_START */
34 .long 0x000a0000 /* INITRD_SIZE */
35 .long 0
Paul Mundte2dfb912006-12-12 08:53:29 +0900361:
37 .skip PAGE_SIZE - empty_zero_page - 1b
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Paul Mundt339547b2007-07-20 17:40:03 +090039 .section .text.head, "ax"
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/*
42 * Condition at the entry of _stext:
43 *
44 * BSC has already been initialized.
45 * INTC may or may not be initialized.
46 * VBR may or may not be initialized.
47 * MMU may or may not be initialized.
48 * Cache may or may not be initialized.
49 * Hardware (including on-chip modules) may or may not be initialized.
50 *
51 */
52ENTRY(_stext)
53 ! Initialize Status Register
54 mov.l 1f, r0 ! MD=1, RB=0, BL=0, IMASK=0xF
55 ldc r0, sr
56 ! Initialize global interrupt mask
Yoshinori Satode398402006-11-05 16:15:19 +090057#ifdef CONFIG_CPU_HAS_SR_RB
Paul Mundtaba10302007-09-21 18:32:32 +090058 mov #0, r0
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 ldc r0, r6_bank
Yoshinori Satode398402006-11-05 16:15:19 +090060#endif
61
Paul Mundtb7e108e2006-09-27 15:00:04 +090062 /*
63 * Prefetch if possible to reduce cache miss penalty.
64 *
65 * We do this early on for SH-4A as a micro-optimization,
66 * as later on we will have speculative execution enabled
67 * and this will become less of an issue.
68 */
69 PREFI(5f, r0)
70 PREFI(6f, r0)
71
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 !
73 mov.l 2f, r0
74 mov r0, r15 ! Set initial r15 (stack pointer)
Yoshinori Satode398402006-11-05 16:15:19 +090075#ifdef CONFIG_CPU_HAS_SR_RB
Paul Mundtaba10302007-09-21 18:32:32 +090076 mov.l 7f, r0
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 ldc r0, r7_bank ! ... and initial thread_info
Yoshinori Satode398402006-11-05 16:15:19 +090078#endif
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 ! Clear BSS area
Paul Mundtaba10302007-09-21 18:32:32 +090081#ifdef CONFIG_SMP
82 mov.l 3f, r0
83 cmp/eq #0, r0 ! skip clear if set to zero
84 bt 10f
85#endif
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 mov.l 3f, r1
88 add #4, r1
89 mov.l 4f, r2
90 mov #0, r0
919: cmp/hs r2, r1
92 bf/s 9b ! while (r1 < r2)
93 mov.l r0,@-r2
Paul Mundtb7e108e2006-09-27 15:00:04 +090094
Paul Mundtaba10302007-09-21 18:32:32 +09009510:
Paul Mundtb7e108e2006-09-27 15:00:04 +090096 ! Additional CPU initialization
97 mov.l 6f, r0
98 jsr @r0
99 nop
100
101 SYNCO() ! Wait for pending instructions..
Paul Mundtaba10302007-09-21 18:32:32 +0900102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 ! Start kernel
104 mov.l 5f, r0
105 jmp @r0
106 nop
107
108 .balign 4
Yoshinori Satode398402006-11-05 16:15:19 +0900109#if defined(CONFIG_CPU_SH2)
1101: .long 0x000000F0 ! IMASK=0xF
111#else
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
Yoshinori Satode398402006-11-05 16:15:19 +0900113#endif
Paul Mundtaba10302007-09-21 18:32:32 +0900114ENTRY(stack_start)
Paul Mundtd153ea82006-09-27 18:20:16 +09001152: .long init_thread_union+THREAD_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163: .long __bss_start
1174: .long _end
1185: .long start_kernel
1196: .long sh_cpu_init
Paul Mundtaba10302007-09-21 18:32:32 +09001207: .long init_thread_union