Logiciels Libres et Systèmes Embarqués

dummy.h

Aller à la documentation de ce fichier.
00001 /*
00002   Copyright (C) 2005 MARTIN Loïc & VINCENT Cédric
00003   
00004   This program is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU General Public License
00006   as published by the Free Software Foundation; either version 2
00007   of the License, or (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 MODULE_LICENSE("GPL\0 rulez !!!");
00020 MODULE_AUTHOR("VINCENT MARTIN");
00021 MODULE_DESCRIPTION("dummy");
00022 MODULE_SUPPORTED_DEVICE("dummy");
00023 
00024 #ifndef DUMMY_H
00025 #define DUMMY_H
00026 
00028 #define DUMMY_MAJOR 0
00029 
00031 #define BUF_SIZE 1024
00032 
00034 #define DEBUG 1
00035 
00037 struct element_fifo 
00038 {
00039         size_t used_bytes; 
00040         char buffer[BUF_SIZE]; 
00041         int position; 
00042         struct element_fifo *next; 
00043         struct element_fifo *prev; 
00044 };
00045 
00047 struct private_dummy
00048 {
00049         int index; 
00050         int in_use; 
00051         struct element_fifo *head; 
00052         struct semaphore in_use_critique; 
00053         struct semaphore rw_critique; 
00054 };
00055 
00056 static int dummy_open (struct inode *inode, struct file *file);
00057 static int dummy_release (struct inode *inode, struct file *file);
00058 static ssize_t dummy_write (struct file *file, const char *buffer, size_t size, loff_t *offset);
00059 static ssize_t dummy_read (struct file *file, char *buffer, size_t size, loff_t *offset);
00060 static int dummy_init(void);
00061 static void dummy_cleanup(void);
00062 
00064 static struct file_operations dummy_fops = {
00065         read: dummy_read,
00066         write:  dummy_write,
00067         open:  dummy_open,
00068         release: dummy_release,
00069 };
00070 
00072 static int DeviceCount = 2; 
00073 
00075 static char *DeviceName = "dummy";
00076 
00078 static int dummy_major = DUMMY_MAJOR;
00079 
00081 static int *already_opened = NULL;
00082 
00084 static struct semaphore *open_critique = NULL;
00085 
00087 static struct private_dummy *device_fifo = NULL;
00088 
00089 #endif //DUMMY_H