ia64/xen-unstable

view xen/common/keyhandler.c @ 6832:5959fae4722a

Set NE bit for VMX guest CR0. VMCS guest CR0.NE bit must
be set, else it will cause "vm-entry failed".

Signed-off-by: Chengyuan Li <chengyuan.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Sep 14 13:37:50 2005 +0000 (2005-09-14)
parents 8651a99cdc09
children bd3268de4145
line source
1 /******************************************************************************
2 * keyhandler.c
3 */
5 #include <asm/regs.h>
6 #include <xen/keyhandler.h>
7 #include <xen/reboot.h>
8 #include <xen/event.h>
9 #include <xen/console.h>
10 #include <xen/serial.h>
11 #include <xen/sched.h>
12 #include <xen/softirq.h>
13 #include <xen/domain.h>
14 #include <asm/debugger.h>
16 #define KEY_MAX 256
17 #define STR_MAX 64
19 static struct {
20 union {
21 keyhandler_t *handler;
22 irq_keyhandler_t *irq_handler;
23 } u;
24 unsigned int flags;
25 char desc[STR_MAX];
26 } key_table[KEY_MAX];
28 #define KEYHANDLER_IRQ_CALLBACK 0x1
30 static unsigned char keypress_key;
32 static void keypress_softirq(void)
33 {
34 keyhandler_t *h;
35 unsigned char key = keypress_key;
36 if ( (h = key_table[key].u.handler) != NULL )
37 (*h)(key);
38 }
40 void handle_keypress(unsigned char key, struct cpu_user_regs *regs)
41 {
42 irq_keyhandler_t *h;
44 if ( key_table[key].flags & KEYHANDLER_IRQ_CALLBACK )
45 {
46 if ( (h = key_table[key].u.irq_handler) != NULL )
47 (*h)(key, regs);
48 }
49 else
50 {
51 keypress_key = key;
52 raise_softirq(KEYPRESS_SOFTIRQ);
53 }
54 }
56 void register_keyhandler(
57 unsigned char key, keyhandler_t *handler, char *desc)
58 {
59 ASSERT(key_table[key].u.handler == NULL);
60 key_table[key].u.handler = handler;
61 key_table[key].flags = 0;
62 strncpy(key_table[key].desc, desc, STR_MAX);
63 key_table[key].desc[STR_MAX-1] = '\0';
64 }
66 void register_irq_keyhandler(
67 unsigned char key, irq_keyhandler_t *handler, char *desc)
68 {
69 ASSERT(key_table[key].u.irq_handler == NULL);
70 key_table[key].u.irq_handler = handler;
71 key_table[key].flags = KEYHANDLER_IRQ_CALLBACK;
72 strncpy(key_table[key].desc, desc, STR_MAX);
73 key_table[key].desc[STR_MAX-1] = '\0';
74 }
76 static void show_handlers(unsigned char key)
77 {
78 int i;
79 printk("'%c' pressed -> showing installed handlers\n", key);
80 for ( i = 0; i < KEY_MAX; i++ )
81 if ( key_table[i].u.handler != NULL )
82 printk(" key '%c' (ascii '%02x') => %s\n",
83 (i<33 || i>126)?(' '):(i),i,
84 key_table[i].desc);
85 }
87 static void dump_registers(unsigned char key, struct cpu_user_regs *regs)
88 {
89 printk("'%c' pressed -> dumping registers\n", key);
90 show_registers(regs);
91 }
93 static void halt_machine(unsigned char key, struct cpu_user_regs *regs)
94 {
95 printk("'%c' pressed -> rebooting machine\n", key);
96 machine_restart(NULL);
97 }
99 static void do_task_queues(unsigned char key)
100 {
101 struct domain *d;
102 struct vcpu *v;
103 s_time_t now = NOW();
105 printk("'%c' pressed -> dumping task queues (now=0x%X:%08X)\n", key,
106 (u32)(now>>32), (u32)now);
108 read_lock(&domlist_lock);
110 for_each_domain ( d )
111 {
112 printk("Xen: DOM %u, flags=%lx refcnt=%d nr_pages=%d "
113 "xenheap_pages=%d\n", d->domain_id, d->domain_flags,
114 atomic_read(&d->refcnt), d->tot_pages, d->xenheap_pages);
116 dump_pageframe_info(d);
118 for_each_vcpu ( d, v ) {
119 printk("Guest: %p CPU %d [has=%c] flags=%lx "
120 "upcall_pend = %02x, upcall_mask = %02x\n", v,
121 v->processor,
122 test_bit(_VCPUF_running, &v->vcpu_flags) ? 'T':'F',
123 v->vcpu_flags,
124 v->vcpu_info->evtchn_upcall_pending,
125 v->vcpu_info->evtchn_upcall_mask);
126 printk("Notifying guest... %d/%d\n", d->domain_id, v->vcpu_id);
127 printk("port %d/%d stat %d %d %d\n",
128 VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
129 test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
130 &d->shared_info->evtchn_pending[0]),
131 test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
132 &d->shared_info->evtchn_mask[0]),
133 test_bit(v->virq_to_evtchn[VIRQ_DEBUG]>>5,
134 &v->vcpu_info->evtchn_pending_sel));
135 send_guest_virq(v, VIRQ_DEBUG);
136 }
137 }
139 read_unlock(&domlist_lock);
140 }
142 extern void dump_runq(unsigned char key);
143 extern void print_sched_histo(unsigned char key);
144 extern void reset_sched_histo(unsigned char key);
145 #ifndef NDEBUG
146 extern void audit_domains_key(unsigned char key);
147 #endif
149 #ifdef PERF_COUNTERS
150 extern void perfc_printall(unsigned char key);
151 extern void perfc_reset(unsigned char key);
152 #endif
154 void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
155 {
156 (void)debugger_trap_fatal(0xf001, regs);
157 nop(); /* Prevent the compiler doing tail call
158 optimisation, as that confuses xendbg a
159 bit. */
160 }
162 #ifndef NDEBUG
163 void debugtrace_key(unsigned char key)
164 {
165 debugtrace_send_to_console = !debugtrace_send_to_console;
166 debugtrace_dump();
167 printk("debugtrace_printk now writing to %s.\n",
168 debugtrace_send_to_console ? "console" : "buffer");
169 }
170 #endif
172 void initialize_keytable(void)
173 {
174 open_softirq(KEYPRESS_SOFTIRQ, keypress_softirq);
176 register_irq_keyhandler(
177 'd', dump_registers, "dump registers");
178 register_keyhandler(
179 'h', show_handlers, "show this message");
180 register_keyhandler(
181 'l', print_sched_histo, "print sched latency histogram");
182 register_keyhandler(
183 'L', reset_sched_histo, "reset sched latency histogram");
184 register_keyhandler(
185 'q', do_task_queues, "dump task queues + guest state");
186 register_keyhandler(
187 'r', dump_runq, "dump run queues");
188 register_irq_keyhandler(
189 'R', halt_machine, "reboot machine");
191 #ifndef NDEBUG
192 register_keyhandler(
193 'o', audit_domains_key, "audit domains >0 EXPERIMENTAL");
194 register_keyhandler(
195 'T', debugtrace_key, "toggle debugtrace to console/buffer");
196 #endif
198 #ifdef PERF_COUNTERS
199 register_keyhandler(
200 'p', perfc_printall, "print performance counters");
201 register_keyhandler(
202 'P', perfc_reset, "reset performance counters");
203 #endif
205 register_irq_keyhandler('%', do_debug_key, "Trap to xendbg");
206 }
208 /*
209 * Local variables:
210 * mode: C
211 * c-set-style: "BSD"
212 * c-basic-offset: 4
213 * tab-width: 4
214 * indent-tabs-mode: nil
215 * End:
216 */