]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/can_devrtl.c
Added glue required for RTL hardware filters updates.
[lincan.git] / lincan / src / can_devrtl.c
index 182eb42aa36572eebbab662219e5b7963c477d6c..559c2db9a0882e99fa41bfbc0bfea293a7ddd7c5 100644 (file)
 
 #include <rtl_malloc.h>
 
+can_spinlock_t can_irq_manipulation_lock;
+
 unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
 {
        struct chip_t *chip;
        struct candevice_t *candev;
        int board_nr;
        int chip_nr;
+       int irq2linux=0;
        pthread_t thread=NULL;
 
        DEBUGMSG("can_rtl_isr invoked for irq %d\n",irq_num);
@@ -37,14 +40,16 @@ unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
 
                        set_bit(MSGOBJ_IRQ_REQUEST_b,&chip->pend_flags);
                        set_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags);
-                       
+                       if(chip->flags & CHIP_IRQ_PCI)
+                               irq2linux=1;
                        if(!chip->worker_thread) continue;
                        thread=chip->worker_thread;
                        pthread_kill(thread,RTL_SIGNAL_WAKEUP);
                }
        }
 
-       /*rtl_global_pend_irq(irq_num);*/
+       if(irq2linux)
+               rtl_global_pend_irq(irq_num);
 
        /*if(thread) rtl_reschedule_thread(thread);*/
 
@@ -106,10 +111,15 @@ void * can_chip_worker_thread(void *arg)
                        for(i=0;i<chip->max_objects;i++){
                                if((obj=chip->msgobj[i])==NULL)
                                        continue;
-                               if(!can_msgobj_test_and_clear_fl(obj,TX_REQUEST))
-                                       continue;
-                               DEBUGMSG("Calling wakeup_tx\n");
-                               chip->chipspecops->wakeup_tx(chip, obj);
+                               if(can_msgobj_test_fl(obj,TX_REQUEST)) {
+                                       DEBUGMSG("Calling wakeup_tx\n");
+                                       chip->chipspecops->wakeup_tx(chip, obj);
+                               }
+                               if(can_msgobj_test_fl(obj,FILTCH_REQUEST)) {
+                                       DEBUGMSG("Calling filtch_rq\n");
+                                       if(chip->chipspecops->filtch_rq)
+                                               chip->chipspecops->filtch_rq(chip, obj);
+                               }
                        }
                        continue;
                }
@@ -134,9 +144,21 @@ void * can_chip_worker_thread(void *arg)
 int can_chip_setup_irq(struct chip_t *chip)
 {
        int ret;
+        struct sched_param sched_param;
+        pthread_attr_t attrib;
+       pthread_attr_t *attrib_p=NULL;
        
        if(chip==NULL)
                return -1;
+       
+       if(can_rtl_priority>=0){
+               pthread_attr_init(&attrib);
+               sched_param.sched_priority = can_rtl_priority;
+               pthread_attr_setschedparam(&attrib, &sched_param);
+               /* pthread_attr_setschedpolicy(&attrib, SCHED_FIFO); */
+               attrib_p=&attrib;
+       }
+       
        if(chip->chipspecops->irq_handler){
                if (rtl_request_irq(chip->chip_irq,can_rtl_isr))
                        return -1;
@@ -145,7 +167,7 @@ int can_chip_setup_irq(struct chip_t *chip)
                        chip->flags |= CHIP_IRQ_SETUP;
                }
        }
-        ret=pthread_create(&chip->worker_thread, NULL, can_chip_worker_thread, chip);
+        ret=pthread_create(&chip->worker_thread, attrib_p, can_chip_worker_thread, chip);
        if(ret<0) chip->worker_thread=NULL;
        
        return ret;