arch/powerpc/purgatory/trampoline_64.S

Source file repositories/reference/linux-study-clean/arch/powerpc/purgatory/trampoline_64.S

File Facts

System
Linux kernel
Corpus path
arch/powerpc/purgatory/trampoline_64.S
Extension
.S
Size
3651 bytes
Lines
163
Domain
Architecture Layer
Bucket
arch/powerpc
Inferred role
Architecture Layer: arch/powerpc
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 <asm/asm-compat.h>
#include <asm/crashdump-ppc64.h>

	.balign 256
	.globl purgatory_start
purgatory_start:
	b	master

	/* ABI: possible run_at_load flag at 0x5c */
	.org purgatory_start + 0x5c
	.globl run_at_load
run_at_load:
	.long 0
	.size run_at_load, . - run_at_load

	/* ABI: slaves start at 60 with r3=phys */
	.org purgatory_start + 0x60
slave:
	b .
	/* ABI: end of copied region */
	.org purgatory_start + 0x100
	.size purgatory_start, . - purgatory_start

/*
 * The above 0x100 bytes at purgatory_start are replaced with the
 * code from the kernel (or next stage) by setup_purgatory().
 */

master:
	or	%r1,%r1,%r1	/* low priority to let other threads catchup */
	isync
	mr	%r17,%r3	/* save cpu id to r17 */
	mr	%r15,%r4	/* save physical address in reg15 */

	/* Work out where we're running */
	bcl	20, 31, 0f
0:	mflr	%r18

	/*
	 * Copy BACKUP_SRC_SIZE bytes from BACKUP_SRC_START to
	 * backup_start 8 bytes at a time.
	 *
	 * Use r3 = dest, r4 = src, r5 = size, r6 = count
	 */
	ld	%r3, (backup_start - 0b)(%r18)
	cmpdi	%cr0, %r3, 0
	beq	.Lskip_copy	/* skip if there is no backup region */
	lis	%r5, BACKUP_SRC_SIZE@h
	ori	%r5, %r5, BACKUP_SRC_SIZE@l
	cmpdi	%cr0, %r5, 0
	beq	.Lskip_copy	/* skip if copy size is zero */
	lis	%r4, BACKUP_SRC_START@h
	ori	%r4, %r4, BACKUP_SRC_START@l
	li	%r6, 0
.Lcopy_loop:
	ldx	%r0, %r6, %r4
	stdx	%r0, %r6, %r3
	addi	%r6, %r6, 8
	cmpld	%cr0, %r6, %r5
	blt	.Lcopy_loop

.Lskip_copy:
	or	%r3,%r3,%r3	/* ok now to high priority, lets boot */
	lis	%r6,0x1
	mtctr	%r6		/* delay a bit for slaves to catch up */
	bdnz	.		/* before we overwrite 0-100 again */

	/* load device-tree address */
	ld	%r3, (dt_offset - 0b)(%r18)
	mr	%r16,%r3	/* save dt address in reg16 */

Annotation

Implementation Notes