entry.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  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, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/unistd.h>
  16. #include <asm/irqflags.h>
  17. #include <asm/processor.h>
  18. #include <arch/abi.h>
  19. #include <arch/spr_def.h>
  20. #ifdef __tilegx__
  21. #define bnzt bnezt
  22. #endif
  23. STD_ENTRY(current_text_addr)
  24. { move r0, lr; jrp lr }
  25. STD_ENDPROC(current_text_addr)
  26. /*
  27. * Implement execve(). The i386 code has a note that forking from kernel
  28. * space results in no copy on write until the execve, so we should be
  29. * careful not to write to the stack here.
  30. */
  31. STD_ENTRY(kernel_execve)
  32. moveli TREG_SYSCALL_NR_NAME, __NR_execve
  33. swint1
  34. jrp lr
  35. STD_ENDPROC(kernel_execve)
  36. /* Delay a fixed number of cycles. */
  37. STD_ENTRY(__delay)
  38. { addi r0, r0, -1; bnzt r0, . }
  39. jrp lr
  40. STD_ENDPROC(__delay)
  41. /*
  42. * We don't run this function directly, but instead copy it to a page
  43. * we map into every user process. See vdso_setup().
  44. *
  45. * Note that libc has a copy of this function that it uses to compare
  46. * against the PC when a stack backtrace ends, so if this code is
  47. * changed, the libc implementation(s) should also be updated.
  48. */
  49. .pushsection .data
  50. ENTRY(__rt_sigreturn)
  51. moveli TREG_SYSCALL_NR_NAME,__NR_rt_sigreturn
  52. swint1
  53. ENDPROC(__rt_sigreturn)
  54. ENTRY(__rt_sigreturn_end)
  55. .popsection
  56. STD_ENTRY(dump_stack)
  57. { move r2, lr; lnk r1 }
  58. { move r4, r52; addli r1, r1, dump_stack - . }
  59. { move r3, sp; j _dump_stack }
  60. jrp lr /* keep backtracer happy */
  61. STD_ENDPROC(dump_stack)
  62. STD_ENTRY(KBacktraceIterator_init_current)
  63. { move r2, lr; lnk r1 }
  64. { move r4, r52; addli r1, r1, KBacktraceIterator_init_current - . }
  65. { move r3, sp; j _KBacktraceIterator_init_current }
  66. jrp lr /* keep backtracer happy */
  67. STD_ENDPROC(KBacktraceIterator_init_current)
  68. /*
  69. * Reset our stack to r1/r2 (sp and ksp0+cpu respectively), then
  70. * free the old stack (passed in r0) and re-invoke cpu_idle().
  71. * We update sp and ksp0 simultaneously to avoid backtracer warnings.
  72. */
  73. STD_ENTRY(cpu_idle_on_new_stack)
  74. {
  75. move sp, r1
  76. mtspr SPR_SYSTEM_SAVE_K_0, r2
  77. }
  78. jal free_thread_info
  79. j cpu_idle
  80. STD_ENDPROC(cpu_idle_on_new_stack)
  81. /* Loop forever on a nap during SMP boot. */
  82. STD_ENTRY(smp_nap)
  83. nap
  84. j smp_nap /* we are not architecturally guaranteed not to exit nap */
  85. jrp lr /* clue in the backtracer */
  86. STD_ENDPROC(smp_nap)
  87. /*
  88. * Enable interrupts racelessly and then nap until interrupted.
  89. * This function's _cpu_idle_nap address is special; see intvec.S.
  90. * When interrupted at _cpu_idle_nap, we bump the PC forward 8, and
  91. * as a result return to the function that called _cpu_idle().
  92. */
  93. STD_ENTRY(_cpu_idle)
  94. {
  95. lnk r0
  96. movei r1, KERNEL_PL
  97. }
  98. {
  99. addli r0, r0, _cpu_idle_nap - .
  100. mtspr INTERRUPT_CRITICAL_SECTION, r1
  101. }
  102. IRQ_ENABLE(r2, r3) /* unmask, but still with ICS set */
  103. mtspr SPR_EX_CONTEXT_K_1, r1 /* Kernel PL, ICS clear */
  104. mtspr SPR_EX_CONTEXT_K_0, r0
  105. iret
  106. .global _cpu_idle_nap
  107. _cpu_idle_nap:
  108. nap
  109. jrp lr
  110. STD_ENDPROC(_cpu_idle)