entry.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
  4. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  5. */
  6. #ifndef __ASM_ARC_ENTRY_H
  7. #define __ASM_ARC_ENTRY_H
  8. #include <asm/unistd.h> /* For NR_syscalls definition */
  9. #include <asm/arcregs.h>
  10. #include <asm/ptrace.h>
  11. #include <asm/processor.h> /* For VMALLOC_START */
  12. #include <asm/mmu.h>
  13. #ifdef __ASSEMBLER__
  14. #ifdef CONFIG_ISA_ARCOMPACT
  15. #include <asm/entry-compact.h> /* ISA specific bits */
  16. #else
  17. #include <asm/entry-arcv2.h>
  18. #endif
  19. /*
  20. * save user mode callee regs as struct callee_regs
  21. * - needed by fork/do_signal/unaligned-access-emulation.
  22. */
  23. .macro SAVE_CALLEE_SAVED_USER
  24. SAVE_ABI_CALLEE_REGS
  25. .endm
  26. /*
  27. * restore user mode callee regs as struct callee_regs
  28. * - could have been changed by ptrace tracer or unaligned-access fixup
  29. */
  30. .macro RESTORE_CALLEE_SAVED_USER
  31. RESTORE_ABI_CALLEE_REGS
  32. .endm
  33. /*
  34. * save/restore kernel mode callee regs at the time of context switch
  35. */
  36. .macro SAVE_CALLEE_SAVED_KERNEL
  37. SAVE_ABI_CALLEE_REGS
  38. .endm
  39. .macro RESTORE_CALLEE_SAVED_KERNEL
  40. RESTORE_ABI_CALLEE_REGS
  41. .endm
  42. /*--------------------------------------------------------------
  43. * Super FAST Restore callee saved regs by simply re-adjusting SP
  44. *-------------------------------------------------------------*/
  45. .macro DISCARD_CALLEE_SAVED_USER
  46. add sp, sp, SZ_CALLEE_REGS
  47. .endm
  48. /*-------------------------------------------------------------
  49. * given a tsk struct, get to the base of its kernel mode stack
  50. * tsk->thread_info is really a PAGE, whose bottom hoists stack
  51. * which grows upwards towards thread_info
  52. *------------------------------------------------------------*/
  53. .macro GET_TSK_STACK_BASE tsk, out
  54. /* Get task->thread_info (this is essentially start of a PAGE) */
  55. ld \out, [\tsk, TASK_THREAD_INFO]
  56. /* Go to end of page where stack begins (grows upwards) */
  57. add2 \out, \out, (THREAD_SIZE)/4
  58. .endm
  59. /*
  60. * @reg [OUT] thread_info->flags of "current"
  61. */
  62. .macro GET_CURR_THR_INFO_FLAGS reg
  63. GET_CURR_THR_INFO_FROM_SP \reg
  64. ld \reg, [\reg, THREAD_INFO_FLAGS]
  65. .endm
  66. #ifdef CONFIG_SMP
  67. /*
  68. * Retrieve the current running task on this CPU
  69. * - loads it from backing _current_task[] (and can't use the
  70. * caching reg for current task
  71. */
  72. .macro GET_CURR_TASK_ON_CPU reg
  73. GET_CPU_ID \reg
  74. ld.as \reg, [@_current_task, \reg]
  75. .endm
  76. /*-------------------------------------------------
  77. * Save a new task as the "current" task on this CPU
  78. * 1. Determine curr CPU id.
  79. * 2. Use it to index into _current_task[ ]
  80. *
  81. * Coded differently than GET_CURR_TASK_ON_CPU (which uses LD.AS)
  82. * because ST r0, [r1, offset] can ONLY have s9 @offset
  83. * while LD can take s9 (4 byte insn) or LIMM (8 byte insn)
  84. */
  85. .macro SET_CURR_TASK_ON_CPU tsk, tmp
  86. GET_CPU_ID \tmp
  87. add2 \tmp, @_current_task, \tmp
  88. st \tsk, [\tmp]
  89. #ifdef CONFIG_ARC_CURR_IN_REG
  90. mov gp, \tsk
  91. #endif
  92. .endm
  93. #else /* Uniprocessor implementation of macros */
  94. .macro GET_CURR_TASK_ON_CPU reg
  95. ld \reg, [@_current_task]
  96. .endm
  97. .macro SET_CURR_TASK_ON_CPU tsk, tmp
  98. st \tsk, [@_current_task]
  99. #ifdef CONFIG_ARC_CURR_IN_REG
  100. mov gp, \tsk
  101. #endif
  102. .endm
  103. #endif /* SMP / UNI */
  104. /*
  105. * Get the ptr to some field of Current Task at @off in task struct
  106. * - Uses current task cached in reg if enabled
  107. */
  108. #ifdef CONFIG_ARC_CURR_IN_REG
  109. .macro GET_CURR_TASK_FIELD_PTR off, reg
  110. add \reg, gp, \off
  111. .endm
  112. #else
  113. .macro GET_CURR_TASK_FIELD_PTR off, reg
  114. GET_CURR_TASK_ON_CPU \reg
  115. add \reg, \reg, \off
  116. .endm
  117. #endif /* CONFIG_ARC_CURR_IN_REG */
  118. #else /* !__ASSEMBLER__ */
  119. extern void do_signal(struct pt_regs *);
  120. extern void do_notify_resume(struct pt_regs *);
  121. extern int do_privilege_fault(unsigned long, struct pt_regs *);
  122. extern int do_extension_fault(unsigned long, struct pt_regs *);
  123. extern int insterror_is_error(unsigned long, struct pt_regs *);
  124. extern int do_memory_error(unsigned long, struct pt_regs *);
  125. extern int trap_is_brkpt(unsigned long, struct pt_regs *);
  126. extern int do_misaligned_error(unsigned long, struct pt_regs *);
  127. extern int do_trap5_error(unsigned long, struct pt_regs *);
  128. extern int do_misaligned_access(unsigned long, struct pt_regs *, struct callee_regs *);
  129. extern void do_machine_check_fault(unsigned long, struct pt_regs *);
  130. extern void do_non_swi_trap(unsigned long, struct pt_regs *);
  131. extern void do_insterror_or_kprobe(unsigned long, struct pt_regs *);
  132. extern void do_page_fault(unsigned long, struct pt_regs *);
  133. #endif
  134. #endif /* __ASM_ARC_ENTRY_H */