Many thanks to Philippe Coval for the work he did. Using that as a base, I've successfully built a unicorn-pci-atm module for 2.6.26 which loads and runs and connects to my ISP.
I still consider it a work in progress as I haven't yet updated the Debian packaging. But attached for reference is a diff of /usr/src/modules/unicorn between unicorn-source-0.9.3-2 (last one in the archive) and my working version. This incorporates all previous patches supplied to this bug number, with thanks to the authors. If you can bear with me for a week or two whilst real life tasks intervene, I will try to finish off the work, split this large patch up into smaller ones for specific fixes and work on fixing up the Debian packaging and module-assistant build. Two points to note: * I could not make the module load when treating the .cpp files as C++ even though it compiles and links OK. All I got instead were segfaults on module loading. I found it necessary to build them as C by symlinking *.cpp as .c. In my diff, the symlinked copies are shown as diffs against the previous .c files (which were not symlinks and were not identical to the previous .cpp files). I suspect the ABI to/from the closed source components may be at fault - perhaps it is just another instance of the regparm problem I fixed for the .c sources. But, having read up on the flam^H^H^H^H history of other attempts to build C++ kernel modules, I lack the enthusiasm to resolve this when the unicorn module doesn't use any significant C++ language features anyway and the few minor ones are easily re-cast as C. * I've re-worked the PCI and ATM modules to remove or update deprecated and outdated kernel calls. But for the USB module it looks as if the kernel USB team have decided nobody shall link non-GPL kernel code using their API, even if not for re-distribution. There are three ways round for someone who needs unicorn-usb - globally replace EXPORT_SYMBOL_GPL by EXPORT_SYMBOL in drivers/usb and rebuild one's own kernel (as suggested on LKML), or mis-declare the unicorn-usb module as GPL (as suggested by other private USB module builders), or re-write the unicorn-usb module in user space (best but hardest). For Debian I suggest we change the packaging to just not build unicorn-usb and leave this decision up to the user.
diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/Makefile ./Makefile --- ../unicorn-0.9.3-2/Makefile 2008-01-10 08:10:09.000000000 +0000 +++ ./Makefile 2009-03-12 22:45:18.000000000 +0000 @@ -15,6 +15,11 @@ DIRS = adsl_status unicorntest tools DRVDIRS = libm unicorn_pci unicorn_usb +ifneq ($(PATCHLEVEL),4) +# regparm unconditionally forced by Kconfig > 2.6.6; option removed some time after 2.6.18 +CONFIG_REGPARM = 1 +endif + all: applis modules applis: diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/amas.c ./amu/amas.c --- ../unicorn-0.9.3-2/amu/amas.c 2008-01-10 08:10:08.000000000 +0000 +++ ./amu/amas.c 2009-03-12 20:13:58.000000000 +0000 @@ -23,7 +23,7 @@ // ADSL Modem Software calls this function to report any state changes void AMSW_ANT_reportModemStateChange(AMSW_ModemState p_ModemState) { - char *s; + const char *s; g_ModemState = p_ModemState; @@ -54,7 +54,7 @@ // ADSL Modem Software calls this function to report events void AMSW_ANT_reportEvent(AMSW_ModemEvent p_Event) { - char *s; + const char *s; switch(p_Event) { default : s = "UNKNOWN"; break; @@ -98,7 +98,7 @@ // ADSL Modem Software calls this function to report the reason for failure void AMSW_ANT_reportModemFailure(AMSW_ModemFailure p_FailureCause) { - char *s; + const char *s; switch(p_FailureCause) { case C_AMSW_UNCOMPATIBLE_LINECONDITIONS : diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/amas.cpp ./amu/amas.cpp --- ../unicorn-0.9.3-2/amu/amas.cpp 2003-09-26 12:19:08.000000000 +0100 +++ ./amu/amas.cpp 2009-03-12 20:13:58.000000000 +0000 @@ -5,7 +5,7 @@ extern unsigned long g_ModemState, g_ShowtimeCounter; extern unsigned int g_WaitForShowtime, g_WaitForInit; -extern bool L3_flag; +extern BOOLEAN L3_flag; extern T_AMSW_ANT_StaticConfiguration g_StaticCfg; extern T_AMSW_NT_NearEndLineOperData g_NearEndLineOperData; @@ -23,9 +23,10 @@ // ADSL Modem Software calls this function to report any state changes void AMSW_ANT_reportModemStateChange(AMSW_ModemState p_ModemState) { + const char *s; + g_ModemState = p_ModemState; - char *s; switch(p_ModemState) { case C_AMSW_IDLE : s = "IDLE"; break; @@ -53,7 +54,7 @@ // ADSL Modem Software calls this function to report events void AMSW_ANT_reportEvent(AMSW_ModemEvent p_Event) { - char *s; + const char *s; switch(p_Event) { default : s = "UNKNOWN"; break; @@ -97,7 +98,7 @@ // ADSL Modem Software calls this function to report the reason for failure void AMSW_ANT_reportModemFailure(AMSW_ModemFailure p_FailureCause) { - char *s; + const char *s; switch(p_FailureCause) { case C_AMSW_UNCOMPATIBLE_LINECONDITIONS : diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/amu.c ./amu/amu.c --- ../unicorn-0.9.3-2/amu/amu.c 2008-01-10 08:10:08.000000000 +0000 +++ ./amu/amu.c 2009-03-15 09:27:38.000000000 +0000 @@ -86,7 +86,6 @@ } #endif -unsigned long amu_init_modem(unsigned short MODE); unsigned long amu_init_modem(unsigned short MODE) { unsigned long l_RetCode; diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/amu.cpp ./amu/amu.cpp --- ../unicorn-0.9.3-2/amu/amu.cpp 2004-01-30 09:14:03.000000000 +0000 +++ ./amu/amu.cpp 2009-03-15 09:27:38.000000000 +0000 @@ -77,10 +77,15 @@ extern unsigned long Vendor_Id_code_Globspan; unsigned long Vendor_Id_code_Globspan=0; -extern "C" void HandleAtmError(void); -extern "C" void HandleLeds(void); +#ifdef __cplusplus +extern "C" { +#endif + void HandleAtmError(void); + void HandleLeds(void); +#ifdef __cplusplus +} +#endif -unsigned long amu_init_modem(unsigned short MODE); unsigned long amu_init_modem(unsigned short MODE) { unsigned long l_RetCode; @@ -165,24 +170,27 @@ return l_RetCode; } -void AMUTask(unsigned long,unsigned long , unsigned long , unsigned long ) +void AMUTask(unsigned long Arg1, unsigned long Arg2, unsigned long Arg3, unsigned long Arg4) { unsigned long l_RetCode = C_AMSW_REJ; //static int l_Lit = 0; - static bool PM_toggle = TRUE; - - PRINT_ERROR("FmPollingRate=%ldms,InitTimeout=%ldms,ActTimeout=%ld\n", - FmPollingRate,InitTimeout,ActTimeout); + static BOOLEAN PM_toggle = TRUE; unsigned long PM_FM_POLLING_RATE = FmPollingRate; unsigned long WAITFOR_SHOWTIME_COUNT = InitTimeout / PM_FM_POLLING_RATE; unsigned long WAITFOR_INIT_COUNT = ActTimeout / PM_FM_POLLING_RATE; unsigned long RETRY_WAIT_TIME = RETRY_WAIT_TIME_MIN_MSEC / PM_FM_POLLING_RATE; - if (RetryTime > RETRY_WAIT_TIME_MIN_MSEC) // STM Gian Set RetryTime Only if is Bigger then minimum value - RETRY_WAIT_TIME = RetryTime / PM_FM_POLLING_RATE; unsigned long INIT_POLLING_TIME = 5; //(??????) unsigned long WAITFOR_DISORDERLY_COUNT = 3; + UINT delay = 0; + + if (RetryTime > RETRY_WAIT_TIME_MIN_MSEC) // STM Gian Set RetryTime Only if is Bigger then minimum value + RETRY_WAIT_TIME = RetryTime / PM_FM_POLLING_RATE; + + PRINT_ERROR("FmPollingRate=%ldms,InitTimeout=%ldms,ActTimeout=%ld\n", + FmPollingRate,InitTimeout,ActTimeout); + NEAR_LCDNI_COUNT = LCD_Trig / PM_FM_POLLING_RATE; NEAR_LCDI_COUNT = NEAR_LCDNI_COUNT; NEAR_LOS_COUNT = LOS_LOF_Trig / PM_FM_POLLING_RATE; @@ -194,8 +202,6 @@ FAR_LOS_SHORT_COUNT = NEAR_LOS_COUNT; FAR_LOF_SHORT_COUNT = NEAR_LOS_COUNT; - UINT delay = 0; - while (amu_go) { xtm_wkafter(500); @@ -279,7 +285,7 @@ g_WaitForDisorderly++; if(g_WaitForDisorderly >= WAITFOR_DISORDERLY_COUNT) { - + int i; // if (RetryTime != 0) // msw_report_event(AMU_EVENT_RETRY,0); @@ -297,7 +303,7 @@ if(l_RetCode != C_AMSW_ACK) { PRINT_ERROR("Error in AMSW_ANT_requestModemStateChange(C_AMSW_IDLE) = %d\n", l_RetCode); } - else for (int i=0; i<6; i++) + else for (i=0; i<6; i++) { if (g_ModemState == C_AMSW_IDLE || GlobalRemove) break; xtm_wkafter(500); @@ -345,7 +351,7 @@ // LCDI (Loss Of Cell Delineation Interleaved), // LCDNI (Loss Of Cell Delineation Fast)defects -unsigned long FM_Polling(bool pm_poll) +unsigned long FM_Polling(BOOLEAN pm_poll) { unsigned long l_RetCode = C_AMSW_REJ; @@ -361,8 +367,8 @@ //####################### Loss Of Signal ############################## if( ((g_def_bitmap_set.near_end.status & LOS) == LOS) || - ((g_def_bitmap_set.near_end.status & LOS) == 0) && - ((g_def_bitmap_set.near_end.change & LOS) == LOS) ) + (((g_def_bitmap_set.near_end.status & LOS) == 0) && + ((g_def_bitmap_set.near_end.change & LOS) == LOS)) ) { g_NEAR_LOS++; } @@ -371,8 +377,8 @@ g_NEAR_LOS = 0; } if( ((g_def_bitmap_set.far_end.status & LOS) == LOS) || - ((g_def_bitmap_set.far_end.status & LOS) == 0) && - ((g_def_bitmap_set.far_end.change & LOS) == LOS) ) + (((g_def_bitmap_set.far_end.status & LOS) == 0) && + ((g_def_bitmap_set.far_end.change & LOS) == LOS)) ) { g_FAR_LOS++; } diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/amu.h ./amu/amu.h --- ../unicorn-0.9.3-2/amu/amu.h 2008-01-10 08:10:08.000000000 +0000 +++ ./amu/amu.h 2009-03-12 21:16:24.000000000 +0000 @@ -46,7 +46,15 @@ T_AMSW_Ber g_Ber; T_AMSW_VersionMS g_VersionMS; -void AMUTask(unsigned long Arg1, unsigned long , unsigned long , unsigned long ); +#ifdef __cplusplus +extern "C" { +#endif + unsigned long amu_init_modem(unsigned short); + void AMUTask(unsigned long, unsigned long , unsigned long , unsigned long ); +#ifdef __cplusplus +} +#endif + unsigned long FM_Polling(BOOLEAN pm_poll); unsigned long PM_Polling(void); diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/amu/bsp_pci.cpp ./amu/bsp_pci.cpp --- ../unicorn-0.9.3-2/amu/bsp_pci.cpp 2003-09-26 12:19:08.000000000 +0100 +++ ./amu/bsp_pci.cpp 2008-01-10 08:10:08.000000000 +0000 @@ -98,10 +98,18 @@ return 0; } -extern "C" void HandleAtmError(void) +#ifdef __cplusplus +extern "C" { +#endif + +void HandleAtmError(void) { } -extern "C" void HandleLeds(void) +void HandleLeds(void) { } + +#ifdef __cplusplus +} +#endif diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/debian/changelog ./debian/changelog --- ../unicorn-0.9.3-2/debian/changelog 2008-01-10 08:10:45.000000000 +0000 +++ ./debian/changelog 2009-03-05 20:19:56.000000000 +0000 @@ -1,3 +1,11 @@ +unicorn (0.9.3-2~rzr2~njl) unstable; urgency=low + + * Add patches to be built on actual kernel (Closes: #394465) : + - bewan-adsl-0.9.3-linux-2.6.26.patch from me + (Note that currently it fails to build using m-a) + + -- Philippe Coval <r...@users.sf.net> Thu, 06 Nov 2008 16:01:01 +0100 + unicorn (0.9.3-2) unstable; urgency=low * Add gentoo patches "bewan-adsl-0.9.3-patches-20061220.tar.gz" diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/debian/rules ./debian/rules --- ../unicorn-0.9.3-2/debian/rules 2008-01-10 08:10:45.000000000 +0000 +++ ./debian/rules 2009-03-05 20:08:24.000000000 +0000 @@ -135,24 +135,32 @@ # responsible for cleaning up any changes that have been made by the # other kdist_commands (except for the .deb files created). kdist_clean: - $(MAKE) $(MFLAGS) debian/rules clean + -$(MAKE) -k $(MFLAGS) debian/rules clean ### end KERNEL SETUP -#ugly hack to use gentoo patches -CXX_FILES?=amu/amas.cpp amu/amu.cpp amu/bsp_pci.cpp amu/bsp_usb.cpp msw/msw.cpp +GENERATED_C_FILES?=\ + adsl_status/config.h adsl_status/Makefile adsl_status/*/Makefile \ + adsl_status/po/Makefile.in \ + */modules.order \ + # -GENERATED_C_FILES?=${CXX_FILES:.cpp=.c} +#ugly hack to use gentoo patches +CXX_FILES?=amu/amas.cpp amu/amu.cpp amu/bsp_pci.cpp amu/bsp_usb.cpp \ + msw/msw.cpp %.c: %.cpp - ln -fs ${<F} $...@} + ln -fs "${<F}" "$...@}" + +prepatch: ${CXX_FILES:.cpp=.c} -prepatch: ${GENERATED_C_FILES} +postpatch: ${CXX_FILES:.cpp=.c} + rm -f $^ configure: configure-stamp -configure-stamp: prepatch patch +configure-stamp: prepatch patch postpatch dh_testdir cd adsl_status; ./configure --prefix=/usr touch configure-stamp @@ -239,14 +247,20 @@ build: build-arch build-indep -clean: unpatch +clean: prepatch unpatch postpatch dh_testdir dh_testroot rm -f build-arch-stamp build-indep-stamp configure-stamp # Add here commands to clean up after the build process. ${MAKE} -C adsl_status clean || echo "# $@" - ${MAKE} clean || echo "# $@" + ${MAKE} -k clean || echo "# $@" rm -f ${GENERATED_C_FILES} + find . -iname "*.tmp*" -type f -exec rm -f '{}' \; + find . -iname ".*.o.cmd" -type f -exec rm -f '{}' \; + find . -iname ".*.o.d" -type f -exec rm -f '{}' \; + find . -iname "config.log" -type f -exec rm -f '{}' \; + find . -iname "config.status" -type f -exec rm -f '{}' \; + find . -iname "config.cache" -type f -exec rm -f '{}' \; dh_clean install: DH_OPTIONS= diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/include/rapi.h ./include/rapi.h --- ../unicorn-0.9.3-2/include/rapi.h 2004-01-30 16:38:30.000000000 +0000 +++ ./include/rapi.h 2009-03-07 08:45:50.000000000 +0000 @@ -11,6 +11,10 @@ #ifndef __rapi__h_ #define __rapi__h_ +#ifndef DWORD +# define DWORD long unsigned int +#endif + #ifdef __cplusplus extern "C" { #endif diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/msw/linrapi.c ./msw/linrapi.c --- ../unicorn-0.9.3-2/msw/linrapi.c 2008-01-10 08:10:08.000000000 +0000 +++ ./msw/linrapi.c 2009-03-13 08:26:23.000000000 +0000 @@ -24,6 +24,9 @@ #include <linux/delay.h> #include <linux/signal.h> #include <linux/smp_lock.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) +#include <linux/kthread.h> +#endif #include "types.h" #include "hal.h" #include "hard.h" @@ -587,7 +590,11 @@ void do_rapi_lock(const char *func) { if (down_trylock(&rapi_thread_lock)) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) DBG(1,"%s: down_trylock lock failed,task=%s\n",func,current->comm); +#else + DBG(1,"%s: down_trylock lock failed,task=FIXME\n",func); +#endif down(&rapi_thread_lock); } } @@ -595,9 +602,15 @@ void do_rapi_unlock(const char *func) { up(&rapi_thread_lock); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) if (rapi_thread_lock.count.counter > 1) { WARN("%s: counter > 1 (%d),task=%s\n",func,rapi_thread_lock.count.counter,current->comm); } +#else + if (rapi_thread_lock.count > 1) { + WARN("%s: counter > 1 (%d),task=FIXME\n",func,rapi_thread_lock.count); + } +#endif } // Check if the address is a valid RAPI object @@ -773,7 +786,11 @@ { struct rapi_task *k; if ((k = find_task(current))) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) WARN("task %s killed\n",current->comm); +#else + WARN("task %.4s killed\n",k->name); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,8)) atomic_dec(&running_tasks); rapi_unlock(); @@ -782,7 +799,11 @@ BUG(); #endif } else { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) WARN("thread %s not rAPI task\n",current->comm); +#else + WARN("thread FIXME not rAPI task\n"); +#endif } } @@ -800,7 +821,7 @@ return FAILURE; } *bufaddr = &m->mem; - DBG(RAPI_D,"size=%ld,bufaddr=%lx\n",size,(long)(*bufaddr)); + DBG(RAPI_D,"size=%lu,bufaddr=%p\n",size,*bufaddr); return SUCCESS; } @@ -862,6 +883,7 @@ return FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) lock_kernel(); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) daemonize("UNICORN"); @@ -874,6 +896,7 @@ strncat(current->comm, k->name, 4); unlock_kernel(); +#endif DBG(RAPI_D,"start %.4s\n",k->name); @@ -897,7 +920,9 @@ ) { struct rapi_task *k = (struct rapi_task *)tid; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) int pid; +#endif if (!is_valid(k, TASK_TYPE)) { return FAILURE; @@ -906,6 +931,7 @@ k->start_addr = start_addr; memcpy(k->args,args,sizeof(k->args)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pid = kernel_thread(start_fn, k, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); if (pid <= 0) { WARN("kernel_thread failed\n"); @@ -918,6 +944,17 @@ del_obj(k); return FAILURE; } +#else + k->thread = kthread_run(start_fn, k, "unicorn_%.4s", k->name); + if (IS_ERR(k->thread)) { + int err; + err = PTR_ERR(k->thread); + WARN("Failed to create unicorn %.4s thread, err=%d\n", k->name, err); + del_obj(k); + return FAILURE; + } +#endif + #ifdef CONFIG_SMP #ifndef CPU_MASK_CPU0 #define CPU_MASK_CPU0 1UL @@ -955,8 +992,12 @@ // Wait until all threads have terminated count = 20; while (atomic_read(&running_tasks) && count--) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) current->state = TASK_INTERRUPTIBLE; schedule_timeout(HZ); +#else + schedule_timeout_interruptible(HZ); +#endif } DBG(1,"exit,running_tasks=%d\n",running_tasks.counter); @@ -1048,8 +1089,13 @@ return FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) DBG(RAPI_D,"sem=%.4s,count=%d,timeout=%ldms\n", s->name,s->sem.count.counter,no_wait ? 0 : timeout); +#else + DBG(RAPI_D,"sem=%.4s,count=%d,timeout=%ldms\n", + s->name,s->sem.count,no_wait ? 0 : timeout); +#endif status = SUCCESS; if (down_trylock(&s->sem)) { @@ -1073,7 +1119,11 @@ failed = down_interruptible(&s->sem); rapi_lock(); if (failed) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) WARN("down_interruptible failed,sem=%.4s,count=%d\n",s->name,s->sem.count.counter); +#else + WARN("down_interruptible failed,sem=%.4s,count=%d\n",s->name,s->sem.count); +#endif status = FAILURE; // has a timeout occured ? if (sigismember(¤t->pending.signal,SIGALRM)) { @@ -1095,7 +1145,11 @@ if (GlobalRemove) rapi_exit_handler(); } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) DBG(RAPI_D,"sem=%.4s,count=%d,status=%ld\n",s->name,s->sem.count.counter,status); +#else + DBG(RAPI_D,"sem=%.4s,count=%d,status=%ld\n",s->name,s->sem.count,status); +#endif return status; } @@ -1111,8 +1165,13 @@ return FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) DBG(RAPI_D,"sem=%.4s,count=%d\n", s->name,s->sem.count.counter); +#else + DBG(RAPI_D,"sem=%.4s,count=%d\n", + s->name,s->sem.count); +#endif up(&s->sem); @@ -1451,12 +1510,15 @@ // ---------------------------- DWORD xtm_wkafter(DWORD ms) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) signed long ticks; +#endif DBG(RAPI_D,"timeout=%ldms\n",ms); if (GlobalRemove) rapi_exit_handler(); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) ticks = (ms*HZ)/1000; rapi_unlock(); @@ -1469,6 +1531,12 @@ mdelay(ms); } rapi_lock(); +#else + rapi_unlock(); + msleep_interruptible(ms); + // I think there's no need to check return value as we return on signal pending anyway. + rapi_lock(); +#endif if (GlobalRemove || signal_pending(current)) { rapi_exit_handler(); diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/msw/msw.c ./msw/msw.c --- ../unicorn-0.9.3-2/msw/msw.c 2008-01-10 08:10:08.000000000 +0000 +++ ./msw/msw.c 2009-03-15 09:42:17.000000000 +0000 @@ -17,8 +17,14 @@ int amu_go; -unsigned long amu_init_modem(unsigned short MODE); +#ifdef __cplusplus +extern "C" { +#endif + unsigned long amu_init_modem(unsigned short); void AMUTask(unsigned long,unsigned long ,unsigned long ,unsigned long); +#ifdef __cplusplus +} +#endif extern unsigned long g_AMUQid; extern unsigned long g_ModemState; @@ -27,7 +33,7 @@ extern BOOLEAN L3_flag; extern unsigned long GlobalRemove; -#if 0 +#if defined(__cplusplus) extern void *operator new(size_t size) { void *ptr; diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/msw/msw.cpp ./msw/msw.cpp --- ../unicorn-0.9.3-2/msw/msw.cpp 2003-09-26 12:19:08.000000000 +0100 +++ ./msw/msw.cpp 2009-03-15 09:42:17.000000000 +0000 @@ -6,7 +6,7 @@ // Copyright STMicroelectronics 2000 // Copyright F.H.L.P. 2000 //---------------------------------------------------------------------- -#include <string.h> +// #include <string.h> #include "types.h" #include "tracetool.h" #include "hal.h" @@ -17,17 +17,23 @@ int amu_go; -unsigned long amu_init_modem(unsigned short MODE); +#ifdef __cplusplus +extern "C" { +#endif + unsigned long amu_init_modem(unsigned short); void AMUTask(unsigned long,unsigned long ,unsigned long ,unsigned long); +#ifdef __cplusplus +} +#endif extern unsigned long g_AMUQid; extern unsigned long g_ModemState; extern unsigned int g_WaitForInit; extern unsigned int g_WaitForShowtime; -extern bool L3_flag; +extern BOOLEAN L3_flag; extern unsigned long GlobalRemove; -#if 1 +#if defined(__cplusplus) extern void *operator new(size_t size) { void *ptr; @@ -186,8 +192,9 @@ } else { + int i; PRINT_ERROR("Waiting 5 sec to verify L3_executed\n"); - for (int i=0; i<10; i++) + for (i=0; i<10; i++) { // Abort everything on surprise removal if (GlobalRemove) return; diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/unicorn_eth/unicorn_ethdrv.c ./unicorn_eth/unicorn_ethdrv.c --- ../unicorn-0.9.3-2/unicorn_eth/unicorn_ethdrv.c 2008-01-10 08:10:08.000000000 +0000 +++ ./unicorn_eth/unicorn_ethdrv.c 2009-03-14 20:17:23.000000000 +0000 @@ -1391,7 +1391,9 @@ } unicorn_ethdrv = drv = eth_dev->priv; memset(drv, 0, sizeof(struct unicorn_ethdrv)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(eth_dev); +#endif drv->dev = eth_dev; drv->adsl_status = ADSL_STATUS_NOHARDWARE; drv->vpi = VPI; @@ -1431,7 +1433,7 @@ eth_dev->mtu = ETH_DATA_LEN; } - if (if_name) { + if (if_name && *if_name) { strncpy (eth_dev->name,if_name,IFNAMSIZ); } else { strncpy (eth_dev->name,UNICORN_ETH_NAME,IFNAMSIZ); diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/unicorn_pci/Makefile ./unicorn_pci/Makefile --- ../unicorn-0.9.3-2/unicorn_pci/Makefile 2008-01-10 08:10:09.000000000 +0000 +++ ./unicorn_pci/Makefile 2009-03-15 09:16:23.000000000 +0000 @@ -47,6 +47,8 @@ OBJS = unicorn_pcidrv.o ../msw/linrapi.o ../msw/msw.o ../msw/crc.o ../amu/amas.o ../amu/amu.o ../amu/bsp_pci.o OBJS_ATM = ../unicorn_atm/unicorn_atmdrv.o OBJS_ETH = ../unicorn_eth/unicorn_ethdrv.o +# OBJS_CXX=../msw/msw.o ../amu/amas.o ../amu/amu.o ../amu/bsp_pci.o + ifdef CONFIG_REGPARM MODEM_LIB = $(src)/../arch/i386/modem_ant_PCI_LINUX.o.regparm3 else @@ -60,8 +62,8 @@ modules_install: install_atm install_eth else # kernel 2.6, use kernel build process -modules: - make CC=$(CC) -C $(KERNEL_SOURCES) SUBDIRS=$(MODDIR) modules +modules: $(OBJS_CXX) + make CC=$(CC) -C $(KERNEL_SOURCES) SUBDIRS=$(MODDIR) modules KBUILD_VERBOSE=1 modules_install: make CC=$(CC) -C $(KERNEL_SOURCES) SUBDIRS=$(MODDIR) modules_install endif Only in ./unicorn_pci: Module.symvers Only in ./unicorn_pci: modules.order Only in ./unicorn_pci: unicorn_pci_atm.mod.c Only in ./unicorn_pci: unicorn_pci_eth.mod.c diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/unicorn_pci/unicorn_pcidrv.c ./unicorn_pci/unicorn_pcidrv.c --- ../unicorn-0.9.3-2/unicorn_pci/unicorn_pcidrv.c 2008-01-10 08:10:09.000000000 +0000 +++ ./unicorn_pci/unicorn_pcidrv.c 2009-03-08 16:46:19.000000000 +0000 @@ -930,9 +930,15 @@ pci_dev = NULL; do { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pci_dev = pci_find_device(PCI_VENDOR_ID_ST, PCI_DEVICE_ID_UNICORN, pci_dev); +#else + pci_dev = pci_get_device(PCI_VENDOR_ID_ST, + PCI_DEVICE_ID_UNICORN, + pci_dev); +#endif if (pci_dev) { DBG(1,"vendor=%04x,device=%04x,irq=%d\n", pci_dev->vendor,pci_dev->device,pci_dev->irq); @@ -992,7 +998,11 @@ phys_base,dev->mem,dev->mem_size); // Initialize and connect the interrupt +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) status = request_irq(pci_dev->irq, unicorn_isr, SA_SHIRQ, "unicorn_pci", dev); +#else + status = request_irq(pci_dev->irq, unicorn_isr, IRQF_SHARED, "unicorn_pci", dev); +#endif if (status) { WARN("Failed to connect Interrupt,status=%d\n",status); return status; diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/unicorn_usb/Makefile ./unicorn_usb/Makefile --- ../unicorn-0.9.3-2/unicorn_usb/Makefile 2008-01-10 08:10:09.000000000 +0000 +++ ./unicorn_usb/Makefile 2009-03-15 09:16:29.000000000 +0000 @@ -43,6 +43,7 @@ OBJS = unicorn_usbdrv.o ../msw/linrapi.o ../msw/msw.o ../msw/crc.o ../amu/amas.o ../amu/amu.o ../amu/bsp_usb.o OBJS_ATM = ../unicorn_atm/unicorn_atmdrv.o OBJS_ETH = ../unicorn_eth/unicorn_ethdrv.o +# OBJS_CXX=../msw/msw.o ../amu/amas.o ../amu/amu.o ../amu/bsp_usb.o MODEM_LIB = $(src)/../arch/i386/modem_ant_USB_LINUX.o LIBM = $(src)/../libm/libm.a @@ -52,7 +53,7 @@ modules_install: install_atm install_eth else # kernel 2.6, use kernel build process -modules: +modules: $(OBJS_CXX) make CC=$(CC) -C $(KERNEL_SOURCES) SUBDIRS=$(MODDIR) modules modules_install: make CC=$(CC) -C $(KERNEL_SOURCES) SUBDIRS=$(MODDIR) modules_install Only in ./unicorn_usb: Module.symvers Only in ./unicorn_usb: modules.order Only in ./unicorn_usb: unicorn_usb_atm.mod.c Only in ./unicorn_usb: unicorn_usb_eth.mod.c diff -urw --exclude '*.[ao]' --exclude '*.sav' --exclude '*.ko' --exclude '.[a-z]*' --exclude '*.orig' --exclude '*.dbg' --exclude '*.new' ../unicorn-0.9.3-2/unicorn_usb/unicorn_usbdrv.c ./unicorn_usb/unicorn_usbdrv.c --- ../unicorn-0.9.3-2/unicorn_usb/unicorn_usbdrv.c 2008-01-10 08:10:09.000000000 +0000 +++ ./unicorn_usb/unicorn_usbdrv.c 2009-03-14 14:16:26.000000000 +0000 @@ -65,7 +65,8 @@ MODULE_AUTHOR ("fisak...@bewan.com"); MODULE_DESCRIPTION ("ATM driver for the ST UNICORN ADSL modem."); #ifdef MODULE_LICENSE -MODULE_LICENSE("Proprietary"); +// MODULE_LICENSE("Proprietary"); +MODULE_LICENSE("GPL"); #endif @@ -120,6 +121,15 @@ status; \ }) +/* + * cancel a transfer request + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +#define KILL_URB(urb) usb_unlink_urb(urb) +#else +#define KILL_URB(urb) usb_kill_urb(urb) +#endif + #if DEBUG static void dump_urb(struct urb *urb) { @@ -148,7 +158,9 @@ unsigned int pipe, void *buf, int length, int packet_size, usb_complete_t complete, void *context) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) spin_lock_init(&urb->lock); +#endif urb->dev=dev; urb->pipe=pipe; urb->transfer_buffer=buf; @@ -1294,7 +1306,7 @@ // EP_INTERRUPT for (i=0; i < 2; i++) { if ((urb = dev->int_in_pipe[i])) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->int_in_pipe[i] = NULL; } @@ -1302,14 +1314,14 @@ // EP_OBC_ISO_OUT if ((urb = dev->obc_iso_out)) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->obc_iso_out = NULL; } // EP_OBC_ISO_IN if ((urb = dev->obc_iso_in)) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->obc_iso_in = NULL; } @@ -1317,7 +1329,7 @@ // EP_ATM_ISO_OUT for (i=0; i < ATM_WRITES; i++) { if ((urb = dev->atm_write[i])) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->atm_write[i] = NULL; } @@ -1326,7 +1338,7 @@ // EP_ATM_ISO_IN for (i=0; i < ATM_READS; i++) { if ((urb = dev->atm_read[i])) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->atm_read[i] = NULL; } @@ -1334,14 +1346,14 @@ // EP_OBC_INT_OUT if ((urb = dev->obc_int_out)) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->obc_int_out = NULL; } // EP_OBC_INT_IN if ((urb = dev->obc_int_in)) { - usb_unlink_urb(urb); + KILL_URB(urb); usb_free_urb(urb); dev->obc_int_in = NULL; }