Xenomai  3.1-devel
thread.h
1 /*
2  * Copyright (C) 2005 Stelian Pop
3  *
4  * Xenomai is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _COBALT_ARM64_ASM_THREAD_H
20 #define _COBALT_ARM64_ASM_THREAD_H
21 
22 #include <linux/version.h>
23 #include <asm-generic/xenomai/thread.h>
24 
25 #if defined(CONFIG_XENO_ARCH_FPU) && LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
26 #define ARM64_XENO_OLD_SWITCH
27 #endif
28 
29 struct xnarchtcb {
30  struct xntcb core;
31 #ifdef ARM64_XENO_OLD_SWITCH
32  struct fpsimd_state xnfpsimd_state;
33  struct fpsimd_state *fpup;
34 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
35 #endif
36  struct {
37  unsigned long pc;
38  unsigned long r0;
39 #ifdef __ARM_EABI__
40  unsigned long r7;
41 #endif
42 #ifdef CONFIG_ARM_THUMB
43  unsigned long psr;
44 #endif
45  } mayday;
46 };
47 
48 #define xnarch_fault_regs(d) ((d)->regs)
49 #define xnarch_fault_trap(d) ((d)->exception)
50 #define xnarch_fault_code(d) (0)
51 #define xnarch_fault_pc(d) ((unsigned long)((d)->regs->pc - 4)) /* XXX ? */
52 
53 #define xnarch_fault_pf_p(d) ((d)->exception == IPIPE_TRAP_ACCESS)
54 #define xnarch_fault_bp_p(d) ((current->ptrace & PT_PTRACED) && \
55  ((d)->exception == IPIPE_TRAP_BREAK || \
56  (d)->exception == IPIPE_TRAP_UNDEFINSTR))
57 
58 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
59 
60 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
61 
62 static inline void xnarch_enter_root(struct xnthread *root) { }
63 
64 int xnarch_escalate(void);
65 
66 #ifdef ARM64_XENO_OLD_SWITCH
67 
68 void xnarch_init_root_tcb(struct xnthread *thread);
69 
70 void xnarch_init_shadow_tcb(struct xnthread *thread);
71 
72 void xnarch_leave_root(struct xnthread *root);
73 
74 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
75 
76 #else /* !ARM64_XENO_OLD_SWITCH */
77 
78 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
79 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
80 static inline void xnarch_leave_root(struct xnthread *root) { }
81 static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { }
82 
83 #endif /* !ARM64_XENO_OLD_SWITCH */
84 
85 static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
86 {
87  return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
88 }
89 
90 static inline int
91 xnarch_handle_fpu_fault(struct xnthread *from,
92  struct xnthread *to, struct ipipe_trap_data *d)
93 {
94  return 0;
95 }
96 
97 static inline void xnarch_enable_kfpu(void) { }
98 
99 static inline void xnarch_disable_kfpu(void) { }
100 
101 #endif /* !_COBALT_ARM64_ASM_THREAD_H */