![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * Copyright (C) 2016 Imagination Technologies 0004 * Author: Paul Burton <paul.burton@mips.com> 0005 */ 0006 0007 #ifndef __MIPS_ASM_DSEMUL_H__ 0008 #define __MIPS_ASM_DSEMUL_H__ 0009 0010 #include <asm/break.h> 0011 #include <asm/inst.h> 0012 0013 /* Break instruction with special math emu break code set */ 0014 #define BREAK_MATH(micromips) (((micromips) ? 0x7 : 0xd) | (BRK_MEMU << 16)) 0015 0016 /* When used as a frame index, indicates the lack of a frame */ 0017 #define BD_EMUFRAME_NONE ((int)BIT(31)) 0018 0019 struct mm_struct; 0020 struct pt_regs; 0021 struct task_struct; 0022 0023 /** 0024 * mips_dsemul() - 'Emulate' an instruction from a branch delay slot 0025 * @regs: User thread register context. 0026 * @ir: The instruction to be 'emulated'. 0027 * @branch_pc: The PC of the branch instruction. 0028 * @cont_pc: The PC to continue at following 'emulation'. 0029 * 0030 * Emulate or execute an arbitrary MIPS instruction within the context of 0031 * the current user thread. This is used primarily to handle instructions 0032 * in the delay slots of emulated branch instructions, for example FP 0033 * branch instructions on systems without an FPU. 0034 * 0035 * Return: Zero on success, negative if ir is a NOP, signal number on failure. 0036 */ 0037 extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir, 0038 unsigned long branch_pc, unsigned long cont_pc); 0039 0040 /** 0041 * do_dsemulret() - Return from a delay slot 'emulation' frame 0042 * @xcp: User thread register context. 0043 * 0044 * Call in response to the BRK_MEMU break instruction used to return to 0045 * the kernel from branch delay slot 'emulation' frames following a call 0046 * to mips_dsemul(). Restores the user thread PC to the value that was 0047 * passed as the cpc parameter to mips_dsemul(). 0048 * 0049 * Return: True if an emulation frame was returned from, else false. 0050 */ 0051 #ifdef CONFIG_MIPS_FP_SUPPORT 0052 extern bool do_dsemulret(struct pt_regs *xcp); 0053 #else 0054 static inline bool do_dsemulret(struct pt_regs *xcp) 0055 { 0056 return false; 0057 } 0058 #endif 0059 0060 /** 0061 * dsemul_thread_cleanup() - Cleanup thread 'emulation' frame 0062 * @tsk: The task structure associated with the thread 0063 * 0064 * If the thread @tsk has a branch delay slot 'emulation' frame 0065 * allocated to it then free that frame. 0066 * 0067 * Return: True if a frame was freed, else false. 0068 */ 0069 #ifdef CONFIG_MIPS_FP_SUPPORT 0070 extern bool dsemul_thread_cleanup(struct task_struct *tsk); 0071 #else 0072 static inline bool dsemul_thread_cleanup(struct task_struct *tsk) 0073 { 0074 return false; 0075 } 0076 #endif 0077 /** 0078 * dsemul_thread_rollback() - Rollback from an 'emulation' frame 0079 * @regs: User thread register context. 0080 * 0081 * If the current thread, whose register context is represented by @regs, 0082 * is executing within a delay slot 'emulation' frame then exit that 0083 * frame. The PC will be rolled back to the branch if the instruction 0084 * that was being 'emulated' has not yet executed, or advanced to the 0085 * continuation PC if it has. 0086 * 0087 * Return: True if a frame was exited, else false. 0088 */ 0089 #ifdef CONFIG_MIPS_FP_SUPPORT 0090 extern bool dsemul_thread_rollback(struct pt_regs *regs); 0091 #else 0092 static inline bool dsemul_thread_rollback(struct pt_regs *regs) 0093 { 0094 return false; 0095 } 0096 #endif 0097 0098 /** 0099 * dsemul_mm_cleanup() - Cleanup per-mm delay slot 'emulation' state 0100 * @mm: The struct mm_struct to cleanup state for. 0101 * 0102 * Cleanup state for the given @mm, ensuring that any memory allocated 0103 * for delay slot 'emulation' book-keeping is freed. This is to be called 0104 * before @mm is freed in order to avoid memory leaks. 0105 */ 0106 #ifdef CONFIG_MIPS_FP_SUPPORT 0107 extern void dsemul_mm_cleanup(struct mm_struct *mm); 0108 #else 0109 static inline void dsemul_mm_cleanup(struct mm_struct *mm) 0110 { 0111 /* no-op */ 0112 } 0113 #endif 0114 0115 #endif /* __MIPS_ASM_DSEMUL_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |