/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)3* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)4*/56#ifndef __ASM_ARC_ENTRY_H7#define __ASM_ARC_ENTRY_H89#include <asm/unistd.h> /* For NR_syscalls definition */10#include <asm/arcregs.h>11#include <asm/ptrace.h>12#include <asm/processor.h> /* For VMALLOC_START */13#include <asm/mmu.h>1415#ifdef __ASSEMBLER__1617#ifdef CONFIG_ISA_ARCOMPACT18#include <asm/entry-compact.h> /* ISA specific bits */19#else20#include <asm/entry-arcv2.h>21#endif2223/*24* save user mode callee regs as struct callee_regs25* - needed by fork/do_signal/unaligned-access-emulation.26*/27.macro SAVE_CALLEE_SAVED_USER28SAVE_ABI_CALLEE_REGS29.endm3031/*32* restore user mode callee regs as struct callee_regs33* - could have been changed by ptrace tracer or unaligned-access fixup34*/35.macro RESTORE_CALLEE_SAVED_USER36RESTORE_ABI_CALLEE_REGS37.endm3839/*40* save/restore kernel mode callee regs at the time of context switch41*/42.macro SAVE_CALLEE_SAVED_KERNEL43SAVE_ABI_CALLEE_REGS44.endm4546.macro RESTORE_CALLEE_SAVED_KERNEL47RESTORE_ABI_CALLEE_REGS48.endm4950/*--------------------------------------------------------------51* Super FAST Restore callee saved regs by simply re-adjusting SP52*-------------------------------------------------------------*/53.macro DISCARD_CALLEE_SAVED_USER54add sp, sp, SZ_CALLEE_REGS55.endm5657/*-------------------------------------------------------------58* given a tsk struct, get to the base of its kernel mode stack59* tsk->thread_info is really a PAGE, whose bottom hoists stack60* which grows upwards towards thread_info61*------------------------------------------------------------*/6263.macro GET_TSK_STACK_BASE tsk, out6465/* Get task->thread_info (this is essentially start of a PAGE) */66ld \out, [\tsk, TASK_THREAD_INFO]6768/* Go to end of page where stack begins (grows upwards) */69add2 \out, \out, (THREAD_SIZE)/47071.endm7273/*74* @reg [OUT] thread_info->flags of "current"75*/76.macro GET_CURR_THR_INFO_FLAGS reg77GET_CURR_THR_INFO_FROM_SP \reg78ld \reg, [\reg, THREAD_INFO_FLAGS]79.endm8081#ifdef CONFIG_SMP8283/*84* Retrieve the current running task on this CPU85* - loads it from backing _current_task[] (and can't use the86* caching reg for current task87*/88.macro GET_CURR_TASK_ON_CPU reg89GET_CPU_ID \reg90ld.as \reg, [@_current_task, \reg]91.endm9293/*-------------------------------------------------94* Save a new task as the "current" task on this CPU95* 1. Determine curr CPU id.96* 2. Use it to index into _current_task[ ]97*98* Coded differently than GET_CURR_TASK_ON_CPU (which uses LD.AS)99* because ST r0, [r1, offset] can ONLY have s9 @offset100* while LD can take s9 (4 byte insn) or LIMM (8 byte insn)101*/102103.macro SET_CURR_TASK_ON_CPU tsk, tmp104GET_CPU_ID \tmp105add2 \tmp, @_current_task, \tmp106st \tsk, [\tmp]107#ifdef CONFIG_ARC_CURR_IN_REG108mov gp, \tsk109#endif110111.endm112113114#else /* Uniprocessor implementation of macros */115116.macro GET_CURR_TASK_ON_CPU reg117ld \reg, [@_current_task]118.endm119120.macro SET_CURR_TASK_ON_CPU tsk, tmp121st \tsk, [@_current_task]122#ifdef CONFIG_ARC_CURR_IN_REG123mov gp, \tsk124#endif125.endm126127#endif /* SMP / UNI */128129/*130* Get the ptr to some field of Current Task at @off in task struct131* - Uses current task cached in reg if enabled132*/133#ifdef CONFIG_ARC_CURR_IN_REG134135.macro GET_CURR_TASK_FIELD_PTR off, reg136add \reg, gp, \off137.endm138139#else140141.macro GET_CURR_TASK_FIELD_PTR off, reg142GET_CURR_TASK_ON_CPU \reg143add \reg, \reg, \off144.endm145146#endif /* CONFIG_ARC_CURR_IN_REG */147148#else /* !__ASSEMBLER__ */149150extern void do_signal(struct pt_regs *);151extern void do_notify_resume(struct pt_regs *);152extern int do_privilege_fault(unsigned long, struct pt_regs *);153extern int do_extension_fault(unsigned long, struct pt_regs *);154extern int insterror_is_error(unsigned long, struct pt_regs *);155extern int do_memory_error(unsigned long, struct pt_regs *);156extern int trap_is_brkpt(unsigned long, struct pt_regs *);157extern int do_misaligned_error(unsigned long, struct pt_regs *);158extern int do_trap5_error(unsigned long, struct pt_regs *);159extern int do_misaligned_access(unsigned long, struct pt_regs *, struct callee_regs *);160extern void do_machine_check_fault(unsigned long, struct pt_regs *);161extern void do_non_swi_trap(unsigned long, struct pt_regs *);162extern void do_insterror_or_kprobe(unsigned long, struct pt_regs *);163extern void do_page_fault(unsigned long, struct pt_regs *);164165#endif166167#endif /* __ASM_ARC_ENTRY_H */168169170