1 ////////////////////////////////////////////////////////////////////////////////////
6 // This file is C source for SWAP driver.
10 // COMPANY NAME: Samsung Research Center in Moscow
11 // DEPT NAME: Advanced Software Group
12 // CREATED: 2008.02.15
14 // REVISION DATE: 2008.12.02
16 ////////////////////////////////////////////////////////////////////////////////////
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
23 schedule_timeout_interruptible (signed long timeout)
25 __set_current_state (TASK_INTERRUPTIBLE);
26 return schedule_timeout (timeout);
28 #endif /* kernel without schedule_timeout_interruptible */
30 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
32 remap_vmalloc_range (struct vm_area_struct *vma, void *addr, unsigned long pgoff)
34 unsigned long uaddr = vma->vm_start;
35 unsigned long usize = vma->vm_end - vma->vm_start;
38 if ((PAGE_SIZE - 1) & (unsigned long) addr)
50 ret = remap_pfn_range (vma, uaddr, vmalloc_to_pfn (addr), PAGE_SIZE, PAGE_SHARED);
62 #endif /* kernel without remap_vmalloc_range() */
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
66 To be mappable to user space, pages of memory allocated via "vmalloc" must
67 be marked with "PG_reserved" flag. Memory allocated via "vmalloc_user"
71 _reserve_pages (void *p, unsigned size)
73 unsigned pages = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
76 SetPageReserved (vmalloc_to_page (p));
84 _unreserve_pages (void *p, unsigned size)
86 unsigned pages = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
89 ClearPageReserved (vmalloc_to_page (p));
97 vmalloc_user (unsigned long size)
99 void *p = __vmalloc (size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
103 _reserve_pages (p, size);
109 vfree_user (void *address, unsigned long size)
111 _unreserve_pages (address, size);
114 #endif /* kernel without vmalloc_user() */