1 --- vmmon-only/linux/driver.c 2008-08-07 22:04:50.000000000 +0200
2 +++ vmmon-only/linux/driver.c 2008-08-07 22:06:57.000000000 +0200
4 #include <linux/smp_lock.h>
6 #include <linux/poll.h>
8 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
9 +# include <linux/mm.h>
12 * Power Management: hook resume to work around
13 * BIOS bugs where VT is not properly enabled after S4
16 static int LinuxDriver_Close(struct inode *inode, struct file *filp);
17 static unsigned int LinuxDriverPoll(struct file *file, poll_table *wait);
18 -#if defined(VMW_NOPAGE_261)
19 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
20 +# if defined(VMW_NOPAGE_261)
21 static struct page *LinuxDriverNoPage(struct vm_area_struct *vma,
22 unsigned long address, int *type);
23 -#elif defined(KERNEL_2_4_0)
24 +# elif defined(KERNEL_2_4_0)
25 static struct page *LinuxDriverNoPage(struct vm_area_struct *vma,
26 unsigned long address, int unused);
29 static unsigned long LinuxDriverNoPage(struct vm_area_struct *vma,
30 unsigned long address, int write_access);
32 -static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma);
34 -static void LinuxDriverPollTimeout(unsigned long clientData);
37 static struct vm_operations_struct vmuser_mops = {
38 .nopage = LinuxDriverNoPage
41 +static int LinuxDriverNoPage(struct vm_area_struct *vma,
42 + struct vm_fault *fdata);
44 +static struct vm_operations_struct vmuser_mops = {
45 + .fault = LinuxDriverNoPage
48 +static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma);
50 +static void LinuxDriverPollTimeout(unsigned long clientData);
52 static struct file_operations vmuser_fops;
53 static struct timer_list tscTimer;
54 @@ -1172,20 +1183,20 @@
56 *-----------------------------------------------------------------------------
59 -#ifdef VMW_NOPAGE_261
60 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
61 +# ifdef VMW_NOPAGE_261
62 static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, //IN
63 unsigned long address, //IN
64 int *type) //OUT: Fault type
65 -#elif defined(KERNEL_2_4_0)
66 +# elif defined(KERNEL_2_4_0)
67 static struct page *LinuxDriverNoPage(struct vm_area_struct *vma, //IN
68 unsigned long address, //IN
72 static unsigned long LinuxDriverNoPage(struct vm_area_struct *vma,//IN
73 unsigned long address, //IN
74 int write_access) //IN
78 VMLinux *vmLinux = (VMLinux *) vma->vm_file->private_data;
80 @@ -1198,15 +1209,37 @@
82 page = vmLinux->pages4Gb[pg];
85 -#ifdef VMW_NOPAGE_261
87 +# ifdef VMW_NOPAGE_261
88 *type = VM_FAULT_MINOR;
94 return page_address(page);
99 +/* For kernel upper or equal to 2.6.26 */
100 +static int LinuxDriverNoPage(struct vm_area_struct *vma,
101 + struct vm_fault *fdata)
103 + VMLinux *vmLinux = (VMLinux *) vma->vm_file->private_data;
108 + pg = VMMON_MAP_OFFSET(pg);
109 + if (pg >= vmLinux->size4Gb) {
110 + return VM_FAULT_MAJOR;
112 + page = vmLinux->pages4Gb[pg];
114 + fdata->page = page;
115 + return VM_FAULT_MINOR;