head.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Startup code for use with the u-boot bootloader.
  3. *
  4. * Copyright (C) 2004-2006 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <asm/setup.h>
  11. #include <asm/thread_info.h>
  12. #include <asm/sysreg.h>
  13. /*
  14. * The kernel is loaded where we want it to be and all caches
  15. * have just been flushed. We get two parameters from u-boot:
  16. *
  17. * r12 contains a magic number (ATAG_MAGIC)
  18. * r11 points to a tag table providing information about
  19. * the system.
  20. */
  21. .section .init.text,"ax"
  22. .global _start
  23. _start:
  24. /* Initialize .bss */
  25. lddpc r2, bss_start_addr
  26. lddpc r3, end_addr
  27. mov r0, 0
  28. mov r1, 0
  29. 1: st.d r2++, r0
  30. cp r2, r3
  31. brlo 1b
  32. /* Initialize status register */
  33. lddpc r0, init_sr
  34. mtsr SYSREG_SR, r0
  35. /* Set initial stack pointer */
  36. lddpc sp, stack_addr
  37. sub sp, -THREAD_SIZE
  38. #ifdef CONFIG_FRAME_POINTER
  39. /* Mark last stack frame */
  40. mov lr, 0
  41. mov r7, 0
  42. #endif
  43. /* Check if the boot loader actually provided a tag table */
  44. lddpc r0, magic_number
  45. cp.w r12, r0
  46. brne no_tag_table
  47. /*
  48. * Save the tag table address for later use. This must be done
  49. * _after_ .bss has been initialized...
  50. */
  51. lddpc r0, tag_table_addr
  52. st.w r0[0], r11
  53. /* Jump to loader-independent setup code */
  54. rjmp kernel_entry
  55. .align 2
  56. magic_number:
  57. .long ATAG_MAGIC
  58. tag_table_addr:
  59. .long bootloader_tags
  60. bss_start_addr:
  61. .long __bss_start
  62. end_addr:
  63. .long _end
  64. init_sr:
  65. .long 0x007f0000 /* Supervisor mode, everything masked */
  66. stack_addr:
  67. .long init_thread_union
  68. panic_addr:
  69. .long panic
  70. no_tag_table:
  71. sub r12, pc, (. - 2f)
  72. /* branch to panic() which can be far away with that construct */
  73. lddpc pc, panic_addr
  74. 2: .asciz "Boot loader didn't provide correct magic number\n"