crt0.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "ppc_asm.h"
  12. .text
  13. .globl _start
  14. _start:
  15. lis r9,_start@h
  16. lis r8,_etext@ha
  17. addi r8,r8,_etext@l
  18. 1: dcbf r0,r9
  19. icbi r0,r9
  20. addi r9,r9,0x20
  21. cmplwi 0,r9,8
  22. blt 1b
  23. sync
  24. isync
  25. ## Clear out the BSS as per ANSI C requirements
  26. lis r7,_end@ha
  27. addi r7,r7,_end@l # r7 = &_end
  28. lis r8,__bss_start@ha #
  29. addi r8,r8,__bss_start@l # r8 = &_bss_start
  30. ## Determine how large an area, in number of words, to clear
  31. subf r7,r8,r7 # r7 = &_end - &_bss_start + 1
  32. addi r7,r7,3 # r7 += 3
  33. srwi. r7,r7,2 # r7 = size in words.
  34. beq 3f # If the size is zero, don't bother
  35. addi r8,r8,-4 # r8 -= 4
  36. mtctr r7 # SPRN_CTR = number of words to clear
  37. li r0,0 # r0 = 0
  38. 2: stwu r0,4(r8) # Clear out a word
  39. bdnz 2b # Keep clearing until done
  40. 3:
  41. b start