spu_save_crt0.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * crt0_s.S: Entry function for SPU-side context save.
  3. *
  4. * Copyright (C) 2005 IBM
  5. *
  6. * Entry function for SPU-side of the context save sequence.
  7. * Saves all 128 GPRs, sets up an initial stack frame, then
  8. * branches to 'main'.
  9. *
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <asm/spu_csa.h>
  26. .data
  27. .align 7
  28. .globl regs_spill
  29. regs_spill:
  30. .space SIZEOF_SPU_SPILL_REGS, 0x0
  31. .text
  32. .global _start
  33. _start:
  34. /* SPU Context Save Step 1: Save the first 16 GPRs. */
  35. stqa $0, regs_spill + 0
  36. stqa $1, regs_spill + 16
  37. stqa $2, regs_spill + 32
  38. stqa $3, regs_spill + 48
  39. stqa $4, regs_spill + 64
  40. stqa $5, regs_spill + 80
  41. stqa $6, regs_spill + 96
  42. stqa $7, regs_spill + 112
  43. stqa $8, regs_spill + 128
  44. stqa $9, regs_spill + 144
  45. stqa $10, regs_spill + 160
  46. stqa $11, regs_spill + 176
  47. stqa $12, regs_spill + 192
  48. stqa $13, regs_spill + 208
  49. stqa $14, regs_spill + 224
  50. stqa $15, regs_spill + 240
  51. /* SPU Context Save, Step 8: Save the remaining 112 GPRs. */
  52. ila $3, regs_spill + 256
  53. save_regs:
  54. lqr $4, save_reg_insts
  55. save_reg_loop:
  56. ai $4, $4, 4
  57. .balignl 16, 0x40200000
  58. save_reg_insts: /* must be quad-word aligned. */
  59. stqd $16, 0($3)
  60. stqd $17, 16($3)
  61. stqd $18, 32($3)
  62. stqd $19, 48($3)
  63. andi $5, $4, 0x7F
  64. stqr $4, save_reg_insts
  65. ai $3, $3, 64
  66. brnz $5, save_reg_loop
  67. /* Initialize the stack pointer to point to 16368
  68. * (16kb-16). The back chain pointer is initialized
  69. * to NULL.
  70. */
  71. il $0, 0
  72. il $SP, 16368
  73. stqd $0, 0($SP)
  74. /* Allocate a minimum stack frame for the called main.
  75. * This is needed so that main has a place to save the
  76. * link register when it calls another function.
  77. */
  78. stqd $SP, -160($SP)
  79. ai $SP, $SP, -160
  80. /* Call the program's main function. */
  81. brsl $0, main
  82. /* In this case main should not return; if it does
  83. * there has been an error in the sequence. Execute
  84. * stop-and-signal with code=0.
  85. */
  86. .global exit
  87. .global _exit
  88. exit:
  89. _exit:
  90. stop 0x0
  91. /* Pad the size of this crt0.o to be multiple of 16 bytes. */
  92. .balignl 16, 0x0