Xenomai  3.0.5
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  struct {
33  unsigned long nip;
34  unsigned long r0;
35  } mayday;
36 };
37 
38 #define xnarch_fault_regs(d) ((d)->regs)
39 #define xnarch_fault_trap(d) ((unsigned int)(d)->regs->trap)
40 #define xnarch_fault_code(d) ((d)->regs->dar)
41 #define xnarch_fault_pc(d) ((d)->regs->nip)
42 #define xnarch_fault_pc(d) ((d)->regs->nip)
43 #define xnarch_fault_fpu_p(d) 0
44 #define xnarch_fault_pf_p(d) ((d)->exception == IPIPE_TRAP_ACCESS)
45 #define xnarch_fault_bp_p(d) ((current->ptrace & PT_PTRACED) && \
46  ((d)->exception == IPIPE_TRAP_IABR || \
47  (d)->exception == IPIPE_TRAP_SSTEP || \
48  (d)->exception == IPIPE_TRAP_DEBUG))
49 #define xnarch_fault_notify(d) (xnarch_fault_bp_p(d) == 0)
50 
51 static inline void xnarch_enter_root(struct xnthread *root) { }
52 
53 #ifdef CONFIG_XENO_ARCH_FPU
54 
55 void xnarch_init_root_tcb(struct xnthread *thread);
56 
57 void xnarch_init_shadow_tcb(struct xnthread *thread);
58 
59 void xnarch_leave_root(struct xnthread *root);
60 
61 #else /* !CONFIG_XENO_ARCH_FPU */
62 
63 static inline void xnarch_init_root_tcb(struct xnthread *thread) { }
64 static inline void xnarch_init_shadow_tcb(struct xnthread *thread) { }
65 static inline void xnarch_leave_root(struct xnthread *root) { }
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 static inline int xnarch_escalate(void)
77 {
78  if (ipipe_root_p) {
79  ipipe_raise_irq(cobalt_pipeline.escalate_virq);
80  return 1;
81  }
82 
83  return 0;
84 }
85 
86 void xnarch_switch_to(struct xnthread *out, struct xnthread *in);
87 
88 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
89 
90 #endif /* !_COBALT_POWERPC_ASM_THREAD_H */