1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* |
3 | * linux/arch/sh/boot/compressed/head.S |
4 | * |
5 | * Copyright (C) 1999 Stuart Menefy |
6 | * Copyright (C) 2003 SUGIOKA Toshinobu |
7 | */ |
8 | |
9 | .text |
10 | |
11 | #include <asm/page.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 #0xffffffe0, 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 0x500000F0 /* Privileged mode, Bank=0, Block=1, IMASK=0xF */ |
96 | kexec_magic: |
97 | .long 0x400000F0 /* magic used by kexec to parse zImage format */ |
98 | init_stack_addr: |
99 | .long stack_start |
100 | decompress_kernel_addr: |
101 | .long decompress_kernel |
102 | kernel_start_addr: |
103 | #ifdef CONFIG_32BIT |
104 | .long ___pa(_text+PAGE_SIZE) |
105 | #else |
106 | .long _text+PAGE_SIZE |
107 | #endif |
108 | |
109 | .align 9 |
110 | fake_headers_as_bzImage: |
111 | .word 0 |
112 | .ascii "HdrS" ! header signature |
113 | .word 0x0202 ! header version number (>= 0x0105) |
114 | ! or else old loadlin-1.5 will fail) |
115 | .word 0 ! default_switch |
116 | .word 0 ! SETUPSEG |
117 | .word 0x1000 |
118 | .word 0 ! pointing to kernel version string |
119 | .byte 0 ! = 0, old one (LILO, Loadlin, |
120 | ! 0xTV: T=0 for LILO |
121 | ! V = version |
122 | .byte 1 ! Load flags bzImage=1 |
123 | .word 0x8000 ! size to move, when setup is not |
124 | .long 0x100000 ! 0x100000 = default for big kernel |
125 | .long 0 ! address of loaded ramdisk image |
126 | .long 0 # its size in bytes |
127 | |