diff -rbNu rtlinux/Makefile ../rtlinuxmod3/Makefile --- rtlinux/Makefile 2003-03-27 08:31:48.000000000 +0100 +++ ../rtlinuxmod3/Makefile 2003-03-03 11:05:50.000000000 +0100 @@ -106,7 +106,7 @@ endif ifeq ($(CONFIG_RT_COMM),y) -DRIVER_DIRS += rt_com +DRIVER_DIRS += rt_com.0.5.5 endif ifdef CONFIG_RTL_DEBUG diff -rbNu rtlinux/debugger/i386/rtl-stub.c ../rtlinuxmod3/debugger/i386/rtl-stub.c --- rtlinux/debugger/i386/rtl-stub.c 2003-03-27 08:31:48.000000000 +0100 +++ ../rtlinuxmod3/debugger/i386/rtl-stub.c 2003-03-21 12:50:57.000000000 +0100 @@ -679,11 +679,11 @@ /* disable breakpoints if they're hit with interrupts disabled or in Linux mode */ if (exceptionVector == 3 && (!(regs.eflags & 0x200) || rtl_running_linux())) { - spin_lock (&bp_lock); + rtl_spin_lock (&bp_lock); if (remove_bp (((char *) regs.eip) - 1) == 0) { --regs.eip; } - spin_unlock (&bp_lock); + rtl_spin_unlock (&bp_lock); rtl_hard_restore_flags(flags) ; return(1) ; } @@ -726,7 +726,7 @@ int cpu_id = cpu_logical_map (i); schedule_t *s = &rtl_sched [cpu_id]; - spin_lock (&s->rtl_tasks_lock); + rtl_spin_lock (&s->rtl_tasks_lock); task = s->rtl_tasks; while (task != &s->rtl_linux_task && ntasks < 31) { sprintf((remcomOutBuffer) + strlen(remcomOutBuffer), @@ -734,7 +734,7 @@ task = task->next; ntasks++; } - spin_unlock (&s->rtl_tasks_lock); + rtl_spin_unlock (&s->rtl_tasks_lock); } sprintf(packethead, "qM%02x%01x", ntasks, 1 /* done */); memcpy(remcomOutBuffer, packethead, strlen(packethead)); @@ -779,14 +779,14 @@ strcpy(remcomOutBuffer, "ERROR"); break; } - spin_lock (&bp_lock); + rtl_spin_lock (&bp_lock); if (remcomInBuffer[0] == 'Z') { res = insert_bp((char *)address); } else { remove_bp((char *)address); res = 0; } - spin_unlock (&bp_lock); + rtl_spin_unlock (&bp_lock); if (res) { strcpy(remcomOutBuffer, "ERROR"); } else { diff -rbNu rtlinux/include/rtl_spinlock.h ../rtlinuxmod3/include/rtl_spinlock.h --- rtlinux/include/rtl_spinlock.h 2003-03-27 08:31:51.000000000 +0100 +++ ../rtlinuxmod3/include/rtl_spinlock.h 2003-03-21 13:02:24.000000000 +0100 @@ -35,7 +35,7 @@ { rtl_irqstate_t flags; rtl_no_interrupts (flags); - spin_lock (&lock->lock); + rtl_spin_lock (&lock->lock); lock->flags = flags; return 0; } diff -rbNu rtlinux/include/rtl_sync.h ../rtlinuxmod3/include/rtl_sync.h --- rtlinux/include/rtl_sync.h 2003-03-27 08:31:51.000000000 +0100 +++ ../rtlinuxmod3/include/rtl_sync.h 2003-03-21 13:02:21.000000000 +0100 @@ -27,9 +27,9 @@ #define rtl_spinlock_t spinlock_t #define rtl_spin_lock_init(x) spin_lock_init(x) -#define rtl_spin_lock(x) spin_lock(x) -#define rtl_spin_trylock(x) spin_trylock(x) -#define rtl_spin_unlock(x) spin_unlock(x) +#define rtl_spin_lock(x) _raw_spin_lock(x) +#define rtl_spin_trylock(x) _raw_spin_trylock(x) +#define rtl_spin_unlock(x) _raw_spin_unlock(x) #define rtl_spin_lock_irqsave(x, flags) \ do { rtl_no_interrupts(flags); rtl_spin_lock(x); } while (0) diff -rbNu rtlinux/include/rtl_tracewrap.h ../rtlinuxmod3/include/rtl_tracewrap.h --- rtlinux/include/rtl_tracewrap.h 2003-03-27 08:31:51.000000000 +0100 +++ ../rtlinuxmod3/include/rtl_tracewrap.h 2003-03-03 12:20:28.000000000 +0100 @@ -24,9 +24,9 @@ #define rtl_hard_sti() do { rtl_trace2(RTL_TRACE_HARD_STI, 0); __rtl_hard_sti(); } while (0) #undef rtl_spin_lock -#define rtl_spin_lock(x) do { spin_lock(x); rtl_trace2(RTL_TRACE_SPIN_LOCK, (long) x); } while (0) +#define rtl_spin_lock(x) do { _raw_spin_lock(x); rtl_trace2(RTL_TRACE_SPIN_LOCK, (long) x); } while (0) #undef rtl_spin_unlock -#define rtl_spin_unlock(x) do { rtl_trace2(RTL_TRACE_SPIN_UNLOCK, (long) x); spin_unlock(x); } while (0) +#define rtl_spin_unlock(x) do { rtl_trace2(RTL_TRACE_SPIN_UNLOCK, (long) x); _raw_spin_unlock(x); } while (0) #endif diff -rbNu rtlinux/main/rtl_core.c ../rtlinuxmod3/main/rtl_core.c --- rtlinux/main/rtl_core.c 2003-03-27 08:31:52.000000000 +0100 +++ ../rtlinuxmod3/main/rtl_core.c 2003-03-27 03:16:39.000000000 +0100 @@ -37,6 +37,8 @@ #include #include +extern struct task_struct* (*get_linux_current_pointer)(void); + /* * Thanks to the wonders of EXTRAVERSION in the kernel, poor naming, * bad Linux planning and plagues of frogs we have to have this and can't @@ -282,6 +284,8 @@ { int irq; HardDeclareAndInit(cpu_id); + struct task_struct *linuxcurrent; + rtl_spin_lock(&rtl_global.hard_irq_controller_lock); if ((irq = rtl_irq_controller_get_irq(regs)) != -1) @@ -299,8 +303,9 @@ G_SET(g_pend_since_sti); } - if(RUN_LINUX_HANDLER(irq)) - { + + if (!L_TEST(l_busy) && L_TEST(l_ienable)){ + if ((G_ISPEND(irq) && G_ISENABLED(irq))){ /* unpend so dispatch doesn't dispatch 2 times*/ G_UNPEND(irq); rtl_soft_cli(); /* disable local soft interrupts */ @@ -315,6 +320,14 @@ RETURN_FROM_INTERRUPT_LINUX; /* goes via ret_from_intr */ } + if (G_TEST(g_pend_since_sti) || L_TEST(l_pend_since_sti)){ + rtl_spin_unlock(&rtl_global.hard_irq_controller_lock); + rtl_hard_sti(); + rtl_process_pending(); + RETURN_FROM_INTERRUPT_LINUX; + } + } // If Linux can be called and has pendent interrupts + #ifdef DEBUG_PENDING /* * If a Linux interrupt has been pended, and we haven't @@ -340,6 +353,11 @@ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock); rtl_trace2 (RTL_TRACE_INTERCEPT_EXIT, irq); + + if (get_linux_current_pointer){ + linuxcurrent = get_linux_current_pointer(); + --linuxcurrent->preempt_count; + } else { --current->preempt_count; } RETURN_FROM_INTERRUPT; } @@ -491,7 +509,12 @@ void rtl_soft_sti(void) { + struct task_struct *linuxcurrent; DeclareAndInit(cpu_id); + if (get_linux_current_pointer){ + linuxcurrent = get_linux_current_pointer(); + ++linuxcurrent->preempt_count; + } else { ++current->preempt_count; } /*debug_test_enabled("rtl_soft_sti");*/ if ( L_TEST(l_pend_since_sti) || G_TEST(g_pend_since_sti) #if LINUX_VERSION_CODE >= 0x020300 @@ -500,6 +523,10 @@ ) rtl_process_pending(); rtl_soft_sti_no_emulation(); + if (get_linux_current_pointer){ + linuxcurrent = get_linux_current_pointer(); + --linuxcurrent->preempt_count; + } else { --current->preempt_count; } } void rtl_soft_save_flags(unsigned long *x) @@ -674,7 +701,6 @@ int init_module(void) { int ret; - if ( arch_takeover() ) { printk("arch_takeover failed\n"); @@ -684,9 +710,9 @@ printk("RTLinux Extensions Loaded (http://www.fsmlabs.com/)\n"); ret = rtl_printf_init(); - if (ret < 0) + if (ret < 0){ return ret; - + } rtl_soft_sti(); rtlinux_suspend_linux_init(); return 0; diff -rbNu rtlinux/main/rtl_printf.c ../rtlinuxmod3/main/rtl_printf.c --- rtlinux/main/rtl_printf.c 2003-03-27 08:31:52.000000000 +0100 +++ ../rtlinuxmod3/main/rtl_printf.c 2003-03-21 10:48:23.000000000 +0100 @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -87,7 +88,7 @@ long linux_flags; __save_flags(linux_flags); __cli(); - spin_lock(&rtl_printf_handler_lock); + rtl_spin_lock(&rtl_printf_handler_lock); rtl_no_interrupts(flags); rtl_spin_lock(&rtl_cprintf_lock); @@ -100,7 +101,7 @@ rtl_restore_interrupts (flags); printk("%s", out_printkbuf); - spin_unlock(&rtl_printf_handler_lock); + rtl_spin_unlock(&rtl_printf_handler_lock); __restore_flags(linux_flags); } diff -rbNu rtlinux/schedulers/rtl_sched.c ../rtlinuxmod3/schedulers/rtl_sched.c --- rtlinux/schedulers/rtl_sched.c 2003-03-27 08:31:55.000000000 +0100 +++ ../rtlinuxmod3/schedulers/rtl_sched.c 2003-03-26 06:35:45.000000000 +0100 @@ -36,6 +36,8 @@ #include #include +extern struct task_struct* (*get_linux_current_pointer)(void); + static spinlock_t rtl_tqueue_lock; static int rtl_sched_irq; @@ -99,13 +101,15 @@ struct task_struct *get_linux_current(void) -{ +{ struct task_struct *lincurrent; #if !defined(__i386__) return current; #else if ( RTL_CURRENT == rtl_get_linux_thread(rtl_getcpuid()) ) { - return current; + __asm__("andl %%esp,%0; ":"=r" (lincurrent) : "0" (~8191UL)); + return lincurrent; + } else { @@ -249,10 +253,10 @@ return ret; } - spin_lock(&rtl_tqueue_lock); + rtl_spin_lock(&rtl_tqueue_lock); thread->next = zombie_threads; zombie_threads = thread; - spin_unlock(&rtl_tqueue_lock); + rtl_spin_unlock(&rtl_tqueue_lock); rtl_global_pend_irq (rtl_sched_irq); @@ -853,7 +857,9 @@ int i; int ret; int my_cpu_id; + schedule_t *s; + unsigned int cpu_id = rtl_getcpuid(); rtl_spin_lock_init (&rtl_tqueue_lock); @@ -893,6 +899,7 @@ s -> rtl_task_fpu_owner = &s->rtl_linux_task; s -> sched_flags = 0; rtl_posix_init (&s->rtl_linux_task); + get_linux_current_pointer = get_linux_current; s-> clock = rtl_getbestclock (cpu_id); if (s->clock && rtl_setclockhandler (s->clock, rtl_sched_timer_interrupt) == 0) { @@ -929,6 +936,7 @@ { int i; int cpu; + schedule_t *s; __errno_location = save_errno_location; @@ -937,6 +945,7 @@ cpu = cpu_logical_map (i); s = &rtl_sched [cpu]; s->clock->uninit(s->clock); + get_linux_current_pointer = NULL; #ifdef CONFIG_SMP rtl_free_ipi(cpu); #endif