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 <asm-generic/xenomai/thread.h>
23 
24 struct xnarchtcb {
25  struct xntcb core;
26 #ifdef CONFIG_XENO_ARCH_FPU
27  struct fpsimd_state xnfpsimd_state;
28  struct fpsimd_state *fpup;
29 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
30 #endif
31  struct {
32  unsigned long pc;
33  unsigned long r0;
34 #ifdef __ARM_EABI__
35  unsigned long r7;
36 #endif
37 #ifdef CONFIG_ARM_THUMB
38  unsigned long psr;
39 #endif
40  } mayday;
41 };
42 
43 #define xnarch_fault_regs(d) ((d)->regs)
44 #define xnarch_fault_trap(d) ((d)->exception)
45 #define xnarch_fault_code(d) (0)
46 #define xnarch_fault_pc(d) ((unsigned long)((d)->regs->pc - 4)) /* XXX ? */
47 
48 #define xnarch_fault_pf_p(d) ((d)->exception == IPIPE_TRAP_ACCESS)
49 #define xnarch_fault_bp_p(d) ((current->ptrace & PT_PTRACED) && \
50  ((d)->exception == IPIPE_TRAP_BREAK || \
51  (d)->exception == IPIPE_TRAP_UNDEFINSTR))
52 
53 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
54 
55 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
56 
57 static inline void xnarch_enter_root(struct xnthread *root) { }
58 
59 int xnarch_escalate(void);
60 
61 #if defined(CONFIG_XENO_ARCH_FPU)
62 
63 static inline void xnarch_init_root_tcb(struct xnthread *thread)
64 {
65  struct xnarchtcb *tcb = xnthread_archtcb(thread);
66  tcb->fpup = NULL;
67 }
68 
69 void xnarch_init_shadow_tcb(struct xnthread *thread);
70 
71 static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
72 {
73  return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
74 }
75 
76 void xnarch_leave_root(struct xnthread *root);
77 
78 void xnarch_save_fpu(struct xnthread *thread);
79 
80 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
81 
82 static inline int
83 xnarch_handle_fpu_fault(struct xnthread *from,
84  struct xnthread *to, struct ipipe_trap_data *d)
85 {
86  return 0;
87 }
88 
89 #else /* !CONFIG_XENO_ARCH_FPU */
90 
91 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
92 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
93 
94 /*
95  * Userland may raise FPU faults with FPU-enabled kernels, regardless
96  * of whether real-time threads actually use FPU, so we simply ignore
97  * these faults.
98  */
99 static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
100 {
101  return 0;
102 }
103 
104 static inline void xnarch_leave_root(struct xnthread *root) { }
105 
106 static inline void xnarch_save_fpu(struct xnthread *thread) { }
107 
108 static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { }
109 
110 static inline int xnarch_handle_fpu_fault(struct xnthread *from,
111  struct xnthread *to, struct ipipe_trap_data *d)
112 {
113  return 0;
114 }
115 #endif /* !CONFIG_XENO_ARCH_FPU */
116 
117 static inline void xnarch_enable_kfpu(void) { }
118 
119 static inline void xnarch_disable_kfpu(void) { }
120 
121 #endif /* !_COBALT_ARM64_ASM_THREAD_H */