# HG changeset patch # User greg # Date 1212389526 -7200 # Node ID 40efa79d27ddbedf717a9c46b857d47c11f1cd42 # Parent b71655eca5e2ee0b37c0795ddefee498f088f23f kerneltest updated for the new api diff -r b71655eca5e2 -r 40efa79d27dd configure --- a/configure Tue May 27 17:43:33 2008 +0200 +++ b/configure Mon Jun 02 08:52:06 2008 +0200 @@ -161,7 +161,7 @@ echo " see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html" echo " \"can4linux\" can4linux driver" echo " see http://www.port.de/engl/canprod/hw_can4linux.html" - echo " --timers=foo Use 'foo' as TIMERS driver (can be 'unix', 'xeno' or 'kernel')" + echo " --timers=foo Use 'foo' as TIMERS driver (can be 'unix', 'xeno', 'rtai' or 'kernel')" echo " --wx=foo force result of WxWidgets detection (0 or 1)" echo " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers" echo " --enable-lss Enable the LSS services" diff -r b71655eca5e2 -r 40efa79d27dd drivers/timers_kernel/timers_kernel.c --- a/drivers/timers_kernel/timers_kernel.c Tue May 27 17:43:33 2008 +0200 +++ b/drivers/timers_kernel/timers_kernel.c Mon Jun 02 08:52:06 2008 +0200 @@ -36,6 +36,15 @@ last_occured_alarm, last_alarm_set; +void TimerInit(void) +{ + /* only used in realtime apps */ +} + +void TimerCleanup(void) +{ + /* only used in realtime apps */ +} void EnterMutex(void) { @@ -71,10 +80,11 @@ LeaveMutex(); } -void StopTimerLoop(void) +void StopTimerLoop(TimerCallback_t exitfunction) { EnterMutex(); del_timer (&timer); + exitfunction(NULL,0); LeaveMutex(); } @@ -99,7 +109,7 @@ *Thread = kthread_run(ReceiveLoopPtr, port, "canReceiveLoop"); } -void WaitReceiveTaskEnd(TASK_HANDLE Thread) +void WaitReceiveTaskEnd(TASK_HANDLE *Thread) { - force_sig (SIGTERM, Thread); + force_sig (SIGTERM, *Thread); } diff -r b71655eca5e2 -r 40efa79d27dd drivers/unix/unix.c --- a/drivers/unix/unix.c Tue May 27 17:43:33 2008 +0200 +++ b/drivers/unix/unix.c Mon Jun 02 08:52:06 2008 +0200 @@ -245,4 +245,5 @@ EXPORT_SYMBOL (canOpen); EXPORT_SYMBOL (canClose); EXPORT_SYMBOL (canSend); +EXPORT_SYMBOL (canChangeBaudRate); #endif diff -r b71655eca5e2 -r 40efa79d27dd examples/kerneltest/TestMasterSlave.c --- a/examples/kerneltest/TestMasterSlave.c Tue May 27 17:43:33 2008 +0200 +++ b/examples/kerneltest/TestMasterSlave.c Mon Jun 02 08:52:06 2008 +0200 @@ -35,8 +35,20 @@ } } +/*************************** EXIT *****************************************/ +void Exit(CO_Data* d, UNS32 id) +{ + masterSendNMTstateChange(&TestMaster_Data, 0x02, NMT_Reset_Node); + + //Stop master + setState(&TestMaster_Data, Stopped); +} + + int TestMasterSlave_start (void) { + TimerInit(); + if(strcmp(SlaveBoard.baudrate, "none")){ TestSlave_Data.heartbeatError = TestSlave_heartbeatError; @@ -83,21 +95,13 @@ { eprintf("Finishing.\n"); - EnterMutex(); - masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Reset_Node); - LeaveMutex(); - - // Stop master - EnterMutex(); - setState(&TestMaster_Data, Stopped); - LeaveMutex(); - // Stop timer thread - StopTimerLoop(); + StopTimerLoop(&Exit); // Close CAN devices (and can threads) if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data); if(strcmp(MasterBoard.baudrate, "none")) canClose(&TestMaster_Data); + TimerCleanup(); eprintf("End.\n"); } diff -r b71655eca5e2 -r 40efa79d27dd examples/kerneltest/console/console.c --- a/examples/kerneltest/console/console.c Tue May 27 17:43:33 2008 +0200 +++ b/examples/kerneltest/console/console.c Mon Jun 02 08:52:06 2008 +0200 @@ -12,7 +12,7 @@ printf("\nCanFestival kernel test example console\n\n"); printf("start - start example\n"); - printf("end - end example\n"); + printf("stop - stop example\n"); printf("quit - quit console\n"); printf("\n"); } @@ -42,7 +42,7 @@ if (strcmp(command,"start") == 0) cmd = CMD_START; - else if (strcmp(command,"end") == 0) + else if (strcmp(command,"stop") == 0) cmd = CMD_STOP; else if (strcmp(command,"quit") == 0) diff -r b71655eca5e2 -r 40efa79d27dd examples/kerneltest/kernel_module.c --- a/examples/kerneltest/kernel_module.c Tue May 27 17:43:33 2008 +0200 +++ b/examples/kerneltest/kernel_module.c Mon Jun 02 08:52:06 2008 +0200 @@ -17,6 +17,9 @@ static DECLARE_MUTEX (canftest_mutex); static int canftest_stopped = 1; +int thread_start (void* data); +int thread_stop (void* data); + // handler processing write() requests from user-space ssize_t canftest_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) @@ -30,15 +33,33 @@ // process integer as command switch (cmd) { case CMD_START: + if (!canftest_stopped) break; + thread_start_p = kthread_create (thread_start, NULL, "canftest_start"); + + if (PTR_ERR(thread_start_p) == -ENOMEM) { + printk(KERN_WARNING "canftest: error creating start thread\n"); + return -ENOMEM; + } + wake_up_process (thread_start_p); break; + case CMD_STOP: if (canftest_stopped) break; + thread_stop_p = kthread_create (thread_stop, NULL, "canftest_stop"); + + if (PTR_ERR(thread_stop_p) == -ENOMEM) { + printk(KERN_WARNING "canftest: error creating stop thread\n"); + return -ENOMEM; + } + wake_up_process (thread_stop_p); break; + // ignore new line character case 10: break; + default: printk("canftest: bad command %d\n", cmd); break; @@ -114,14 +135,6 @@ return ret; } - thread_start_p = kthread_create (thread_start, NULL, "canftest_start"); - thread_stop_p = kthread_create (thread_stop, NULL, "canftest_stop"); - - if (PTR_ERR(thread_start_p) == -ENOMEM || PTR_ERR(thread_stop_p) == -ENOMEM) { - printk(KERN_WARNING "canftest: error creating threads\n"); - return -ENOMEM; - } - return 0; } diff -r b71655eca5e2 -r 40efa79d27dd src/symbols.c --- a/src/symbols.c Tue May 27 17:43:33 2008 +0200 +++ b/src/symbols.c Mon Jun 02 08:52:06 2008 +0200 @@ -124,7 +124,9 @@ // timers_driver.h EXPORT_SYMBOL (EnterMutex); EXPORT_SYMBOL (LeaveMutex); -EXPORT_SYMBOL (WaitReceiveTaskEnd); +EXPORT_SYMBOL (TimerInit); +EXPORT_SYMBOL (TimerCleanup); EXPORT_SYMBOL (StartTimerLoop); EXPORT_SYMBOL (StopTimerLoop); EXPORT_SYMBOL (CreateReceiveTask); +EXPORT_SYMBOL (WaitReceiveTaskEnd);