X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/dd8f5100e766813dca62a82c6b99ebf3648f2448..50e9e47fc21191ea9ea758fea1e7f2bd5a275e98:/lincan/src/can_quertl.c diff --git a/lincan/src/can_quertl.c b/lincan/src/can_quertl.c index 2ebc265..50d6081 100644 --- a/lincan/src/can_quertl.c +++ b/lincan/src/can_quertl.c @@ -1,10 +1,35 @@ -/* can_quertl.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.2 9 Jul 2003 - */ +/**************************************************************************/ +/* File: can_quertl.c - CAN message queues functions for the RT-Linux */ +/* */ +/* LinCAN - (Not only) Linux CAN bus driver */ +/* Copyright (C) 2002-2009 DCE FEE CTU Prague */ +/* Copyright (C) 2002-2009 Pavel Pisa */ +/* 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 @@ -14,8 +39,8 @@ #include -/* - * Modifies Tx message processing +/* + * Modifies Tx message processing * 0 .. local message processing disabled * 1 .. local messages disabled by default but can be enabled by canque_set_filt * 2 .. local messages enabled by default, can be disabled by canque_set_filt @@ -40,7 +65,7 @@ canqueue_rtl2lin_handler(int irq, void *ignore, struct pt_regs *ignoreregs) unsigned pending_inops; unsigned pending_outops; int i; - + can_spin_lock_irqsave (&canque_pending_edges_lock, flags); while(!list_empty(&canque_pending_edges_list)){ @@ -69,7 +94,7 @@ canqueue_rtl2lin_handler(int irq, void *ignore, struct pt_regs *ignoreregs) if(pending_inops&1) canque_notify_inends(qedge,i); } - + canque_edge_decref(qedge); can_spin_lock_irqsave (&canque_pending_edges_lock, flags); } @@ -84,7 +109,7 @@ canqueue_rtl2lin_handler(int irq, void *ignore, struct pt_regs *ignoreregs) /** - * canqueue_rtl2lin_check_and_pend - postpones edge notification if called from RT-Linux + * canqueue_rtl2lin_check_and_pend - postpones edge notification if called from RT-Linux * @qends: notification target ends * @qedge: edge delivering notification * @what: notification type @@ -101,7 +126,7 @@ int canqueue_rtl2lin_check_and_pend(struct canque_ends_t *qends, if(rtl_rt_system_is_idle()) return 0; can_spin_lock_irqsave (&canque_pending_edges_lock, flags); - + if(what>CANQUE_PENDOPS_LIMIT) what=CANQUE_PENDOPS_LIMIT; if(qends == qedge->inends) { @@ -117,7 +142,7 @@ int canqueue_rtl2lin_check_and_pend(struct canque_ends_t *qends, } can_spin_unlock_irqrestore (&canque_pending_edges_lock, flags); - + return 1; } @@ -144,7 +169,7 @@ int canque_get_inslot4id_wait_rtl(struct canque_ends_t *qends, int ret; unsigned old_age; rtl_sigset_t sigset; - + old_age=atomic_read(&qends->endinfo.rtlinfo.rtl_writeq_age); while((ret=canque_get_inslot4id(qends,qedgep,slotp,cmd,id,prio))==-1){ rtl_sigemptyset(&sigset); @@ -156,7 +181,7 @@ int canque_get_inslot4id_wait_rtl(struct canque_ends_t *qends, return -1; old_age=atomic_read(&qends->endinfo.rtlinfo.rtl_writeq_age); } - + return ret; } @@ -180,7 +205,7 @@ int canque_get_outslot_wait_rtl(struct canque_ends_t *qends, int ret; unsigned old_age; rtl_sigset_t sigset; - + old_age=atomic_read(&qends->endinfo.rtlinfo.rtl_readq_age); while((ret=canque_test_outslot(qends,qedgep,slotp))==-1){ rtl_sigemptyset(&sigset); @@ -211,7 +236,7 @@ int canque_sync_wait_rtl(struct canque_ends_t *qends, struct canque_edge_t *qedg int ret; unsigned old_age; rtl_sigset_t sigset; - + old_age=atomic_read(&qends->endinfo.rtlinfo.rtl_emptyq_age); while(!(ret=canque_fifo_test_fl(&qedge->fifo,EMPTY)?1:0)){ rtl_sigemptyset(&sigset); @@ -223,7 +248,7 @@ int canque_sync_wait_rtl(struct canque_ends_t *qends, struct canque_edge_t *qedg return -1; old_age=atomic_read(&qends->endinfo.rtlinfo.rtl_emptyq_age); } - + return ret; } @@ -307,13 +332,13 @@ void canque_ends_free_rtl(struct canque_ends_t *qends) /** * canqueue_notify_rtl - notification callback handler for Linux userspace clients * @qends: pointer to the callback side ends structure - * @qedge: edge which invoked notification + * @qedge: edge which invoked notification * @what: notification type */ void canqueue_notify_rtl(struct canque_ends_t *qends, struct canque_edge_t *qedge, int what) { rtl_irqstate_t flags; - + switch(what){ case CANQUEUE_NOTIFY_EMPTY: rtl_spin_lock_irqsave(&qends->endinfo.rtlinfo.rtl_lock, flags); @@ -372,7 +397,7 @@ int canqueue_ends_init_rtl(struct canque_ends_t *qends) rtl_wait_init(&(qends->endinfo.rtlinfo.rtl_readq)); rtl_wait_init(&(qends->endinfo.rtlinfo.rtl_writeq)); rtl_wait_init(&(qends->endinfo.rtlinfo.rtl_emptyq)); - + qends->notify=canqueue_notify_rtl; qends->endinfo.rtlinfo.pend_flags=0; return 0; @@ -397,7 +422,7 @@ int canqueue_ends_dispose_rtl(struct canque_ends_t *qends, int sync) /*Wait for sending of all pending messages in the output FIFOs*/ /*if(sync) canqueue_ends_sync_all_rtl(qends);*/ - + /* Finish or kill all outgoing edges listed in inends */ delayed=canqueue_ends_kill_inlist(qends, 1); /* Kill all incoming edges listed in outends */