dummy/module.c
changeset 882 a7222d7fb7a8
parent 881 c5ac0ab2d6cf
child 883 4963e22a267a
equal deleted inserted replaced
881:c5ac0ab2d6cf 882:a7222d7fb7a8
     1 /******************************************************************************
       
     2  *
       
     3  *  $Id$
       
     4  *
       
     5  *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
       
     6  *
       
     7  *  This file is part of the IgH EtherCAT Master.
       
     8  *
       
     9  *  The IgH EtherCAT Master is free software; you can redistribute it
       
    10  *  and/or modify it under the terms of the GNU General Public License
       
    11  *  as published by the Free Software Foundation; either version 2 of the
       
    12  *  License, or (at your option) any later version.
       
    13  *
       
    14  *  The IgH EtherCAT Master is distributed in the hope that it will be
       
    15  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    17  *  GNU General Public License for more details.
       
    18  *
       
    19  *  You should have received a copy of the GNU General Public License
       
    20  *  along with the IgH EtherCAT Master; if not, write to the Free Software
       
    21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    22  *
       
    23  *  The right to use EtherCAT Technology is granted and comes free of
       
    24  *  charge under condition of compatibility of product made by
       
    25  *  Licensee. People intending to distribute/sell products based on the
       
    26  *  code, have to sign an agreement to guarantee that products using
       
    27  *  software based on IgH EtherCAT master stay compatible with the actual
       
    28  *  EtherCAT specification (which are released themselves as an open
       
    29  *  standard) as the (only) precondition to have the right to use EtherCAT
       
    30  *  Technology, IP and trade marks.
       
    31  *
       
    32  *****************************************************************************/
       
    33 
       
    34 /**
       
    35    \file
       
    36    Dummy EtherCAT master driver module.
       
    37 */
       
    38 
       
    39 /*****************************************************************************/
       
    40 
       
    41 #include <linux/module.h>
       
    42 //#include <linux/kernel.h>
       
    43 //#include <linux/init.h>
       
    44 
       
    45 #include "../master/globals.h"
       
    46 #include "../include/ecrt.h"
       
    47 
       
    48 /*****************************************************************************/
       
    49 
       
    50 int __init ec_init_module(void);
       
    51 void __exit ec_cleanup_module(void);
       
    52 
       
    53 char *ec_master_version_str = EC_MASTER_VERSION;
       
    54 
       
    55 /*****************************************************************************/
       
    56 
       
    57 /** \cond */
       
    58 
       
    59 MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
       
    60 MODULE_DESCRIPTION("DUMMY EtherCAT master driver module");
       
    61 MODULE_LICENSE("GPL");
       
    62 MODULE_VERSION(EC_MASTER_VERSION);
       
    63 
       
    64 /** \endcond */
       
    65 
       
    66 /*****************************************************************************/
       
    67 
       
    68 #define DUMMY_SIZE (PAGE_SIZE * 8)
       
    69 
       
    70 uint8_t dummy_data[DUMMY_SIZE];
       
    71 off_t dummy_off = 0;
       
    72 
       
    73 uint8_t *get_dummy_data(void)
       
    74 {
       
    75     off_t cur = dummy_off;
       
    76 
       
    77     dummy_off += 64;
       
    78     dummy_off %= DUMMY_SIZE;
       
    79 
       
    80     return dummy_data + cur;
       
    81 }
       
    82 
       
    83 /*****************************************************************************/
       
    84 
       
    85 /**
       
    86  * Module initialization.
       
    87  * Initializes \a ec_master_count masters.
       
    88  * \return 0 on success, else < 0
       
    89  */
       
    90 
       
    91 int __init ec_init_module(void)
       
    92 {
       
    93     EC_INFO("Master DUMMY driver %s\n", EC_MASTER_VERSION);
       
    94 
       
    95     memset(dummy_data, 0x00, DUMMY_SIZE);
       
    96 
       
    97     return 0;
       
    98 }
       
    99 
       
   100 /*****************************************************************************/
       
   101 
       
   102 /**
       
   103    Module cleanup.
       
   104    Clears all master instances.
       
   105 */
       
   106 
       
   107 void __exit ec_cleanup_module(void)
       
   108 {
       
   109     EC_INFO("Master DUMMY module cleaned up.\n");
       
   110 }
       
   111 
       
   112 /******************************************************************************
       
   113  *  Realtime interface
       
   114  *****************************************************************************/
       
   115 
       
   116 unsigned int ecrt_version_magic(void)
       
   117 {
       
   118     return ECRT_VERSION_MAGIC;
       
   119 }
       
   120 
       
   121 /*****************************************************************************/
       
   122 
       
   123 ec_master_t *ecrt_request_master(unsigned int master_index
       
   124                                  /**< master index */
       
   125                                  )
       
   126 {
       
   127     EC_INFO("Requesting DUMMY master %u...\n", master_index);
       
   128     return (void *) master_index + 1;
       
   129 }
       
   130 
       
   131 /*****************************************************************************/
       
   132 
       
   133 /**
       
   134    Releases a reserved EtherCAT master.
       
   135    \ingroup RealtimeInterface
       
   136 */
       
   137 
       
   138 void ecrt_release_master(ec_master_t *master /**< EtherCAT master */)
       
   139 {
       
   140     EC_INFO("Released DUMMY master %u.\n", (unsigned int) master - 1);
       
   141 }
       
   142 
       
   143 /*****************************************************************************/
       
   144 
       
   145 /** \cond */
       
   146 
       
   147 module_init(ec_init_module);
       
   148 module_exit(ec_cleanup_module);
       
   149 
       
   150 EXPORT_SYMBOL(ecrt_request_master);
       
   151 EXPORT_SYMBOL(ecrt_release_master);
       
   152 EXPORT_SYMBOL(ecrt_version_magic);
       
   153 
       
   154 /** \endcond */
       
   155 
       
   156 /*****************************************************************************/