debuggers.hg

view xen/common/keyhandler.c @ 3763:0823f72cd071

bitkeeper revision 1.1159.223.80 (4208de05Xtv_u_3smJSRU6ex6bTAfA)

Some functions aren't static and could be (damn C language!).

I tried turning on -Wmissing-prototypes: unfortunately gives warnings
for functions used in asm, which means introducing gratuitous prototypes
for them. Not sure it's worth it.

1) keyhandler.c: keypress_softirq() and do_task_queues() can be static.
2) physdev.c: pcidev_dom0_hidden() can be static.
3) resource.c/resource.h: check_region is deprecated (racy): remove.
4) sched_bvt.c: lots of things can be static.
5) pci/compat.c: not required for Xen.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@freefall.cl.cam.ac.uk
date Tue Feb 08 15:43:01 2005 +0000 (2005-02-08)
parents d331c6994d28
children a00d7a994a59 0dc3b8b8c298
line source
1 /******************************************************************************
2 * keyhandler.c
3 */
5 #include <xen/keyhandler.h>
6 #include <xen/reboot.h>
7 #include <xen/event.h>
8 #include <xen/console.h>
9 #include <xen/serial.h>
10 #include <xen/sched.h>
11 #include <xen/softirq.h>
13 #define KEY_MAX 256
14 #define STR_MAX 64
16 static struct {
17 union {
18 keyhandler_t *handler;
19 irq_keyhandler_t *irq_handler;
20 } u;
21 unsigned int flags;
22 char desc[STR_MAX];
23 } key_table[KEY_MAX];
25 #define KEYHANDLER_IRQ_CALLBACK 0x1
27 static unsigned char keypress_key;
29 static void keypress_softirq(void)
30 {
31 keyhandler_t *h;
32 unsigned char key = keypress_key;
33 if ( (h = key_table[key].u.handler) != NULL )
34 (*h)(key);
35 }
37 void handle_keypress(unsigned char key, struct xen_regs *regs)
38 {
39 irq_keyhandler_t *h;
41 if ( key_table[key].flags & KEYHANDLER_IRQ_CALLBACK )
42 {
43 if ( (h = key_table[key].u.irq_handler) != NULL )
44 (*h)(key, regs);
45 }
46 else
47 {
48 keypress_key = key;
49 raise_softirq(KEYPRESS_SOFTIRQ);
50 }
51 }
53 void register_keyhandler(
54 unsigned char key, keyhandler_t *handler, char *desc)
55 {
56 ASSERT(key_table[key].u.handler == NULL);
57 key_table[key].u.handler = handler;
58 key_table[key].flags = 0;
59 strncpy(key_table[key].desc, desc, STR_MAX);
60 key_table[key].desc[STR_MAX-1] = '\0';
61 }
63 void register_irq_keyhandler(
64 unsigned char key, irq_keyhandler_t *handler, char *desc)
65 {
66 ASSERT(key_table[key].u.irq_handler == NULL);
67 key_table[key].u.irq_handler = handler;
68 key_table[key].flags = KEYHANDLER_IRQ_CALLBACK;
69 strncpy(key_table[key].desc, desc, STR_MAX);
70 key_table[key].desc[STR_MAX-1] = '\0';
71 }
73 static void show_handlers(unsigned char key)
74 {
75 int i;
76 printk("'%c' pressed -> showing installed handlers\n", key);
77 for ( i = 0; i < KEY_MAX; i++ )
78 if ( key_table[i].u.handler != NULL )
79 printk(" key '%c' (ascii '%02x') => %s\n",
80 (i<33 || i>126)?(' '):(i),i,
81 key_table[i].desc);
82 }
84 static void dump_registers(unsigned char key, struct xen_regs *regs)
85 {
86 printk("'%c' pressed -> dumping registers\n", key);
87 show_registers(regs);
88 }
90 static void halt_machine(unsigned char key, struct xen_regs *regs)
91 {
92 printk("'%c' pressed -> rebooting machine\n", key);
93 machine_restart(NULL);
94 }
96 static void do_task_queues(unsigned char key)
97 {
98 struct domain *d;
99 s_time_t now = NOW();
101 printk("'%c' pressed -> dumping task queues (now=0x%X:%08X)\n", key,
102 (u32)(now>>32), (u32)now);
104 read_lock(&domlist_lock);
106 for_each_domain ( d )
107 {
108 printk("Xen: DOM %u, CPU %d [has=%c] flags=%lx refcnt=%d nr_pages=%d "
109 "xenheap_pages=%d\n",
110 d->id, d->processor,
111 test_bit(DF_RUNNING, &d->flags) ? 'T':'F', d->flags,
112 atomic_read(&d->refcnt), d->tot_pages, d->xenheap_pages);
114 dump_pageframe_info(d);
116 printk("Guest: upcall_pend = %02x, upcall_mask = %02x\n",
117 d->shared_info->vcpu_data[0].evtchn_upcall_pending,
118 d->shared_info->vcpu_data[0].evtchn_upcall_mask);
119 printk("Notifying guest...\n");
120 send_guest_virq(d, VIRQ_DEBUG);
121 }
123 read_unlock(&domlist_lock);
124 }
126 extern void dump_runq(unsigned char key);
127 extern void print_sched_histo(unsigned char key);
128 extern void reset_sched_histo(unsigned char key);
129 #ifndef NDEBUG
130 extern void audit_domains_key(unsigned char key);
131 #endif
133 #ifdef PERF_COUNTERS
134 extern void perfc_printall(unsigned char key);
135 extern void perfc_reset(unsigned char key);
136 #endif
138 void initialize_keytable(void)
139 {
140 open_softirq(KEYPRESS_SOFTIRQ, keypress_softirq);
142 register_irq_keyhandler(
143 'd', dump_registers, "dump registers");
144 register_keyhandler(
145 'h', show_handlers, "show this message");
146 register_keyhandler(
147 'l', print_sched_histo, "print sched latency histogram");
148 register_keyhandler(
149 'L', reset_sched_histo, "reset sched latency histogram");
150 register_keyhandler(
151 'q', do_task_queues, "dump task queues + guest state");
152 register_keyhandler(
153 'r', dump_runq, "dump run queues");
154 register_irq_keyhandler(
155 'R', halt_machine, "reboot machine");
157 #ifndef NDEBUG
158 register_keyhandler(
159 'o', audit_domains_key, "audit domains >0 EXPERIMENTAL");
160 #endif
162 #ifdef PERF_COUNTERS
163 register_keyhandler(
164 'p', perfc_printall, "print performance counters");
165 register_keyhandler(
166 'P', perfc_reset, "reset performance counters");
167 #endif
168 }