Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs...
[deliverable/linux.git] / arch / powerpc / boot / crt0.S
CommitLineData
1da177e4
LT
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
decd300b 12#include "ppc_asm.h"
1da177e4
LT
13
14 .text
66a45dd3 15 /* a procedure descriptor used when booting this as a COFF file */
f40e524e 16 .globl _zimage_start_opd
66a45dd3
PM
17_zimage_start_opd:
18 .long _zimage_start, 0, 0, 0
19
cd197ffc 20 .weak _zimage_start
67a1b682
OH
21 .globl _zimage_start
22_zimage_start:
160cc3ec
MM
23 .globl _zimage_start_lib
24_zimage_start_lib:
66a45dd3
PM
25 /* Work out the offset between the address we were linked at
26 and the address where we're running. */
68643cfb 27 bl 1f
66a45dd3 281: mflr r0
68643cfb
OH
29 lis r9,1b@ha
30 addi r9,r9,1b@l
a4497235 31 subf. r0,r9,r0
66a45dd3 32 beq 3f /* if running at same address as linked */
a4497235 33
66a45dd3
PM
34 /* The .got2 section contains a list of addresses, so add
35 the address offset onto each entry. */
a4497235
OH
36 lis r9,__got2_start@ha
37 addi r9,r9,__got2_start@l
38 lis r8,__got2_end@ha
39 addi r8,r8,__got2_end@l
40 subf. r8,r9,r8
68643cfb 41 beq 3f
a4497235
OH
42 srwi. r8,r8,2
43 mtctr r8
44 add r9,r0,r9
66a45dd3 452: lwz r8,0(r9)
a4497235
OH
46 add r8,r8,r0
47 stw r8,0(r9)
48 addi r9,r9,4
68643cfb 49 bdnz 2b
a4497235 50
cd197ffc 51 /* Do a cache flush for our text, in case the loader didn't */
eacb1962
OH
523: lis r9,_start@ha
53 addi r9,r9,_start@l
a4497235 54 add r9,r0,r9
1da177e4
LT
55 lis r8,_etext@ha
56 addi r8,r8,_etext@l
a4497235 57 add r8,r0,r8
68643cfb 584: dcbf r0,r9
1da177e4
LT
59 icbi r0,r9
60 addi r9,r9,0x20
eacb1962 61 cmplw cr0,r9,r8
68643cfb 62 blt 4b
1da177e4
LT
63 sync
64 isync
65
cd197ffc
DG
66 /* Clear the BSS */
67 lis r9,__bss_start@ha
68 addi r9,r9,__bss_start@l
f4bdbfc4 69 add r9,r0,r9
cd197ffc
DG
70 lis r8,_end@ha
71 addi r8,r8,_end@l
f4bdbfc4
MM
72 add r8,r0,r8
73 li r10,0
745: stw r10,0(r9)
cd197ffc
DG
75 addi r9,r9,4
76 cmplw cr0,r9,r8
77 blt 5b
1da177e4 78
cd197ffc
DG
79 /* Possibly set up a custom stack */
80.weak _platform_stack_top
81 lis r8,_platform_stack_top@ha
82 addi r8,r8,_platform_stack_top@l
83 cmpwi r8,0
84 beq 6f
f4bdbfc4 85 add r8,r0,r8
cd197ffc 86 lwz r1,0(r8)
f4bdbfc4 87 add r1,r0,r1
cd197ffc
DG
88 li r0,0
89 stwu r0,-16(r1) /* establish a stack frame */
906:
91
92 /* Call platform_init() */
93 bl platform_init
94
95 /* Call start */
cd197ffc 96 b start
This page took 0.425858 seconds and 5 git commands to generate.