1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
4 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
7 #ifndef __ASM_ARC_ENTRY_H
8 #define __ASM_ARC_ENTRY_H
10 #include <asm/unistd.h> /* For NR_syscalls definition */
11 #include <asm/arcregs.h>
12 #include <asm/ptrace.h>
13 #include <asm/processor.h> /* For VMALLOC_START */
18 #ifdef CONFIG_ISA_ARCOMPACT
19 #include <asm/entry-compact.h> /* ISA specific bits */
21 #include <asm/entry-arcv2.h>
25 * save user mode callee regs as struct callee_regs
26 * - needed by fork/do_signal/unaligned-access-emulation.
28 .macro SAVE_CALLEE_SAVED_USER
33 * restore user mode callee regs as struct callee_regs
34 * - could have been changed by ptrace tracer or unaligned-access fixup
36 .macro RESTORE_CALLEE_SAVED_USER
37 RESTORE_ABI_CALLEE_REGS
41 * save/restore kernel mode callee regs at the time of context switch
43 .macro SAVE_CALLEE_SAVED_KERNEL
47 .macro RESTORE_CALLEE_SAVED_KERNEL
48 RESTORE_ABI_CALLEE_REGS
51 /*--------------------------------------------------------------
52 * Super FAST Restore callee saved regs by simply re-adjusting SP
53 *-------------------------------------------------------------*/
54 .macro DISCARD_CALLEE_SAVED_USER
55 add sp
, sp
, SZ_CALLEE_REGS
58 /*-------------------------------------------------------------
59 * given a tsk struct, get to the base of its kernel mode stack
60 * tsk->thread_info is really a PAGE, whose bottom hoists stack
61 * which grows upwards towards thread_info
62 *------------------------------------------------------------*/
64 .macro GET_TSK_STACK_BASE tsk
, out
66 /* Get task->thread_info (this is essentially start of a PAGE) */
67 ld \out
, [\tsk
, TASK_THREAD_INFO
]
69 /* Go to end of page where stack begins (grows upwards) */
70 add2 \out
, \out
, (THREAD_SIZE
)/4
75 * @reg [OUT] thread_info->flags of "current"
77 .macro GET_CURR_THR_INFO_FLAGS reg
78 GET_CURR_THR_INFO_FROM_SP
\reg
79 ld
\reg
, [\reg
, THREAD_INFO_FLAGS
]
85 * Retrieve the current running task on this CPU
86 * - loads it from backing _current_task[] (and can't use the
87 * caching reg for current task
89 .macro GET_CURR_TASK_ON_CPU reg
91 ld
.as
\reg
, [@_current_task
, \reg
]
94 /*-------------------------------------------------
95 * Save a new task as the "current" task on this CPU
96 * 1. Determine curr CPU id.
97 * 2. Use it to index into _current_task[ ]
99 * Coded differently than GET_CURR_TASK_ON_CPU (which uses LD.AS)
100 * because ST r0, [r1, offset] can ONLY have s9 @offset
101 * while LD can take s9 (4 byte insn) or LIMM (8 byte insn)
104 .macro SET_CURR_TASK_ON_CPU tsk
, tmp
106 add2
\tmp
, @_current_task
, \tmp
108 #ifdef CONFIG_ARC_CURR_IN_REG
115 #else /* Uniprocessor implementation of macros */
117 .macro GET_CURR_TASK_ON_CPU reg
118 ld
\reg
, [@_current_task
]
121 .macro SET_CURR_TASK_ON_CPU tsk
, tmp
122 st
\tsk
, [@_current_task
]
123 #ifdef CONFIG_ARC_CURR_IN_REG
128 #endif /* SMP / UNI */
131 * Get the ptr to some field of Current Task at @off in task struct
132 * - Uses current task cached in reg if enabled
134 #ifdef CONFIG_ARC_CURR_IN_REG
136 .macro GET_CURR_TASK_FIELD_PTR off
, reg
142 .macro GET_CURR_TASK_FIELD_PTR off
, reg
143 GET_CURR_TASK_ON_CPU
\reg
147 #endif /* CONFIG_ARC_CURR_IN_REG */
149 #else /* !__ASSEMBLY__ */
151 extern void do_signal(struct pt_regs
*);
152 extern void do_notify_resume(struct pt_regs
*);
153 extern int do_privilege_fault(unsigned long, struct pt_regs
*);
154 extern int do_extension_fault(unsigned long, struct pt_regs
*);
155 extern int insterror_is_error(unsigned long, struct pt_regs
*);
156 extern int do_memory_error(unsigned long, struct pt_regs
*);
157 extern int trap_is_brkpt(unsigned long, struct pt_regs
*);
158 extern int do_misaligned_error(unsigned long, struct pt_regs
*);
159 extern int do_trap5_error(unsigned long, struct pt_regs
*);
160 extern int do_misaligned_access(unsigned long, struct pt_regs
*, struct callee_regs
*);
161 extern void do_machine_check_fault(unsigned long, struct pt_regs
*);
162 extern void do_non_swi_trap(unsigned long, struct pt_regs
*);
163 extern void do_insterror_or_kprobe(unsigned long, struct pt_regs
*);
164 extern void do_page_fault(unsigned long, struct pt_regs
*);
168 #endif /* __ASM_ARC_ENTRY_H */