1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/arch/m32r/kernel/head.S
7 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata,
11 #include <linux/init.h>
16 #include <linux/linkage.h>
17 #include <asm/segment.h>
19 #include <asm/pgtable.h>
20 #include <asm/assembler.h>
22 #include <asm/mmu_context.h>
25 * References to members of the boot_cpu_data structure.
33 /* Setup up the stack pointer */
34 LDIMM (r0, spi_stack_top)
35 LDIMM (r1, spu_stack_top)
40 ldi r0, #0x0000 /* use SPI, disable EI */
43 /* Set up the stack pointer */
44 LDIMM (r0, stack_start)
49 * Clear BSS first so that there are no surprises...
51 #ifdef CONFIG_ISA_DUAL_ISSUE
53 LDIMM (r2, __bss_start)
55 sub r3, r2 ; BSS size in bytes
56 ; R4 = BSS size in longwords (rounded down)
57 mv r4, r3 || ldi r1, #0
58 srli r4, #4 || addi r2, #-4
61 #ifndef CONFIG_CHIP_M32310
62 ; Touch memory for the no-write-allocating cache.
65 st r1, @+r2 || addi r4, #-1
68 st r1, @+r2 || cmpeq r1, r4 ; R4 = 0?
75 stb r1, @r2 || addi r4, #-1
80 #else /* not CONFIG_ISA_DUAL_ISSUE */
82 LDIMM (r2, __bss_start)
84 sub r3, r2 ; BSS size in bytes
86 srli r4, #2 ; R4 = BSS size in longwords (rounded down)
87 ldi r1, #0 ; clear R1 for longwords store
88 addi r2, #-4 ; account for pre-inc store
89 beqz r4, .Lendloop1 ; any more to go?
91 st r1, @+r2 ; yep, zero out another longword
92 addi r4, #-1 ; decrement count
93 bnez r4, .Lloop1 ; go do some more
95 and3 r4, r3, #3 ; get no. of remaining BSS bytes to clear
96 addi r2, #4 ; account for pre-inc store
97 beqz r4, .Lendloop2 ; any more to go?
99 stb r1, @r2 ; yep, zero out another byte
100 addi r2, #1 ; bump address
101 addi r4, #-1 ; decrement count
102 bnez r4, .Lloop2 ; go do some more
105 #endif /* not CONFIG_ISA_DUAL_ISSUE */
107 #if 0 /* M32R_FIXME */
109 * Copy data segment from ROM to RAM.
111 .global ROM_D, TOP_DATA, END_DATA
126 LDIMM (r2, start_kernel)
130 bra 1b ; main should never return here, but
131 ; just in case, we know what happens.
140 LDIMM (r4, eit_vector)
147 or3 r4, r4, #low(MATM)
149 st r5, @r4 ; Set MATM Reg(T bit ON)
150 ld r6, @r4 ; MATM Check
157 ld r6, @r4 ; MATM Check
158 seth r4, #high(M32R_ICU_ISTS_ADDR)
159 or3 r4, r4, #low(M32R_ICU_ISTS_ADDR)
160 ld r5, @r4 ; Read ISTSi reg.
162 slli r5, #13 ; PIML check
164 seth r4, #high(M32R_ICU_IMASK_ADDR)
165 or3 r4, r4, #low(M32R_ICU_IMASK_ADDR)
166 st r5, @r4 ; Write IMASKi reg.
167 slli r6, #4 ; ISN check
169 seth r4, #high(M32R_IRQ_IPI5)
170 or3 r4, r4, #low(M32R_IRQ_IPI5)
171 bne r4, r6, 2f ; if (ISN != CPU_BOOT_IPI) goto sleep;
173 ;; check cpu_bootout_map and set cpu_bootin_map
174 LDIMM (r4, cpu_bootout_map)
176 seth r5, #high(M32R_CPUID_PORTL)
177 or3 r5, r5, #low(M32R_CPUID_PORTL)
183 LDIMM (r4, cpu_bootin_map)
193 LDIMM (r4, stack_start)
197 ;; setup BPC (start_secondary)
198 LDIMM (r4, start_secondary)
201 rte ; goto startup_secondary
209 or3 r4, r4, #low(MATM)
211 st r5, @r4 ; Set MATM Reg(T bit OFF)
212 ld r6, @r4 ; MATM Check
214 seth r5, #high(__PAGE_OFFSET)
215 or3 r5, r5, #low(__PAGE_OFFSET)
222 ;; SLEEP and wait IPI
224 seth r5, #high(__PAGE_OFFSET)
225 or3 r5, r5, #low(__PAGE_OFFSET)
231 #endif /* CONFIG_SMP */
235 .long init_thread_union+8192
239 * This is initialized to create a identity-mapping at 0-4M (for bootup
240 * purposes) and another mapping of the 0-4M area at virtual address
245 #define MOUNT_ROOT_RDONLY 1
246 #define RAMDISK_FLAGS 0 ; 1024KB
247 #define ORIG_ROOT_DEV 0x0100 ; /dev/ram0 (major:01, minor:00)
248 #define LOADER_TYPE 1 ; (??? - non-zero value seems
249 ; to be needed to boot from initrd)
251 #define COMMAND_LINE ""
253 .section .empty_zero_page, "aw"
254 ENTRY(empty_zero_page)
255 .long MOUNT_ROOT_RDONLY /* offset: +0x00 */
259 .long 0 /* INITRD_START */ /* +0x10 */
260 .long 0 /* INITRD_SIZE */
261 .long 0 /* CPU_CLOCK */
262 .long 0 /* BUS_CLOCK */
263 .long 0 /* TIMER_DIVIDE */ /* +0x20 */
269 /*------------------------------------------------------------------------
272 .section .init.data, "aw"
274 .global spi_stack_top
278 .section .init.data, "aw"
280 .global spu_stack_top