ia64/xen-unstable

changeset 16044:50edcaff5520

Add XENPF_getidletime.
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Tue Oct 02 10:46:23 2007 +0100 (2007-10-02)
parents 8c67b2038ff2
children d9039e8103e4
files xen/arch/x86/platform_hypercall.c xen/include/public/platform.h
line diff
     1.1 --- a/xen/arch/x86/platform_hypercall.c	Tue Oct 02 10:45:53 2007 +0100
     1.2 +++ b/xen/arch/x86/platform_hypercall.c	Tue Oct 02 10:46:23 2007 +0100
     1.3 @@ -36,6 +36,8 @@ DEFINE_SPINLOCK(xenpf_lock);
     1.4  # define copy_from_compat copy_from_guest
     1.5  # undef copy_to_compat
     1.6  # define copy_to_compat copy_to_guest
     1.7 +# undef guest_from_compat_handle
     1.8 +# define guest_from_compat_handle(x,y) ((x)=(y))
     1.9  #else
    1.10  extern spinlock_t xenpf_lock;
    1.11  #endif
    1.12 @@ -142,21 +144,14 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
    1.13      case XENPF_microcode_update:
    1.14      {
    1.15          extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len);
    1.16 -#ifdef COMPAT
    1.17          XEN_GUEST_HANDLE(void) data;
    1.18 -#endif
    1.19  
    1.20          ret = xsm_microcode();
    1.21          if ( ret )
    1.22              break;
    1.23  
    1.24 -#ifndef COMPAT
    1.25 -        ret = microcode_update(op->u.microcode.data,
    1.26 -                               op->u.microcode.length);
    1.27 -#else
    1.28          guest_from_compat_handle(data, op->u.microcode.data);
    1.29          ret = microcode_update(data, op->u.microcode.length);
    1.30 -#endif
    1.31      }
    1.32      break;
    1.33  
    1.34 @@ -286,6 +281,9 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
    1.35          break;
    1.36  
    1.37      case XENPF_change_freq:
    1.38 +        ret = -ENOSYS;
    1.39 +        if ( cpufreq_controller != FREQCTL_dom0_kernel )
    1.40 +            break;
    1.41          ret = -EINVAL;
    1.42          if ( op->u.change_freq.flags != 0 )
    1.43              break;
    1.44 @@ -294,11 +292,46 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
    1.45                                          &op->u.change_freq.freq);
    1.46          break;
    1.47  
    1.48 +    case XENPF_getidletime:
    1.49 +    {
    1.50 +        uint32_t i, nr_cpus;
    1.51 +        uint64_t idletime;
    1.52 +        struct vcpu *v;
    1.53 +        XEN_GUEST_HANDLE(uint64_t) idletimes;
    1.54 +
    1.55 +        ret = -ENOSYS;
    1.56 +        if ( cpufreq_controller != FREQCTL_dom0_kernel )
    1.57 +            break;
    1.58 +
    1.59 +        guest_from_compat_handle(idletimes, op->u.getidletime.idletime);
    1.60 +        nr_cpus = min_t(uint32_t, op->u.getidletime.max_cpus, NR_CPUS);
    1.61 +
    1.62 +        for ( i = 0; i < nr_cpus; i++ )
    1.63 +        {
    1.64 +            /* Assume no holes in idle-vcpu map. */
    1.65 +            if ( (v = idle_vcpu[i]) == NULL )
    1.66 +                break;
    1.67 +
    1.68 +            idletime = v->runstate.time[RUNSTATE_running];
    1.69 +            if ( v->is_running )
    1.70 +                idletime += NOW() - v->runstate.state_entry_time;
    1.71 +
    1.72 +            ret = -EFAULT;
    1.73 +            if ( copy_to_guest_offset(idletimes, i, &idletime, 1) )
    1.74 +                goto out;
    1.75 +        }
    1.76 +
    1.77 +        op->u.getidletime.nr_cpus = i;
    1.78 +        ret = copy_to_guest(u_xenpf_op, op, 1) ? -EFAULT : 0;
    1.79 +    }
    1.80 +    break;
    1.81 +
    1.82      default:
    1.83          ret = -ENOSYS;
    1.84          break;
    1.85      }
    1.86  
    1.87 + out:
    1.88      spin_unlock(&xenpf_lock);
    1.89  
    1.90      return ret;
     2.1 --- a/xen/include/public/platform.h	Tue Oct 02 10:45:53 2007 +0100
     2.2 +++ b/xen/include/public/platform.h	Tue Oct 02 10:46:23 2007 +0100
     2.3 @@ -164,7 +164,7 @@ struct xenpf_enter_acpi_sleep {
     2.4  typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
     2.5  DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t);
     2.6  
     2.7 -#define XENPF_change_freq       52
     2.8 +#define XENPF_change_freq         52
     2.9  struct xenpf_change_freq {
    2.10      /* IN variables */
    2.11      uint32_t flags; /* Must be zero. */
    2.12 @@ -174,6 +174,17 @@ struct xenpf_change_freq {
    2.13  typedef struct xenpf_change_freq xenpf_change_freq_t;
    2.14  DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t);
    2.15  
    2.16 +#define XENPF_getidletime         53
    2.17 +struct xenpf_getidletime {
    2.18 +    /* IN variables. */
    2.19 +    uint32_t max_cpus;
    2.20 +    XEN_GUEST_HANDLE(uint64_t) idletime;
    2.21 +    /* OUT variables. */
    2.22 +    uint32_t nr_cpus;
    2.23 +};
    2.24 +typedef struct xenpf_getidletime xenpf_getidletime_t;
    2.25 +DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
    2.26 +
    2.27  struct xen_platform_op {
    2.28      uint32_t cmd;
    2.29      uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
    2.30 @@ -187,6 +198,7 @@ struct xen_platform_op {
    2.31          struct xenpf_firmware_info     firmware_info;
    2.32          struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
    2.33          struct xenpf_change_freq       change_freq;
    2.34 +        struct xenpf_getidletime       getidletime;
    2.35          uint8_t                        pad[128];
    2.36      } u;
    2.37  };