Mercurial > mplayer.hg
annotate vidix/dhahelper/dhahelper.c @ 26907:f0d0b666ee35
Fix compilation with internal dvdnav
author | rtogni |
---|---|
date | Sat, 31 May 2008 13:42:09 +0000 |
parents | af5408de478f |
children | ad17225e13b4 |
rev | line source |
---|---|
26901
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
1 /* |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
2 Direct Hardware Access kernel helper |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
3 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
4 (C) 2002 Alex Beregszaszi <alex@fsn.hu> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
5 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
6 Accessing hardware from userspace as USER (no root needed!) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
7 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
8 Tested on 2.2.x (2.2.19) and 2.4.x (2.4.3,2.4.17). |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
9 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
10 License: GPL |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
11 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
12 WARNING! THIS MODULE VIOLATES SEVERAL SECURITY LINES! DON'T USE IT |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
13 ON PRODUCTION SYSTEMS, ONLY AT HOME, ON A "SINGLE-USER" SYSTEM. |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
14 NO WARRANTY! |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
15 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
16 Tech: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
17 Communication between userspace and kernelspace goes over character |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
18 device using ioctl. |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
19 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
20 Usage: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
21 mknod -m 666 /dev/dhahelper c 180 0 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
22 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
23 Also you can change the major number, setting the "dhahelper_major" |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
24 module parameter, the default is 180, specified in dhahelper.h. |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
25 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
26 Note: do not use other than minor==0, the module forbids it. |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
27 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
28 TODO: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
29 * do memory mapping without fops:mmap |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
30 * implement unmap memory |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
31 * select (request?) a "valid" major number (from Linux project? ;) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
32 * make security |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
33 * is pci handling needed? (libdha does this with lowlevel port funcs) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
34 * is mttr handling needed? |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
35 * test on older kernels (2.0.x (?)) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
36 */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
37 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
38 #ifndef MODULE |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
39 #define MODULE |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
40 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
41 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
42 #ifndef __KERNEL__ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
43 #define __KERNEL__ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
44 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
45 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
46 #include <linux/config.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
47 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
48 #ifdef CONFIG_MODVERSION |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
49 #define MODVERSION |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
50 #include <linux/modversions.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
51 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
52 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
53 #include <linux/version.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
54 #include <linux/module.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
55 #include <linux/types.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
56 #include <linux/kernel.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
57 #include <linux/sched.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
58 #include <linux/mm.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
59 #include <linux/string.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
60 #include <linux/errno.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
61 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
62 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
63 #include <linux/malloc.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
64 #else |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
65 #include <linux/slab.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
66 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
67 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
68 #include <linux/pci.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
69 #include <linux/ioport.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
70 #include <linux/init.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
71 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
72 #include <asm/uaccess.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
73 #include <asm/system.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
74 #include <asm/io.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
75 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
76 #include <linux/mman.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
77 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
78 #include <linux/fs.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
79 #include <linux/unistd.h> |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
80 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
81 #include "dhahelper.h" |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
82 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
83 MODULE_AUTHOR("Alex Beregszaszi <alex@fsn.hu>"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
84 MODULE_DESCRIPTION("Provides userspace access to hardware (security violation!)"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
85 #ifdef MODULE_LICENSE |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
86 MODULE_LICENSE("GPL"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
87 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
88 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
89 static int dhahelper_major = DEFAULT_MAJOR; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
90 MODULE_PARM(dhahelper_major, "i"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
91 MODULE_PARM_DESC(dhahelper_major, "Major number of dhahelper characterdevice"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
92 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
93 /* 0 = silent */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
94 /* 1 = report errors (default) */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
95 /* 2 = debug */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
96 static int dhahelper_verbosity = 1; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
97 MODULE_PARM(dhahelper_verbosity, "i"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
98 MODULE_PARM_DESC(dhahelper_verbosity, "Level of verbosity (0 = silent, 1 = only errors, 2 = debug)"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
99 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
100 static dhahelper_memory_t last_mem_request; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
101 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
102 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
103 static int dhahelper_open(struct inode *inode, struct file *file) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
104 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
105 if (dhahelper_verbosity > 1) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
106 printk(KERN_DEBUG "dhahelper: device opened\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
107 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
108 if (MINOR(inode->i_rdev) != 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
109 return -ENXIO; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
110 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
111 MOD_INC_USE_COUNT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
112 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
113 return 0; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
114 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
115 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
116 static int dhahelper_release(struct inode *inode, struct file *file) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
117 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
118 if (dhahelper_verbosity > 1) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
119 printk(KERN_DEBUG "dhahelper: device released\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
120 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
121 if (MINOR(inode->i_rdev) != 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
122 return -ENXIO; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
123 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
124 MOD_DEC_USE_COUNT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
125 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
126 return 0; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
127 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
128 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
129 static int dhahelper_ioctl(struct inode *inode, struct file *file, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
130 unsigned int cmd, unsigned long arg) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
131 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
132 if (dhahelper_verbosity > 1) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
133 printk(KERN_DEBUG "dhahelper: ioctl(cmd=%x, arg=%lx)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
134 cmd, arg); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
135 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
136 if (MINOR(inode->i_rdev) != 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
137 return -ENXIO; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
138 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
139 switch(cmd) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
140 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
141 case DHAHELPER_GET_VERSION: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
142 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
143 int version = API_VERSION; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
144 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
145 if (copy_to_user((int *)arg, &version, sizeof(int))) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
146 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
147 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
148 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
149 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
150 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
151 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
152 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
153 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
154 case DHAHELPER_PORT: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
155 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
156 dhahelper_port_t port; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
157 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
158 if (copy_from_user(&port, (dhahelper_port_t *)arg, sizeof(dhahelper_port_t))) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
159 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
160 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
161 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
162 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
163 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
164 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
165 switch(port.operation) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
166 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
167 case PORT_OP_READ: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
168 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
169 switch(port.size) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
170 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
171 case 1: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
172 port.value = inb(port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
173 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
174 case 2: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
175 port.value = inw(port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
176 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
177 case 4: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
178 port.value = inl(port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
179 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
180 default: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
181 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
182 printk(KERN_ERR "dhahelper: invalid port read size (%d)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
183 port.size); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
184 return -EINVAL; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
185 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
186 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
187 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
188 case PORT_OP_WRITE: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
189 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
190 switch(port.size) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
191 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
192 case 1: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
193 outb(port.value, port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
194 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
195 case 2: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
196 outw(port.value, port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
197 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
198 case 4: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
199 outl(port.value, port.addr); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
200 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
201 default: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
202 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
203 printk(KERN_ERR "dhahelper: invalid port write size (%d)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
204 port.size); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
205 return -EINVAL; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
206 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
207 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
208 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
209 default: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
210 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
211 printk(KERN_ERR "dhahelper: invalid port operation (%d)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
212 port.operation); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
213 return -EINVAL; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
214 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
215 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
216 /* copy back only if read was performed */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
217 if (port.operation == PORT_OP_READ) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
218 if (copy_to_user((dhahelper_port_t *)arg, &port, sizeof(dhahelper_port_t))) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
219 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
220 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
221 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
222 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
223 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
224 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
225 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
226 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
227 case DHAHELPER_MEMORY: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
228 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
229 dhahelper_memory_t mem; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
230 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
231 if (copy_from_user(&mem, (dhahelper_memory_t *)arg, sizeof(dhahelper_memory_t))) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
232 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
233 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
234 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
235 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
236 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
237 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
238 switch(mem.operation) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
239 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
240 case MEMORY_OP_MAP: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
241 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
242 #if 1 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
243 memcpy(&last_mem_request, &mem, sizeof(dhahelper_memory_t)); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
244 #else |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
245 mem.ret = do_mmap(file, mem.start, mem.size, PROT_READ|PROT_WRITE, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
246 MAP_SHARED, mem.offset); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
247 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
248 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
249 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
250 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
251 case MEMORY_OP_UNMAP: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
252 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
253 default: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
254 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
255 printk(KERN_ERR "dhahelper: invalid memory operation (%d)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
256 mem.operation); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
257 return -EINVAL; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
258 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
259 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
260 if (copy_to_user((dhahelper_memory_t *)arg, &mem, sizeof(dhahelper_memory_t))) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
261 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
262 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
263 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
264 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
265 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
266 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
267 break; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
268 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
269 default: |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
270 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
271 printk(KERN_ERR "dhahelper: invalid ioctl (%x)\n", cmd); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
272 return -EINVAL; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
273 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
274 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
275 return 0; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
276 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
277 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
278 static int dhahelper_mmap(struct file *file, struct vm_area_struct *vma) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
279 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
280 if (last_mem_request.operation != MEMORY_OP_MAP) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
281 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
282 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
283 printk(KERN_ERR "dhahelper: mapping not requested before mmap\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
284 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
285 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
286 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
287 if (dhahelper_verbosity > 1) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
288 printk(KERN_INFO "dhahelper: mapping %x (size: %x)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
289 last_mem_request.start+last_mem_request.offset, last_mem_request.size); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
290 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
291 if (remap_page_range(0, last_mem_request.start + last_mem_request.offset, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
292 last_mem_request.size, vma->vm_page_prot)) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
293 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
294 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
295 printk(KERN_ERR "dhahelper: error mapping memory\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
296 return -EFAULT; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
297 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
298 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
299 return 0; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
300 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
301 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
302 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
303 static struct file_operations dhahelper_fops = |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
304 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
305 /*llseek*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
306 /*read*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
307 /*write*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
308 /*readdir*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
309 /*poll*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
310 /*ioctl*/ dhahelper_ioctl, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
311 /*mmap*/ dhahelper_mmap, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
312 /*open*/ dhahelper_open, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
313 /*flush*/ NULL, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
314 /*release*/ dhahelper_release, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
315 /* zero out the last 5 entries too ? */ |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
316 }; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
317 #else |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
318 static struct file_operations dhahelper_fops = |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
319 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
320 owner: THIS_MODULE, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
321 ioctl: dhahelper_ioctl, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
322 mmap: dhahelper_mmap, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
323 open: dhahelper_open, |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
324 release: dhahelper_release |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
325 }; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
326 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
327 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
328 #if KERNEL_VERSION < KERNEL_VERSION(2,4,0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
329 int init_module(void) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
330 #else |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
331 static int __init init_dhahelper(void) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
332 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
333 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
334 printk(KERN_INFO "Direct Hardware Access kernel helper (C) Alex Beregszaszi\n"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
335 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
336 if(register_chrdev(dhahelper_major, "dhahelper", &dhahelper_fops)) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
337 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
338 if (dhahelper_verbosity > 0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
339 printk(KERN_ERR "dhahelper: unable to register character device (major: %d)\n", |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
340 dhahelper_major); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
341 return -EIO; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
342 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
343 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
344 return 0; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
345 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
346 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
347 #if KERNEL_VERSION < KERNEL_VERSION(2,4,0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
348 void cleanup_module(void) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
349 #else |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
350 static void __exit exit_dhahelper(void) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
351 #endif |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
352 { |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
353 unregister_chrdev(dhahelper_major, "dhahelper"); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
354 } |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
355 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
356 EXPORT_NO_SYMBOLS; |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
357 |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
358 #if KERNEL_VERSION >= KERNEL_VERSION(2,4,0) |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
359 module_init(init_dhahelper); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
360 module_exit(exit_dhahelper); |
af5408de478f
Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents:
diff
changeset
|
361 #endif |