]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/virtual.c
LinCAN sources go through big white-space cleanup.
[lincan.git] / lincan / src / virtual.c
index 3b300a992813f8bf46c182ecac2b320f4c9a97cd..eb8043f82c24af44ef1b17c2c16bf2a0e8ff104a 100644 (file)
@@ -1,11 +1,36 @@
-/* virtual.c
- * Linux CAN-bus device driver.
- * Written for new CAN driver version 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: virtual.c - virtual chip/board support                           */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 #include "../include/can.h"
 #include "../include/can_sysdep.h"
 #include "../include/main.h"
@@ -113,7 +138,7 @@ int virtual_pre_read_config(struct canchip_t *chip, struct msgobj_t *obj)
  * Return Value: negative value reports error.
  * File: src/virtual.c
  */
-int virtual_pre_write_config(struct canchip_t *chip, struct msgobj_t *obj, 
+int virtual_pre_write_config(struct canchip_t *chip, struct msgobj_t *obj,
                                                        struct canmsg_t *msg)
 {
        return 0;
@@ -130,7 +155,7 @@ int virtual_pre_write_config(struct canchip_t *chip, struct msgobj_t *obj,
  * Return Value: negative value reports error.
  * File: src/virtual.c
  */
-int virtual_send_msg(struct canchip_t *chip, struct msgobj_t *obj, 
+int virtual_send_msg(struct canchip_t *chip, struct msgobj_t *obj,
                                                        struct canmsg_t *msg)
 {
        return 0;
@@ -159,7 +184,7 @@ int virtual_check_tx_stat(struct canchip_t *chip)
  * Return Value: negative value reports error.
  * File: src/virtual.c
  */
-int virtual_set_btregs(struct canchip_t *chip, unsigned short btr0, 
+int virtual_set_btregs(struct canchip_t *chip, unsigned short btr0,
                                                        unsigned short btr1)
 {
        return 0;
@@ -189,6 +214,30 @@ int virtual_stop_chip(struct canchip_t *chip)
        return 0;
 }
 
+/**
+ * virtual_attach_to_chip: - attaches to the chip, setups registers and state
+ * @chip: pointer to chip state structure
+ *
+ * Return Value: negative value reports error.
+ * File: src/virtual.c
+ */
+int virtual_attach_to_chip(struct canchip_t *chip)
+{
+       return 0;
+}
+
+/**
+ * virtual_release_chip: - called before chip structure removal if %CHIP_ATTACHED is set
+ * @chip: pointer to chip state structure
+ *
+ * Return Value: negative value reports error.
+ * File: src/virtual.c
+ */
+int virtual_release_chip(struct canchip_t *chip)
+{
+       virtual_stop_chip(chip);
+       return 0;
+}
 
 /**
  * virtual_remote_request: - configures message object and asks for RTR message
@@ -272,7 +321,7 @@ void virtual_irq_write_handler(struct canchip_t *chip, struct msgobj_t *obj)
  *     The CAN driver uses this pointer to store relationship of interrupt
  *     to chip state structure - @struct canchip_t
  * @regs: system dependent value pointing to registers stored in exception frame
- * 
+ *
  * Interrupt handler is activated when state of CAN controller chip changes,
  * there is message to be read or there is more space for new messages or
  * error occurs. The receive events results in reading of the message from
@@ -293,20 +342,20 @@ void virtual_schedule_next(struct msgobj_t *obj)
        can_preempt_disable();
 
        can_msgobj_set_fl(obj,TX_REQUEST);
-       
+
        while(!can_msgobj_test_and_set_fl(obj,TX_LOCK)){
 
                can_msgobj_clear_fl(obj,TX_REQUEST);
-               
+
                cmd=canque_test_outslot(obj->qends, &obj->tx_qedge, &obj->tx_slot);
                if(cmd>=0) {
                        mod_timer(&obj->tx_timeout,
                                jiffies+virtual_bus_latency(obj));
                        DEBUGMSG("virtual: scheduled delivery\n");
 
-               } else          
+               } else
                        can_msgobj_clear_fl(obj,TX_LOCK);
-               
+
                if(!can_msgobj_test_fl(obj,TX_REQUEST)) break;
                DEBUGMSG("TX looping in virtual_schedule_next\n");
        }
@@ -318,7 +367,7 @@ void virtual_schedule_next(struct msgobj_t *obj)
 void virtual_do_tx_timeout(unsigned long data)
 {
        struct msgobj_t *obj=(struct msgobj_t *)data;
-       
+
        if(obj->tx_slot) {
                /* fill CAN message timestamp */
                can_filltimestamp(&obj->tx_slot->msg.timestamp);
@@ -349,7 +398,7 @@ void virtual_do_tx_timeout(unsigned long data)
 int virtual_wakeup_tx(struct canchip_t *chip, struct msgobj_t *obj)
 {
        /* can_msgobj_set_fl(obj,TX_REQUEST); */
-       
+
        struct canque_edge_t *qedge;
        struct canque_slot_t *slot;
        int cmd;
@@ -364,7 +413,7 @@ int virtual_wakeup_tx(struct canchip_t *chip, struct msgobj_t *obj)
                        if(cmd==0) {
                                /* fill CAN message timestamp */
                                can_filltimestamp(&slot->msg.timestamp);
-                               
+
                                canque_filter_msg2edges(obj->qends, &slot->msg);
                                DEBUGMSG("virtual: direct delivery\n");
                        }
@@ -426,7 +475,7 @@ int virtual_reset(struct candevice_t *candev)
  * Return Value: The function always returns zero
  * File: src/virtual.c
  */
-int virtual_init_hw_data(struct candevice_t *candev) 
+int virtual_init_hw_data(struct candevice_t *candev)
 {
        candev->res_addr=0;
        candev->nr_82527_chips=0;
@@ -473,6 +522,8 @@ int virtual_init_chip_data(struct candevice_t *candev, int chipnr)
        chip->chipspecops->remote_request=virtual_remote_request;
        chip->chipspecops->enable_configuration=virtual_enable_configuration;
        chip->chipspecops->disable_configuration=virtual_disable_configuration;
+       chip->chipspecops->attach_to_chip=virtual_attach_to_chip;
+       chip->chipspecops->release_chip=virtual_release_chip;
        chip->chipspecops->set_btregs=virtual_set_btregs;
        chip->chipspecops->start_chip=virtual_start_chip;
        chip->chipspecops->stop_chip=virtual_stop_chip;