All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]mini-os: Using new hypercall interfaces
@ 2006-11-22 14:48 Dietmar Hahn
  2006-11-22 22:12 ` Grzegorz Milos
  0 siblings, 1 reply; 4+ messages in thread
From: Dietmar Hahn @ 2006-11-22 14:48 UTC (permalink / raw)
  To: Grzegorz Milos; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Hi,

this patch switches to the newer interfaces for
HYPERVISOR_sched_op() and HYPERVISOR_event_channel_op().
I testet it only on x86_32 because I have no x86_64 machine!
Please have a look!
Thanks.

Dietmar.

[-- Attachment #2: mini-os_hypercall.patch --]
[-- Type: text/x-diff, Size: 4404 bytes --]

# HG changeset patch
# User dietmar.hahn@fujitsu-siemens.com
# Date 1164206513 -3600
# Node ID 74abfaeeb7ba15d7ca366c814c412d1ccc594532
# Parent  1ef9954a26686b35b946d889726d4d35c283c2a0
Switched to new interfaces HYPERVISOR_sched_op() and
HYPERVISOR_event_channel_op().

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>


diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/events.c
--- a/extras/mini-os/events.c	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/events.c	Wed Nov 22 15:41:53 2006 +0100
@@ -88,18 +88,18 @@ void unbind_evtchn(evtchn_port_t port )
 
 int bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
 {
-	evtchn_bind_virq_t op;
-
-	/* Try to bind the virq to a port */
-	op.virq = virq;
-	op.vcpu = smp_processor_id();
-
-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op) != 0 )
+	struct evtchn_bind_virq send =
+	{
+		.virq = virq,
+		.vcpu = smp_processor_id()
+	};
+	if(HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &send) != 0)
 	{
 		printk("Failed to bind virtual IRQ %d\n", virq);
 		return 1;
-    }
-    bind_evtchn(op.port, handler, data);
+	}
+	bind_evtchn(send.port, handler, NULL);
+
 	return 0;
 }
 
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_32/hypercall-x86_32.h
--- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 15:41:53 2006 +0100
@@ -165,9 +165,16 @@ HYPERVISOR_fpu_taskswitch(
 	return _hypercall1(int, fpu_taskswitch, set);
 }
 
+ static inline int
+HYPERVISOR_sched_op_compat(
+	int cmd, unsigned long arg)
+{
+	return _hypercall2(int, sched_op_compat, cmd, arg);
+}
+
 static inline int
 HYPERVISOR_sched_op(
-	int cmd, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
@@ -238,9 +245,21 @@ HYPERVISOR_update_va_mapping(
 
 static inline int
 HYPERVISOR_event_channel_op(
-	int cmd, void *op)
-{
-	return _hypercall2(int, event_channel_op, cmd, op);
+	int cmd, void *arg)
+{
+	int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
+	if (unlikely(rc == -ENOSYS)) {
+		struct evtchn_op op;
+		op.cmd = cmd;
+		memcpy(&op.u, arg, sizeof(op.u));
+		rc = _hypercall1(int, event_channel_op_compat, &op);
+		memcpy(arg, &op.u, sizeof(op.u));
+	}
+#endif
+
+	return rc;
 }
 
 static inline int
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_64/hypercall-x86_64.h
--- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 15:41:53 2006 +0100
@@ -170,8 +170,15 @@ HYPERVISOR_fpu_taskswitch(
 }
 
 static inline int
+HYPERVISOR_sched_op_compat(
+	int cmd, unsigned long arg)
+{
+	return _hypercall2(int, sched_op_compat, cmd, arg);
+}
+
+static inline int
 HYPERVISOR_sched_op(
-	int cmd, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
@@ -235,9 +242,21 @@ HYPERVISOR_update_va_mapping(
 
 static inline int
 HYPERVISOR_event_channel_op(
-       int cmd, void *op)
-{
-    return _hypercall2(int, event_channel_op, cmd, op);
+	int cmd, void *arg)
+{
+	int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
+	if (unlikely(rc == -ENOSYS)) {
+		struct evtchn_op op;
+		op.cmd = cmd;
+		memcpy(&op.u, arg, sizeof(op.u));
+		rc = _hypercall1(int, event_channel_op_compat, &op);
+		memcpy(arg, &op.u, sizeof(op.u));
+	}
+#endif
+
+	return rc;
 }
 
 static inline int
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/kernel.c	Wed Nov 22 15:41:53 2006 +0100
@@ -28,6 +28,7 @@
  */
 
 #include <os.h>
+#include <errno.h>
 #include <hypervisor.h>
 #include <mm.h>
 #include <events.h>
@@ -159,5 +160,14 @@ void do_exit(void)
 void do_exit(void)
 {
     printk("Do_exit called!\n");
-    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+    for( ;; )
+    {
+        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
+        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+        int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+        if(rc == -ENOSYS)
+        {
+            HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, SHUTDOWN_crash);
+        }
+    }
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-24 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 14:48 [PATCH]mini-os: Using new hypercall interfaces Dietmar Hahn
2006-11-22 22:12 ` Grzegorz Milos
2006-11-23  8:09   ` Dietmar Hahn
2006-11-24 17:22     ` Grzegorz Milos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.