WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [HVM] Save/restore: save HPET registers

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [HVM] Save/restore: save HPET registers
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Jan 2007 13:20:15 -0800
Delivery-date: Wed, 31 Jan 2007 13:20:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Date 1170267300 0
# Node ID 6db6b5df4f6f1ebe94738c3624d19e6b4053bcf3
# Parent  5d09e6098f93da0f4cd96c21b6ab0230a38e5048
[HVM] Save/restore: save HPET registers
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/hpet.c       |   44 +++++++++++++++++++++++++++++++++++-------
 xen/include/asm-x86/hvm/vpt.h |   25 +++--------------------
 xen/include/public/hvm/save.h |   32 +++++++++++++++++++++++++++++-
 3 files changed, 72 insertions(+), 29 deletions(-)

diff -r 5d09e6098f93 -r 6db6b5df4f6f xen/arch/x86/hvm/hpet.c
--- a/xen/arch/x86/hvm/hpet.c   Wed Jan 31 17:22:17 2007 +0000
+++ b/xen/arch/x86/hvm/hpet.c   Wed Jan 31 18:15:00 2007 +0000
@@ -279,7 +279,7 @@ static void hpet_write(
              (h->hpet.timers[tn].config & HPET_TN_SETVAL) )
             h->hpet.timers[tn].cmp = new_val;
         else
-            h->period[tn] = new_val;
+            h->hpet.period[tn] = new_val;
         h->hpet.timers[tn].config &= ~HPET_TN_SETVAL;
         if ( hpet_enabled(h) && timer_enabled(h, tn) )
             hpet_set_timer(h, tn);
@@ -289,7 +289,7 @@ static void hpet_write(
     case HPET_T1_ROUTE:
     case HPET_T2_ROUTE:
         tn = (addr - HPET_T0_ROUTE) >> 5;
-        h->hpet.timers[tn].hpet_fsb[0] = new_val;
+        h->hpet.timers[tn].fsb = new_val;
         break;
 
     default:
@@ -351,21 +351,22 @@ static void hpet_timer_fn(void *opaque)
 
     hpet_route_interrupt(h, tn);
 
-    if ( timer_is_periodic(h, tn) && (h->period[tn] != 0) )
+    if ( timer_is_periodic(h, tn) && (h->hpet.period[tn] != 0) )
     {
         uint64_t mc = hpet_read_maincounter(h);
         if ( timer_is_32bit(h, tn) )
         {
             while ( hpet_time_after(mc, h->hpet.timers[tn].cmp) )
                 h->hpet.timers[tn].cmp = (uint32_t)(
-                    h->hpet.timers[tn].cmp + h->period[tn]);
+                    h->hpet.timers[tn].cmp + h->hpet.period[tn]);
         }
         else
         {
             while ( hpet_time_after64(mc, h->hpet.timers[tn].cmp) )
-                h->hpet.timers[tn].cmp += h->period[tn];
-        }
-        set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, h->period[tn]));
+                h->hpet.timers[tn].cmp += h->hpet.period[tn];
+        }
+        set_timer(&h->timers[tn], 
+                  NOW() + hpet_tick_to_ns(h, h->hpet.period[tn]));
     }
 }
 
@@ -377,6 +378,35 @@ void hpet_migrate_timers(struct vcpu *v)
     for ( i = 0; i < HPET_TIMER_NUM; i++ )
         migrate_timer(&h->timers[i], v->processor);
 }
+
+static int hpet_save(struct domain *d, hvm_domain_context_t *h)
+{
+    HPETState *hp = &d->arch.hvm_domain.pl_time.vhpet;
+
+    /* Save the HPET registers */
+    return hvm_save_entry(HPET, 0, h, &hp->hpet);
+}
+
+static int hpet_load(struct domain *d, hvm_domain_context_t *h)
+{
+    HPETState *hp = &d->arch.hvm_domain.pl_time.vhpet;
+    int i;
+
+    /* Reload the HPET registers */
+    if ( hvm_load_entry(HPET, h, &hp->hpet) )
+        return -EINVAL;
+    
+    /* Recalculate the offset between the main counter and guest time */
+    hp->mc_offset = hp->hpet.mc64 - hvm_get_guest_time(hp->vcpu);
+                
+    /* Restart the timers */
+    for ( i = 0; i < HPET_TIMER_NUM; i++ )
+        hpet_set_timer(hp, i);
+
+    return 0;
+}
+
+HVM_REGISTER_SAVE_RESTORE(HPET, hpet_save, hpet_load);
 
 void hpet_init(struct vcpu *v)
 {
diff -r 5d09e6098f93 -r 6db6b5df4f6f xen/include/asm-x86/hvm/vpt.h
--- a/xen/include/asm-x86/hvm/vpt.h     Wed Jan 31 17:22:17 2007 +0000
+++ b/xen/include/asm-x86/hvm/vpt.h     Wed Jan 31 18:15:00 2007 +0000
@@ -31,22 +31,6 @@
 #include <asm/hvm/vpic.h>
 #include <public/hvm/save.h>
 
-#define HPET_TIMER_NUM     3    /* 3 timers supported now */
-struct HPET {
-    uint64_t capability;        /* capabilities */
-    uint64_t res0;              /* reserved */
-    uint64_t config;            /* configuration */
-    uint64_t res1;              /* reserved */
-    uint64_t isr;               /* interrupt status reg */
-    uint64_t res2[25];          /* reserved */
-    uint64_t mc64;              /* main counter */
-    uint64_t res3;              /* reserved */
-    struct {                    /* timers */
-        uint64_t config;        /* configuration/cap */
-        uint64_t cmp;           /* comparator */
-        uint64_t hpet_fsb[2];   /* FSB route, not supported now */
-    } timers[HPET_TIMER_NUM];
-};
 
 struct HPETState;
 struct HPET_timer_fn_info {
@@ -55,11 +39,10 @@ struct HPET_timer_fn_info {
 };
 
 typedef struct HPETState {
-    struct HPET     hpet;
-    struct vcpu     *vcpu;
-    uint64_t        tsc_freq;
-    uint64_t        mc_offset;
-    uint64_t        period[HPET_TIMER_NUM];
+    struct hvm_hw_hpet hpet;
+    struct vcpu *vcpu;
+    uint64_t tsc_freq;
+    uint64_t mc_offset;
     struct timer timers[HPET_TIMER_NUM];
     struct HPET_timer_fn_info timer_fn_info[HPET_TIMER_NUM]; 
 } HPETState;
diff -r 5d09e6098f93 -r 6db6b5df4f6f xen/include/public/hvm/save.h
--- a/xen/include/public/hvm/save.h     Wed Jan 31 17:22:17 2007 +0000
+++ b/xen/include/public/hvm/save.h     Wed Jan 31 18:15:00 2007 +0000
@@ -381,10 +381,40 @@ DECLARE_HVM_SAVE_TYPE(RTC, 9, struct hvm
 DECLARE_HVM_SAVE_TYPE(RTC, 9, struct hvm_hw_rtc);
 
 
+/*
+ * HPET
+ */
+
+#define HPET_TIMER_NUM     3    /* 3 timers supported now */
+struct hvm_hw_hpet {
+    /* Memory-mapped, software visible registers */
+    uint64_t capability;        /* capabilities */
+    uint64_t res0;              /* reserved */
+    uint64_t config;            /* configuration */
+    uint64_t res1;              /* reserved */
+    uint64_t isr;               /* interrupt status reg */
+    uint64_t res2[25];          /* reserved */
+    uint64_t mc64;              /* main counter */
+    uint64_t res3;              /* reserved */
+    struct {                    /* timers */
+        uint64_t config;        /* configuration/cap */
+        uint64_t cmp;           /* comparator */
+        uint64_t fsb;           /* FSB route, not supported now */
+        uint64_t res4;          /* reserved */
+    } timers[HPET_TIMER_NUM];
+    uint64_t res5[4*(24-HPET_TIMER_NUM)];  /* reserved, up to 0x3ff */
+
+    /* Hidden register state */
+    uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
+};
+
+DECLARE_HVM_SAVE_TYPE(HPET, 10, struct hvm_hw_hpet);
+
+
 /* 
  * Largest type-code in use
  */
-#define HVM_SAVE_CODE_MAX 9
+#define HVM_SAVE_CODE_MAX 10
 
 
 /* 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [HVM] Save/restore: save HPET registers, Xen patchbot-unstable <=