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

[Xen-API] [PATCH] # HG changeset patch


  • To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
  • From: Vincent Hanquez <vincent@xxxxxxxxxxxxx>
  • Date: Wed, 24 Feb 2010 14:37:03 +0000
  • Delivery-date: Wed, 24 Feb 2010 12:36:18 -0800
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

# HG changeset patch
# User Vincent Hanquez <vincent@xxxxxxxxxxxxx>
# HG changeset patch
# User Vincent Hanquez <vincent@xxxxxxxxxxxxx>
# Date 1266397503 0
# Node ID 5774dadc15e5e4f66d1a90d3ddc99f76f242298d
# Parent  e7c6445e5660bf483e6ac29f3cf1c87d09b345ba
# HG changeset patch
# User Vincent Hanquez <vincent@xxxxxxxxxxxxx>
CP-1634: Bindings for xc_get_boot_cpufeatures

Signed-off-by: Vincent Hanquez <vincent@xxxxxxxxxxxxx>
Acked-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r e7ac3fa2ec6b xc/Makefile
--- a/xc/Makefile       Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/Makefile       Wed Feb 24 14:22:19 2010 +0000
@@ -67,5 +67,5 @@
        python ../doc/doc.py $(DOCDIR) "xc" "package" "$(OBJS)" "." "mmap,uuid" 
""
        
 clean:
-       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) 
$(PROGRAMS) $(INTF)
+       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) 
$(PROGRAMS) $(INTF) *~ *.rej *.orig
 
diff -r e7ac3fa2ec6b xc/xc.h
--- a/xc/xc.h   Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/xc.h   Wed Feb 24 14:22:19 2010 +0000
@@ -20,6 +20,7 @@
 #include <xen/domctl.h>
 #include <xen/sched.h>
 #include <xen/sysctl.h>
+#include <xen/platform.h>
 #if XEN_SYSCTL_INTERFACE_VERSION < 4
 #include <xen/linux/privcmd.h>
 #else
@@ -187,6 +188,9 @@
 int xc_domain_trigger_power(int handle, unsigned int domid);
 int xc_domain_trigger_sleep(int handle, unsigned int domid);
 
+int xc_get_boot_cpufeatures(int handle, uint32_t *, uint32_t *, uint32_t *,
+       uint32_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
+
 #if XEN_SYSCTL_INTERFACE_VERSION >= 6
 #define SAFEDIV(a, b)                                  (((b) >= 0) ? (a) / (b) 
: (a))
 #define COMPAT_FIELD_physinfo_get_nr_cpus(p)           (p).nr_cpus
diff -r e7ac3fa2ec6b xc/xc.ml
--- a/xc/xc.ml  Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/xc.ml  Wed Feb 24 14:22:19 2010 +0000
@@ -270,6 +270,9 @@
 external watchdog : handle -> int -> int32 -> int
   = "stub_xc_watchdog"
 
+external get_boot_cpufeatures: handle ->
+       (int32 * int32 * int32 * int32 * int32 * int32 * int32 * int32) = 
"stub_xc_get_boot_cpufeatures"
+
 (* core dump structure *)
 type core_magic = Magic_hvm | Magic_pv
 
diff -r e7ac3fa2ec6b xc/xc.mli
--- a/xc/xc.mli Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/xc.mli Wed Feb 24 14:22:19 2010 +0000
@@ -213,3 +213,6 @@
 external cpuid_check: (int64 * (int64 option)) -> string option array -> (bool 
* string option array)
        = "stub_xc_cpuid_check"
 
+external get_boot_cpufeatures: handle ->
+       (int32 * int32 * int32 * int32 * int32 * int32 * int32 * int32) = 
"stub_xc_get_boot_cpufeatures"
+
diff -r e7ac3fa2ec6b xc/xc_lib.c
--- a/xc/xc_lib.c       Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/xc_lib.c       Wed Feb 24 14:22:19 2010 +0000
@@ -44,6 +44,12 @@
        struct xen_sysctl sysctl = {    \
                .cmd = _cmd,            \
                .interface_version = XEN_SYSCTL_INTERFACE_VERSION, \
+       }
+
+#define DECLARE_PLATFORM(_cmd)         \
+       struct xen_platform_op platform = { \
+               .cmd = _cmd,            \
+               .interface_version = XENPF_INTERFACE_VERSION, \
        }
 
 #define DECLARE_HYPERCALL2(_cmd, _arg0, _arg1) \
@@ -203,6 +209,24 @@
                xc_error_hypercall(hypercall, ret);
 
        munlock(sysctl, sizeof(*sysctl));
+       return ret;
+}
+
+static int do_platform(int handle, struct xen_platform_op *platform)
+{
+       int ret;
+       DECLARE_HYPERCALL1(__HYPERVISOR_platform_op, platform);
+
+       if (mlock(platform, sizeof(*platform)) != 0) {
+               xc_error_set("mlock failed: %s", strerror(errno));
+               return -1;
+       }
+
+       ret = do_xen_hypercall(handle, &hypercall);
+       if (ret < 0)
+               xc_error_hypercall(hypercall, ret);
+
+       munlock(platform, sizeof(*platform));
        return ret;
 }
 
@@ -1575,6 +1599,35 @@
     return ret;
 }
 
+int xc_get_boot_cpufeatures(int handle,
+                            uint32_t *base_ecx, uint32_t *base_edx,
+                            uint32_t *ext_ecx, uint32_t *ext_edx,
+                            uint32_t *masked_base_ecx, 
+                            uint32_t *masked_base_edx,
+                            uint32_t *masked_ext_ecx, 
+                            uint32_t *masked_ext_edx)
+{
+       int ret = -EINVAL;
+#ifdef XENPF_get_cpu_features 
+       DECLARE_PLATFORM(XENPF_get_cpu_features);
+
+       ret = do_platform(handle, &platform);
+       if (ret != 0)
+               xc_error_set("getting boot cpu features failed: %s", 
xc_error_get());
+       else {
+               *base_ecx = platform.u.cpu_features.base_ecx;
+               *base_edx = platform.u.cpu_features.base_edx;
+               *ext_ecx = platform.u.cpu_features.ext_ecx;
+               *ext_edx = platform.u.cpu_features.ext_edx;
+               *masked_base_ecx = platform.u.cpu_features.masked_base_ecx;
+               *masked_base_edx = platform.u.cpu_features.masked_base_edx;
+               *masked_ext_ecx = platform.u.cpu_features.masked_ext_ecx;
+               *masked_ext_edx = platform.u.cpu_features.masked_ext_edx;
+       }
+#endif
+       return ret;
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: t
diff -r e7ac3fa2ec6b xc/xc_stubs.c
--- a/xc/xc_stubs.c     Wed Feb 24 10:20:01 2010 +0000
+++ b/xc/xc_stubs.c     Wed Feb 24 14:22:19 2010 +0000
@@ -1223,6 +1223,30 @@
        CAMLreturn(Val_unit);
 }
 
+CAMLprim value stub_xc_get_boot_cpufeatures(value handle)
+{
+       CAMLparam1(handle);
+       CAMLlocal1(v);
+       uint32_t a, b, c, d, e, f, g, h;
+       int ret;
+
+       ret = xc_get_boot_cpufeatures(_H(handle), &a, &b, &c, &d, &e, &f, &g, 
&h);
+       if (ret < 0)
+               failwith_xc();
+       
+       v = caml_alloc_tuple(8);
+       Store_field(v, 0, caml_copy_int32(a));
+       Store_field(v, 1, caml_copy_int32(b));
+       Store_field(v, 2, caml_copy_int32(c));
+       Store_field(v, 3, caml_copy_int32(d));
+       Store_field(v, 4, caml_copy_int32(e));
+       Store_field(v, 5, caml_copy_int32(f));
+       Store_field(v, 6, caml_copy_int32(g));
+       Store_field(v, 7, caml_copy_int32(h));
+
+       CAMLreturn(v);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: t

Attachment: xc_boot_cpufeatures
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

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