internal.h
1 /* 2 * Copyright (C) 2005-2007 Jan Kiszka <jan.kiszka@web.de>. 3 * Copyright (C) 2005 Joerg Langenberg <joerg.langenberg@gmx.net>. 4 * 5 * with adaptions for RTAI by Paolo Mantegazza <mantegazza@aero.polimi.it> 6 * 7 * RTAI is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * RTAI is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with RTAI; if not, write to the Free Software Foundation, 19 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 #ifndef _RTDM_INTERNAL_H 23 #define _RTDM_INTERNAL_H 24 25 #include <linux/list.h> 26 #include <linux/proc_fs.h> 27 #include <linux/sem.h> 28 29 30 31 #include <rtdm/rtdm_driver.h> 32 33 #define RTDM_FD_MAX CONFIG_RTAI_RTDM_FD_MAX 34 35 #define DEF_DEVNAME_HASHTAB_SIZE 256 /* entries in name hash table */ 36 #define DEF_PROTO_HASHTAB_SIZE 256 /* entries in protocol hash table */ 37 38 struct rtdm_fildes { 39 struct rtdm_dev_context *context; 40 }; 41 42 struct rtdm_process { 43 #ifdef CONFIG_PROC_FS 44 char name[32]; 45 pid_t pid; 46 #endif /* CONFIG_PROC_FS */ 47 48 49 }; 50 51 DECLARE_EXTERN_XNLOCK(rt_fildes_lock); 52 DECLARE_EXTERN_XNLOCK(rt_dev_lock); 53 54 extern int __rtdm_muxid; 55 extern struct rtdm_fildes fildes_table[]; 56 extern int open_fildes; 57 extern struct semaphore nrt_dev_lock; 58 extern unsigned int devname_hashtab_size; 59 extern unsigned int protocol_hashtab_size; 60 extern struct list_head *rtdm_named_devices; 61 extern struct list_head *rtdm_protocol_devices; 62 63 #ifdef MODULE 64 #define rtdm_initialised 1 65 #else /* !MODULE */ 66 extern int rtdm_initialised; 67 #endif /* MODULE */ 68 69 void cleanup_owned_contexts(void *user_info); 70 int rtdm_no_support(void); 71 struct rtdm_device *get_named_device(const char *name); 72 struct rtdm_device *get_protocol_device(int protocol_family, int socket_type); 73 74 static inline void rtdm_dereference_device(struct rtdm_device *device) 75 { 76 atomic_dec(&device->reserved.refcount); 77 } 78 79 int __init rtdm_dev_init(void); 80 void rtdm_dev_cleanup(void); 81 82 #ifdef CONFIG_PROC_FS 83 int __init rtdm_proc_init(void); 84 void rtdm_proc_cleanup(void); 85 int rtdm_proc_register_device(struct rtdm_device *device); 86 void rtdm_proc_unregister_device(struct rtdm_device *device); 87 #else 88 static inline int rtdm_proc_init(void) 89 { 90 return 0; 91 } 92 void rtdm_proc_cleanup(void) 93 { 94 } 95 static int rtdm_proc_register_device(struct rtdm_device *device) 96 { 97 return 0; 98 } 99 static void rtdm_proc_unregister_device(struct rtdm_device *device) 100 { 101 } 102 #endif 103 104 void rtdm_apc_handler(void *cookie); 105 106 #endif /* _RTDM_INTERNAL_H */