[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [Patch v4 5/5] x86/hpet: debug keyhandlers



Debug key for dumping HPET state.

This patch is not intended for committing.
---
 xen/arch/x86/hpet.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index dedfa04..781f0f4 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -9,6 +9,7 @@
 #include <xen/cpuidle.h>
 #include <xen/errno.h>
 #include <xen/softirq.h>
+#include <xen/keyhandler.h>
 
 #include <mach_apic.h>
 
@@ -68,6 +69,7 @@ boolean_param("hpetbroadcast", force_hpet_broadcast);
 
 static bool_t __read_mostly hpet_verbose;
 static bool_t __read_mostly hpet_debug;
+static bool_t __initdata hpet_debug_tick;
 static void __init parse_hpet_param(char * s)
 {
     char *ss;
@@ -90,6 +92,8 @@ static void __init parse_hpet_param(char * s)
             if ( val )
                 hpet_verbose = 1;
         }
+        else if ( !strcmp(s, "tick") )
+            hpet_debug_tick = val;
 
         s = ss + 1;
     } while ( ss );
@@ -764,6 +768,33 @@ int hpet_legacy_irq_tick(void)
 
 static u32 *hpet_boot_cfg;
 
+static void do_hpet_dump_state(unsigned char key)
+{
+    unsigned i;
+    printk("'%c' pressed - dumping HPET state\n", key);
+
+    for ( i = 0; i < num_hpets_used; ++i )
+        dump_hpet_timer(i);
+}
+
+static struct keyhandler hpet_dump_state = {
+    .irq_callback = 0,
+    .u.fn = do_hpet_dump_state,
+    .desc = "Dump hpet state"
+};
+
+static struct timer hpet_dbg_tick;
+static void hpet_dbg_tick_fn(void *data)
+{
+    static s_time_t last = 0;
+    s_time_t now = NOW();
+
+    printk("In HPET debug tick. Time is %"PRId64", delta is %"PRId64"\n",
+           now, now - last);
+    set_timer(&hpet_dbg_tick, now + SECONDS(5));
+    last = now;
+}
+
 u64 __init hpet_setup(void)
 {
     static u64 __initdata hpet_rate;
@@ -821,6 +852,14 @@ u64 __init hpet_setup(void)
     hpet_rate = 1000000000000000ULL; /* 10^15 */
     (void)do_div(hpet_rate, hpet_period);
 
+    register_keyhandler('1', &hpet_dump_state);
+
+    if ( hpet_debug_tick )
+    {
+        init_timer(&hpet_dbg_tick, hpet_dbg_tick_fn, NULL, 0);
+        set_timer(&hpet_dbg_tick, NOW() + SECONDS(5));
+    }
+
     return hpet_rate;
 }
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.