This source file includes following definitions.
- set_bitmap
- sys_ioperm
- sys_iopl
- find_gap
1
2
3
4 #include <linux/sched.h>
5 #include <linux/kernel.h>
6 #include <linux/errno.h>
7 #include <linux/types.h>
8 #include <linux/ioport.h>
9
10 #define IOTABLE_SIZE 32
11
12 typedef struct resource_entry_t {
13 u_long from, num;
14 const char *name;
15 struct resource_entry_t *next;
16 } resource_entry_t;
17
18
19 static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
20 {
21 int mask;
22 unsigned long *bitmap_base = bitmap + (base >> 5);
23 unsigned short low_index = base & 0x1f;
24 int length = low_index + extent;
25
26 if (low_index != 0) {
27 mask = (~0 << low_index);
28 if (length < 32)
29 mask &= ~(~0 << length);
30 if (new_value)
31 *bitmap_base++ |= mask;
32 else
33 *bitmap_base++ &= ~mask;
34 length -= 32;
35 }
36
37 mask = (new_value ? ~0 : 0);
38 while (length >= 32) {
39 *bitmap_base++ = mask;
40 length -= 32;
41 }
42
43 if (length > 0) {
44 mask = ~(~0 << length);
45 if (new_value)
46 *bitmap_base++ |= mask;
47 else
48 *bitmap_base++ &= ~mask;
49 }
50 }
51
52
53
54
55 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
56 {
57 return -ENOSYS;
58 }
59
60 unsigned int *stack;
61
62
63
64
65
66
67
68
69
70
71
72 asmlinkage int sys_iopl(long ebx,long ecx,long edx,
73 long esi, long edi, long ebp, long eax, long ds,
74 long es, long fs, long gs, long orig_eax,
75 long eip,long cs,long eflags,long esp,long ss)
76 {
77 return -ENOSYS;
78 }
79
80
81
82
83 static resource_entry_t *find_gap(resource_entry_t *root,
84 u_long from, u_long num)
85 {
86 unsigned long flags;
87 resource_entry_t *p;
88
89 if (from > from+num-1)
90 return NULL;
91 save_flags(flags);
92 cli();
93 for (p = root; ; p = p->next) {
94 if ((p != root) && (p->from+p->num-1 >= from)) {
95 p = NULL;
96 break;
97 }
98 if ((p->next == NULL) || (p->next->from > from+num-1))
99 break;
100 }
101 restore_flags(flags);
102 return p;
103 }