ia64/xen-unstable

view unmodified_drivers/linux-2.6/platform-pci/platform-compat.c @ 13908:df25547d7638

[LINUX] Call ctrl_alt_del() to trigger a reboot so we benefit from the
generic infrastructure for cad_pid etc.

Add a ctrl_alt_del() implemenation to the PV on HVM compatibility
layer since ctrl_alt_del() is not exported on native kernels.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Tue Feb 13 15:32:25 2007 +0000 (2007-02-13)
parents c242b6d6a64a
children e47738923a05
line source
1 #include <linux/config.h>
2 #include <linux/version.h>
4 #include <linux/mm.h>
5 #include <linux/module.h>
6 #include <linux/sched.h>
7 #include <linux/slab.h>
9 #include <xen/platform-compat.h>
11 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
12 static int system_state = 1;
13 EXPORT_SYMBOL(system_state);
14 #endif
16 static inline void ctrl_alt_del(void)
17 {
18 kill_proc(1, SIGINT, 1); /* interrupt init */
19 }
20 EXPORT_SYMBOL(ctrl_alt_del);
22 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
23 size_t strcspn(const char *s, const char *reject)
24 {
25 const char *p;
26 const char *r;
27 size_t count = 0;
29 for (p = s; *p != '\0'; ++p) {
30 for (r = reject; *r != '\0'; ++r) {
31 if (*p == *r)
32 return count;
33 }
34 ++count;
35 }
37 return count;
38 }
39 EXPORT_SYMBOL(strcspn);
40 #endif
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
43 /*
44 * Map a vmalloc()-space virtual address to the physical page frame number.
45 */
46 unsigned long vmalloc_to_pfn(void * vmalloc_addr)
47 {
48 return page_to_pfn(vmalloc_to_page(vmalloc_addr));
49 }
50 EXPORT_SYMBOL(vmalloc_to_pfn);
51 #endif
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
54 unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
55 {
56 might_sleep();
58 spin_lock_irq(&x->wait.lock);
59 if (!x->done) {
60 DECLARE_WAITQUEUE(wait, current);
62 wait.flags |= WQ_FLAG_EXCLUSIVE;
63 __add_wait_queue_tail(&x->wait, &wait);
64 do {
65 __set_current_state(TASK_UNINTERRUPTIBLE);
66 spin_unlock_irq(&x->wait.lock);
67 timeout = schedule_timeout(timeout);
68 spin_lock_irq(&x->wait.lock);
69 if (!timeout) {
70 __remove_wait_queue(&x->wait, &wait);
71 goto out;
72 }
73 } while (!x->done);
74 __remove_wait_queue(&x->wait, &wait);
75 }
76 x->done--;
77 out:
78 spin_unlock_irq(&x->wait.lock);
79 return timeout;
80 }
81 EXPORT_SYMBOL(wait_for_completion_timeout);
82 #endif
84 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
85 /*
86 fake do_exit using complete_and_exit
87 */
88 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
89 asmlinkage NORET_TYPE void do_exit(long code)
90 #else
91 fastcall NORET_TYPE void do_exit(long code)
92 #endif
93 {
94 complete_and_exit(NULL, code);
95 }
96 EXPORT_SYMBOL_GPL(do_exit);
97 #endif
99 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
100 signed long schedule_timeout_interruptible(signed long timeout)
101 {
102 __set_current_state(TASK_INTERRUPTIBLE);
103 return schedule_timeout(timeout);
104 }
105 EXPORT_SYMBOL(schedule_timeout_interruptible);
106 #endif
108 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
109 /**
110 * kzalloc - allocate memory. The memory is set to zero.
111 * @size: how many bytes of memory are required.
112 * @flags: the type of memory to allocate.
113 */
114 void *kzalloc(size_t size, int flags)
115 {
116 void *ret = kmalloc(size, flags);
117 if (ret)
118 memset(ret, 0, size);
119 return ret;
120 }
121 EXPORT_SYMBOL(kzalloc);
122 #endif
124 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
125 /* Simplified asprintf. */
126 char *kasprintf(gfp_t gfp, const char *fmt, ...)
127 {
128 va_list ap;
129 unsigned int len;
130 char *p, dummy[1];
132 va_start(ap, fmt);
133 len = vsnprintf(dummy, 0, fmt, ap);
134 va_end(ap);
136 p = kmalloc(len + 1, gfp);
137 if (!p)
138 return NULL;
139 va_start(ap, fmt);
140 vsprintf(p, fmt, ap);
141 va_end(ap);
142 return p;
143 }
144 EXPORT_SYMBOL(kasprintf);
145 #endif