arch/powerpc/boot/crt0.S

Source file repositories/reference/linux-study-clean/arch/powerpc/boot/crt0.S

File Facts

System
Linux kernel
Corpus path
arch/powerpc/boot/crt0.S
Extension
.S
Size
6812 bytes
Lines
309
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 "ppc_asm.h"

RELA = 7
RELASZ = 8
RELAENT = 9

	.data
	/* A procedure descriptor used when booting this as a COFF file.
	 * When making COFF, this comes first in the link and we're
	 * linked at 0x500000.
	 */
	.globl	_zimage_start_opd
_zimage_start_opd:
	.long	0x500000, 0, 0, 0
	.text
	b	_zimage_start

#ifdef __powerpc64__
.balign 8
p_start:	.8byte	_start
p_etext:	.8byte	_etext
p_bss_start:	.8byte	__bss_start
p_end:		.8byte	_end

p_toc:		.8byte	.TOC. - p_base
p_dyn:		.8byte	__dynamic_start - p_base
p_rela:		.8byte	__rela_dyn_start - p_base
p_prom:		.8byte	0
	.weak	_platform_stack_top
p_pstack:	.8byte	_platform_stack_top
#else
p_start:	.long	_start
p_etext:	.long	_etext
p_bss_start:	.long	__bss_start
p_end:		.long	_end

	.weak	_platform_stack_top
p_pstack:	.long	_platform_stack_top
#endif

	.weak	_zimage_start
_zimage_start:
	.globl	_zimage_start_lib
_zimage_start_lib:
	/* Work out the offset between the address we were linked at
	   and the address where we're running. */
	bcl	20,31,.+4
p_base:	mflr	r10		/* r10 now points to runtime addr of p_base */
#ifndef __powerpc64__
	/* grab the link address of the dynamic section in r11 */
	addis	r11,r10,(_GLOBAL_OFFSET_TABLE_-p_base)@ha
	lwz	r11,(_GLOBAL_OFFSET_TABLE_-p_base)@l(r11)
	cmpwi	r11,0
	beq	3f		/* if not linked -pie */
	/* get the runtime address of the dynamic section in r12 */
	.weak	__dynamic_start
	addis	r12,r10,(__dynamic_start-p_base)@ha
	addi	r12,r12,(__dynamic_start-p_base)@l
	subf	r11,r11,r12	/* runtime - linktime offset */

	/* The dynamic section contains a series of tagged entries.
	 * We need the RELA and RELACOUNT entries. */
	li	r9,0
	li	r0,0
9:	lwz	r8,0(r12)	/* get tag */
	cmpwi	r8,0
	beq	10f		/* end of list */
	cmpwi	r8,RELA
	bne	11f
	lwz	r9,4(r12)	/* get RELA pointer in r9 */

Annotation

Implementation Notes