blob: 3e7d00b7985a21f6282c782c1529d2068e7f7f06 [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>
15#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Paul Mundtb7e108e2006-09-27 15:00:04 +090017#ifdef CONFIG_CPU_SH4A
18#define SYNCO() synco
19
20#define PREFI(label, reg) \
21 mov.l label, reg; \
22 prefi @reg
23#else
24#define SYNCO()
25#define PREFI(label, reg)
26#endif
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 .section .empty_zero_page, "aw"
29ENTRY(empty_zero_page)
30 .long 1 /* MOUNT_ROOT_RDONLY */
31 .long 0 /* RAMDISK_FLAGS */
32 .long 0x0200 /* ORIG_ROOT_DEV */
33 .long 1 /* LOADER_TYPE */
34 .long 0x00360000 /* INITRD_START */
35 .long 0x000a0000 /* INITRD_SIZE */
36 .long 0
37 .balign 4096,0,4096
38
39 .text
40/*
41 * Condition at the entry of _stext:
42 *
43 * BSC has already been initialized.
44 * INTC may or may not be initialized.
45 * VBR may or may not be initialized.
46 * MMU may or may not be initialized.
47 * Cache may or may not be initialized.
48 * Hardware (including on-chip modules) may or may not be initialized.
49 *
50 */
51ENTRY(_stext)
52 ! Initialize Status Register
53 mov.l 1f, r0 ! MD=1, RB=0, BL=0, IMASK=0xF
54 ldc r0, sr
55 ! Initialize global interrupt mask
56 mov #0, r0
57 ldc r0, r6_bank
Paul Mundtb7e108e2006-09-27 15:00:04 +090058
59 /*
60 * Prefetch if possible to reduce cache miss penalty.
61 *
62 * We do this early on for SH-4A as a micro-optimization,
63 * as later on we will have speculative execution enabled
64 * and this will become less of an issue.
65 */
66 PREFI(5f, r0)
67 PREFI(6f, r0)
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 !
70 mov.l 2f, r0
71 mov r0, r15 ! Set initial r15 (stack pointer)
72 mov #0x20, r1 !
73 shll8 r1 ! r1 = 8192
74 sub r1, r0 !
75 ldc r0, r7_bank ! ... and initial thread_info
Paul Mundtb7e108e2006-09-27 15:00:04 +090076
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 ! Clear BSS area
78 mov.l 3f, r1
79 add #4, r1
80 mov.l 4f, r2
81 mov #0, r0
829: cmp/hs r2, r1
83 bf/s 9b ! while (r1 < r2)
84 mov.l r0,@-r2
Paul Mundtb7e108e2006-09-27 15:00:04 +090085
86 ! Additional CPU initialization
87 mov.l 6f, r0
88 jsr @r0
89 nop
90
91 SYNCO() ! Wait for pending instructions..
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 ! Start kernel
94 mov.l 5f, r0
95 jmp @r0
96 nop
97
98 .balign 4
991: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
Paul Mundtd153ea82006-09-27 18:20:16 +09001002: .long init_thread_union+THREAD_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013: .long __bss_start
1024: .long _end
1035: .long start_kernel
1046: .long sh_cpu_init