Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / ppc64 / boot / crt0.S
blob04d3e74cd72f7d53fd9fbbfe7378a6b2f5e62e2f
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  */
12 #include <asm/ppc_asm.h>
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
28         ## Clear out the BSS as per ANSI C requirements
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
35         ## Determine how large an area, in number of words, to clear
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
47         b       start