| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  *  linux/arch/sh/boot/compressed/head.S | 
 | 3 |  * | 
 | 4 |  *  Copyright (C) 1999 Stuart Menefy | 
 | 5 |  *  Copyright (C) 2003 SUGIOKA Toshinobu | 
 | 6 |  */ | 
 | 7 |  | 
 | 8 | .text | 
 | 9 |  | 
 | 10 | #include <linux/config.h> | 
 | 11 | #include <linux/linkage.h> | 
 | 12 |  | 
 | 13 | 	.global	startup | 
 | 14 | startup: | 
 | 15 | 	/* Load initial status register */ | 
 | 16 | 	mov.l   init_sr, r1 | 
 | 17 | 	ldc     r1, sr | 
 | 18 |  | 
 | 19 | 	/* Move myself to proper location if necessary */ | 
 | 20 | 	mova	1f, r0 | 
 | 21 | 	mov.l	1f, r2 | 
 | 22 | 	cmp/eq	r2, r0 | 
 | 23 | 	bt	clear_bss | 
 | 24 | 	sub	r0, r2 | 
 | 25 | 	mov.l	bss_start_addr, r0 | 
 | 26 | 	mov	#0xe0, r1 | 
 | 27 | 	and	r1, r0			! align cache line | 
 | 28 | 	mov.l	text_start_addr, r3 | 
 | 29 | 	mov	r0, r1 | 
 | 30 | 	sub	r2, r1 | 
 | 31 | 3: | 
 | 32 | 	mov.l	@r1, r4 | 
 | 33 | 	mov.l	@(4,r1), r5 | 
 | 34 | 	mov.l	@(8,r1), r6 | 
 | 35 | 	mov.l	@(12,r1), r7 | 
 | 36 | 	mov.l	@(16,r1), r8 | 
 | 37 | 	mov.l	@(20,r1), r9 | 
 | 38 | 	mov.l	@(24,r1), r10 | 
 | 39 | 	mov.l	@(28,r1), r11 | 
 | 40 | 	mov.l	r4, @r0 | 
 | 41 | 	mov.l	r5, @(4,r0) | 
 | 42 | 	mov.l	r6, @(8,r0) | 
 | 43 | 	mov.l	r7, @(12,r0) | 
 | 44 | 	mov.l	r8, @(16,r0) | 
 | 45 | 	mov.l	r9, @(20,r0) | 
 | 46 | 	mov.l	r10, @(24,r0) | 
 | 47 | 	mov.l	r11, @(28,r0) | 
 | 48 | #ifdef CONFIG_CPU_SH4 | 
 | 49 | 	ocbwb	@r0 | 
 | 50 | #endif | 
 | 51 | 	cmp/hi	r3, r0 | 
 | 52 | 	add	#-32, r0 | 
 | 53 | 	bt/s	3b | 
 | 54 | 	 add	#-32, r1 | 
 | 55 | 	mov.l	2f, r0 | 
 | 56 | 	jmp	@r0 | 
 | 57 | 	 nop | 
 | 58 |  | 
 | 59 | 	.align 2 | 
 | 60 | 1:	.long	1b | 
 | 61 | 2:	.long	clear_bss | 
 | 62 | text_start_addr: | 
 | 63 | 	.long	startup | 
 | 64 |  | 
 | 65 | 	/* Clear BSS */ | 
 | 66 | clear_bss: | 
 | 67 | 	mov.l	end_addr, r1 | 
 | 68 | 	mov.l	bss_start_addr, r2 | 
 | 69 | 	mov	#0, r0 | 
 | 70 | l1: | 
 | 71 | 	mov.l	r0, @-r1 | 
 | 72 | 	cmp/eq	r1,r2 | 
 | 73 | 	bf	l1 | 
 | 74 |  | 
 | 75 | 	/* Set the initial pointer. */ | 
 | 76 | 	mov.l	init_stack_addr, r0 | 
 | 77 | 	mov.l	@r0, r15 | 
 | 78 |  | 
 | 79 | 	/* Decompress the kernel */ | 
 | 80 | 	mov.l	decompress_kernel_addr, r0 | 
 | 81 | 	jsr	@r0 | 
 | 82 | 	nop | 
 | 83 |  | 
 | 84 | 	/* Jump to the start of the decompressed kernel */ | 
 | 85 | 	mov.l	kernel_start_addr, r0 | 
 | 86 | 	jmp	@r0 | 
 | 87 | 	nop | 
 | 88 | 	 | 
 | 89 | 	.align	2 | 
 | 90 | bss_start_addr: | 
 | 91 | 	.long	__bss_start | 
 | 92 | end_addr: | 
 | 93 | 	.long	_end | 
 | 94 | init_sr: | 
 | 95 | 	.long	0x400000F0	/* Privileged mode, Bank=0, Block=0, IMASK=0xF */ | 
 | 96 | init_stack_addr: | 
 | 97 | 	.long	stack_start | 
 | 98 | decompress_kernel_addr: | 
 | 99 | 	.long	decompress_kernel | 
 | 100 | kernel_start_addr: | 
 | 101 | 	.long	_text+0x1000 | 
 | 102 |  | 
 | 103 | 	.align	9 | 
 | 104 | fake_headers_as_bzImage: | 
 | 105 | 	.word	0 | 
 | 106 | 	.ascii	"HdrS"		! header signature | 
 | 107 | 	.word	0x0202		! header version number (>= 0x0105) | 
 | 108 | 				! or else old loadlin-1.5 will fail) | 
 | 109 | 	.word	0		! default_switch | 
 | 110 | 	.word	0		! SETUPSEG | 
 | 111 | 	.word	0x1000 | 
 | 112 | 	.word	0		! pointing to kernel version string | 
 | 113 | 	.byte	0		! = 0, old one (LILO, Loadlin, | 
 | 114 | 				! 0xTV: T=0 for LILO | 
 | 115 | 				!       V = version | 
 | 116 | 	.byte	1		! Load flags bzImage=1 | 
 | 117 | 	.word	0x8000		! size to move, when setup is not | 
 | 118 | 	.long	0x100000	! 0x100000 = default for big kernel | 
 | 119 | 	.long	0		! address of loaded ramdisk image | 
 | 120 | 	.long	0		# its size in bytes |