Xenomai  3.1
thread.h
1 /*
2  * Copyright (C) 2004-2013 Philippe Gerum.
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_POWERPC_ASM_THREAD_H
20 #define _COBALT_POWERPC_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 };
33 
34 #define xnarch_fault_regs(d) ((d)->regs)
35 #define xnarch_fault_trap(d) ((unsigned int)(d)->regs->trap)
36 #define xnarch_fault_code(d) ((d)->regs->dar)
37 #define xnarch_fault_pc(d) ((d)->regs->nip)
38 #define xnarch_fault_pc(d) ((d)->regs->nip)
39 #define xnarch_fault_fpu_p(d) 0
40 #define xnarch_fault_pf_p(d) ((d)->exception == IPIPE_TRAP_ACCESS)
41 #define xnarch_fault_bp_p(d) ((current->ptrace & PT_PTRACED) && \
42  ((d)->exception == IPIPE_TRAP_IABR || \
43  (d)->exception == IPIPE_TRAP_SSTEP || \
44  (d)->exception == IPIPE_TRAP_DEBUG))
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_init_root_tcb(struct xnthread *thread);
52 
53 void xnarch_init_shadow_tcb(struct xnthread *thread);
54 
55 void xnarch_leave_root(struct xnthread *root);
56 
57 #else /* !CONFIG_XENO_ARCH_FPU */
58 
59 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
60 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
61 static inline void xnarch_leave_root(struct xnthread *root) { }
62 
63 #endif /* !CONFIG_XENO_ARCH_FPU */
64 
65 static inline int
66 xnarch_handle_fpu_fault(struct xnthread *from,
67  struct xnthread *to, struct ipipe_trap_data *d)
68 {
69  return 0;
70 }
71 
72 static inline int xnarch_escalate(void)
73 {
74  if (ipipe_root_p) {
75  ipipe_raise_irq(cobalt_pipeline.escalate_virq);
76  return 1;
77  }
78 
79  return 0;
80 }
81 
82 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
83 
84 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
85 
86 #endif /* !_COBALT_POWERPC_ASM_THREAD_H */