summaryrefslogtreecommitdiff
path: root/src/arch/ppc/init/crt0.S.lb
blob: be54d03d20af7405ba04f161d9c60b5c741ca195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright 2000  AG Electronics Ltd. */
/* This code is distributed without warranty under the GPL v2 (see COPYING) */

#define ASM
#include "ppcreg.h"
#include <ppc_asm.tmpl>

.section ".rom.reset", "ax", @progbits

.globl _start
_start:
	b	system_reset

%%EXCEPTION_VECTOR_TABLE%%

.section ".rom.data", "a", @progbits
.section ".rom.text", "ax", @progbits

system_reset:

%%EARLY_INIT%%

start_payload:
	/*
	 * Relocate payload (text & data) to ram
	 */
	lis     r3, _liseg@ha
	addi    r3, r3, _liseg@l
	lis     r4, _iseg@ha
	addi    r4, r4, _iseg@l

	/*
	 * Skip if they're the same
	 */
	cmp     0, 0, r3, r4
	beq     1f

	lis     r7, _eliseg@ha
	addi    r7, r7, _eliseg@l

2:
	lwzx	r5, 0, r3
	stwx	r5, 0, r4
	addi    r3, r3, 4
	addi    r4, r4, 4
	cmp     0, 0, r3, r7
	ble     2b

1:
	/*
	 * Start payload
	 */
	b  	_iseg

%%NORTHBRIDGE_INIT%%