crt1.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * libc/sysdeps/linux/microblaze/crt1.S -- Initial program entry point for linux/microblaze
  3. *
  4. * Copyright (C) 2009 Meyer Sound Laboratories
  5. * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
  6. * Copyright (C) 2001,2002 NEC Corporation
  7. * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
  8. *
  9. * This file is subject to the terms and conditions of the GNU Lesser
  10. * General Public License. See the file COPYING.LIB in the main
  11. * directory of this archive for more details.
  12. *
  13. * Written by Miles Bader <miles@gnu.org>
  14. */
  15. #include <libc-symbols.h>
  16. /* Upon entry, the stack contains the following data:
  17. argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
  18. */
  19. .text
  20. .globl C_SYMBOL_NAME(_start)
  21. .align 4
  22. C_SYMBOL_NAME(_start):
  23. /* Load SDAs */
  24. la r2, r0, C_SYMBOL_NAME(_SDA2_BASE_) /* in the original source r2 was SDA, and r13 was SDA2, no idea why */
  25. la r13, r0, C_SYMBOL_NAME(_SDA_BASE_)
  26. /*
  27. Preparing arguments for uClibc's startup routine.
  28. The routine has 6 arguments, so 5 of them are placed
  29. into registers, one on the stack
  30. */
  31. la r5, r0, C_SYMBOL_NAME(main) /* Arg 1: main() */
  32. lw r6, r0, r1 /* Arg 2: argc */
  33. addi r7, r1, 4 /* Arg 3: argv */
  34. la r8, r0, _init /* Arg 4: init */
  35. la r9, r0, _fini /* Arg 5: fini */
  36. addk r10,r0,r0 /* Arg 6: rtld_fini = NULL */
  37. /* Reserve space for __uClibc_main to save parameters
  38. (Microblaze ABI stack calling convention)
  39. and for stack_end argument to __uClibc_main */
  40. add r3, r1, r0
  41. addi r1, r1, -32
  42. /* tail-call uClibc's startup routine */
  43. brid C_SYMBOL_NAME(__uClibc_main)
  44. swi r3, r1, 28 /* Arg 7: stack end [DELAY SLOT] */
  45. /* Define a symbol for the first piece of initialized data. */
  46. .data
  47. .globl __data_start
  48. __data_start:
  49. .long 0
  50. .weak data_start
  51. data_start = __data_start