2 * Copyright (C) 2009 Philippe Gerum <rpm@xenomai.org>.
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.
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.
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
20 #ifndef _XENO_ASM_NIOS2_BITS_SHADOW_H
21 #define _XENO_ASM_NIOS2_BITS_SHADOW_H
24 #error "Pure kernel header included from user-space!"
27 #include <asm/cacheflush.h>
29 static inline void xnarch_init_shadow_tcb(xnarchtcb_t
* tcb
,
30 struct xnthread
*thread
,
33 struct task_struct
*task
= current
;
35 tcb
->user_task
= task
;
36 tcb
->active_task
= NULL
;
37 tcb
->tsp
= &task
->thread
;
39 tcb
->active_mm
= NULL
;
40 #ifdef CONFIG_XENO_HW_UNLOCKED_SWITCH
41 tcb
->tip
= task_thread_info(task
);
50 static inline int xnarch_local_syscall(struct pt_regs
*regs
)
52 unsigned long ptr
, x
, r
;
54 switch (__xn_reg_arg1(regs
)) {
57 /* lsys_xchg(ptr,newval,&oldval) */
58 ptr
= __xn_reg_arg2(regs
);
59 x
= __xn_reg_arg3(regs
);
60 r
= xchg((unsigned long *)ptr
, x
);
61 __xn_put_user(r
, (unsigned long *)__xn_reg_arg4(regs
));
72 #define xnarch_schedule_tail(prev) do { } while(0)
74 #ifdef XNARCH_HAVE_MAYDAY
76 static inline void xnarch_setup_mayday_page(void *page
)
79 * We want this code to appear at the top of the MAYDAY page:
81 * 00c00334 movhi r3,#__xn_sys_mayday
82 * 18c08ac4 addi r3,r3,#__xn_sys_mux
94 .movhi_r3h
= 0x00c00334,
95 .addi_r3l
= 0x18c08ac4,
96 .movi_r2
= 0x00800004,
97 .syscall
= 0x003b683a,
101 memcpy(page
, &code
, sizeof(code
));
103 flush_dcache_range((unsigned long)page
,
104 (unsigned long)page
+ sizeof(code
));
107 static inline void xnarch_call_mayday(struct task_struct
*p
)
109 rthal_return_intercept(p
);
112 static inline void xnarch_handle_mayday(struct xnarchtcb
*tcb
,
113 struct pt_regs
*regs
,
116 tcb
->mayday
.ea
= regs
->ea
;
117 tcb
->mayday
.r2
= regs
->r2
;
118 tcb
->mayday
.r3
= regs
->r3
;
122 static inline void xnarch_fixup_mayday(struct xnarchtcb
*tcb
,
123 struct pt_regs
*regs
)
125 regs
->ea
= tcb
->mayday
.ea
;
126 regs
->r2
= tcb
->mayday
.r2
;
127 regs
->r3
= tcb
->mayday
.r3
;
130 #endif /* XNARCH_HAVE_MAYDAY */
132 #endif /* !_XENO_ASM_NIOS2_BITS_SHADOW_H */