]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/can_devrtl.c
Actual driver code for directly mapped SJA1000 into PCI mem region 0.
[lincan.git] / lincan / src / can_devrtl.c
index ad6d6c206327050092c492b64547d98b1fbd033d..585956c93d52cdcfb844eb2bba9e0de61c20b8dc 100644 (file)
@@ -1,10 +1,35 @@
-/* can_devrtl.c - CAN message queues functions for the RT-Linux
- * Linux CAN-bus device driver.
- * New CAN queues by Pavel Pisa - OCERA team member
- * email:pisa@cmp.felk.cvut.cz
- * This software is released under the GPL-License.
- * Version lincan-0.3  17 Jun 2004
- */
+/**************************************************************************/
+/* File: can_devrtl.c - CAN message queues functions for the RT-Linux     */
+/*                                                                        */
+/* LinCAN - (Not only) Linux CAN bus driver                               */
+/* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz>   */
+/* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz>             */
+/* Funded by OCERA and FRESCOR IST projects                               */
+/*                                                                        */
+/* LinCAN is free software; you can redistribute it and/or modify it      */
+/* under terms of the GNU General Public License as published by the      */
+/* Free Software Foundation; either version 2, or (at your option) any    */
+/* later version.  LinCAN is distributed in the hope that it will be      */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU    */
+/* General Public License for more details. You should have received a    */
+/* copy of the GNU General Public License along with LinCAN; see file     */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
+/* Cambridge, MA 02139, USA.                                              */
+/*                                                                        */
+/* To allow use of LinCAN in the compact embedded systems firmware        */
+/* and RT-executives (RTEMS for example), main authors agree with next    */
+/* special exception:                                                     */
+/*                                                                        */
+/* Including LinCAN header files in a file, instantiating LinCAN generics */
+/* or templates, or linking other files with LinCAN objects to produce    */
+/* an application image/executable, does not by itself cause the          */
+/* resulting application image/executable to be covered by                */
+/* the GNU General Public License.                                        */
+/* This exception does not however invalidate any other reasons           */
+/* why the executable file might be covered by the GNU Public License.    */
+/* Publication of enhanced or derived LinCAN files is required although.  */
+/**************************************************************************/
 
 #ifdef CAN_WITH_RTL
 
@@ -35,7 +60,7 @@ unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
        pthread_t thread=NULL;
 
        DEBUGMSG("can_rtl_isr invoked for irq %d\n",irq_num);
-       
+
        /* I hate next loop, but RT-Linux does not provide context to ISR */
        for (board_nr=hardware_p->nr_boards; board_nr--; ) {
                if((candev=hardware_p->candevice[board_nr])==NULL)
@@ -82,10 +107,10 @@ RTL_MARK_READY(pthread_self())
 RTL_MARK_SUSPENDED(pthread_self());
 return rtl_schedule();
 can_enable_irq
-can_disable_irq 
+can_disable_irq
 rtl_critical( state )
 rtl_end_critical( state )
-rtl_request_global_irq( irq, isr ); 
+rtl_request_global_irq( irq, isr );
 rtl_free_global_irq( irq )
 */
 
@@ -96,23 +121,23 @@ void * can_chip_worker_thread(void *arg)
        int ret, i;
        int loop_cnt;
        rtl_irqstate_t flags;
-       
+
        if(!chip) return 0;
-       
-       
+
+
        if (!(chip->flags & CHIP_CONFIGURED)){
                if (chip->chipspecops->chip_config(chip))
                        CANMSG("Error configuring chip.\n");
                else
-                       chip->flags |= CHIP_CONFIGURED; 
+                       chip->flags |= CHIP_CONFIGURED;
 
                if((chip->msgobj[0])!=NULL)
                        if (chip->chipspecops->pre_read_config(chip,chip->msgobj[0])<0)
                                CANMSG("Error initializing chip for receiving\n");
-                               
+
        } /* End of chip configuration */
        set_bit(MSGOBJ_IRQ_REQUEST_b,&chip->pend_flags);
-       
+
 
        while (1) {
                DEBUGMSG("Worker thread for chip %d active\n",chip->chip_idx);
@@ -155,7 +180,7 @@ void * can_chip_worker_thread(void *arg)
                         *
                         * irq_accept added to the LinCAN driver now,
                         * and above workaround should not be required.
-                        * Enable rtl_hard_enable_irq() at line 
+                        * Enable rtl_hard_enable_irq() at line
                         * ca91c042.c:1045
                         */
                    #endif /*CAN_ENABLE_VME_SUPPORT*/
@@ -183,10 +208,10 @@ int can_chip_setup_irq(struct canchip_t *chip)
         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;
@@ -194,7 +219,7 @@ int can_chip_setup_irq(struct canchip_t *chip)
                /* pthread_attr_setschedpolicy(&attrib, SCHED_FIFO); */
                attrib_p=&attrib;
        }
-       
+
        if(chip->chipspecops->irq_handler && !(chip->flags & CHIP_IRQ_CUSTOM)){
                int (*my_request_irq)(unsigned int vector, unsigned int (*rtl_handler)(unsigned int irq, struct pt_regs *regs));
 #ifdef CAN_ENABLE_VME_SUPPORT
@@ -213,7 +238,7 @@ int can_chip_setup_irq(struct canchip_t *chip)
        }
         ret=pthread_create(&chip->worker_thread, attrib_p, can_chip_worker_thread, chip);
        if(ret<0) chip->worker_thread=NULL;
-       
+
        return ret;
 }