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