diff options
Diffstat (limited to 'arch/ppc64/boot/crt0.S')
-rw-r--r-- | arch/ppc64/boot/crt0.S | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/ppc64/boot/crt0.S b/arch/ppc64/boot/crt0.S new file mode 100644 index 000000000000..04d3e74cd72f --- /dev/null +++ b/arch/ppc64/boot/crt0.S | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * NOTE: this code runs in 32 bit mode and is packaged as ELF32. | ||
10 | */ | ||
11 | |||
12 | #include <asm/ppc_asm.h> | ||
13 | |||
14 | .text | ||
15 | .globl _start | ||
16 | _start: | ||
17 | lis r9,_start@h | ||
18 | lis r8,_etext@ha | ||
19 | addi r8,r8,_etext@l | ||
20 | 1: dcbf r0,r9 | ||
21 | icbi r0,r9 | ||
22 | addi r9,r9,0x20 | ||
23 | cmplwi 0,r9,8 | ||
24 | blt 1b | ||
25 | sync | ||
26 | isync | ||
27 | |||
28 | ## Clear out the BSS as per ANSI C requirements | ||
29 | |||
30 | lis r7,_end@ha | ||
31 | addi r7,r7,_end@l # r7 = &_end | ||
32 | lis r8,__bss_start@ha # | ||
33 | addi r8,r8,__bss_start@l # r8 = &_bss_start | ||
34 | |||
35 | ## Determine how large an area, in number of words, to clear | ||
36 | |||
37 | subf r7,r8,r7 # r7 = &_end - &_bss_start + 1 | ||
38 | addi r7,r7,3 # r7 += 3 | ||
39 | srwi. r7,r7,2 # r7 = size in words. | ||
40 | beq 3f # If the size is zero, don't bother | ||
41 | addi r8,r8,-4 # r8 -= 4 | ||
42 | mtctr r7 # SPRN_CTR = number of words to clear | ||
43 | li r0,0 # r0 = 0 | ||
44 | 2: stwu r0,4(r8) # Clear out a word | ||
45 | bdnz 2b # Keep clearing until done | ||
46 | 3: | ||
47 | b start | ||
48 | |||