Xenomai  3.0.8
rtnet_rtpc.h
1 /***
2  *
3  * include/rtnet_rtpc.h
4  *
5  * RTnet - real-time networking subsystem
6  *
7  * Copyright (C) 2003, 2004 Jan Kiszka <jan.kiszka@web.de>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * 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 this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  */
24 
25 #ifndef __RTNET_RTPC_H_
26 #define __RTNET_RTPC_H_
27 
28 #include <linux/init.h>
29 
30 #include <rtnet_internal.h>
31 
32 
33 struct rt_proc_call;
34 
35 typedef int (*rtpc_proc)(struct rt_proc_call *call);
36 typedef void (*rtpc_copy_back_proc)(struct rt_proc_call *call,
37  void *priv_data);
38 typedef void (*rtpc_cleanup_proc)(void *priv_data);
39 
40 struct rt_proc_call {
41  struct list_head list_entry;
42  int processed;
43  rtpc_proc proc;
44  int result;
45  atomic_t ref_count;
46  wait_queue_head_t call_wq;
47  rtpc_cleanup_proc cleanup_handler;
48  char priv_data[0] __attribute__ ((aligned(8)));
49 };
50 
51 #define CALL_PENDING 1000 /* result value for blocked calls */
52 
53 
54 int rtnet_rtpc_dispatch_call(rtpc_proc rt_proc, unsigned int timeout,
55  void *priv_data, size_t priv_data_size,
56  rtpc_copy_back_proc copy_back_handler,
57  rtpc_cleanup_proc cleanup_handler);
58 
59 
60 void rtnet_rtpc_complete_call(struct rt_proc_call *call, int result);
61 void rtnet_rtpc_complete_call_nrt(struct rt_proc_call *call, int result);
62 
63 #define rtpc_dispatch_call rtnet_rtpc_dispatch_call
64 #define rtpc_complete_call rtnet_rtpc_complete_call
65 #define rtpc_complete_call_nrt rtnet_rtpc_complete_call_nrt
66 
67 #define rtpc_get_priv(call, type) (type *)(call->priv_data)
68 #define rtpc_get_result(call) call->result
69 #define rtpc_set_result(call, new_result) call->result = new_result
70 #define rtpc_set_cleanup_handler(call, handler) \
71  call->cleanup_handler = handler;
72 
73 
74 int __init rtpc_init(void);
75 void rtpc_cleanup(void);
76 
77 #endif /* __RTNET_RTPC_H_ */
Copyright © 2011 Gilles Chanteperdrix gilles.chanteperdrix@xenomai.org.
Definition: atomic.h:24