Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

irmod.h

Go to the documentation of this file.
00001 /*********************************************************************
00002  *                
00003  * Filename:      irmod.h
00004  * Version:       0.3
00005  * Description:   IrDA module and utilities functions
00006  * Status:        Experimental.
00007  * Author:        Dag Brattli <dagb@cs.uit.no>
00008  * Created at:    Mon Dec 15 13:58:52 1997
00009  * Modified at:   Sun Oct 31 20:01:17 1999
00010  * Modified by:   Dag Brattli <dagb@cs.uit.no>
00011  *
00012  *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
00013  *      
00014  *     This program is free software; you can redistribute it and/or 
00015  *     modify it under the terms of the GNU General Public License as 
00016  *     published by the Free Software Foundation; either version 2 of 
00017  *     the License, or (at your option) any later version.
00018  *  
00019  *     Neither Dag Brattli nor University of Tromsų admit liability nor
00020  *     provide warranty for any of this software. This material is 
00021  *     provided "AS-IS" and at no charg.
00022  *     
00023  ********************************************************************/
00024 
00025 #ifndef IRMOD_H
00026 #define IRMOD_H
00027 
00028 #include <linux/skbuff.h>
00029 #include <linux/miscdevice.h>
00030 
00031 #include <net/irda/irqueue.h>
00032 
00033 #define IRMGR_IOC_MAGIC 'm'
00034 #define IRMGR_IOCTNPC     _IO(IRMGR_IOC_MAGIC, 1)
00035 #define IRMGR_IOC_MAXNR   1 
00036 
00037 /*
00038  *  Events that we pass to the user space manager
00039  */
00040 typedef enum {
00041         EVENT_DEVICE_DISCOVERED = 0,
00042         EVENT_REQUEST_MODULE,
00043         EVENT_IRLAN_START,
00044         EVENT_IRLAN_STOP,
00045         EVENT_IRLPT_START,  /* Obsolete */
00046         EVENT_IRLPT_STOP,   /* Obsolete */
00047         EVENT_IROBEX_START, /* Obsolete */
00048         EVENT_IROBEX_STOP,  /* Obsolete */
00049         EVENT_IRDA_STOP,
00050         EVENT_NEED_PROCESS_CONTEXT,
00051 } IRMGR_EVENT;
00052 
00053 /*
00054  *  Event information passed to the IrManager daemon process
00055  */
00056 struct irmanager_event {
00057         IRMGR_EVENT event;
00058         char devname[10];
00059         char info[32];
00060         int service;
00061         __u32 saddr;
00062         __u32 daddr;
00063 };
00064 
00065 typedef void (*TODO_CALLBACK)( void *self, __u32 param);
00066 
00067 /*
00068  *  Same as irmanager_event but this one can be queued and inclueds some
00069  *  addtional information
00070  */
00071 struct irda_event {
00072         queue_t q; /* Must be first */
00073         
00074         struct irmanager_event event;
00075 };
00076 
00077 /*
00078  *  Funtions with needs to be called with a process context
00079  */
00080 struct irda_todo {
00081         queue_t q; /* Must be first */
00082 
00083         void *self;
00084         TODO_CALLBACK callback;
00085         __u32 param;
00086 };
00087 
00088 /*
00089  *  Main structure for the IrDA device (not much here :-)
00090  */
00091 struct irda_cb {
00092         struct miscdevice dev;  
00093         struct wait_queue *wait_queue;
00094 
00095         int in_use;
00096 
00097         queue_t *event_queue; /* Events queued for the irmanager */
00098         queue_t *todo_queue;  /* Todo list */
00099 };
00100 
00101 int irmod_init_module(void);
00102 void irmod_cleanup_module(void);
00103 
00104 /*
00105  * Function irda_lock (lock)
00106  *
00107  *    Lock variable. Returns false if the lock is already set.
00108  *    
00109  */
00110 static inline int irda_lock(int *lock) 
00111 {
00112         if (test_and_set_bit( 0, (void *) lock))  {
00113                 IRDA_DEBUG(3, __FUNCTION__ 
00114                       "(), Trying to lock, already locked variable!\n");
00115                 return FALSE;
00116         }  
00117         return TRUE;
00118 }
00119 
00120 inline int irda_unlock(int *lock);
00121 
00122 void irda_notify_init(notify_t *notify);
00123 
00124 void irda_execute_as_process(void *self, TODO_CALLBACK callback, __u32 param);
00125 void irmanager_notify(struct irmanager_event *event);
00126 
00127 extern void irda_proc_modcount(struct inode *, int);
00128 void irda_mod_inc_use_count(void);
00129 void irda_mod_dec_use_count(void);
00130 
00131 #endif /* IRMOD_H */
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140