diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc/boot/common/crt0.S |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/ppc/boot/common/crt0.S')
-rw-r--r-- | arch/ppc/boot/common/crt0.S | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/arch/ppc/boot/common/crt0.S b/arch/ppc/boot/common/crt0.S new file mode 100644 index 000000000000..4d31b824bbd1 --- /dev/null +++ b/arch/ppc/boot/common/crt0.S | |||
@@ -0,0 +1,81 @@ | |||
1 | /* Copyright (c) 1997 Paul Mackerras <paulus@cs.anu.edu.au> | ||
2 | * Initial Power Macintosh COFF version. | ||
3 | * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu> | ||
4 | * Modifications for IBM PowerPC 400-class processor evaluation | ||
5 | * boards. | ||
6 | * | ||
7 | * Module name: crt0.S | ||
8 | * | ||
9 | * Description: | ||
10 | * Boot loader execution entry point. Clears out .bss section as per | ||
11 | * ANSI C requirements. Invalidates and flushes the caches over the | ||
12 | * range covered by the boot loader's .text section. Sets up a stack | ||
13 | * below the .text section entry point. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License | ||
17 | * as published by the Free Software Foundation; either version | ||
18 | * 2 of the License, or (at your option) any later version. | ||
19 | */ | ||
20 | |||
21 | #include <linux/config.h> | ||
22 | #include <asm/ppc_asm.h> | ||
23 | |||
24 | .text | ||
25 | |||
26 | .globl _start | ||
27 | _start: | ||
28 | #ifdef XCOFF | ||
29 | .long __start,0,0 | ||
30 | |||
31 | .globl __start | ||
32 | __start: | ||
33 | #endif | ||
34 | |||
35 | ## Flush and invalidate the caches for the range in memory covering | ||
36 | ## the .text section of the boot loader | ||
37 | |||
38 | lis r9,_start@h # r9 = &_start | ||
39 | lis r8,_etext@ha # | ||
40 | addi r8,r8,_etext@l # r8 = &_etext | ||
41 | 3: dcbf r0,r9 # Flush the data cache | ||
42 | icbi r0,r9 # Invalidate the instruction cache | ||
43 | addi r9,r9,0x10 # Increment by one cache line | ||
44 | cmplw cr0,r9,r8 # Are we at the end yet? | ||
45 | blt 3b # No, keep flushing and invalidating | ||
46 | sync # sync ; isync after flushing the icache | ||
47 | isync | ||
48 | |||
49 | ## Clear out the BSS as per ANSI C requirements | ||
50 | |||
51 | lis r7,_end@ha | ||
52 | addi r7,r7,_end@l # r7 = &_end | ||
53 | lis r8,__bss_start@ha # | ||
54 | addi r8,r8,__bss_start@l # r8 = &_bss_start | ||
55 | |||
56 | ## Determine how large an area, in number of words, to clear | ||
57 | |||
58 | subf r7,r8,r7 # r7 = &_end - &_bss_start + 1 | ||
59 | addi r7,r7,3 # r7 += 3 | ||
60 | srwi. r7,r7,2 # r7 = size in words. | ||
61 | beq 2f # If the size is zero, do not bother | ||
62 | addi r8,r8,-4 # r8 -= 4 | ||
63 | mtctr r7 # SPRN_CTR = number of words to clear | ||
64 | li r0,0 # r0 = 0 | ||
65 | 1: stwu r0,4(r8) # Clear out a word | ||
66 | bdnz 1b # If we are not done yet, keep clearing | ||
67 | 2: | ||
68 | |||
69 | #ifdef CONFIG_40x | ||
70 | ## Set up the stack | ||
71 | |||
72 | lis r9,_start@h # r9 = &_start (text section entry) | ||
73 | ori r9,r9,_start@l | ||
74 | subi r1,r9,64 # Start the stack 64 bytes below _start | ||
75 | clrrwi r1,r1,4 # Make sure it is aligned on 16 bytes. | ||
76 | li r0,0 | ||
77 | stwu r0,-16(r1) | ||
78 | mtlr r9 | ||
79 | #endif | ||
80 | |||
81 | b start # All done, start the real work. | ||