]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
CP-1634: Bindings for xc_get_boot_cpufeatures
authorVincent Hanquez <vincent@xensource.com>
Wed, 17 Feb 2010 09:05:03 +0000 (09:05 +0000)
committerVincent Hanquez <vincent@xensource.com>
Wed, 17 Feb 2010 09:05:03 +0000 (09:05 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
Acked-by: Rob Hoes <rob.hoes@citrix.com>
xc/Makefile
xc/xc.h
xc/xc.ml
xc/xc.mli
xc/xc_lib.c
xc/xc_stubs.c

index e95d51a43405a2560d8b319452fa568238769033..b73f0d711d916acb94fe9c3265cb1813cf5636b7 100644 (file)
@@ -67,5 +67,5 @@ doc: $(INTF)
        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 --git a/xc/xc.h b/xc/xc.h
index a7c0f6c333814898bb6c3542d26c366f441f3000..6ffb52d4612a658bfbe329fe9ebf4b4fec756462 100644 (file)
--- a/xc/xc.h
+++ b/xc/xc.h
@@ -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_get_acpi_s_state(int handle, unsigned int domid);
 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
index 4dcb801d653bc4aba0975b90e93e640016486bc0..af4c0de981f7232fcf9eb1dc4a6cd32d72736ab6 100644 (file)
--- a/xc/xc.ml
+++ b/xc/xc.ml
@@ -270,6 +270,9 @@ external version_capabilities: handle -> string =
 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
 
index 84703a21d79fd949ce72e68e3eb3d4b0de203455..f7ca795907d48922e825a4b74818ff3fc5657d5c 100644 (file)
--- a/xc/xc.mli
+++ b/xc/xc.mli
@@ -213,3 +213,6 @@ external domain_cpuid_apply: handle -> domid -> bool -> unit
 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"
+
index 1a0dc84df179b22b0b9b950191daaef782505133..cbb3f34b68bf371b539bf9e641b00c954e5963a2 100644 (file)
                .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) \
        privcmd_hypercall_t hypercall = {       \
                .op = _cmd,                     \
@@ -206,6 +212,24 @@ static int do_sysctl(int handle, struct xen_sysctl *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;
+}
+
 static int do_evtchnctl(int handle, int cmd, void *arg, size_t arg_size)
 {
        DECLARE_HYPERCALL2(__HYPERVISOR_event_channel_op, cmd, arg);
@@ -1575,6 +1599,35 @@ int xc_domain_trigger_sleep(int handle, unsigned int domid)
     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
index a5fcf050cfd133e85469ef9f48cf6b8cb0c44bbb..3da39ce1b192d74752741f104aeac19cc62eeb6b 100644 (file)
@@ -1223,6 +1223,30 @@ CAMLprim value stub_xc_domain_trigger_sleep(value handle, value domid)
        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