startup.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* startup.S - Startup code for the PowerPC. */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/symbol.h>
  20. #include <grub/offsets.h>
  21. .extern __bss_start
  22. .extern _end
  23. .text
  24. .align 2
  25. .globl start, _start
  26. start:
  27. _start:
  28. li 2, 0
  29. li 13, 0
  30. /* Stage1 won't zero BSS for us. In other cases, why not do it again? */
  31. lis 6, (__bss_start - 4)@h
  32. ori 6, 6, (__bss_start - 4)@l
  33. 2: stb 2, 4(6)
  34. addi 6, 6, 1
  35. andi. 7, 6, 3
  36. cmpi 0, 1, 7, 0
  37. bne 2b
  38. lis 7, (_end - 4)@h
  39. ori 7, 7, (_end - 4)@l
  40. subf 7, 6, 7
  41. subi 8, 7, 1
  42. andi. 8, 8, 3
  43. addi 8, 8, 1
  44. sub 7, 7, 8
  45. srwi 7, 7, 2 /* We store 4 bytes at a time. */
  46. mtctr 7
  47. 2: stwu 2, 4(6) /* We know r2 is already 0 from above. */
  48. bdnz 2b
  49. mtctr 8
  50. 2: stb 2, 4(6) /* We know r2 is already 0 from above. */
  51. addi 6, 6, 1
  52. bdnz 2b
  53. /* Store r5 in grub_ieee1275_entry_fn. */
  54. lis 9, grub_ieee1275_entry_fn@ha
  55. stw 5, grub_ieee1275_entry_fn@l(9)
  56. bl grub_main
  57. 1: b 1b