rt-Verzeichnis aufger?umt. kernel2.6
authorFlorian Pose <fp@igh-essen.com>
Fri, 16 Dec 2005 09:44:54 +0000
branchkernel2.6
changeset 32 7d9809fbf7b9
parent 31 2b3e06f48ffe
child 33 f4171b8aadf8
rt-Verzeichnis aufger?umt.
rt/TAGS
rt/aip_com.c
rt/aip_com.h
rt/aip_comP.h
rt/cif-rtai-io.h
rt/msr_io.c
rt/msr_io.h
rt/tmp/_msr_io.c
rt/tmp/_msr_io.h
--- a/rt/TAGS	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-
-_msr_io.c,315
-#  define __KERNEL__44,1091
-#  define MODULE47,1134
-spinlock_t data_lock 64,1449
-#define PB_CARDS 79,1926
-} card[91,2142
-void x_PB_io(109,2505
-int msr_io_init(151,3460
-#define FIFO_BUF 157,3532
-int msr_io_register(235,5684
-int msr_io_write(261,6090
-int msr_io_read(363,8522
-void msr_io_cleanup(400,9200
-
-_msr_io.h,100
-#define _MSR_IO_H_119,3261
-struct cif_in_t cif_in_t128,3512
-struct cif_out_t cif_out_t135,3664
-
-cif-rtai-io.h,0
-
-msr_io.c,559
-RT_TASK check_running;54,1293
-RT_TASK process_image;55,1316
-SEM data_lock;57,1340
-#define PARAM_FILENO 60,1381
-#define CVT_FILENO 61,1405
-#define MSG_FILENO	62,1427
-#define PB_CARDS 64,1449
-} card[78,1692
-int msr_print(80,1711
-inline int msr_print_error(97,1982
-inline int msr_print_info(106,2138
-inline int msr_print_warn(115,2294
-void x_PB_io(140,2830
-void process_thread(145,2909
-void check_thread(254,6015
-void msr_io_cleanup(343,8029
-int msr_init(374,8740
-#define FIFO_BUF 389,9019
-#define TIMERTICS 396,9180
-#define MSG_BUF 397,9245
-
-msr_io.h,363
-#define _AIM_GLOBALS_H_35,698
-struct P101_In P101_In37,723
-struct P201_In P201_In45,859
-struct P301_In P301_In50,940
-struct P101_Out P101_Out56,1022
-struct P201_Out P201_Out62,1120
-struct P301_Out P301_Out65,1161
-struct IMO_to_dSPACE IMO_to_dSPACE69,1203
-struct dSPACE_to_IMO dSPACE_to_IMO76,1338
-} IMO;99,1765
-} cvt;128,2230
-} param;131,2247
--- a/rt/aip_com.c	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,851 +0,0 @@
-/** rt_com
- *  ======
- *
- * RT-Linux kernel module for communication across serial lines.
- *
- * Copyright (C) 1997 Jens Michaelsen
- * Copyright (C) 1997-2000 Jochen Kupper
- * Copyright (C) 1999 Hua Mao <hmao@nmt.edu>
- * Copyright (C) 1999 Roberto Finazzi
- * Copyright (C) 2000-2002 Giuseppe Renoldi
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 this program; see the file License. if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * $Id: aip_com.c,v 1.1 2005/09/16 14:16:31 hm Exp hm $ */
-#define VERSION "0.6.pre2-rtaicvs (modified by Hm, IgH for aip)"   //Hm, IgH
-
-#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/version.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#ifdef _RTAI
-#include <rtai.h>
-#endif
-
-#include "aip_com.h"
-#include "aip_comP.h"
-
-#include <msr_rcsinfo.h>
-
-RCS_ID("$Header: /home/hm/projekte/msr_messen_steuern_regeln/ethercat/src-hm/rs232rt/RCS/aip_com.c,v 1.1 2005/09/16 14:16:31 hm Exp hm $");
-
-/* Hm, IgH
-MODULE_AUTHOR("Jochen Kuepper");
-MODULE_DESCRIPTION("real-time serial port driver");
-MODULE_LICENSE("GPL");
-*/
-
-
-/* size of internal queues
-* This is the default value. */
-unsigned int            rt_com_buffersize = RT_COM_BUF_SIZ;
-
-/** Default: mode=0 - no hw flow control
- *           used=0 - port and irq setting by rt_com_hwparam.
- *                    If you want to work like
- *                    a standard rt_com you can set used=1. */
-struct rt_com_struct    rt_com_table[] = { 
-       {    // ttyS0 - COM1
-        RT_COM_BASE_BAUD,   // int baud_base;
-        0x3f8,          // int port;
-        4,              // int irq;
-        rt_com0_isr,    // void (*isr)(void);
-        115200,  // int baud;
-        8,  // unsigned int wordlength;
-        RT_COM_PARITY_NONE, // unsigned int parity;
-        1,  // stopbits;
-        RT_COM_NO_HAND_SHAKE,   // int mode;
-        RT_COM_FIFO_SIZE_8,     // int fifotrig;
-        1 //Hm, IgH   // int used;
-    }, {    // ttyS1 - COM2
-        RT_COM_BASE_BAUD,   // int baud_base;
-        0x2f8,          // int port;
-        3,              // int irq;
-        rt_com1_isr,    // void (*isr)(void);
-        0,  // int baud;
-        8,  // unsigned int wordlength;
-        RT_COM_PARITY_NONE, // unsigned int parity;
-        1,  // stopbits;
-        RT_COM_NO_HAND_SHAKE,   // int mode;
-        RT_COM_FIFO_SIZE_8,     // int fifotrig;
-        0   // int used;
-    }
-};
-
-/** Number and descriptions of serial ports to manage.  You also need
- * to create an ISR ( rt_comN_isr() ) for each port.  */
-#define RT_COM_CNT  (sizeof(rt_com_table) / sizeof(struct rt_com_struct))
-
-/** Internal: Remaining free space of buffer
- *
- * @return amount of free space remaining in a buffer (input or output)
- *
- * @author Jochen Kupper
- * @version 2000/03/10 */
-static inline unsigned int rt_com_buffer_free(unsigned int head, unsigned int tail)
-{
-    return(head < tail) ? (tail - head) : (rt_com_buffersize - (head - tail));
-}
-
-/** Clear input buffer.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @return       0 if all right, -ENODEV or -EPERM on error.
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12 */
-int rt_com_clear_input(unsigned int ttyS)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else if (0 >= (rt_com_table[ttyS]).used) {
-        return(-EPERM);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        struct rt_buf_struct    *b = &(p->ibuf);
-        long                    state;
-        rt_com_irq_off(state);
-        b->tail = b->head;
-        if (p->fifotrig)
-            outb(inb(p->port + RT_COM_FCR) | FCR_INPUT_FIFO_RESET, p->port + RT_COM_FCR);
-        rt_com_irq_on(state);
-        if (p->mode & RT_COM_HW_FLOW) {
-            /* with hardware flow set RTS */
-            p->mcr |= MCR_RTS;
-            outb(p->mcr, p->port + RT_COM_MCR);
-        }
-
-        return(0);
-    }
-}
-
-/** Clear output buffer.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @return       0 if all right, negative error conditions otherwise
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12
- */
-int rt_com_clear_output(unsigned int ttyS)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 >= (rt_com_table[ttyS]).used) {
-            return(-EPERM);
-        }
-        else {
-            struct rt_buf_struct    *b = &(p->obuf);
-            long                    state;
-            rt_com_irq_off(state);
-            p->ier &= ~IER_ETBEI;
-            outb(p->ier, p->port | RT_COM_IER);
-            b->tail = b->head;
-            if (p->fifotrig)
-                outb(inb(p->port + RT_COM_FCR) | FCR_OUTPUT_FIFO_RESET, p->port + RT_COM_FCR);
-            rt_com_irq_on(state);
-            return(0);
-        }
-    }
-}
-
-/** Set functioning mode.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param mode   functioning mode 
- * @return       0 if all right, negative on error
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12
- */
-int rt_com_set_mode(unsigned int ttyS, int mode)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 >= p->used) {
-            return(-EPERM);
-        }
-        else {
-            p->mode = mode;
-            if (p->used & RT_COM_PORT_SETUP) {
-                /* setup done */
-                if (mode == RT_COM_NO_HAND_SHAKE) {
-                    /* if no hw signals disable modem interrupts */
-                    p->ier &= ~IER_EDSSI;
-                }
-                else {
-                    /* else enable it */
-                    p->ier |= IER_EDSSI;
-                }
-
-                outb(p->ier, p->port + RT_COM_IER);
-            }
-
-            return(0);
-        }
-    }
-}
-
-/** Set receiver fifo trigger level.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param fifotrig   receiver fifo trigger level 
- * @return           0 if all right, negative on error
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12
- */
-int rt_com_set_fifotrig(unsigned int ttyS, int fifotrig)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        p->fifotrig = fifotrig;
-        if (p->used & RT_COM_PORT_SETUP) {
-            /* setup done */
-            if (p->fifotrig)
-                outb(FCR_FIFO_ENABLE | p->fifotrig, p->port + RT_COM_FCR);  // enable fifo
-            else
-                outb(0, p->port + RT_COM_FCR);  // disable fifo	
-        }
-    }
-
-    return(0);
-}
-
-/** Set output signal for modem control (DTR, RTS).
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param signal Output signals: RT_COM_DTR or RT_COM_RTS.
- * @param value  Status: 0 or 1. 
- * @return       0 if all right, negative error code otherwise
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12 */
-int rt_com_write_modem(unsigned int ttyS, int signal, int value)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else if (value &~0x01) {
-        return(-EINVAL);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 >= p->used) {
-            return(-EPERM);
-        }
-        else {
-            if (value)
-                p->mcr |= signal;
-            else
-                p->mcr &= ~signal;
-            outb(p->mcr, p->port + RT_COM_MCR);
-            return(0);
-        }
-    }
-}
-
-/** Read input signal from modem (CTS, DSR, RI, DCD).
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param signal Input signals: RT_COM_CTS, RT_COM_DSR, RT_COM_RI, RT_COM_DCD
- *               or any combination.  
- * @return       input signal status; that is the bitwise-OR of the signal
- *               argument and the MSR register.
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/12 */
-int rt_com_read_modem(unsigned int ttyS, int signal)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else if (signal & 0xf) {
-        return(-EINVAL);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 >= p->used) {
-            return(-EPERM);
-        }
-        else {
-            return(inb(p->port + RT_COM_MSR) & signal);
-        }
-    }
-}
-
-/** Return last error detected.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @return       bit 0 :1 = Input buffer overflow
- *               bit 1 :1 = Receive data overrun 
- *               bit 2 :1 = Parity error 
- *               bit 3 :1 = Framing error
- *               bit 4 :1 = Break detected 
- *
- * @author Roberto Finazzi
- * @version 2000/03/12
- */
-int rt_com_error(unsigned int ttyS)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        int                     tmp = p->error;
-        p->error = 0;
-        return(tmp);
-    }
-}
-
-/** Write data to a line.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param buffer Address of data.
- * @param count  Number of bytes to write. If negative, send byte only if 
- *               possible to send them all together.
- * @return       Number of bytes not written. Negative values are error
- *               conditions.
- *
- * @author Jens Michaelsen, Jochen Kupper, Giuseppe Renoldi
- * @version 2000/03/12 */
-int rt_com_write(unsigned int ttyS, char *buffer, int count)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (!(p->used & RT_COM_PORT_SETUP)) {
-            return(-EPERM);
-        }
-        else {
-            struct rt_buf_struct    *b = &(p->obuf);
-            long                    state;
-            int                     bytestosend;
-            if (count == 0)
-                return(0);
-            bytestosend = rt_com_buffer_free(b->head, b->tail);
-            if (count < 0) {
-                count = -count;
-                if (count > bytestosend)
-                    return(count);
-                bytestosend = count;
-            }
-            else {
-                if (count <= bytestosend)
-                    bytestosend = count;
-            }
-
-            rt_com_irq_off(state);  
-            while (bytestosend-- > 0) {
-                /* put byte into buffer, move pointers to next elements */
-                b->buf[b->head++] = *buffer++;
-                if (b->head >= rt_com_buffersize)
-                    b->head = 0;
-                --count;
-            }
-
-            p->ier |= IER_ETBEI;
-            outb(p->ier, p->port + RT_COM_IER);
-            rt_com_irq_on(state);
-            return(count);
-        }
-    }
-}
-
-/** Read data we got from a line.
- *
- * @param ttyS   Port to use corresponding to internal numbering scheme.
- * @param buffer Address of data buffer. Needs to be of size > cnt !
- * @param count  Number of bytes to read.
- * @return       Number of bytes actually read.
- *
- * @author Jens Michaelsen, Jochen Kupper
- * @version 2000/03/17 */
-int rt_com_read(unsigned int ttyS, char *buffer, int count)
-{
-    if (0 > count) {
-        return(-EINVAL);
-    }
-    else if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (!(p->used & RT_COM_PORT_SETUP)) {
-            return(-EPERM);
-        }
-        else {
-            struct rt_buf_struct    *b = &(p->ibuf);
-            int                     done = 0;
-            long                    state;
-            rt_com_irq_off(state);
-            while ((b->head != b->tail) && (--count >= 0)) {
-                done++;
-                *buffer++ = b->buf[b->tail++];
-                b->tail &= (RT_COM_BUF_SIZ - 1);
-            }
-
-            rt_com_irq_on(state);
-            if ((p->mode & RT_COM_HW_FLOW) && (rt_com_buffer_free(b->head, b->tail) > RT_COM_BUF_HI)) {
-                /* if hardware flow and enough free space on input buffer
-				   then set RTS */
-                p->mcr |= MCR_RTS;
-                outb(p->mcr, p->port + RT_COM_MCR);
-            }
-
-            return(done);
-        }
-    }
-}
-
-/** Get first byte from the write buffer.
- *
- * @param p  rt_com_struct of the line we are writing to.
- * @param c  Address to put the char in.
- * @return   Number of characters we actually got.
- * 
- * @author Jens Michaelsen, Jochen Kupper
- * @version 1999/10/01
- */
-static inline int rt_com_irq_get(struct rt_com_struct *p, unsigned char *c)
-{
-    struct rt_buf_struct    *b = &(p->obuf);
-    if (b->head != b->tail) {
-        *c = b->buf[b->tail++];
-        b->tail &= (RT_COM_BUF_SIZ - 1);
-        return(1);
-    }
-
-    return(0);
-}
-
-/** Concatenate a byte to the read buffer.
- *
- * @param p   rt_com_struct of the line we are writing to.
- * @param ch  Byte to put into buffer.
- *
- * @author Jens Michaelsen, Jochen Kupper
- * @version 1999/07/20 */
-static inline void rt_com_irq_put(struct rt_com_struct *p, unsigned char ch)
-{
-    struct rt_buf_struct    *b = &(p->ibuf);
-    b->buf[b->head++] = ch;
-    b->head &= (RT_COM_BUF_SIZ - 1);
-}
-
-/** Real interrupt handler.
- *
- * This one is called by the registered ISRs and does the actual work.
- *
- * @param ttyS  Port to use corresponding to internal numbering scheme.
- *
- * @author Jens Michaelsen, Jochen Kupper, Hua Mao, Roberto Finazzi
- * @version 2000/03/17 */
-static inline int rt_com_isr(unsigned int ttyS)
-{
-    struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-    struct rt_buf_struct    *b = &(p->ibuf);
-    unsigned int            base = p->port;
-    int                     buff, data_to_tx;
-    int                     loop = 4;
-    int                     toFifo = 16;
-    unsigned char           data, msr, lsr, iir;
-
-    do {
-        //iir=inb(base + RT_COM_IIR);
-        //rt_printk("iir=0x%02x\n",iir);
-        /* get available data from port */
-        lsr = inb(base + RT_COM_LSR);
-        if (0x1e & lsr)
-            p->error = lsr & 0x1e;
-        while (LSR_DATA_READY & lsr) {
-            data = inb(base + RT_COM_RXB);
-
-            //rt_printk("[%02x<- ",data);	
-            rt_com_irq_put(p, data);
-            lsr = inb(base + RT_COM_LSR);
-            if (0x1e & lsr)
-                p->error = 0x1e & lsr;
-        }
-
-        /* controls on buffer full and RTS clear on hardware flow
-           control */
-        buff = rt_com_buffer_free(b->head, b->tail);
-        if (buff < RT_COM_BUF_FULL)
-            p->error = RT_COM_BUFFER_FULL;
-
-        if ((p->mode & RT_COM_HW_FLOW) && (buff < RT_COM_BUF_LOW)) {
-            p->mcr &= ~MCR_RTS;
-            outb(p->mcr, p->port + RT_COM_MCR);
-        }
-
-        /* if possible, put data to port */
-        msr = inb(base + RT_COM_MSR);
-        if
-        (
-            (p->mode == RT_COM_NO_HAND_SHAKE) ||
-            ((p->mode & RT_COM_DSR_ON_TX) && (MSR_DSR & msr) && (p->mode & RT_COM_HW_FLOW) && (MSR_CTS & msr))
-        ) {
-            /* (DSR && (CTS || Mode==no hw flow)) or Mode==no handshake */
-            // if (THRE==1) i.e. transmitter empty
-            if ((lsr = inb(base + RT_COM_LSR)) & LSR_THRE) {
-                // if there are data to transmit
-                if ((data_to_tx = rt_com_irq_get(p, &data)) != 0) {
-                    do {
-                        //rt_printk("->%02x] ",data);	
-                        outb(data, base + RT_COM_TXB);
-                    } while ((--toFifo > 0) && (data_to_tx = rt_com_irq_get(p, &data) != 0));
-                }
-
-                if (!data_to_tx) {
-                    /* no data in output buffer, disable Transmitter
-	               	   Holding Register Empty Interrupt */
-                    p->ier &= ~IER_ETBEI;
-                    outb(p->ier, base + RT_COM_IER);
-                }
-            }
-        }
-
-        /* check the low nibble of IIR wheather there is another pending
-           interrupt.  bit 0 = 0 if interrupt pending, bits 1,2,3 
-		   are the interrupt ID */
-        iir = inb(base + RT_COM_IIR);
-    } while (((iir & 0x0F) != 1) && (--loop > 0));
-
-#if defined RTLINUX_V2
-    rtl_hard_enable_irq(p->irq);
-#endif
-    return 0;
-}
-
-/** Interrupt Service Routines
- *
- * These are the Interrupt Service Routines to be registered with the
- * OS. They simply call the genereric interrupt handler for the
- * current port to do the work.
- *
- * @author Jens Michaelsen, Jochen Kupper, Hua Mao
- * @version 1999/11/11 */
-static void rt_com0_isr(void)
-{
-    //rt_printk("rt_com0_isr\n");
-    rt_com_isr(0);
-}
-
-static void rt_com1_isr(void)
-{
-    //rt_printk("rt_com1_isr\n");
-    rt_com_isr(1);
-}
-
-/** Setup one port
- *
- * Calls from init_module + cleanup_module have baud == 0; in these
- * cases we only do some cleanup.
- *
- * To allocate a port, give usefull setup parameter, to deallocate
- * give negative baud.
- *
- * @param ttyS       Number corresponding to internal port numbering scheme.
- *                   This is esp. the index of the rt_com_table to use.
- * @param baud       Data transmission rate to use [Byte/s]. If negative,
- *                   deallocate port instead. Called with baud == 0 from
- *                   init_module for basic initialization. Needs to be called
- *                   by user-task again before use !
- * @param mode       see rt_com_set_mode docs for now
- * @param parity     Parity for transmission protocol.
- *                   (RT_COM_PARITY_EVEN, RT_COM_PARITY_ODD, RT_COM_PARITY_NONE)
- * @param stopbits   Number of stopbits to use. 1 gives you one stopbit, 2
- *                   actually gives really two stopbits for wordlengths of
- *                   6 - 8 bit, but 1.5 stopbits for a wordlength of 5 bits.
- * @param wordlength Number of bits per word (5 - 8 bits).
- * @param fifotrig   if <0 set trigger fifo using default value set
- *                   in rt_com_table[], otherwise set trigger fifo accordingly
- *                   to the parameter
- * @return           0       - all right
- *                   -ENODEV - no entry for that ttyS in rt_com_table
- *                   -EPERM  - get hardware resources first (the port needs to
- *                             be setup hardware-wise first, that means you have
- *                             to specify a positive used flag at compile time
- *                             or call rt_com_set_hwparm first.)
- *
- * @author Jens Michaelsen, Jochen Kupper, Roberto Finazzi
- * @version 2000/03/12 */
-int rt_com_setup
-(
-    unsigned int    ttyS,
-    int             baud,
-    int             mode,
-    unsigned int    parity,
-    unsigned int    stopbits,
-    unsigned int    wordlength,
-    int             fifotrig			
-)
-{
-    if (ttyS >= RT_COM_CNT) {
-        return(-ENODEV);
-    }
-    else {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 == p->used) {
-            /*  */
-            return(-EPERM);
-        }
-        else {
-            unsigned int    base = p->port;
-
-            /* Stop everything, set DLAB */
-            outb(0x00, base + RT_COM_IER);
-            outb(0x80, base + RT_COM_LCR);
-
-            /* clear irqs */
-            inb(base + RT_COM_IIR);
-            inb(base + RT_COM_LSR);
-            inb(base + RT_COM_RXB);
-            inb(base + RT_COM_MSR);
-
-            /* initialize error code */
-            p->error = 0;
-
-            /* if 0 == baud, nothing else to do ! */
-            if (baud == 0)
-                return(0);
-
-            if (0 > baud) {
-                /* free the port */
-                /* disable interrupts */
-                outb(0, base + RT_COM_IER);
-                //MOD_DEC_USE_COUNT;  Hm, IgH
-                return(0);
-            }
-            else {
-                /* allocate and set-up the port */
-                unsigned int    divider = p->baud_base / baud;
-
-                //MOD_INC_USE_COUNT; Hm, IgH
-
-                /* set transfer rate */
-                outb(divider % 256, base + RT_COM_DLL);
-                outb(divider / 256, base + RT_COM_DLM);
-
-                /* bits 3,4 + 5 determine parity, mask away anything else */
-                parity &= 0x38;
-
-                /* set transmission parameters and clear DLAB */
-                outb((wordlength - 5) | ((stopbits - 1) << 2) | parity, base + RT_COM_LCR);
-
-                /* set-up MCR value and write it */
-                p->mcr = MCR_DTR | MCR_RTS | MCR_OUT1 | MCR_OUT2;
-                outb(p->mcr, base + RT_COM_MCR);
-
-                /* set-up IER value and write it */
-                p->mode = mode;
-                if (p->mode == RT_COM_NO_HAND_SHAKE) {
-                    /* if no handshaking signals enable only receiver interrupts  */
-                    p->ier = IER_ERBI | IER_ELSI;
-                }
-                else {
-                    /* enable receiver and modem interrupts */
-                    p->ier = IER_ERBI | IER_ELSI | IER_EDSSI;
-                }
-
-                outb(p->ier, base + RT_COM_IER);
-		if (fifotrig>=0)
-		    p->fifotrig = fifotrig;	
-                outb(FCR_FIFO_ENABLE | p->fifotrig, base + RT_COM_FCR); // enable fifo
-                /* mark setup done */
-                p->used |= RT_COM_PORT_SETUP;
-                return(0);
-            }
-        }
-
-        return(0);
-    }
-}
-
-/** Set hardware parameter for a specific port.
- *
- * Change port address and irq setting for a specified port. The port
- * must have an entry in rt_com_table beforehand.
- *
- * To allow the specification of additional ports we would need to
- * dynamically allocate memory, that's not really feasible within a
- * real-time context, although we could preallocate a few entries in
- * init_module. However, it doesn't make too much sense, as you can
- * specify all ports that really exist (in hardware) at compile time
- * and enable only these you want to use.
- *
- * @param ttyS   Port to use; corresponding to internal numbering scheme.
- * @param port   port address, if zero, use standard value from rt_com_table
- * @param irq    irq address, if zero, use standard value from rt_com_table
- * @return        0       everything all right,
- *               -ENODEV  no entry in rt_com_table for that device,
- *               -EBUSY   port-region is used already.
- *
- * @author Roberto Finazzi, Jochen Kupper
- * @version 2000/03/10 */
-int rt_com_hwsetup(unsigned int ttyS, int port, int irq)
-{
-    if (ttyS < RT_COM_CNT) {
-        struct rt_com_struct    *p = &(rt_com_table[ttyS]);
-        if (0 == p->used) {
-            if (0 != port)
-                p->port = port;
-            if (0 != irq)
-                p->irq = irq;
-            if (-EBUSY == check_region(p->port, 8)) {
-                return(-EBUSY);
-            }
-
-            request_region(p->port, 8, RT_COM_NAME);
-            rt_com_request_irq(p->irq, p->isr);
-            p->used = 1;
-            rt_com_setup(ttyS, p->baud, p->mode, p->parity, p->stopbits, p->wordlength, p->fifotrig);
-            return(0);
-        }
-        else {
-            if (port >= 0)
-                return(-EBUSY);
-            rt_com_setup(ttyS, 0, 0, 0, 0, 0, 0);
-            rt_com_free_irq(p->irq);
-            release_region(p->port, 8);
-            p->used = 0;
-            return(0);
-        }
-    }
-
-    return(-ENODEV);
-}
-
-/** Initialization
- *
- * For all ports that have a used flag greater than 0, request port
- * memory and register ISRs. If we cannot get the memory of all these
- * ports, release all already requested ports and return an error.
- *
- * @return Success status, zero on success. With a non-zero return
- * value of this routine, insmod will fail to load the module !
- *
- * @author Jochen Kupper, Hua Mao, Roberto Finazzi
- * @version 2000/03/10 */
-//int init_module(void)   //Hm, IgH
-int init_aip_com(void)
-{
-    int             errorcode = 0;
-    unsigned int    i, j;
-
-    printk(KERN_INFO "rt_com: Loading real-time serial port driver (version "VERSION ").\n");
-
-    for (i = 0; i < RT_COM_CNT; i++) {
-        struct rt_com_struct    *p = &(rt_com_table[i]);
-
-        // if used set default values
-        if (p->used > 0) {
-	    printk(KERN_WARNING "RS232 testing %d\n",i);
-            if (-EBUSY == check_region(p->port, 8)) {
-                errorcode = -EBUSY;
-                printk(KERN_WARNING "rt_com: error %d: cannot request port region %x\n", errorcode, p->port);
-                break;
-            }
-
-            request_region(p->port, 8, "rt_com");
-            rt_com_request_irq(p->irq, p->isr);
-	    printk(KERN_WARNING "RS232 Request IRQ: %d\n",p->irq);
-            rt_com_setup(i, p->baud, p->mode, p->parity, p->stopbits, p->wordlength, p->fifotrig);
-        }
-    }
-
-    if (0 != errorcode) {
-        printk(KERN_WARNING "rt_com: giving up.\n");
-        for (j = 0; j < i; j++) {
-            struct rt_com_struct    *p = &(rt_com_table[j]);
-            if (0 < p->used) {
-                rt_com_free_irq(p->irq);
-                release_region(p->port, 8);
-            }
-        }
-    }
-    else {
-        printk(KERN_INFO "rt_com: sucessfully loaded.\n");
-    }
-
-    return(errorcode);
-}
-
-/** Cleanup
- *
- * Unregister ISR and releases memory for all ports
- *
- * @author Jochen Kupper
- * @version 1999/10/01 */
-//void cleanup_module(void)  Hm, IgH
-void cleanup_aip_com(void)
-{
-    int i;
-    for (i = 0; i < RT_COM_CNT; i++) {
-        struct rt_com_struct    *p = &(rt_com_table[i]);
-        if (0 < p->used) {
-            rt_com_free_irq(p->irq);
-            rt_com_setup(i, 0, 0, 0, 0, 0, 0);
-            release_region(p->port, 8);
-        }
-    }
-
-    printk(KERN_INFO "rt_com: unloaded.\n");
-}
-
-/*
-EXPORT_SYMBOL(rt_com_buffersize);
-EXPORT_SYMBOL(rt_com_clear_input);
-EXPORT_SYMBOL(rt_com_clear_output);
-EXPORT_SYMBOL(rt_com_error);
-EXPORT_SYMBOL(rt_com_hwsetup);
-EXPORT_SYMBOL(rt_com_read);
-EXPORT_SYMBOL(rt_com_read_modem);
-EXPORT_SYMBOL(rt_com_setup);
-EXPORT_SYMBOL(rt_com_table);
-EXPORT_SYMBOL(rt_com_write);
-EXPORT_SYMBOL(rt_com_write_modem);
-EXPORT_SYMBOL(rt_com_set_mode);
-EXPORT_SYMBOL(rt_com_set_fifotrig);
-*/
-
-/**
- * Local Variables:
- * mode: C
- * c-file-style: "Stroustrup"
- * End:
- */
--- a/rt/aip_com.h	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/**************************************************************************************************
-*
-*                          aip_com.h
-*
-*           Macros für Kommunikation über serielle Schnittstelle
-*           Basiert auf rt_com.h von rtai !! (siehe unten)
-*
-*           
-*           Autor: Wilhelm Hagemeister
-*
-*           (C) Copyright IgH 2002
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: hm@igh-essen.com
-*
-*
-*           $RCSfile: aip_com.h,v $
-*           $Revision: 1.1 $
-*           $Author: hm $
-*           $Date: 2004/09/30 15:50:32 $
-*           $State: Exp $
-*
-*
-*
-*
-*
-*
-*
-*
-*
-**************************************************************************************************/
-
-/** rt_com
- *  ======
- *
- * RT-Linux kernel module for communication across serial lines.
- *
- * Copyright (C) 1997 Jens Michaelsen
- * Copyright (C) 1997-2000 Jochen Kupper
- * Copyright (C) 2002 Giuseppe Renoldi
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 this program; see the file License. if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * $Id: aip_com.h,v 1.1 2004/09/30 15:50:32 hm Exp $ */
-
-
-
-#ifndef AIP_COM_H
-#define AIP_COM_H
-
-/** This is the interface definition of the plain rt_com API.
- *
- * This should be all you need to use rt_com within your real-time
- * kernel module.
- *
- * (When POSIX is done, we will reference the appropriate header
- * here - probably depending on a flag.) */
-
-int init_aip_com(void);              //Hm, IgH
-void cleanup_aip_com(void);          //Hm, IgH
-
-
-/** specify hardware parameters, set-up communication parameters */
-extern int rt_com_hwsetup( unsigned int ttyS, int base, int irq );
-extern int rt_com_setup( unsigned int ttyS, int baud, int mode,
-			 unsigned int parity, unsigned int stopbits,
-			 unsigned int wordlength, int fifotrig );
-
-/** read/write from/to input/output buffer */
-extern int rt_com_read( unsigned int, char *, int );
-extern int rt_com_write( unsigned int ttyS, char *buffer, int count );
-
-/** clear input or output buffer */
-extern int rt_com_clear_input( unsigned int ttyS );
-extern int rt_com_clear_output( unsigned int ttyS );
-
-/** read input signal from modem (CTS,DSR,RI,DCD), set output signal
- * for modem control (DTR,RTS) */
-extern int rt_com_read_modem( unsigned int ttyS, int signal );
-extern int rt_com_write_modem( unsigned int ttyS, int signal, int value );
-
-/** functioning mode and fifo trigger setting */
-extern int rt_com_set_mode( unsigned int ttyS, int mode);
-extern int rt_com_set_fifotrig( unsigned int ttyS, int fifotrig);
-
-/** return last error detected */
-extern int rt_com_error( unsigned int ttyS );
-
-
-/** size of internal queues, this is constant during module lifetime */
-extern unsigned int rt_com_buffersize;
-
-#define rt_com_set_param rt_com_hwsetup
-#define rt_com_setup_old(a,b,c,d,e) rt_com_setup((a),(b),0,(c),(d),(e),-1)
-
-
-/** functioning modes */
-#define RT_COM_NO_HAND_SHAKE  0x00
-#define RT_COM_DSR_ON_TX      0x01
-#define RT_COM_HW_FLOW	      0x02
-
-/** parity flags */
-#define RT_COM_PARITY_EVEN    0x18
-#define RT_COM_PARITY_NONE    0x00
-#define RT_COM_PARITY_ODD     0x08
-#define RT_COM_PARITY_HIGH    0x28
-#define RT_COM_PARITY_LOW     0x38
-
-/* FIFO Control */
-#define RT_COM_FIFO_DISABLE   0x00
-#define RT_COM_FIFO_SIZE_1    0x00
-#define RT_COM_FIFO_SIZE_4    0x40
-#define RT_COM_FIFO_SIZE_8    0x80
-#define RT_COM_FIFO_SIZE_14   0xC0
-
-/** rt_com_write_modem  masks */
-#define RT_COM_DTR            0x01
-#define RT_COM_RTS            0x02 
-
-/** rt_com_read_modem masks */
-#define RT_COM_CTS            0x10
-#define RT_COM_DSR            0x20
-#define RT_COM_RI             0x40
-#define RT_COM_DCD            0x80
-
-/** rt_com_error masks */
-#define RT_COM_BUFFER_FULL    0x01
-#define RT_COM_OVERRUN_ERR    0x02
-#define RT_COM_PARITY_ERR     0x04
-#define RT_COM_FRAMING_ERR    0x08
-#define RT_COM_BREAK          0x10
-
-
-#endif /* RT_COM_H */
-
-
-
-/**
- * Local Variables:
- * mode: C
- * c-file-style: "Stroustrup"
- * End:
- */
--- a/rt/aip_comP.h	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/**
- * rt_com
- * ======
- *
- * RT-Linux kernel module for communication across serial lines.
- *
- * Copyright (C) 1997 Jens Michaelsen
- * Copyright (C) 1997-2000 Jochen Kupper
- * Copyright (C) 1999 Hua Mao <hmao@nmt.edu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 this program; see the file License. if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-
-
-#ifndef AIP_COM_P_H
-#define AIP_COM_P_H
-
-
-#define RT_COM_NAME "rt_com(aip)"  //Hm, IgH
-
-/* input/ouput buffer (FIFO) sizes */
-#define RT_COM_BUF_SIZ        256	// MUST BE ONLY POWER OF 2 !!
-/* amount of free space on input buffer for RTS reset */
-#define RT_COM_BUF_LOW        (RT_COM_BUF_SIZ / 3)
-/* amount of free space on input buffer for RTS set */
-#define RT_COM_BUF_HI         (RT_COM_BUF_SIZ * 2 / 3)
-/* limit of free space on input buffer for buffer full error */
-#define RT_COM_BUF_FULL       20
-
-
-/* usage flags */
-#define RT_COM_PORT_FREE      0x00
-#define RT_COM_PORT_INUSE     0x01
-#define RT_COM_PORT_SETUP     0x02
-
-
-/* Some hardware description */
-#define RT_COM_BASE_BAUD      115200
-
-/** Interrupt Service Routines
- * These are private functions */
-static void rt_com0_isr( void );
-static void rt_com1_isr( void );
-
-
-
-
-/** Interrupt handling
- *
- * Define internal convinience macros for interrupt handling, so we
- * get rid of the system dependencies.
- */
-//#define rt_com_irq_off( state )         do{}while(0) //rt_global_save_flags( &state ); rt_global_cli() schreiben und lesen sowieso in IRQ Hm
-//#define rt_com_irq_on(state)            do{}while(0) //rt_global_restore_flags( state ) 
-#define rt_com_irq_off( state )         rt_global_save_flags( &state ); rt_global_cli() 
-#define rt_com_irq_on(state)            rt_global_restore_flags( state ) 
-#define rt_com_request_irq( irq, isr )  rt_request_global_irq( irq, isr ); rt_enable_irq( irq );
-#define rt_com_free_irq( irq )          rt_free_global_irq( irq )
-
-
-/* port register offsets */
-#define RT_COM_RXB  0x00
-#define RT_COM_TXB  0x00
-#define RT_COM_IER  0x01
-#define RT_COM_IIR  0x02
-#define RT_COM_FCR  0x02
-#define RT_COM_LCR  0x03
-#define RT_COM_MCR  0x04
-#define RT_COM_LSR  0x05
-#define RT_COM_MSR  0x06
-#define RT_COM_DLL  0x00
-#define RT_COM_DLM  0x01
-
-/** MCR Modem Control Register masks */
-#define MCR_DTR               0x01 // Data Terminal Ready
-#define MCR_RTS               0x02 // Request To Send 
-#define MCR_OUT1              0x04
-#define MCR_OUT2              0x08
-#define MCR_LOOP              0x10
-#define MCR_AFE               0x20 // AutoFlow Enable
-
-/** IER Interrupt Enable Register masks */
-#define IER_ERBI              0x01  // Enable Received Data Available Interrupt
-#define IER_ETBEI             0x02  // Enable Transmitter Holding Register
-                                    // Empty Interrupt
-#define IER_ELSI              0x04  // Enable Receiver Line Status Interrupt
-#define IER_EDSSI             0x08  // Enable Modem Status Interrupt
-
-/** MSR Modem Status Register masks */
-#define MSR_DELTA_CTS         0x01
-#define MSR_DELTA_DSR         0x02
-#define MSR_TERI              0x04
-#define MSR_DELTA_DCD         0x08
-#define MSR_CTS               0x10
-#define MSR_DSR               0x20
-#define MSR_RI                0x40
-#define MSR_DCD               0x80
-
-/** LSR Line Status Register masks */
-#define LSR_DATA_READY        0x01
-#define LSR_OVERRUN_ERR       0x02
-#define LSR_PARITY_ERR        0x04
-#define LSR_FRAMING_ERR       0x08
-#define LSR_BREAK             0x10
-#define LSR_THRE              0x20	// Transmitter Holding Register
-#define LSR_TEMT              0x40	// Transmitter Empty
-
-/** FCR FIFO Control Register masks */
-#define FCR_FIFO_ENABLE       0x01
-#define FCR_INPUT_FIFO_RESET  0x02
-#define FCR_OUTPUT_FIFO_RESET 0x04
-
-/** data buffer
- *
- * Used for buffering of input and output data. Two buffers per port
- * (one for input, one for output). Organized as a FIFO */
-struct rt_buf_struct{
-    unsigned int  head;
-    unsigned int  tail;
-    char buf[ RT_COM_BUF_SIZ ];
-};
-
-
-
-/** Port data
- *
- * Internal information structure containing all data for a port. One
- * structure for every port.
- *
- * Contains all current setup parameters and all data currently
- * buffered by rt_com.
- *
- * mode (functioning mode)
- *   possible values:
- *   - RT_COM_DSR_ON_TX     - for standard functioning mode (DSR needed on TX)
- *   - RT_COM_NO_HAND_SHAKE - for comunication without hand shake signals
- *                            (only RXD-TXD-GND)
- *   - RT_COM_HW_FLOW       - for hardware flow control (RTS-CTS)
- *   Of course RT_COM_DSR_ON_TX and RT_COM_NO_HAND_SHAKE cannot be
- *   sppecified at the same time.
- *
- *   NOTE: When you select a mode that uses hand shake signals pay
- *   attention that no input signals (CTS,DSR,RI,DCD) must be
- *   floating.
- *
- * used (usage flag)
- *   possible values:
- *   - RT_COM_PORT_INUSE - port region requested by init_module
- *   - RT_COM_PORT_FREE  - port region requested by rt_com_set_param
- *   - RT_COM_PORT_SETUP - port parameters are setup,
- *                         don't specify at compile time !
- *
- * error
- *   last error detected
- *
- * ier (interrupt enable register)
- *   copy of IER chip register, last value set by rt_com.
- *
- * mcr (modem control register)
- *   copy of the MCR internal register
- */
-struct rt_com_struct{
-    int baud_base;
-    int port;
-    int irq;
-    void (*isr)(void);
-	int baud;
-	unsigned int wordlength;
-	unsigned int parity;
-	unsigned int stopbits;
-    int mode;
-	int fifotrig;
-    int used;
-	int error;
-    int type;
-    int ier;
-    int mcr;
-    struct rt_buf_struct ibuf;
-    struct rt_buf_struct obuf;
-};
-
-
-#endif /* RT_COM_P_H */
-
-
-
-/**
- * Local Variables:
- * mode: C
- * c-file-style: "Stroustrup"
- * End:
- */
--- a/rt/cif-rtai-io.h	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-unsigned long cif_open_card(
-		unsigned int board_no,
-		unsigned int in_size,
-		unsigned int out_size,
-		void (*callback)(unsigned long priv_data),
-		unsigned long priv_data
-		);
-
-void cif_close_card(
-		unsigned long fd
-		);
-
-int cif_reset_card(
-		unsigned long fd,
-		unsigned int timeout,
-		unsigned int context	// 1 = interrupt context
-		);
-
-void cif_set_host_state(
-		unsigned long fd,
-		unsigned int state
-		);
-
-int cif_exchange_io(
-		unsigned long fd,
-		void *recv_data,
-		void *send_data
-		);
-
-int cif_read_io(
-		unsigned long fd,
-		void *recv_data
-		);
-
-int cif_write_io(
-		unsigned long fd,
-		void *send_data
-		);
-
-int cif_card_ready(
-		unsigned long fd
-		);
-
--- a/rt/msr_io.c	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,539 +0,0 @@
-/******************************************************************************
- *
- * msr_io.c
- *
- * Sample Modul für EtherCAT
- *           
- * Autoren: Wilhelm Hagemeister, Florian Pose
- *
- * $Date$
- * $Author$
- *
- * (C) Copyright IgH 2005
- * Ingenieurgemeinschaft IgH
- * Heinz-Bäcker Str. 34
- * D-45356 Essen
- * Tel.: +49 201/61 99 31
- * Fax.: +49 201/61 98 36
- * E-mail: hm@igh-essen.com
- *
- * /bin/setserial /dev/ttyS0 uart none
- * /bin/setserial /dev/ttyS1 uart none
- *
- ******************************************************************************/
-
-/*--Includes-----------------------------------------------------------------*/
-
-#include <linux/module.h>
-#include <linux/tqueue.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-
-#include <msr_reg.h>
-#include <msr_messages.h>
-#include <msr_main.h>
-
-#include <rtai.h>
-#include <rtai_sched.h>
-
-#include "msr_io.h"
-
-//#include <msr_float.h>
-
-#include "../drivers/ec_master.h"
-#include "../drivers/ec_device.h"
-#include "../drivers/ec_types.h"
-#include "../rs232dbg/rs232dbg.h"
-
-/*--Defines------------------------------------------------------------------*/
-
-#define TIMERTICS 1e6	// in ns; Thus have a task time of 1ms
-#define MSR_ABTASTFREQUENZ (1e9/TIMERTICS)
-
-//#define MSR_ABTASTFREQUENZ (1000) //1e9/TIMERTICS)
-#define TICK ((1000000 / MSR_ABTASTFREQUENZ) * 1000)
-#define TIMER_FREQ (APIC_TIMER ? FREQ_APIC : FREQ_8254)
-#define APIC_TIMER 0
-
-//#define MSR_SLOW_DEBUG
-
-/*--Globale Variablen--------------------------------------------------------*/
-
-RT_TASK process_image;
-
-const int Tick = TICK;
-
-unsigned int ecat_tx_delay = 0; //Zeit vom Ende der TimerInterruptRoutine bis
-                                //TX-Interrupt der Netzwerkkarte 
-unsigned int ecat_rx_delay = 0; //RX-Interrupt der Netzwerkkarte
-
-unsigned int tx_intr = 0;
-unsigned int rx_intr = 0;
-unsigned int total_intr = 0;
-
-unsigned int thread_end = 0;
-
-#define USE_ETHERCAT
-
-#ifdef USE_ETHERCAT
-
-static EtherCAT_master_t *ecat_master = NULL;
-
-extern EtherCAT_device_t rtl_ecat_dev;
-
-//#define ECAT_SLAVES_COUNT 16
-
-static EtherCAT_slave_t ecat_slaves[] =
-{
-    //Block 1
-/*  ECAT_INIT_SLAVE(Beckhoff_EK1100),
-  ECAT_INIT_SLAVE(Beckhoff_EL4102),
-  ECAT_INIT_SLAVE(Beckhoff_EL3162),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL3102),
-  ECAT_INIT_SLAVE(Beckhoff_EL4102),
-  ECAT_INIT_SLAVE(Beckhoff_EL4102),
-  ECAT_INIT_SLAVE(Beckhoff_EL4102),
-  ECAT_INIT_SLAVE(Beckhoff_EL3162),
-  ECAT_INIT_SLAVE(Beckhoff_EL3162),
-  ECAT_INIT_SLAVE(Beckhoff_EL3162),
-  ECAT_INIT_SLAVE(Beckhoff_EL3102),
-  ECAT_INIT_SLAVE(Beckhoff_EL3102),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004), */
-  //Block 2
-  ECAT_INIT_SLAVE(Beckhoff_EK1100),
-  ECAT_INIT_SLAVE(Beckhoff_EL4102),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL3162),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL3102),
-  //Block 3
-  ECAT_INIT_SLAVE(Beckhoff_EK1100),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL2004),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014),
-  ECAT_INIT_SLAVE(Beckhoff_EL1014)
-
-
-};
-
-#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves)/sizeof(EtherCAT_slave_t))
-
-#endif
-
-double value;
-int dig1;
-
-
-static int next2004(int *wrap)
-{
-    static int i=0;
-
-    int j=0;
-
-    *wrap = 0;
-    for(j=0;j<ECAT_SLAVES_COUNT;j++) {
-	i++;
-	i %= ECAT_SLAVES_COUNT;
-	if(i == 0) *wrap = 1;
-	if(ecat_slaves[i].desc == Beckhoff_EL2004) {
-	    return i;
-	}
-    }
-    return -1;
-}
-
-/*
-*******************************************************************************
-*
-* Function: msr_controller
-*
-* Beschreibung: Zyklischer Prozess
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-*******************************************************************************
-*/
-
-void msr_controller(void)
-{
-  static int ms = 0;
-  static int cnt = 0;
-  static unsigned long int k = 0;
-  static int firstrun = 1;
-
-  static int klemme = 12;
-  static int kanal = 0;
-  static int up_down = 0;
-  int wrap = 0;
-
-  ms++;
-  ms %= 1000;
-
-#ifdef USE_ETHERCAT
-  ecat_tx_delay = ((unsigned int) (100000 / HZ) * (ecat_master->dev->tx_time-k))
-    / (current_cpu_data.loops_per_jiffy / 10);  
-  ecat_rx_delay = ((unsigned int) (100000 / HZ) * (ecat_master->dev->rx_time-k))
-    / (current_cpu_data.loops_per_jiffy / 10);  
-
-  rx_intr = ecat_master->dev->rx_intr_cnt;
-  tx_intr = ecat_master->dev->tx_intr_cnt;
-  total_intr = ecat_master->dev->intr_cnt;
-  // Prozessdaten lesen
-  if(!firstrun) {
-      EtherCAT_read_process_data(ecat_master);
-
-      // Daten lesen und skalieren
-      value = EtherCAT_read_value(&ecat_master->slaves[5], 0) / 3276.7;
-      dig1 = EtherCAT_read_value(&ecat_master->slaves[3], 0);
-  }
-  // Daten schreiben
-
-  EtherCAT_write_value(&ecat_master->slaves[4], 0, ms > 500 ? 1 : 0);
-  EtherCAT_write_value(&ecat_master->slaves[4], 1, ms > 500 ? 0 : 1);
-  EtherCAT_write_value(&ecat_master->slaves[4], 2, ms > 500 ? 0 : 1);
-  EtherCAT_write_value(&ecat_master->slaves[4], 3, ms > 500 ? 1 : 0);
-
-
-   if(cnt++ > 20) {
-      cnt = 0;
-      if(++kanal > 3) {
-	  kanal = 0;
-	  klemme = next2004(&wrap);
-	  if (wrap == 1) { 
-	      if(up_down == 1) 
-		  up_down = 0;
-	      else up_down = 1;
-	      }
-	  }
-      }
-   if (klemme >=0)
-    EtherCAT_write_value(&ecat_master->slaves[klemme], kanal,up_down);
-  
-//  EtherCAT_write_value(&ecat_master->slaves[13], 1, ms > 500 ? 0 : 1);
-//  EtherCAT_write_value(&ecat_master->slaves[14], 2, ms > 500 ? 0 : 1);
-//  EtherCAT_write_value(&ecat_master->slaves[15], 3, ms > 500 ? 1 : 0);
-
-  // Prozessdaten schreiben
-  rdtscl(k);
-  EtherCAT_write_process_data(ecat_master);
-  firstrun = 0;
-#endif
-}
-
-/*
-*******************************************************************************
-*
-* Function: msr_run_interrupt
-*
-* Beschreibung: Interrupt abarbeiten
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-*******************************************************************************
-*/
-
-void process_thread(int priv_data)
-{
-  while (1)
-  {
-
-#ifdef USE_ETHERCAT
-    MSR_RTAITHREAD_CODE(msr_controller(); msr_write_kanal_list(); );  
-#else
-    MSR_RTAITHREAD_CODE( msr_write_kanal_list(); );  
-#endif
-
-
-
-    /*   if(counter++ >=MSR_ABTASTFREQUENZ) {
-	counter = 0;
-	sprintf(buf,"rt:life");
-	msr_print_info(buf);
-    }
-    */
-    rt_task_wait_period();
-  }
-  thread_end = 1;
-}
-
-/*
-*******************************************************************************
-*
-* Function: msr_register_channels
-*
-* Beschreibung: Kanäle registrieren
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-*******************************************************************************
-*/
-
-int msr_globals_register(void)
-{
-  msr_reg_kanal("/value", "V", &value, TDBL);
-  msr_reg_kanal("/dig1", "", &dig1, TINT);
-  msr_reg_kanal("/Taskinfo/Ecat/TX-Delay","us",&ecat_tx_delay,TUINT);
-  msr_reg_kanal("/Taskinfo/Ecat/RX-Delay","us",&ecat_rx_delay,TUINT);
-  msr_reg_kanal("/Taskinfo/Ecat/TX-Cnt","",&tx_intr,TUINT);
-  msr_reg_kanal("/Taskinfo/Ecat/RX-Cnt","",&rx_intr,TUINT);
-  msr_reg_kanal("/Taskinfo/Ecat/Total-Cnt","",&total_intr,TUINT);
-
-  return 0;
-}
-
-/*
-*******************************************************************************
-*
-* Function: msr_init
-*
-* Beschreibung: MSR initialisieren
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-*******************************************************************************
-*/
-
-int msr_init(void)
-{   
-  int rv = -1;
-  RTIME tick_period, now;
-
-//  rt_mount_rtai();
-
-  msr_print_info("Initialising rtlib.");
-
-  // RT-lib initialisieren    
-  if (msr_rtlib_init(1, MSR_ABTASTFREQUENZ, 10, msr_globals_register) < 0)
-  {
-    msr_print_warn("msr_modul: can't initialize rtlib!");
-    goto out_umount;
-  }
-
-#ifdef USE_ETHERCAT
-  msr_print_info("Opening EtherCAT device.");
-
-  mdelay(100);
-
-  if (EtherCAT_device_open(&rtl_ecat_dev) < 0)
-  {
-    msr_print_warn("msr_modul: Could not initialize EtherCAT NIC.");
-    goto out_rtlib;
-  }
-
-  if (!rtl_ecat_dev.dev) // Es gibt kein EtherCAT-Device
-  {  
-    msr_print_warn("msr_modul: No EtherCAT device!");
-    goto out_close;
-  }
-//    goto out_close;
-
-  // EtherCAT-Master und Slaves initialisieren
-
-  msr_print_info("Initialising EtherCAT master");
-
-  if ((ecat_master = (EtherCAT_master_t *) kmalloc(sizeof(EtherCAT_master_t), GFP_KERNEL)) == 0)
-  {
-    msr_print_warn(KERN_ERR "msr_modul: Could not alloc memory for EtherCAT master!\n");
-    goto out_close;
-  }
-
-  if (EtherCAT_master_init(ecat_master, &rtl_ecat_dev) < 0)
-  {
-    msr_print_warn(KERN_ERR "EtherCAT could not init master!\n");
-    goto out_master;
-  }
-
-  msr_print_info("Checking EtherCAT slaves.");
-  mdelay(10); //Nachricht abwarten
-
-  if (EtherCAT_check_slaves(ecat_master, ecat_slaves, ECAT_SLAVES_COUNT) != 0)
-  {
-    msr_print_warn(KERN_ERR "EtherCAT: Could not init slaves!\n");
-    goto out_masterclear;
-  }
-
-  msr_print_info("Activating all EtherCAT slaves.");
-  mdelay(10); //Nachricht abwarten
-
-  if (EtherCAT_activate_all_slaves(ecat_master) != 0)
-  {
-    printk(KERN_ERR "EtherCAT: Could not activate slaves!\n");
-    goto out_masterclear;
-  }
-
-  // Zyklischen Aufruf starten
-
-#endif
-  msr_print_info("Starting cyclic sample thread.");
-  mdelay(10); //Nachricht abwarten
-
-  EtherCAT_write_process_data(ecat_master);
-
-  //mdelay(100);
-  tick_period = start_rt_timer(nano2count(TIMERTICS));
-  now = rt_get_time();
-
-  if ((rv = rt_task_init(&process_image, process_thread, 0/*data*/, 64000/*stacksize*/, 0/*prio*/, 1/*use fpu*/, 0/*signal*/)))
-  {
-      msr_print_error("Could not initialise process_thread\n");
-      goto out_stoptimer;
-  }
-
-  msr_print_info("Initialised sample thread\n");
-
-  if ((rv = rt_task_make_periodic(&process_image, 
-				  now + tick_period, 
-				  tick_period)))
-  {
-      msr_print_error("Could not start process_thread\n");
-      goto out_stoptask;
-  }
-
-  msr_print_info("Started sample thread.");
-
-  return 0;
-
- out_stoptask:
-  msr_print_info("Deleting task....");
-  rt_task_delete(&process_image);
-
- out_stoptimer:
-  msr_print_info("Stopping timer.");
-  stop_rt_timer();
-
-#ifdef USE_ETHERCAT
- out_masterclear:
-  msr_print_info("Clearing EtherCAT master.");
-  EtherCAT_master_clear(ecat_master);
-
- out_master:
-    msr_print_info("Freeing EtherCAT master.");
-  kfree(ecat_master);
-
- out_close:
-  msr_print_info("Closing device.");
-
-  EtherCAT_device_close(&rtl_ecat_dev);
-#endif
-
- out_rtlib:
-  msr_print_info("msr_rtlib_cleanup()");
-  mdelay(10);
-  msr_rtlib_cleanup();
-
- out_umount:
-//  rt_umount_rtai();
-
-  return rv;
-}
-
-/*
-*******************************************************************************
-*
-* Function: msr_io_cleanup
-*
-* Beschreibung: Aufräumen
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-*******************************************************************************
-*/
-
-void msr_io_cleanup(void)
-{
-
-  msr_print_info("Stopping timer.");
-
-  stop_rt_timer();
-
-  msr_print_info("Deleting task....");
-
-  rt_task_delete(&process_image);
-/*
-  for(i=0;i<1000;i++) {
-      udelay(100);
-      if(thread_end == 1) {
-	  msr_print_info("Task ended at count %d",i);
-	  break;
-      }
-  }
-*/
-  //noch einmal lesen
-
-  msr_print_info("Read Processdata");
-  EtherCAT_read_process_data(ecat_master);
-
-  //EtherCAT_read_process_data(ecat_master);
-#ifdef USE_ETHERCAT
-  if (ecat_master)
-  {
-
-    msr_print_info("Deactivating slaves.");
-
-
-    EtherCAT_deactivate_all_slaves(ecat_master);    
-
-
-    msr_print_info("Clearing EtherCAT master.");
-
-    EtherCAT_master_clear(ecat_master);
-
-    msr_print_info("Freeing EtherCAT master.");
-
-
-    kfree(ecat_master);
-    ecat_master = NULL;
-  }
-
-  msr_print_info("Closing device.");
-
-  EtherCAT_device_close(&rtl_ecat_dev);
-
-#endif
-  msr_print_info("msr_rtlib_cleanup()");
-
-  msr_rtlib_cleanup();
-  //rt_umount_rtai();
-}
-
-/*---Treiber-Einsprungspunkte etc.-------------------------------------------*/
-
-MODULE_LICENSE("GPL");
-
-module_init(msr_init);
-module_exit(msr_io_cleanup);
-
-/*---Ende--------------------------------------------------------------------*/
--- a/rt/msr_io.h	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-
-/******************************************************************************
-*
-*
-*           Alle globalen Variabeln
-*           
-*           Autor: Richard Hacker
-*
-*           (C) Copyright IgH 2005
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: ha@igh-essen.com
-*
-*
-*           $RCSfile: msr_io.h,v $
-*           $Revision: 1.2 $
-*           $Author: hm $
-*           $Date: 2005/09/02 10:26:38 $
-*           $State: Exp $
-*
-*
-*
-*
-*
-*
-*
-*
-*
-******************************************************************************/
-
-#ifndef _ETH_GLOBALS_H_
-#define _ETH_GLOBALS_H_
-
-
-#endif
-
--- a/rt/tmp/_msr_io.c	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,420 +0,0 @@
-/**************************************************************************************************
-*
-*                          msr_io.c
-*
-*           Verwaltung der IO-Karten
-*           
-*           
-*           Autor: Wilhelm Hagemeister
-*
-*           (C) Copyright IgH 2002
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: sp@igh-essen.com
-*
-*
-*           $RCSfile: msr_io.c,v $
-*           $Revision: 1.9 $
-*           $Author: ha $
-*           $Date: 2005/06/24 20:06:56 $
-*           $State: Exp $
-*
-*
-*           $Log: msr_io.c,v $
-*           Revision 1.9  2005/06/24 20:06:56  ha
-*           *** empty log message ***
-*
-*           Revision 1.8  2005/06/24 17:39:05  ha
-*           *** empty log message ***
-*
-*
-*
-*
-*
-*
-**************************************************************************************************/
-
-
-/*--includes-------------------------------------------------------------------------------------*/
-
-#ifndef __KERNEL__
-#  define __KERNEL__
-#endif
-#ifndef MODULE
-#  define MODULE
-#endif
-
-#include <linux/delay.h> 	/* mdelay() */
-#include <linux/spinlock.h> 
-#include <linux/param.h>	/* HZ */
-#include <linux/sched.h> 	/* jiffies */
-#include <linux/fs.h>     /* everything... */
-#include <rtai_fifos.h>
-
-#include "msr_io.h"
-
-#include <msr_messages.h>
-
-
-#include "aim_globals.h"
-
-spinlock_t data_lock = SPIN_LOCK_UNLOCKED;
-
-#include "cif-rtai-io.h"
-
-/*--defines--------------------------------------------------------------------------------------*/
-
-
-/*--external functions---------------------------------------------------------------------------*/
-
-
-/*--external data--------------------------------------------------------------------------------*/
-
-
-/*--public data----------------------------------------------------------------------------------*/
-
-#define PB_CARDS 4
-struct {
-	unsigned int fd;
-	unsigned int timestamp;
-	unsigned int fault;
-	unsigned int active;
-	void *in_buf;
-	void *out_buf;
-	size_t in_buf_len;
-	size_t out_buf_len;
-
-	unsigned int reset_timeout;
-} card[PB_CARDS];
-
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_init
-*
-* Beschreibung: Initialisieren der I/O-Karten
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-void x_PB_io(unsigned long card_no) {
-	int rv = 0;
-	unsigned int flags;
-
-	spin_lock_irqsave(&data_lock, flags);
-
-	switch (card_no) {
-	case 0:
-		rv = cif_exchange_io(card[0].fd,card[0].in_buf,card[0].out_buf);
-		if (!rv)
-			card[0].timestamp = jiffies;
-		break;
-	case 1:
-		rv = cif_exchange_io(card[1].fd,card[1].in_buf,card[1].out_buf);
-//		rv = cif_read_io(card[1].fd,card[1].in_buf);
-//		IMO.to_dSPACE.P101.HX_Stat = 51;
-//		IMO.from_dSPACE.P101.HX_Control |= IMO.to_dSPACE.P101.HX_Stat<<4;
-//		rv += cif_write_io(card[1].fd,card[1].out_buf);
-		if (!rv)
-			card[1].timestamp = jiffies;
-		break;
-	/*
-	case 2:
-		rv = cif_exchange_io(card[2].fd,&cif_in.P201,&cif_out.P201);
-		break;
-	*/
-	case 3:
-		rv = cif_exchange_io(card[3].fd,card[3].in_buf,card[3].out_buf);
-		if (!rv)
-			card[3].timestamp = jiffies;
-		break;
-	}
-
-	if (rv) {
-			msr_print_error("Error during exchange_io %i %i", 
-					card_no, rv );
-	}
-
-	spin_unlock_irqrestore(&data_lock, flags);
-
-}
-
-int msr_io_init()
-{   
-    int rv;
-
-    memset(card, 0, sizeof(card));
-
-#define FIFO_BUF 10000
-
-    if ((rv = rtf_create(0, FIFO_BUF)) < 0) {
-	    msr_print_error("Could not open FIFO %i", rv);
-	    return -1;
-    }
-
-#ifndef _SIMULATION
-/*
-    card[0].in_buf_len = sizeof(IMO.from_dSPACE);
-    card[0].out_buf_len = sizeof(IMO.to_dSPACE);
-    card[0].in_buf = &IMO.from_dSPACE;
-    card[0].out_buf = &IMO.to_dSPACE;
-    card[0].active = 1;
-    if (!(card[0].fd = cif_open_card(0, card[0].in_buf_len,
-				    card[0].out_buf_len, x_PB_io, 0))) {
-	msr_print_error("Cannot open CIF card PB01");
-	return -1;
-    }
- 
-
-    card[1].in_buf_len = sizeof(IMO.to_dSPACE.P101);
-    card[1].out_buf_len = sizeof(IMO.from_dSPACE.P101);
-    card[1].in_buf = &IMO.to_dSPACE.P101;
-    card[1].out_buf = &IMO.from_dSPACE.P101;
-    card[1].active = 1;
-    if (!(card[1].fd = cif_open_card(1, card[1].in_buf_len, 
-				    card[1].out_buf_len, x_PB_io, 1))) {
-	msr_print_error("Cannot open CIF card P101");
-	return -1;
-    }
- 
-    card[2].in_buf_len = sizeof(IMO.to_dSPACE.P201);
-    card[2].out_buf_len = sizeof(IMO.from_dSPACE.P201);
-    card[2].in_buf = &IMO.to_dSPACE.P201;
-    card[2].out_buf = &IMO.from_dSPACE.P201;
-    if (!(card[2].fd = cif_open_card(2, card[2].in_buf_len, 
-				    card[2].out_buf_len, x_PB_io, 2))) {
-	msr_print_error("Cannot open CIF card P201");
-	return -1;
-    }
- 
-*/
-    card[3].in_buf_len = sizeof(dSPACE.in);
-    card[3].out_buf_len = sizeof(dSPACE.out);
-    card[3].in_buf = &dSPACE.in;
-    card[3].out_buf = &dSPACE.out;
-    card[3].active = 1;
-    if (!(card[3].fd = cif_open_card(0,  card[3].in_buf_len, 
-				    card[3].out_buf_len, x_PB_io,3))) {
-	msr_print_error("Cannot open CIF card P301");
-	return -1;
-    }
- 
-    //msr_reg_chk_failure(&int_cif_io_fail,TINT,T_CHK_HIGH,0,T_CRIT,"CIF Card was not ready to exchange data");
-
-
-#endif
-
-    return 0;
-}
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_register
-*
-* Beschreibung: Rohdaten als Kanaele registrieren
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-
-int msr_io_register()
-{
-
-#ifndef _SIMULATION
-
-#endif
-
-    return 0;
-}
-
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_write
-*
-* Beschreibung: Schreiben der Werte
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-int msr_io_write()
-{
-    static int return_value = 0;
-    int rv;
-    int i = 0;
-    unsigned int flags;
-    unsigned int com_check_timestamp = 0;
-    static int COM_Up = 1;
-
-    if (jiffies - com_check_timestamp > HZ/20) {
-
-	    if ( rtf_put_if(0,&IMO,sizeof(IMO)) != sizeof(IMO)) {
-		    //msr_print_error("Could not output data");
-	    }
-
-	    com_check_timestamp = jiffies;
-
-	    spin_lock_irqsave(&data_lock, flags);
-	    for ( i=0; i < PB_CARDS; i++) {
-		    // Ignore inactive and cards that already have a fault
-		    if (!card[i].active || card[i].fault)
-			    continue;
-
-		    // For active cards, check timestamp value. Mark card
-		    // as faulty if there was no data exchange in the last
-		    // 50ms
-		    if (jiffies - card[i].timestamp > HZ/20) {
-			    COM_Up = 0;
-			    card[i].fault = 1;
-			    card[i].reset_timeout = jiffies;
-			    msr_print_error("Card %i timed out", i);
-		    }
-
-	    }
-    
-	    spin_unlock_irqrestore(&data_lock, flags);
-    
-	    for ( i = 0; i < PB_CARDS; i++ ) {
-		    if (!card[i].active || (card[i].active && !card[i].fault))
-			    continue;
-
-		    switch (card[i].fault) {
-		    case 1:
-			    rv = cif_write_io(card[i].fd,card[i].out_buf);
-
-			    if (!rv) {
-				    msr_print_error("Card %i online", i);
-				    card[i].fault = 0;
-				    card[i].timestamp = jiffies;
-				    break;
-			    }
-
-			    msr_print_error("rv of cif_write_io(%i) = %i", 
-					    i, rv);
-
-			    card[i].fault = 2;
-			    cif_set_host_state(card[i].fd,0);
-			    card[i].reset_timeout = jiffies;
-
-		    case 2:
-			    if (cif_card_ready(card[i].fd)) {
-				    cif_set_host_state(card[i].fd,1);
-				    card[i].fault = 0;
-				    break;
-			    }
-			    if (jiffies < card[i].reset_timeout)
-				    break;
-
-			    rv = cif_reset_card(card[i].fd,10,1);
-			    msr_print_error("rv of cif_reset_card(%i) = %i", 
-					    i, rv);
-
-			    // Reset again in 10 seconds
-			    card[i].reset_timeout += 10*HZ;
-		    }
-	    }
-    }
-
-    if (COM_Up)
-	    IMO.to_dSPACE.Status = IMO.from_dSPACE.WatchDog;
-
-//    if (return_value)
-//	int_cif_io_fail = 1;
-
-    return return_value;
-}
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_read
-*
-* Beschreibung: Lesen der Werte
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-int msr_io_read()
-{
-    int return_value = 0;
-
-#ifndef _SIMULATION
-
-    int_cif_io_fail = 0;
-    /*
-    return_value = cif_exchange_io(fd_PB01,
-		    &cif_out,&cif_in,
-		    sizeof(cif_out),sizeof(cif_in)
-		    );
-		    */
-/*     if (return_value) */
-/* 	int_cif_io_fail = 1; */
-//    printk("%i\n", return_value);
-
-#endif
-    return return_value;
-}
-
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_cleanup
-*
-* Beschreibung: Aufräumen
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-void msr_io_cleanup()
-{
-/*
-    cif_set_host_state(card[0].fd,0);
-    cif_close_card(card[0].fd);
-
-    cif_set_host_state(card[1].fd,0);
-    cif_close_card(card[1].fd);
-
-    cif_set_host_state(card[2].fd,0);
-    cif_close_card(card[2].fd);
-
-
-*/
-    cif_set_host_state(card[3].fd,0);
-    cif_close_card(card[3].fd);
-
-    rtf_destroy(0);
-}
-
-
--- a/rt/tmp/_msr_io.h	Fri Dec 16 09:23:56 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-/**************************************************************************************************
-*
-*                          msr_io.h
-*
-*           Verwaltung der IO-Karten
-
-*           
-*           Autor: Wilhelm Hagemeister
-*
-*           (C) Copyright IgH 2002
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: sp@igh-essen.com
-*
-*
-*           $RCSfile: msr_io.h,v $
-*           $Revision: 1.5 $
-*           $Author: ha $
-*           $Date: 2005/06/24 20:08:15 $
-*           $State: Exp $
-*
-*
-*           $Log: msr_io.h,v $
-*           Revision 1.5  2005/06/24 20:08:15  ha
-*           *** empty log message ***
-*
-*           Revision 1.4  2005/06/24 17:39:05  ha
-*           *** empty log message ***
-*
-*           Revision 1.3  2005/02/28 17:11:48  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2005/02/10 16:34:24  hm
-*           Initial revision
-*
-*           Revision 1.4  2004/12/21 22:03:54  hm
-*           *** empty log message ***
-*
-*           Revision 1.3  2004/12/16 15:44:01  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2004/12/01 17:07:49  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2004/11/26 15:14:21  hm
-*           Initial revision
-*
-*           Revision 1.1  2004/11/01 11:05:20  hm
-*           Initial revision
-*
-*           Revision 1.1  2004/10/21 12:09:23  hm
-*           Initial revision
-*
-*           Revision 1.3  2004/09/21 18:10:58  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2004/07/22 17:28:02  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2004/06/21 08:46:52  hm
-*           Initial revision
-*
-*           Revision 1.4  2004/06/02 20:38:42  hm
-*           *** empty log message ***
-*
-*           Revision 1.3  2004/06/02 20:38:18  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2004/06/02 12:15:17  hm
-*           *** empty log message ***
-*
-*           Revision 1.5  2003/02/20 17:33:37  hm
-*           *** empty log message ***
-*
-*           Revision 1.4  2003/02/14 18:17:28  hm
-*           *** empty log message ***
-*
-*           Revision 1.3  2003/02/13 17:11:12  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2003/01/30 15:05:58  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2003/01/24 20:40:09  hm
-*           Initial revision
-*
-*           Revision 1.1  2003/01/22 15:55:40  hm
-*           Initial revision
-*
-*           Revision 1.1  2002/08/13 16:26:27  hm
-*           Initial revision
-*
-*           Revision 1.4  2002/07/04 13:34:27  sp
-*           *** empty log message ***
-*
-*           Revision 1.3  2002/07/04 12:08:34  sp
-*           *** empty log message ***
-*
-*           Revision 1.2  2002/07/04 08:44:19  sp
-*           Änderung des Autors :) und des Datums
-*
-*           Revision 1.1  2002/07/04 08:25:26  sp
-*           Initial revision
-*
-*
-*
-*
-*
-*
-*
-**************************************************************************************************/
-
-/*--Schutz vor mehrfachem includieren------------------------------------------------------------*/
-
-#ifndef _MSR_IO_H_
-#define _MSR_IO_H_
-
-/*--includes-------------------------------------------------------------------------------------*/
-
-//#include "msr_control.h"
-
-/*--defines--------------------------------------------------------------------------------------*/
-
-
-struct cif_in_t {			/* Von Feld nach dSPACE */
-	uint8_t CIM_stat;
-	uint8_t P101[91];
-	uint8_t P201[72];
-	uint8_t P301[72];
-} __attribute__ ((packed));
-
-struct cif_out_t {			/* Von dSPACE zum Feld */
-	uint8_t WatchDog;
-	uint8_t P101[39];
-	uint8_t P201[32];
-	uint8_t P301[32];
-} __attribute__ ((packed));
-
-/*--external functions---------------------------------------------------------------------------*/
-
-/*--external data--------------------------------------------------------------------------------*/
-
-/*--public data----------------------------------------------------------------------------------*/
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_init
-*
-* Beschreibung: Initialisieren der I/O-Karten
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-int msr_io_init();
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_register
-*
-* Beschreibung: Kanaele oder Parameter registrieren
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-
-int msr_io_register();
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_write
-*
-* Beschreibung: Schreiben der Werte
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-int msr_io_write();
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_write
-*
-* Beschreibung: Lesen der Werte
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-int msr_io_read();
-
-/*
-***************************************************************************************************
-*
-* Function: msr_io_cleanup
-*
-* Beschreibung: Aufräumen
-*
-* Parameter:
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
-void msr_io_cleanup();
-
-#endif
-
-