ia64/xen-unstable

changeset 18766:3dfe1a7c729e

[IA64] minios: Clean up the hypervisor interface

move all hypervisor calls to xencomm

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
author dietmar.hahn@fujitsu-siemens.com
date Mon Nov 17 09:19:45 2008 +0100 (2008-11-17)
parents 008b68ff6095
children cf3b9afb8568
files extras/mini-os/arch/ia64/xencomm.c extras/mini-os/include/ia64/hypercall-ia64.h extras/mini-os/include/ia64/os.h
line diff
     1.1 --- a/extras/mini-os/arch/ia64/xencomm.c	Tue Nov 18 10:33:55 2008 +0900
     1.2 +++ b/extras/mini-os/arch/ia64/xencomm.c	Mon Nov 17 09:19:45 2008 +0100
     1.3 @@ -24,6 +24,8 @@
     1.4  
     1.5  
     1.6  #include <os.h>
     1.7 +#include <mini-os/errno.h>
     1.8 +#include <mini-os/lib.h>
     1.9  #include <hypervisor.h>
    1.10  #include <xen/xencomm.h>
    1.11  #include <xen/grant_table.h>
    1.12 @@ -38,6 +40,7 @@ struct xencomm_mini
    1.13  
    1.14  #define xen_guest_handle(hnd)  ((hnd).p)
    1.15  
    1.16 +struct xencomm_handle;
    1.17  
    1.18  /* Translate virtual address to physical address.  */
    1.19  uint64_t
    1.20 @@ -52,6 +55,16 @@ xencomm_vaddr_to_paddr(uint64_t vaddr)
    1.21  	return 0;
    1.22  }
    1.23  
    1.24 +/* Inline version.  To be used only on linear space (kernel space).  */
    1.25 +static struct xencomm_handle *
    1.26 +xencomm_create_inline(void *buffer)
    1.27 +{
    1.28 +	unsigned long paddr;
    1.29 +
    1.30 +	paddr = xencomm_vaddr_to_paddr((unsigned long)buffer);
    1.31 +	return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
    1.32 +}
    1.33 +
    1.34  #define min(a,b) (((a) < (b)) ? (a) : (b))
    1.35  static int
    1.36  xencomm_init_desc(struct xencomm_desc *desc, void *buffer, unsigned long bytes)
    1.37 @@ -201,6 +214,14 @@ xencommize_mini_grant_table_op(struct xe
    1.38  	return rc;
    1.39  }
    1.40  
    1.41 +static inline int
    1.42 +xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
    1.43 +                                      struct xencomm_handle *uop,
    1.44 +                                      unsigned int count)
    1.45 +{
    1.46 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
    1.47 +}
    1.48 +
    1.49  int
    1.50  xencomm_mini_hypercall_grant_table_op(unsigned int cmd, void *op,
    1.51                                        unsigned int count)
    1.52 @@ -268,3 +289,107 @@ HYPERVISOR_suspend(unsigned long srec)
    1.53          return xencomm_arch_hypercall_suspend(xencomm_create_inline(&arg));
    1.54  }
    1.55  
    1.56 +int
    1.57 +HYPERVISOR_event_channel_op(int cmd, void *arg)
    1.58 +{
    1.59 +	int rc;
    1.60 +	struct xencomm_handle *newArg;
    1.61 +
    1.62 +	newArg = xencomm_create_inline(arg);
    1.63 +	rc = _hypercall2(int, event_channel_op, cmd, newArg);
    1.64 +	if (unlikely(rc == -ENOSYS)) {
    1.65 +		struct evtchn_op op;
    1.66 +
    1.67 +		op.cmd = SWAP(cmd);
    1.68 +		memcpy(&op.u, arg, sizeof(op.u));
    1.69 +		rc = _hypercall1(int, event_channel_op_compat, &op);
    1.70 +	}
    1.71 +	return rc;
    1.72 +}
    1.73 +
    1.74 +static int
    1.75 +xencomm_arch_xen_version(int cmd, struct xencomm_handle *arg)
    1.76 +{
    1.77 +	return _hypercall2(int, xen_version, cmd, arg);
    1.78 +}
    1.79 +
    1.80 +static int
    1.81 +xencomm_arch_xen_feature(int cmd, struct xencomm_handle *arg)
    1.82 +{
    1.83 +	struct xencomm_handle *newArg;
    1.84 +
    1.85 +	newArg = xencomm_create_inline(arg);
    1.86 +	return _hypercall2(int, xen_version, cmd, newArg);
    1.87 +}
    1.88 +
    1.89 +int
    1.90 +HYPERVISOR_xen_version(int cmd, void *arg)
    1.91 +{
    1.92 +	switch(cmd) {
    1.93 +		case XENVER_version:
    1.94 +			return xencomm_arch_xen_version(cmd, 0);
    1.95 +		case XENVER_get_features:
    1.96 +			return xencomm_arch_xen_feature(cmd, arg);
    1.97 +		default:
    1.98 +			return -1;
    1.99 +	}
   1.100 +}
   1.101 +
   1.102 +int
   1.103 +HYPERVISOR_console_io(int cmd, int count, char *str)
   1.104 +{
   1.105 +	struct xencomm_handle *newStr;
   1.106 +
   1.107 +	newStr = xencomm_create_inline(str);
   1.108 +	return _hypercall3(int, console_io, cmd, count, newStr);
   1.109 +}
   1.110 +
   1.111 +int
   1.112 +HYPERVISOR_sched_op_compat(int cmd, unsigned long arg)
   1.113 +{
   1.114 +	return _hypercall2(int, sched_op_compat, cmd, arg);
   1.115 +}
   1.116 +
   1.117 +int
   1.118 +HYPERVISOR_sched_op(int cmd, void *arg)
   1.119 +{
   1.120 +	struct xencomm_handle *newArg;
   1.121 +
   1.122 +	newArg = xencomm_create_inline(arg);
   1.123 +	return _hypercall2(int, sched_op, cmd, newArg);
   1.124 +}
   1.125 +
   1.126 +int
   1.127 +HYPERVISOR_callback_op(int cmd, void *arg)
   1.128 +{
   1.129 +	struct xencomm_handle *newArg;
   1.130 +
   1.131 +	newArg = xencomm_create_inline(arg);
   1.132 +	return _hypercall2(int, callback_op, cmd, newArg);
   1.133 +}
   1.134 +
   1.135 +int
   1.136 +HYPERVISOR_opt_feature(void *arg)
   1.137 +{
   1.138 +	struct xencomm_handle *new_arg;
   1.139 +
   1.140 +	new_arg = xencomm_create_inline(arg);
   1.141 +
   1.142 +	return _hypercall1(int, opt_feature, new_arg);
   1.143 +}
   1.144 +
   1.145 +int
   1.146 +HYPERVISOR_shutdown(unsigned int reason)
   1.147 +{
   1.148 +	struct sched_shutdown sched_shutdown = {
   1.149 +		.reason = reason
   1.150 +	};
   1.151 +
   1.152 +	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
   1.153 +
   1.154 +	if (rc == -ENOSYS)
   1.155 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
   1.156 +
   1.157 +	return rc;
   1.158 +}
   1.159 +
     2.1 --- a/extras/mini-os/include/ia64/hypercall-ia64.h	Tue Nov 18 10:33:55 2008 +0900
     2.2 +++ b/extras/mini-os/include/ia64/hypercall-ia64.h	Mon Nov 17 09:19:45 2008 +0100
     2.3 @@ -34,8 +34,6 @@
     2.4  #ifndef __HYPERCALL_H__
     2.5  #define __HYPERCALL_H__
     2.6  
     2.7 -#include <mini-os/lib.h>	/* memcpy() */
     2.8 -#include <mini-os/errno.h>	/* ENOSYS() */
     2.9  #include <xen/event_channel.h>
    2.10  #include <xen/sched.h>
    2.11  #include <xen/version.h>
    2.12 @@ -114,123 +112,24 @@ extern unsigned long __hypercall(unsigne
    2.13  })
    2.14  
    2.15  
    2.16 -extern unsigned long xencomm_vaddr_to_paddr(unsigned long vaddr);
    2.17 -struct xencomm_handle;
    2.18 -
    2.19 -/* Inline version.  To be used only on linear space (kernel space).  */
    2.20 -static inline struct xencomm_handle *
    2.21 -xencomm_create_inline(void *buffer)
    2.22 -{
    2.23 -	unsigned long paddr;
    2.24 -
    2.25 -	paddr = xencomm_vaddr_to_paddr((unsigned long)buffer);
    2.26 -	return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
    2.27 -}
    2.28 -
    2.29 -static inline int
    2.30 -xencomm_arch_event_channel_op(int cmd, void *arg)
    2.31 -{
    2.32 -	int rc;
    2.33 -	struct xencomm_handle *newArg;
    2.34 -
    2.35 -	newArg = xencomm_create_inline(arg);
    2.36 -	rc = _hypercall2(int, event_channel_op, cmd, newArg);
    2.37 -	if (unlikely(rc == -ENOSYS)) {
    2.38 -		struct evtchn_op op;
    2.39 -
    2.40 -		op.cmd = SWAP(cmd);
    2.41 -		memcpy(&op.u, arg, sizeof(op.u));
    2.42 -		rc = _hypercall1(int, event_channel_op_compat, &op);
    2.43 -	}
    2.44 -	return rc;
    2.45 -}
    2.46 -#define HYPERVISOR_event_channel_op xencomm_arch_event_channel_op
    2.47 -
    2.48 -static inline int
    2.49 -xencomm_arch_xen_version(int cmd, struct xencomm_handle *arg)
    2.50 -{
    2.51 -	return _hypercall2(int, xen_version, cmd, arg);
    2.52 -}
    2.53 -
    2.54 -static inline int
    2.55 -xencomm_arch_xen_feature(int cmd, struct xencomm_handle *arg)
    2.56 -{
    2.57 -	struct xencomm_handle *newArg;
    2.58 -
    2.59 -	newArg = xencomm_create_inline(arg);
    2.60 -	return _hypercall2(int, xen_version, cmd, newArg);
    2.61 -}
    2.62 +int HYPERVISOR_event_channel_op(int cmd, void *arg);
    2.63  
    2.64 -static inline int
    2.65 -HYPERVISOR_xen_version(int cmd, void *arg)
    2.66 -{
    2.67 -	switch(cmd) {
    2.68 -		case XENVER_version:
    2.69 -			return xencomm_arch_xen_version(cmd, 0);
    2.70 -		case XENVER_get_features:
    2.71 -			return xencomm_arch_xen_feature(cmd, arg);
    2.72 -		default:
    2.73 -			return -1;
    2.74 -	}
    2.75 -}
    2.76 -
    2.77 -static inline int
    2.78 -xencomm_arch_console_io(int cmd, int count, char *str)
    2.79 -{
    2.80 -	struct xencomm_handle *newStr;
    2.81 -
    2.82 -	newStr = xencomm_create_inline(str);
    2.83 -	return _hypercall3(int, console_io, cmd, count, newStr);
    2.84 -}
    2.85 -
    2.86 -
    2.87 -#define HYPERVISOR_console_io xencomm_arch_console_io
    2.88 +int HYPERVISOR_xen_version(int cmd, void *arg);
    2.89  
    2.90 -static inline int
    2.91 -HYPERVISOR_sched_op_compat(int cmd, unsigned long arg)
    2.92 -{
    2.93 -	return _hypercall2(int, sched_op_compat, cmd, arg);
    2.94 -}
    2.95 -
    2.96 -static inline int
    2.97 -xencomm_arch_sched_op(int cmd, void *arg)
    2.98 -{
    2.99 -	struct xencomm_handle *newArg;
   2.100 -
   2.101 -	newArg = xencomm_create_inline(arg);
   2.102 -	return _hypercall2(int, sched_op, cmd, newArg);
   2.103 -}
   2.104 -
   2.105 -#define HYPERVISOR_sched_op xencomm_arch_sched_op
   2.106 +int HYPERVISOR_console_io(int cmd, int count, char *str);
   2.107  
   2.108 -static inline int
   2.109 -xencomm_arch_callback_op(int cmd, void *arg)
   2.110 -{
   2.111 -	struct xencomm_handle *newArg;
   2.112 +int HYPERVISOR_sched_op_compat(int cmd, unsigned long arg);
   2.113  
   2.114 -	newArg = xencomm_create_inline(arg);
   2.115 -	return _hypercall2(int, callback_op, cmd, newArg);
   2.116 -}
   2.117 -#define HYPERVISOR_callback_op xencomm_arch_callback_op
   2.118 +int HYPERVISOR_sched_op(int cmd, void *arg);
   2.119  
   2.120 -static inline int
   2.121 -xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
   2.122 -                                      struct xencomm_handle *uop,
   2.123 -                                      unsigned int count)
   2.124 -{
   2.125 -	return _hypercall3(int, grant_table_op, cmd, uop, count);
   2.126 -}
   2.127 +int HYPERVISOR_callback_op(int cmd, void *arg);
   2.128  
   2.129  int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
   2.130  
   2.131 -static inline int
   2.132 -HYPERVISOR_opt_feature(void *arg)
   2.133 -{
   2.134 -	struct xencomm_handle *new_arg;
   2.135 +int HYPERVISOR_opt_feature(void *arg);
   2.136  
   2.137 -	new_arg = xencomm_create_inline(arg);
   2.138 +int HYPERVISOR_suspend(unsigned long srec);
   2.139  
   2.140 -	return _hypercall1(int, opt_feature, new_arg);
   2.141 -}
   2.142 +int HYPERVISOR_shutdown(unsigned int reason);
   2.143  
   2.144  #endif /* __HYPERCALL_H__ */
     3.1 --- a/extras/mini-os/include/ia64/os.h	Tue Nov 18 10:33:55 2008 +0900
     3.2 +++ b/extras/mini-os/include/ia64/os.h	Mon Nov 17 09:19:45 2008 +0100
     3.3 @@ -192,21 +192,6 @@ static inline unsigned long
     3.4  
     3.5  extern shared_info_t *HYPERVISOR_shared_info;
     3.6  
     3.7 -static inline int
     3.8 -HYPERVISOR_shutdown(unsigned int reason)
     3.9 -{
    3.10 -	struct sched_shutdown sched_shutdown = {
    3.11 -		.reason = reason
    3.12 -	};
    3.13 -
    3.14 -	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
    3.15 -
    3.16 -	if (rc == -ENOSYS)
    3.17 -		rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
    3.18 -
    3.19 -	return rc;
    3.20 -}
    3.21 -
    3.22  
    3.23  /*
    3.24   * This code is from the originally os.h and should be put in a