1 ////////////////////////////////////////////////////////////////////////////////////
6 // This file is C source for SWAP driver.
9 // AUTHOR: L.Komkov, A.Gerenkov
10 // COMPANY NAME: Samsung Research Center in Moscow
11 // DEPT NAME: Advanced Software Group
12 // CREATED: 2008.02.15
14 // REVISION DATE: 2008.12.03
16 ////////////////////////////////////////////////////////////////////////////////////
20 char gl_szDefaultDeviceName[128] = DEFAULT_DEVICE_NAME;
21 char* device_name = NULL;
22 module_param (device_name, charp, 0);
23 MODULE_PARM_DESC (device_name, "device name for '/proc/devices'");
25 unsigned int device_major = 0;
26 module_param (device_major, uint, 0);
27 MODULE_PARM_DESC (device_major, "default device major number");
29 #if (LINUX_VERSION_CODE != KERNEL_VERSION(2, 6, 16))
30 void (*__real_put_task_struct) (struct task_struct * tsk);
31 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11))
32 #define SWAPDRV_PUT_TASK_STRUCT "put_task_struct"
34 put_task_struct (struct task_struct *tsk)
36 __real_put_task_struct (tsk);
39 #define SWAPDRV_PUT_TASK_STRUCT "__put_task_struct"
41 __put_task_struct (struct task_struct *tsk)
43 __real_put_task_struct (tsk);
47 void (*__real_put_task_struct) (struct rcu_head * rhp);
48 #define SWAPDRV_PUT_TASK_STRUCT "__put_task_struct_cb"
50 __put_task_struct_cb (struct rcu_head *rhp)
52 __real_put_task_struct (rhp);
55 /*void (*__real_put_task_struct)(struct task_struct *tsk);
56 void __put_task_struct(struct task_struct *tsk)
58 __real_put_task_struct(tsk);
61 #if defined(CONFIG_MIPS)
62 void (*flush_cache_page) (struct vm_area_struct * vma, unsigned long page);
65 static int __init InitializeModule(void)
67 if(device_name == NULL) {
68 EPRINTF("Using default device name!");
69 device_name = gl_szDefaultDeviceName;
71 if(device_major == 0) {
72 EPRINTF("Using default device major number!");
73 device_major = DEFAULT_DEVICE_MAJOR;
76 __real_put_task_struct = (void *)swap_ksyms(SWAPDRV_PUT_TASK_STRUCT);
77 if (!__real_put_task_struct)
79 EPRINTF (SWAPDRV_PUT_TASK_STRUCT " is not found! Oops. Where is it?");
83 #if defined(CONFIG_MIPS)
84 flush_cache_page = (void *)swap_ksyms("r4k_flush_cache_page");
85 if (!flush_cache_page)
87 EPRINTF ("failed to resolve 'flush_cache_page'!\n");
92 if(probes_manager_init() < 0) {
93 EPRINTF ("Cannot initialize probe manager!");
96 if(device_init() < 0) {
97 EPRINTF ("Cannot initialize device!");
101 INIT_LIST_HEAD(&cond_list.list);
103 DPRINTF ("is successfully initialized.");
107 static void __exit UninitializeModule (void)
111 probes_manager_down ();
112 DPRINTF ("is successfully finished.");
115 module_init (InitializeModule);
116 module_exit (UninitializeModule);
117 MODULE_LICENSE ("GPL");
118 MODULE_AUTHOR("Adwanced Software Group (SRC, Moscow)");
119 MODULE_DESCRIPTION("SWAP Device Driver");
120 MODULE_VERSION("4:1.0");