ia64/xen-unstable

changeset 8905:2a2aaef05d70

[IA64] hypercall cleanup

hypercall clean up.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Fri Feb 24 08:24:58 2006 -0700 (2006-02-24)
parents 4f03ac87d31b
children 062ab30ba434
files linux-2.6-xen-sparse/include/asm-ia64/hypercall.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Fri Feb 24 08:23:33 2006 -0700
     1.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Fri Feb 24 08:24:58 2006 -0700
     1.3 @@ -46,6 +46,74 @@
     1.4   * Assembler stubs for hyper-calls.
     1.5   */
     1.6  
     1.7 +#define _hypercall0(type, name)					\
     1.8 +({								\
     1.9 +	long __res;						\
    1.10 +	__asm__ __volatile__ (";;\n"				\
    1.11 +			      "mov r2=%1\n"			\
    1.12 +			      "break 0x1000 ;;\n"		\
    1.13 +			      "mov %0=r8 ;;\n"			\
    1.14 +			      : "=r" (__res)			\
    1.15 +			      : "i" (__HYPERVISOR_##name)	\
    1.16 +			      : "r2","r8"			\
    1.17 +				"memory" );			\
    1.18 +	(type)__res;						\
    1.19 +})
    1.20 +
    1.21 +#define _hypercall1(type, name, a1)				\
    1.22 +({								\
    1.23 +	long __res;						\
    1.24 +	__asm__ __volatile__ (";;\n"				\
    1.25 +			      "mov r14=%2\n"			\
    1.26 +			      "mov r2=%1\n"			\
    1.27 +			      "break 0x1000 ;;\n"		\
    1.28 +			      "mov %0=r8 ;;\n"			\
    1.29 +			      : "=r" (__res)			\
    1.30 +			      : "i" (__HYPERVISOR_##name),	\
    1.31 +				"r" ((unsigned long)(a1))	\
    1.32 +			      : "r14","r2","r8",		\
    1.33 +				"memory" );			\
    1.34 +	(type)__res;						\
    1.35 +})
    1.36 +
    1.37 +#define _hypercall2(type, name, a1, a2)				\
    1.38 +({								\
    1.39 +	long __res;						\
    1.40 +	__asm__ __volatile__ (";;\n"				\
    1.41 +			      "mov r14=%2\n"			\
    1.42 +			      "mov r15=%3\n"			\
    1.43 +			      "mov r2=%1\n"			\
    1.44 +			      "break 0x1000 ;;\n"		\
    1.45 +			      "mov %0=r8 ;;\n"			\
    1.46 +			      : "=r" (__res)			\
    1.47 +			      : "i" (__HYPERVISOR_##name),	\
    1.48 +				"r" ((unsigned long)(a1)),	\
    1.49 +				"r" ((unsigned long)(a2))	\
    1.50 +			      : "r14","r15","r2","r8",		\
    1.51 +				"memory" );			\
    1.52 +	(type)__res;						\
    1.53 +})
    1.54 +
    1.55 +#define _hypercall3(type, name, a1, a2, a3)			\
    1.56 +({								\
    1.57 +	long __res;						\
    1.58 +	__asm__ __volatile__ (";;\n"                            \
    1.59 +			      "mov r14=%2\n"                    \
    1.60 +			      "mov r15=%3\n"                    \
    1.61 +			      "mov r16=%4\n"                    \
    1.62 +			      "mov r2=%1\n"                     \
    1.63 +			      "break 0x1000 ;;\n"               \
    1.64 +			      "mov %0=r8 ;;\n"                  \
    1.65 +			      : "=r" (__res)                    \
    1.66 +			      : "i" (__HYPERVISOR_##name),      \
    1.67 +				"r" ((unsigned long)(a1)),	\
    1.68 +				"r" ((unsigned long)(a2)),	\
    1.69 +				"r" ((unsigned long)(a3))	\
    1.70 +			      : "r14","r15","r16","r2","r8",    \
    1.71 +				"memory" );                     \
    1.72 +	(type)__res;                                            \
    1.73 +})
    1.74 +
    1.75  #if 0
    1.76  static inline int
    1.77  HYPERVISOR_set_trap_table(
    1.78 @@ -369,24 +437,14 @@ static inline int
    1.79  HYPERVISOR_memory_op(
    1.80      unsigned int cmd, void *arg)
    1.81  {
    1.82 -    int ret;
    1.83 -    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
    1.84 -        : "=r" (ret)
    1.85 -        : "i" (__HYPERVISOR_memory_op), "r"(cmd), "r"(arg)
    1.86 -        : "r14","r15","r2","r8","memory" );
    1.87 -    return ret;
    1.88 +    return _hypercall2(int, memory_op, cmd, arg);
    1.89  }
    1.90  
    1.91  static inline int
    1.92  HYPERVISOR_event_channel_op(
    1.93      void *op)
    1.94  {
    1.95 -    int ret;
    1.96 -    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
    1.97 -        : "=r" (ret)
    1.98 -        : "i" (__HYPERVISOR_event_channel_op), "r"(op)
    1.99 -        : "r14","r2","r8","memory" );
   1.100 -    return ret;
   1.101 +    return _hypercall1(int, event_channel_op, op);
   1.102  }
   1.103  
   1.104  #if 0
   1.105 @@ -414,12 +472,7 @@ static inline int
   1.106  HYPERVISOR_console_io(
   1.107      int cmd, int count, char *str)
   1.108  {
   1.109 -    int ret;
   1.110 -    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r16=%4 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
   1.111 -        : "=r" (ret)
   1.112 -        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(count), "r"(str)
   1.113 -        : "r14","r15","r16","r2","r8","memory" );
   1.114 -    return ret;
   1.115 +    return _hypercall3(int, console_io, cmd, count, str);
   1.116  }
   1.117  
   1.118  #if 0
   1.119 @@ -447,12 +500,7 @@ static inline int
   1.120  HYPERVISOR_grant_table_op(
   1.121      unsigned int cmd, void *uop, unsigned int count)
   1.122  {
   1.123 -    int ret;
   1.124 -    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r16=%4 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
   1.125 -        : "=r" (ret)
   1.126 -        : "i" (__HYPERVISOR_grant_table_op), "r"(cmd), "r"(uop), "r"(count)
   1.127 -        : "r14","r15","r16","r2","r8","memory" );
   1.128 -    return ret;
   1.129 +    return _hypercall3(int, grant_table_op, cmd, uop, count);
   1.130  }
   1.131  
   1.132  #if 0