Hi all,
this hack allowed me to run RTAI 3.2 on a 2.6.11.9-adeos-r10c3 kernel.
It does not fix all warnings, only the relevant ones, it does not touch
all scheduler variants, and it does only address x86 - but I think it
should show the required modifications related to recent kernel
development. I dared to define put_current_on_cpu() empty for non-SMP
because I got some unresolved symbol (cpu_online_map) otherwise, hope
this is ok.
Jan
Index: base/arch/i386/hal/hal.c
===================================================================
RCS file: /cvs/rtai/vulcano/base/arch/i386/hal/hal.c,v
retrieving revision 1.4
diff -u -p -r1.4 hal.c
--- base/arch/i386/hal/hal.c 10 May 2005 06:35:46 -0000 1.4
+++ base/arch/i386/hal/hal.c 12 May 2005 16:56:34 -0000
@@ -1252,9 +1252,9 @@ static void rtai_trap_fault (adevinfo_t
does in math_state_restore anyhow, to stay on the safe side.
In any case we inform the user. */
rtai_hw_cli(); /* in task context, so we can be preempted */
- if (!linux_task->used_math) {
+ if (!tsk_used_math(linux_task)) {
init_xfpu(); /* Does clts(). */
- linux_task->used_math = 1;
+ set_stopped_child_used_math(linux_task);
rt_printk("\nUNEXPECTED FPU INITIALIZATION FROM PID =
%d\n", linux_task->pid);
} else {
rt_printk("\nUNEXPECTED FPU TRAP FROM HARD PID = %d\n",
linux_task->pid);
@@ -1483,6 +1483,7 @@ void (*rt_set_ihook (void (*hookfn)(int)
#endif /* CONFIG_RTAI_SCHED_ISR_LOCK */
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
static int errno;
static inline _syscall3(int,
@@ -1490,6 +1491,7 @@ static inline _syscall3(int,
pid_t,pid,
int,policy,
struct sched_param *,param)
+#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
void rtai_set_linux_task_priority (struct task_struct *task, int policy, int
prio)
@@ -1503,15 +1505,22 @@ void rtai_set_linux_task_priority (struc
void rtai_set_linux_task_priority (struct task_struct *task, int policy, int
prio)
{
+ int rc;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ struct sched_param param;
+
+ param.sched_priority = prio;
+ rc = sched_setscheduler(task,policy,¶m);
+#else
struct sched_param __user param;
mm_segment_t old_fs;
- int rc;
param.sched_priority = prio;
old_fs = get_fs();
set_fs(KERNEL_DS);
rc = sched_setscheduler(task->pid,policy,¶m);
set_fs(old_fs);
+#endif
if (rc)
printk("RTAI[hal]: sched_setscheduler(policy=%d,prio=%d) failed, code
%d (%s -- pid=%d)\n",
Index: base/include/asm-i386/rtai_fpu.h
===================================================================
RCS file: /cvs/rtai/vulcano/base/include/asm-i386/rtai_fpu.h,v
retrieving revision 1.2
diff -u -p -r1.2 rtai_fpu.h
--- base/include/asm-i386/rtai_fpu.h 18 Mar 2005 09:29:59 -0000 1.2
+++ base/include/asm-i386/rtai_fpu.h 12 May 2005 16:56:34 -0000
@@ -38,7 +38,7 @@ typedef union i387_union FPU_ENV;
#ifdef CONFIG_RTAI_FPU_SUPPORT
#define init_fpu(tsk) \
- do { init_xfpu(); tsk->used_math = 1; set_tsk_used_fpu(tsk); } while(0)
+ do { init_xfpu(); set_stopped_child_used_math(tsk);
set_tsk_used_fpu(tsk); } while(0)
#define restore_fpu(tsk) \
do { restore_fpenv_lxrt((tsk)); set_tsk_used_fpu(tsk); } while (0)
Index: base/include/asm-i386/rtai_shm.h
===================================================================
RCS file: /cvs/rtai/vulcano/base/include/asm-i386/rtai_shm.h,v
retrieving revision 1.1
diff -u -p -r1.1 rtai_shm.h
--- base/include/asm-i386/rtai_shm.h 18 Mar 2005 08:57:24 -0000 1.1
+++ base/include/asm-i386/rtai_shm.h 12 May 2005 16:56:34 -0000
@@ -49,7 +49,12 @@ static inline unsigned long uvirt_to_kva
pte_t *ptep, pte;
if(!pgd_none(*pgd)) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
pmd = pmd_offset(pgd, adr);
+#else /* >= 2.6.11 */
+ pud_t *pud = pud_offset(pgd, adr);
+ pmd = pmd_offset(pud, adr);
+#endif /* < 2.6.11 */
if (!pmd_none(*pmd)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
ptep = pte_offset(pmd, adr);
Index: base/sched/sched.c
===================================================================
RCS file: /cvs/rtai/vulcano/base/sched/sched.c,v
retrieving revision 1.8
diff -u -p -r1.8 sched.c
--- base/sched/sched.c 4 May 2005 12:15:12 -0000 1.8
+++ base/sched/sched.c 12 May 2005 16:56:34 -0000
@@ -205,6 +205,7 @@ int get_min_tasks_cpuid(void)
return cpuid;
}
+#ifdef CONFIG_SMP
static void put_current_on_cpu(int cpuid)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
@@ -222,6 +223,9 @@ static void put_current_on_cpu(int cpuid
#endif /* KERNEL_VERSION < 2.6.0 */
}
+#else /* !CONFIG_SMP */
+static inline void put_current_on_cpu(int cpuid) {}
+#endif /* CONFIG_SMP */
int set_rtext(RT_TASK *task, int priority, int uses_fpu, void(*signal)(void),
unsigned int cpuid, struct task_struct *relink)
{
@@ -748,7 +752,7 @@ void rt_schedule_on_schedule_ipi(void)
}
if (!rt_current->is_hard) {
UNLOCK_LINUX(cpuid);
- } else if (prev->used_math) {
+ } else if (tsk_used_math(prev)) {
restore_fpu(prev);
}
}
@@ -843,7 +847,7 @@ void rt_schedule(void)
goto sched_soft;
}
} else {
- if (prev->used_math) {
+ if (tsk_used_math(prev)) {
restore_fpu(prev);
}
if (rt_current->force_soft) {
@@ -1150,7 +1154,7 @@ static void rt_timer_handler(void)
}
if (!rt_current->is_hard) {
UNLOCK_LINUX(cpuid);
- } else if (prev->used_math) {
+ } else if (tsk_used_math(prev)) {
restore_fpu(prev);
}
}
@@ -1907,7 +1911,7 @@ void steal_from_linux(RT_TASK *rt_task)
rt_task->base_priority -= BASE_SOFT_PRIORITY;
rt_task->priority -= BASE_SOFT_PRIORITY;
}
- if (current->used_math) {
+ if (used_math()) {
restore_fpu(current);
}
rtai_sti();
Index: base/sched/sys.c
===================================================================
RCS file: /cvs/rtai/vulcano/base/sched/sys.c,v
retrieving revision 1.3
diff -u -p -r1.3 sys.c
--- base/sched/sys.c 1 Apr 2005 16:41:27 -0000 1.3
+++ base/sched/sys.c 12 May 2005 16:56:34 -0000
@@ -531,11 +531,11 @@ static inline long long handle_lxrt_requ
case HRT_USE_FPU: {
struct arg { RT_TASK *task; int use_fpu; };
if(!larg->use_fpu) {
- ((larg->task)->lnxtsk)->used_math = 0;
+
clear_stopped_child_used_math((larg->task)->lnxtsk);
set_tsk_used_fpu(((larg->task)->lnxtsk));
} else {
init_xfpu();
- ((larg->task)->lnxtsk)->used_math = 1;
+
set_stopped_child_used_math((larg->task)->lnxtsk);
set_tsk_used_fpu(((larg->task)->lnxtsk));
}
return 0;