This source file includes following definitions.
- set_bitmap
- sys_ioperm
- sys_iopl
1
2
3
4
5
6
7
8 #include <linux/sched.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/types.h>
12 #include <linux/ioport.h>
13
14
15 static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
16 {
17 int mask;
18 unsigned long *bitmap_base = bitmap + (base >> 5);
19 unsigned short low_index = base & 0x1f;
20 int length = low_index + extent;
21
22 if (low_index != 0) {
23 mask = (~0 << low_index);
24 if (length < 32)
25 mask &= ~(~0 << length);
26 if (new_value)
27 *bitmap_base++ |= mask;
28 else
29 *bitmap_base++ &= ~mask;
30 length -= 32;
31 }
32
33 mask = (new_value ? ~0 : 0);
34 while (length >= 32) {
35 *bitmap_base++ = mask;
36 length -= 32;
37 }
38
39 if (length > 0) {
40 mask = ~(~0 << length);
41 if (new_value)
42 *bitmap_base++ |= mask;
43 else
44 *bitmap_base++ &= ~mask;
45 }
46 }
47
48
49
50
51 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
52 {
53 if (from + num <= from)
54 return -EINVAL;
55 if (from + num > IO_BITMAP_SIZE*32)
56 return -EINVAL;
57 if (!suser())
58 return -EPERM;
59
60 set_bitmap((unsigned long *)current->tss.io_bitmap, from, num, !turn_on);
61 return 0;
62 }
63
64 unsigned int *stack;
65
66
67
68
69
70
71
72
73
74
75
76 asmlinkage int sys_iopl(long ebx,long ecx,long edx,
77 long esi, long edi, long ebp, long eax, long ds,
78 long es, long fs, long gs, long orig_eax,
79 long eip,long cs,long eflags,long esp,long ss)
80 {
81 unsigned int level = ebx;
82
83 if (level > 3)
84 return -EINVAL;
85 if (!suser())
86 return -EPERM;
87 *(&eflags) = (eflags & 0xffffcfff) | (level << 12);
88 return 0;
89 }