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