Xenomai  3.0-rc6
thread.h
1 /*
2  * Copyright (C) 2011,2013 Philippe Gerum <rpm@xenomai.org>.
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_SH_ASM_THREAD_H
20 #define _COBALT_SH_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 thread_struct *fpup;
28 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
29 #else
30 #define xnarch_fpu_ptr(tcb) NULL
31 #endif
32  struct {
33  unsigned long pc;
34  unsigned long r3;
35  } mayday;
36 };
37 
38 #define xnarch_fault_trap(d) ((d)->exception)
39 #define xnarch_fault_code(d) 0
40 #define xnarch_fault_pc(d) ((d)->regs->pc)
41 #define xnarch_fault_fpu_p(d) ((d)->exception == IPIPE_TRAP_FPUERR)
42 #define xnarch_fault_pf_p(d) ((d)->exception == IPIPE_TRAP_PF)
43 #define xnarch_fault_bp_p(d) ((current->ptrace & PT_PTRACED) && \
44  (d)->exception == IPIPE_TRAP_BP)
45 #define xnarch_fault_notify(d) (xnarch_fault_bp_p(d) == 0)
46 
47 static inline void xnarch_enter_root(struct xnthread *root) { }
48 
49 #ifdef CONFIG_XENO_ARCH_FPU
50 
51 void xnarch_leave_root(struct xnthread *root);
52 
53 static inline void xnarch_init_root_tcb(struct xnthread *thread)
54 {
55  struct xnarchtcb *tcb = xnthread_archtcb(thread);
56  tcb->fpup = NULL;
57 }
58 
59 void xnarch_init_shadow_tcb(struct xnthread *thread);
60 
61 #else /* !CONFIG_XENO_ARCH_FPU */
62 
63 static inline void xnarch_leave_root(struct xnthread *root) { }
64 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
65 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
66 
67 #endif /* !CONFIG_XENO_ARCH_FPU */
68 
69 static inline int
70 xnarch_handle_fpu_fault(struct xnthread *from,
71  struct xnthread *to, struct ipipe_trap_data *d)
72 {
73  return 0;
74 }
75 
76 #endif /* !_COBALT_SH_ASM_THREAD_H */