2 * kernel driver for pthread peers
5 #include <linux/module.h>
6 #include <linux/moduleparam.h>
7 #include <linux/init.h>
8 #include <linux/sched.h>
9 #include <linux/kernel.h>
10 #include <linux/slab.h>
12 #include <linux/errno.h>
13 #include <linux/timer.h>
14 #include <linux/types.h>
15 #include <linux/vmalloc.h>
16 #include <linux/genhd.h>
17 #include <linux/blkdev.h>
18 #include <linux/bio.h>
19 #include <linux/device.h>
20 #include <linux/completion.h>
22 #include <xseg/xseg.h>
23 #include <sys/kernel/segdev.h>
25 #include <xtypes/xpool.h>
27 MODULE_DESCRIPTION("xseg_pthread");
28 MODULE_AUTHOR("XSEG");
29 MODULE_LICENSE("GPL");
31 static int pthread_signal_init(void)
36 static void pthread_signal_quit(void)
41 static int pthread_prepare_wait(struct xseg *xseg, uint32_t portno)
46 static int pthread_cancel_wait(struct xseg *xseg, uint32_t portno)
51 static int pthread_wait_signal(struct xseg *xseg, uint32_t timeout)
56 static int pthread_signal(struct xseg *xseg, uint32_t portno)
59 struct task_struct *task;
63 struct xseg_port *port = xseg_get_port(xseg, portno);
68 /* XXX Security: xseg peers can kill anyone */
69 idx = xpool_peek(&port->waiters, &data, portno); //FIXME portno is not the caller but the callee
74 pid = find_vpid((pid_t) data);
77 task = pid_task(pid, PIDTYPE_PID);
81 ret = send_sig(SIGIO, task, 1);
87 static void *pthread_malloc(uint64_t size)
92 static void *pthread_realloc(void *mem, uint64_t size)
97 static void pthread_mfree(void *mem) { }
99 static struct xseg_peer xseg_peer_pthread = {
100 /* xseg signal operations */
102 .signal_init = pthread_signal_init,
103 .signal_quit = pthread_signal_quit,
104 .cancel_wait = pthread_cancel_wait,
105 .prepare_wait = pthread_prepare_wait,
106 .wait_signal = pthread_wait_signal,
107 .signal = pthread_signal,
108 .malloc = pthread_malloc,
109 .realloc = pthread_realloc,
110 .mfree = pthread_mfree
116 static int pthread_init(void)
120 XSEGLOG("registering xseg types");
122 r = xseg_register_peer(&xseg_peer_pthread);
127 static int pthread_quit(void)
129 xseg_unregister_peer(xseg_peer_pthread.name);
133 /* *************************** */
134 /* ** Module Initialization ** */
135 /* *************************** */
137 static int __init xseg_pthread_init(void)
141 ret = pthread_init();
145 XSEGLOG("initialization complete");
150 static void __exit xseg_pthread_exit(void)
155 module_init(xseg_pthread_init);
156 module_exit(xseg_pthread_exit);