More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / arch / ppc / treeboot / crt0.S
blobe54ac23315378d790a0e251dbe9fa82578a500d9
1 /*
2  *    Copyright (c) 1997 Paul Mackerras <paulus@cs.anu.edu.au>
3  *      Initial Power Macintosh COFF version.
4  *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
5  *      Modifications for IBM PowerPC 400-class processor evaluation
6  *      boards.
7  *
8  *    Module name: crt0.S
9  *
10  *    Description:
11  *      Boot loader execution entry point. Clears out .bss section as per
12  *      ANSI C requirements. Invalidates and flushes the caches over the
13  *      range covered by the boot loader's .text section. Sets up a stack
14  *      below the .text section entry point.
15  *
16  *    This program is free software; you can redistribute it and/or
17  *    modify it under the terms of the GNU General Public License
18  *    as published by the Free Software Foundation; either version
19  *    2 of the License, or (at your option) any later version.
20  *
21  */
23 #include "../kernel/ppc_asm.tmpl"
25         .text
27         .globl  _start
28 _start: 
29         ## Clear out the BSS as per ANSI C requirements
31         lis     r7,_end@ha              # 
32         addi    r7,r7,_end@l            # r7 = &_end
33         lis     r8,__bss_start@ha       # 
34         addi    r8,r8,__bss_start@l     # r8 = &_bss_start
36         ## Determine how large an area, in number of words, to clear
37         
38         subf    r7,r8,r7                # r7 = &_end - &_bss_start + 1 
39         addi    r7,r7,3                 # r7 += 3
40         srwi.   r7,r7,2                 # r7 = size in words.
41         beq     2f                      # If the size is zero, do not bother
42         addi    r8,r8,-4                # r8 -= 4
43         mtctr   r7                      # SPRN_CTR = number of words to clear
44         li      r0,0                    # r0 = 0
45 1:      stwu    r0,4(r8)                # Clear out a word
46         bdnz    1b                      # If we are not done yet, keep clearing
47         
48         ## Flush and invalidate the caches for the range in memory covering
49         ## the .text section of the boot loader
50         
51 2:      lis     r9,_start@h             # r9 = &_start
52         lis     r8,_etext@ha            # 
53         addi    r8,r8,_etext@l          # r8 = &_etext
54 3:      dcbf    r0,r9                   # Flush the data cache
55         icbi    r0,r9                   # Invalidate the instruction cache
56         addi    r9,r9,0x10              # Increment by one cache line
57         cmplwi  cr0,r9,r8               # Are we at the end yet?
58         blt     3b                      # No, keep flushing and invalidating
60         ## Set up the stack
62         lis     r9,_start@h             # r9 = &_start (text section entry)
63         addi    r9,r9,_start@l
64         subi    r1,r9,64                # Start the stack 64 bytes below _start
65         clrrwi  r1,r1,4                 # Make sure it is aligned on 16 bytes.
66         li      r0,0
67         stwu    r0,-16(r1)
68         mtlr    r9
69         
70         b       start                   # All done, start the real work.