Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
9d42c84f | 2 | /* |
6d1a20b1 | 3 | * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) |
9d42c84f | 4 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
9d42c84f VG |
5 | */ |
6 | ||
7 | #ifndef __ASM_ARC_ENTRY_H | |
8 | #define __ASM_ARC_ENTRY_H | |
9 | ||
ebfc2fd8 | 10 | #include <asm/unistd.h> /* For NR_syscalls definition */ |
9d42c84f VG |
11 | #include <asm/arcregs.h> |
12 | #include <asm/ptrace.h> | |
080c3747 | 13 | #include <asm/processor.h> /* For VMALLOC_START */ |
4ffd9e2c | 14 | #include <asm/mmu.h> |
9d42c84f | 15 | |
4d369680 VG |
16 | #ifdef __ASSEMBLY__ |
17 | ||
1f6ccfff | 18 | #ifdef CONFIG_ISA_ARCOMPACT |
6d1a20b1 | 19 | #include <asm/entry-compact.h> /* ISA specific bits */ |
1f6ccfff VG |
20 | #else |
21 | #include <asm/entry-arcv2.h> | |
22 | #endif | |
6d1a20b1 | 23 | |
cfca4b5a VG |
24 | /* |
25 | * save user mode callee regs as struct callee_regs | |
26 | * - needed by fork/do_signal/unaligned-access-emulation. | |
27 | */ | |
9d42c84f | 28 | .macro SAVE_CALLEE_SAVED_USER |
9de7fc30 | 29 | SAVE_ABI_CALLEE_REGS |
cfca4b5a | 30 | .endm |
3ebedbb2 | 31 | |
cfca4b5a VG |
32 | /* |
33 | * restore user mode callee regs as struct callee_regs | |
34 | * - could have been changed by ptrace tracer or unaligned-access fixup | |
35 | */ | |
36 | .macro RESTORE_CALLEE_SAVED_USER | |
9de7fc30 | 37 | RESTORE_ABI_CALLEE_REGS |
9d42c84f VG |
38 | .endm |
39 | ||
cfca4b5a VG |
40 | /* |
41 | * save/restore kernel mode callee regs at the time of context switch | |
42 | */ | |
9d42c84f | 43 | .macro SAVE_CALLEE_SAVED_KERNEL |
9de7fc30 | 44 | SAVE_ABI_CALLEE_REGS |
9d42c84f VG |
45 | .endm |
46 | ||
9d42c84f | 47 | .macro RESTORE_CALLEE_SAVED_KERNEL |
9de7fc30 | 48 | RESTORE_ABI_CALLEE_REGS |
c3581039 VG |
49 | .endm |
50 | ||
9d42c84f VG |
51 | /*-------------------------------------------------------------- |
52 | * Super FAST Restore callee saved regs by simply re-adjusting SP | |
53 | *-------------------------------------------------------------*/ | |
54 | .macro DISCARD_CALLEE_SAVED_USER | |
16f9afe6 | 55 | add sp, sp, SZ_CALLEE_REGS |
9d42c84f VG |
56 | .endm |
57 | ||
9d42c84f | 58 | /*------------------------------------------------------------- |
ebfc2fd8 | 59 | * given a tsk struct, get to the base of its kernel mode stack |
9d42c84f VG |
60 | * tsk->thread_info is really a PAGE, whose bottom hoists stack |
61 | * which grows upwards towards thread_info | |
62 | *------------------------------------------------------------*/ | |
63 | ||
64 | .macro GET_TSK_STACK_BASE tsk, out | |
65 | ||
66 | /* Get task->thread_info (this is essentially start of a PAGE) */ | |
67 | ld \out, [\tsk, TASK_THREAD_INFO] | |
68 | ||
69 | /* Go to end of page where stack begins (grows upwards) */ | |
283237a0 | 70 | add2 \out, \out, (THREAD_SIZE)/4 |
9d42c84f VG |
71 | |
72 | .endm | |
73 | ||
9d42c84f VG |
74 | /* |
75 | * @reg [OUT] thread_info->flags of "current" | |
76 | */ | |
77 | .macro GET_CURR_THR_INFO_FLAGS reg | |
78 | GET_CURR_THR_INFO_FROM_SP \reg | |
79 | ld \reg, [\reg, THREAD_INFO_FLAGS] | |
80 | .endm | |
81 | ||
41195d23 VG |
82 | #ifdef CONFIG_SMP |
83 | ||
cfca4b5a | 84 | /* |
41195d23 | 85 | * Retrieve the current running task on this CPU |
cfca4b5a VG |
86 | * - loads it from backing _current_task[] (and can't use the |
87 | * caching reg for current task | |
41195d23 VG |
88 | */ |
89 | .macro GET_CURR_TASK_ON_CPU reg | |
90 | GET_CPU_ID \reg | |
91 | ld.as \reg, [@_current_task, \reg] | |
92 | .endm | |
93 | ||
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[ ] | |
98 | * | |
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) | |
102 | */ | |
103 | ||
104 | .macro SET_CURR_TASK_ON_CPU tsk, tmp | |
105 | GET_CPU_ID \tmp | |
106 | add2 \tmp, @_current_task, \tmp | |
107 | st \tsk, [\tmp] | |
108 | #ifdef CONFIG_ARC_CURR_IN_REG | |
cfca4b5a | 109 | mov gp, \tsk |
41195d23 VG |
110 | #endif |
111 | ||
112 | .endm | |
113 | ||
114 | ||
115 | #else /* Uniprocessor implementation of macros */ | |
116 | ||
9d42c84f VG |
117 | .macro GET_CURR_TASK_ON_CPU reg |
118 | ld \reg, [@_current_task] | |
119 | .endm | |
120 | ||
121 | .macro SET_CURR_TASK_ON_CPU tsk, tmp | |
122 | st \tsk, [@_current_task] | |
080c3747 | 123 | #ifdef CONFIG_ARC_CURR_IN_REG |
cfca4b5a | 124 | mov gp, \tsk |
080c3747 | 125 | #endif |
9d42c84f VG |
126 | .endm |
127 | ||
41195d23 VG |
128 | #endif /* SMP / UNI */ |
129 | ||
cfca4b5a | 130 | /* |
9d42c84f | 131 | * Get the ptr to some field of Current Task at @off in task struct |
cfca4b5a | 132 | * - Uses current task cached in reg if enabled |
9d42c84f | 133 | */ |
080c3747 VG |
134 | #ifdef CONFIG_ARC_CURR_IN_REG |
135 | ||
136 | .macro GET_CURR_TASK_FIELD_PTR off, reg | |
cfca4b5a | 137 | add \reg, gp, \off |
080c3747 VG |
138 | .endm |
139 | ||
140 | #else | |
141 | ||
9d42c84f VG |
142 | .macro GET_CURR_TASK_FIELD_PTR off, reg |
143 | GET_CURR_TASK_ON_CPU \reg | |
144 | add \reg, \reg, \off | |
145 | .endm | |
146 | ||
080c3747 VG |
147 | #endif /* CONFIG_ARC_CURR_IN_REG */ |
148 | ||
4d369680 VG |
149 | #else /* !__ASSEMBLY__ */ |
150 | ||
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 *); | |
165 | ||
166 | #endif | |
167 | ||
9d42c84f | 168 | #endif /* __ASM_ARC_ENTRY_H */ |