| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $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 Mundt | d153ea8 | 2006-09-27 18:20:16 +0900 | [diff] [blame] | 14 | #include <asm/thread_info.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  | 
| Paul Mundt | b7e108e | 2006-09-27 15:00:04 +0900 | [diff] [blame] | 16 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | 	.section	.empty_zero_page, "aw" | 
 | 28 | ENTRY(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 Mundt | e2dfb91 | 2006-12-12 08:53:29 +0900 | [diff] [blame] | 36 | 1: | 
 | 37 | 	.skip	PAGE_SIZE - empty_zero_page - 1b | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  */ | 
 | 51 | ENTRY(_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 | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 57 | #ifdef CONFIG_CPU_HAS_SR_RB | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | 	ldc	r0, r6_bank | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 59 | #endif | 
 | 60 | 	 | 
| Paul Mundt | b7e108e | 2006-09-27 15:00:04 +0900 | [diff] [blame] | 61 | 	/* | 
 | 62 | 	 * Prefetch if possible to reduce cache miss penalty. | 
 | 63 | 	 * | 
 | 64 | 	 * We do this early on for SH-4A as a micro-optimization, | 
 | 65 | 	 * as later on we will have speculative execution enabled | 
 | 66 | 	 * and this will become less of an issue. | 
 | 67 | 	 */ | 
 | 68 | 	PREFI(5f, r0) | 
 | 69 | 	PREFI(6f, r0) | 
 | 70 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | 	! | 
 | 72 | 	mov.l	2f, r0 | 
 | 73 | 	mov	r0, r15		! Set initial r15 (stack pointer) | 
| Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 74 | 	mov	#(THREAD_SIZE >> 10), r1 | 
| Paul Mundt | a6a31139 | 2006-09-27 18:22:14 +0900 | [diff] [blame] | 75 | 	shll8	r1		! r1 = THREAD_SIZE | 
| Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 76 | 	shll2	r1 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | 	sub	r1, r0		! | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 78 | #ifdef CONFIG_CPU_HAS_SR_RB | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | 	ldc	r0, r7_bank	! ... and initial thread_info | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 80 | #endif | 
 | 81 | 	 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | 	!			Clear BSS area | 
 | 83 | 	mov.l	3f, r1 | 
 | 84 | 	add	#4, r1 | 
 | 85 | 	mov.l	4f, r2 | 
 | 86 | 	mov	#0, r0 | 
 | 87 | 9:	cmp/hs	r2, r1 | 
 | 88 | 	bf/s	9b		! while (r1 < r2) | 
 | 89 | 	 mov.l	r0,@-r2 | 
| Paul Mundt | b7e108e | 2006-09-27 15:00:04 +0900 | [diff] [blame] | 90 |  | 
 | 91 | 	!			Additional CPU initialization | 
 | 92 | 	mov.l	6f, r0 | 
 | 93 | 	jsr	@r0 | 
 | 94 | 	 nop | 
 | 95 |  | 
 | 96 | 	SYNCO()			! Wait for pending instructions.. | 
 | 97 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | 	!			Start kernel | 
 | 99 | 	mov.l	5f, r0 | 
 | 100 | 	jmp	@r0 | 
 | 101 | 	 nop | 
 | 102 |  | 
 | 103 | 	.balign 4 | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 104 | #if defined(CONFIG_CPU_SH2) | 
 | 105 | 1:	.long	0x000000F0		! IMASK=0xF | 
 | 106 | #else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | 1:	.long	0x400080F0		! MD=1, RB=0, BL=0, FD=1, IMASK=0xF | 
| Yoshinori Sato | de39840 | 2006-11-05 16:15:19 +0900 | [diff] [blame] | 108 | #endif | 
| Paul Mundt | d153ea8 | 2006-09-27 18:20:16 +0900 | [diff] [blame] | 109 | 2:	.long	init_thread_union+THREAD_SIZE | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | 3:	.long	__bss_start | 
 | 111 | 4:	.long	_end | 
 | 112 | 5:	.long	start_kernel | 
 | 113 | 6:	.long	sh_cpu_init |