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
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.
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.
23 #include "../kernel/ppc_asm.tmpl"
29 ## Clear out the BSS as per ANSI C requirements
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
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
45 1: stwu r0,4(r8) # Clear out a word
46 bdnz 1b # If we are not done yet, keep clearing
48 ## Flush and invalidate the caches for the range in memory covering
49 ## the .text section of the boot loader
51 2: lis r9,_start@h # r9 = &_start
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
62 lis r9,_start@h # r9 = &_start (text section entry)
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.
70 b start # All done, start the real work.