arch/sh/kernel/relocate_kernel.S

Source file repositories/reference/linux-study-clean/arch/sh/kernel/relocate_kernel.S

File Facts

System
Linux kernel
Corpus path
arch/sh/kernel/relocate_kernel.S
Extension
.S
Size
4088 bytes
Lines
231
Domain
Architecture Layer
Bucket
arch/sh
Inferred role
Architecture Layer: arch/sh
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/linkage.h>
#include <asm/addrspace.h>
#include <asm/page.h>

		.globl relocate_new_kernel
relocate_new_kernel:
	/* r4 = indirection_page   */
	/* r5 = reboot_code_buffer */
	/* r6 = start_address      */

	mov.l	10f, r0		/* PAGE_SIZE */
	add	r5, r0		/* setup new stack at end of control page */

	/* save r15->r8 to new stack */
	mov.l	r15, @-r0
	mov	r0, r15
	mov.l	r14, @-r15
	mov.l	r13, @-r15
	mov.l	r12, @-r15
	mov.l	r11, @-r15
	mov.l	r10, @-r15
	mov.l	r9, @-r15
	mov.l	r8, @-r15

	/* save other random registers */
	sts.l	macl, @-r15
	sts.l	mach, @-r15
	stc.l	gbr, @-r15
	stc.l	ssr, @-r15
	stc.l	sr, @-r15
	sts.l	pr, @-r15
	stc.l	spc, @-r15

	/* switch to bank1 and save r7->r0 */
	mov.l	12f, r9
	stc	sr, r8
	or	r9, r8
	ldc	r8, sr
	mov.l	r7, @-r15
	mov.l	r6, @-r15
	mov.l	r5, @-r15
	mov.l	r4, @-r15
	mov.l	r3, @-r15
	mov.l	r2, @-r15
	mov.l	r1, @-r15
	mov.l	r0, @-r15

	/* switch to bank0 and save r7->r0 */
	mov.l	12f, r9
	not	r9, r9
	stc	sr, r8
	and	r9, r8
	ldc	r8, sr
	mov.l	r7, @-r15
	mov.l	r6, @-r15
	mov.l	r5, @-r15
	mov.l	r4, @-r15
	mov.l	r3, @-r15
	mov.l	r2, @-r15
	mov.l	r1, @-r15
	mov.l	r0, @-r15

	mov.l	r4, @-r15	/* save indirection page again */

	bsr	swap_pages	/* swap pages before jumping to new kernel */
	 nop

	mova	11f, r0
	mov.l	r15, @r0	/* save pointer to stack */

Annotation

Implementation Notes