blob: 6aca4bc6ec5d55e5dd649edb36be0aa3702d7925 [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 Mundt510c72ad2006-11-27 12:06:26 +090036 .balign PAGE_SIZE,0,PAGE_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38 .text
39/*
40 * Condition at the entry of _stext:
41 *
42 * BSC has already been initialized.
43 * INTC may or may not be initialized.
44 * VBR may or may not be initialized.
45 * MMU may or may not be initialized.
46 * Cache may or may not be initialized.
47 * Hardware (including on-chip modules) may or may not be initialized.
48 *
49 */
50ENTRY(_stext)
51 ! Initialize Status Register
52 mov.l 1f, r0 ! MD=1, RB=0, BL=0, IMASK=0xF
53 ldc r0, sr
54 ! Initialize global interrupt mask
55 mov #0, r0
Yoshinori Satode398402006-11-05 16:15:19 +090056#ifdef CONFIG_CPU_HAS_SR_RB
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 ldc r0, r6_bank
Yoshinori Satode398402006-11-05 16:15:19 +090058#endif
59
Paul Mundtb7e108e2006-09-27 15:00:04 +090060 /*
61 * Prefetch if possible to reduce cache miss penalty.
62 *
63 * We do this early on for SH-4A as a micro-optimization,
64 * as later on we will have speculative execution enabled
65 * and this will become less of an issue.
66 */
67 PREFI(5f, r0)
68 PREFI(6f, r0)
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 !
71 mov.l 2f, r0
72 mov r0, r15 ! Set initial r15 (stack pointer)
Paul Mundt510c72ad2006-11-27 12:06:26 +090073 mov #(THREAD_SIZE >> 10), r1
Paul Mundta6a311392006-09-27 18:22:14 +090074 shll8 r1 ! r1 = THREAD_SIZE
Paul Mundt510c72ad2006-11-27 12:06:26 +090075 shll2 r1
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 sub r1, r0 !
Yoshinori Satode398402006-11-05 16:15:19 +090077#ifdef CONFIG_CPU_HAS_SR_RB
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 ldc r0, r7_bank ! ... and initial thread_info
Yoshinori Satode398402006-11-05 16:15:19 +090079#endif
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 ! Clear BSS area
82 mov.l 3f, r1
83 add #4, r1
84 mov.l 4f, r2
85 mov #0, r0
869: cmp/hs r2, r1
87 bf/s 9b ! while (r1 < r2)
88 mov.l r0,@-r2
Paul Mundtb7e108e2006-09-27 15:00:04 +090089
90 ! Additional CPU initialization
91 mov.l 6f, r0
92 jsr @r0
93 nop
94
95 SYNCO() ! Wait for pending instructions..
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 ! Start kernel
98 mov.l 5f, r0
99 jmp @r0
100 nop
101
102 .balign 4
Yoshinori Satode398402006-11-05 16:15:19 +0900103#if defined(CONFIG_CPU_SH2)
1041: .long 0x000000F0 ! IMASK=0xF
105#else
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
Yoshinori Satode398402006-11-05 16:15:19 +0900107#endif
Paul Mundtd153ea82006-09-27 18:20:16 +09001082: .long init_thread_union+THREAD_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093: .long __bss_start
1104: .long _end
1115: .long start_kernel
1126: .long sh_cpu_init