ia64/xen-unstable

changeset 16057:74a3ee6e1795

hvm: Do not include full hvm_hw_hpet in 'struct domain'. It is very
large due to the number of (unused) reserved registers. This
unnecessarily blots the size of the domain structure.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Wed Oct 03 15:47:47 2007 +0100 (2007-10-03)
parents a5b239d68cc2
children ca1085e8ab82
files xen/arch/x86/hvm/hpet.c xen/include/asm-x86/hvm/vpt.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hpet.c	Wed Oct 03 14:56:31 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/hpet.c	Wed Oct 03 15:47:47 2007 +0100
     1.3 @@ -93,8 +93,33 @@
     1.4  
     1.5  static inline uint64_t hpet_read64(HPETState *h, unsigned long addr)
     1.6  {
     1.7 -    uint64_t *p = (uint64_t *)(((unsigned long)&h->hpet) + addr);
     1.8 -    return (addr >= HPET_T3_CFG) ? 0 : *p;
     1.9 +    addr &= ~7;
    1.10 +
    1.11 +    switch ( addr )
    1.12 +    {
    1.13 +    case HPET_ID:
    1.14 +        return h->hpet.capability;
    1.15 +    case HPET_CFG:
    1.16 +        return h->hpet.config;
    1.17 +    case HPET_STATUS:
    1.18 +        return h->hpet.isr;
    1.19 +    case HPET_COUNTER:
    1.20 +        return h->hpet.mc64;
    1.21 +    case HPET_T0_CFG:
    1.22 +    case HPET_T1_CFG:
    1.23 +    case HPET_T2_CFG:
    1.24 +        return h->hpet.timers[(addr - HPET_T0_CFG) >> 5].config;
    1.25 +    case HPET_T0_CMP:
    1.26 +    case HPET_T1_CMP:
    1.27 +    case HPET_T2_CMP:
    1.28 +        return h->hpet.timers[(addr - HPET_T0_CMP) >> 5].cmp;
    1.29 +    case HPET_T0_ROUTE:
    1.30 +    case HPET_T1_ROUTE:
    1.31 +    case HPET_T2_ROUTE:
    1.32 +        return h->hpet.timers[(addr - HPET_T0_ROUTE) >> 5].fsb;
    1.33 +    }
    1.34 +
    1.35 +    return 0;
    1.36  }
    1.37  
    1.38  static inline int hpet_check_access_length(
    1.39 @@ -135,7 +160,7 @@ static unsigned long hpet_read(
    1.40  
    1.41      spin_lock(&h->lock);
    1.42  
    1.43 -    val = hpet_read64(h, addr & ~7);
    1.44 +    val = hpet_read64(h, addr);
    1.45      if ( (addr & ~7) == HPET_COUNTER )
    1.46          val = hpet_read_maincounter(h);
    1.47  
    1.48 @@ -223,7 +248,7 @@ static void hpet_write(
    1.49  
    1.50      spin_lock(&h->lock);
    1.51  
    1.52 -    old_val = hpet_read64(h, addr & ~7);
    1.53 +    old_val = hpet_read64(h, addr);
    1.54      if ( (addr & ~7) == HPET_COUNTER )
    1.55          old_val = hpet_read_maincounter(h);
    1.56  
    1.57 @@ -420,7 +445,31 @@ static int hpet_save(struct domain *d, h
    1.58      hp->hpet.mc64 = hp->mc_offset + guest_time_hpet(hp->vcpu);
    1.59  
    1.60      /* Save the HPET registers */
    1.61 -    rc = hvm_save_entry(HPET, 0, h, &hp->hpet);
    1.62 +    rc = _hvm_init_entry(h, HVM_SAVE_CODE(HPET), 0, HVM_SAVE_LENGTH(HPET));
    1.63 +    if ( rc == 0 )
    1.64 +    {
    1.65 +        struct hvm_hw_hpet *rec = (struct hvm_hw_hpet *)&h->data[h->cur];
    1.66 +        h->cur += HVM_SAVE_LENGTH(HPET);
    1.67 +        memset(rec, 0, HVM_SAVE_LENGTH(HPET));
    1.68 +#define C(x) rec->x = hp->hpet.x
    1.69 +        C(capability);
    1.70 +        C(config);
    1.71 +        C(isr);
    1.72 +        C(mc64);
    1.73 +        C(timers[0].config);
    1.74 +        C(timers[0].cmp);
    1.75 +        C(timers[0].fsb);
    1.76 +        C(timers[1].config);
    1.77 +        C(timers[1].cmp);
    1.78 +        C(timers[1].fsb);
    1.79 +        C(timers[2].config);
    1.80 +        C(timers[2].cmp);
    1.81 +        C(timers[2].fsb);
    1.82 +        C(period[0]);
    1.83 +        C(period[1]);
    1.84 +        C(period[2]);
    1.85 +#undef C
    1.86 +    }
    1.87  
    1.88      spin_unlock(&hp->lock);
    1.89  
    1.90 @@ -430,16 +479,39 @@ static int hpet_save(struct domain *d, h
    1.91  static int hpet_load(struct domain *d, hvm_domain_context_t *h)
    1.92  {
    1.93      HPETState *hp = &d->arch.hvm_domain.pl_time.vhpet;
    1.94 +    struct hvm_hw_hpet *rec;
    1.95      int i;
    1.96  
    1.97      spin_lock(&hp->lock);
    1.98  
    1.99      /* Reload the HPET registers */
   1.100 -    if ( hvm_load_entry(HPET, h, &hp->hpet) )
   1.101 +    if ( _hvm_check_entry(h, HVM_SAVE_CODE(HPET), HVM_SAVE_LENGTH(HPET)) )
   1.102      {
   1.103          spin_unlock(&hp->lock);
   1.104          return -EINVAL;
   1.105      }
   1.106 +
   1.107 +    rec = (struct hvm_hw_hpet *)&h->data[h->cur];
   1.108 +    h->cur += HVM_SAVE_LENGTH(HPET);
   1.109 +
   1.110 +#define C(x) hp->hpet.x = rec->x
   1.111 +        C(capability);
   1.112 +        C(config);
   1.113 +        C(isr);
   1.114 +        C(mc64);
   1.115 +        C(timers[0].config);
   1.116 +        C(timers[0].cmp);
   1.117 +        C(timers[0].fsb);
   1.118 +        C(timers[1].config);
   1.119 +        C(timers[1].cmp);
   1.120 +        C(timers[1].fsb);
   1.121 +        C(timers[2].config);
   1.122 +        C(timers[2].cmp);
   1.123 +        C(timers[2].fsb);
   1.124 +        C(period[0]);
   1.125 +        C(period[1]);
   1.126 +        C(period[2]);
   1.127 +#undef C
   1.128      
   1.129      /* Recalculate the offset between the main counter and guest time */
   1.130      hp->mc_offset = hp->hpet.mc64 - guest_time_hpet(hp->vcpu);
     2.1 --- a/xen/include/asm-x86/hvm/vpt.h	Wed Oct 03 14:56:31 2007 +0100
     2.2 +++ b/xen/include/asm-x86/hvm/vpt.h	Wed Oct 03 15:47:47 2007 +0100
     2.3 @@ -34,12 +34,28 @@
     2.4  
     2.5  struct HPETState;
     2.6  struct HPET_timer_fn_info {
     2.7 -    struct HPETState       *hs;
     2.8 -    unsigned int    tn;
     2.9 +    struct HPETState *hs;
    2.10 +    unsigned int tn;
    2.11 +};
    2.12 +
    2.13 +struct hpet_registers {
    2.14 +    /* Memory-mapped, software visible registers */
    2.15 +    uint64_t capability;        /* capabilities */
    2.16 +    uint64_t config;            /* configuration */
    2.17 +    uint64_t isr;               /* interrupt status reg */
    2.18 +    uint64_t mc64;              /* main counter */
    2.19 +    struct {                    /* timers */
    2.20 +        uint64_t config;        /* configuration/cap */
    2.21 +        uint64_t cmp;           /* comparator */
    2.22 +        uint64_t fsb;           /* FSB route, not supported now */
    2.23 +    } timers[HPET_TIMER_NUM];
    2.24 +
    2.25 +    /* Hidden register state */
    2.26 +    uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
    2.27  };
    2.28  
    2.29  typedef struct HPETState {
    2.30 -    struct hvm_hw_hpet hpet;
    2.31 +    struct hpet_registers hpet;
    2.32      struct vcpu *vcpu;
    2.33      uint64_t tsc_freq;
    2.34      uint64_t mc_offset;