ia64/xen-unstable

changeset 7542:f8087c9297aa

I've created a patch to get the mini-os to compile in Xen-unstable. The patch
is pretty big, but this is mostly because I've replaced hypervisor.h with the
hypercalls.h header file from Linux (which seems easier to maintain
anyway). I've ignored X86_64.

Signed-off-by: Simon Kagstrom <simon.kagstrom@bth.se>
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 27 17:43:29 2005 +0100 (2005-10-27)
parents 602f7fc3e1b1
children c5cd971aa96c
files extras/mini-os/include/events.h extras/mini-os/include/hypervisor.h extras/mini-os/include/os.h extras/mini-os/include/types.h extras/mini-os/kernel.c extras/mini-os/time.c extras/mini-os/xenbus/xenbus_xs.c
line diff
     1.1 --- a/extras/mini-os/include/events.h	Thu Oct 27 17:29:39 2005 +0100
     1.2 +++ b/extras/mini-os/include/events.h	Thu Oct 27 17:43:29 2005 +0100
     1.3 @@ -47,7 +47,7 @@ static inline int notify_via_evtchn(int 
     1.4  {
     1.5      evtchn_op_t op;
     1.6      op.cmd = EVTCHNOP_send;
     1.7 -    op.u.send.local_port = port;
     1.8 +    op.u.send.port = port;
     1.9      return HYPERVISOR_event_channel_op(&op);
    1.10  }
    1.11  
     2.1 --- a/extras/mini-os/include/hypervisor.h	Thu Oct 27 17:29:39 2005 +0100
     2.2 +++ b/extras/mini-os/include/hypervisor.h	Thu Oct 27 17:43:29 2005 +0100
     2.3 @@ -14,6 +14,7 @@
     2.4  
     2.5  #include <types.h>
     2.6  #include <xen/xen.h>
     2.7 +#include <xen/dom0_ops.h>
     2.8  
     2.9  /*
    2.10   * a placeholder for the start of day information passed up from the hypervisor
    2.11 @@ -37,548 +38,281 @@ void clear_evtchn(u32 port);
    2.12   * Assembler stubs for hyper-calls.
    2.13   */
    2.14  #if defined(__i386__)
    2.15 +/* Taken from Linux */
    2.16 +
    2.17 +#ifndef __HYPERCALL_H__
    2.18 +#define __HYPERCALL_H__
    2.19 +
    2.20 +#include <xen/sched.h>
    2.21 +
    2.22 +#define _hypercall0(type, name)			\
    2.23 +({						\
    2.24 +	long __res;				\
    2.25 +	asm volatile (				\
    2.26 +		TRAP_INSTR			\
    2.27 +		: "=a" (__res)			\
    2.28 +		: "0" (__HYPERVISOR_##name)	\
    2.29 +		: "memory" );			\
    2.30 +	(type)__res;				\
    2.31 +})
    2.32 +
    2.33 +#define _hypercall1(type, name, a1)				\
    2.34 +({								\
    2.35 +	long __res, __ign1;					\
    2.36 +	asm volatile (						\
    2.37 +		TRAP_INSTR					\
    2.38 +		: "=a" (__res), "=b" (__ign1)			\
    2.39 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1))	\
    2.40 +		: "memory" );					\
    2.41 +	(type)__res;						\
    2.42 +})
    2.43 +
    2.44 +#define _hypercall2(type, name, a1, a2)				\
    2.45 +({								\
    2.46 +	long __res, __ign1, __ign2;				\
    2.47 +	asm volatile (						\
    2.48 +		TRAP_INSTR					\
    2.49 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)	\
    2.50 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    2.51 +		"2" ((long)(a2))				\
    2.52 +		: "memory" );					\
    2.53 +	(type)__res;						\
    2.54 +})
    2.55 +
    2.56 +#define _hypercall3(type, name, a1, a2, a3)			\
    2.57 +({								\
    2.58 +	long __res, __ign1, __ign2, __ign3;			\
    2.59 +	asm volatile (						\
    2.60 +		TRAP_INSTR					\
    2.61 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	\
    2.62 +		"=d" (__ign3)					\
    2.63 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    2.64 +		"2" ((long)(a2)), "3" ((long)(a3))		\
    2.65 +		: "memory" );					\
    2.66 +	(type)__res;						\
    2.67 +})
    2.68 +
    2.69 +#define _hypercall4(type, name, a1, a2, a3, a4)			\
    2.70 +({								\
    2.71 +	long __res, __ign1, __ign2, __ign3, __ign4;		\
    2.72 +	asm volatile (						\
    2.73 +		TRAP_INSTR					\
    2.74 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    2.75 +		"=d" (__ign3), "=S" (__ign4)			\
    2.76 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    2.77 +		"2" ((long)(a2)), "3" ((long)(a3)),		\
    2.78 +		"4" ((long)(a4))				\
    2.79 +		: "memory" );					\
    2.80 +	(type)__res;						\
    2.81 +})
    2.82 +
    2.83 +#define _hypercall5(type, name, a1, a2, a3, a4, a5)		\
    2.84 +({								\
    2.85 +	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;	\
    2.86 +	asm volatile (						\
    2.87 +		TRAP_INSTR					\
    2.88 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    2.89 +		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)	\
    2.90 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    2.91 +		"2" ((long)(a2)), "3" ((long)(a3)),		\
    2.92 +		"4" ((long)(a4)), "5" ((long)(a5))		\
    2.93 +		: "memory" );					\
    2.94 +	(type)__res;						\
    2.95 +})
    2.96 +
    2.97  static inline int
    2.98  HYPERVISOR_set_trap_table(
    2.99 -    trap_info_t *table)
   2.100 +	trap_info_t *table)
   2.101  {
   2.102 -    int ret;
   2.103 -    unsigned long ignore;
   2.104 -
   2.105 -    __asm__ __volatile__ (
   2.106 -        TRAP_INSTR
   2.107 -        : "=a" (ret), "=b" (ignore)
   2.108 -	: "0" (__HYPERVISOR_set_trap_table), "1" (table)
   2.109 -	: "memory" );
   2.110 -
   2.111 -    return ret;
   2.112 +	return _hypercall1(int, set_trap_table, table);
   2.113  }
   2.114  
   2.115  static inline int
   2.116  HYPERVISOR_mmu_update(
   2.117 -    mmu_update_t *req, int count, int *success_count, domid_t domid)
   2.118 +	mmu_update_t *req, int count, int *success_count, domid_t domid)
   2.119  {
   2.120 -    int ret;
   2.121 -    unsigned long ign1, ign2, ign3, ign4;
   2.122 -
   2.123 -    __asm__ __volatile__ (
   2.124 -        TRAP_INSTR
   2.125 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   2.126 -	: "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   2.127 -        "3" (success_count), "4" (domid)
   2.128 -	: "memory" );
   2.129 -
   2.130 -    return ret;
   2.131 +	return _hypercall4(int, mmu_update, req, count, success_count, domid);
   2.132  }
   2.133  
   2.134  static inline int
   2.135  HYPERVISOR_mmuext_op(
   2.136 -    struct mmuext_op *op, int count, int *success_count, domid_t domid)
   2.137 +	struct mmuext_op *op, int count, int *success_count, domid_t domid)
   2.138  {
   2.139 -    int ret;
   2.140 -    unsigned long ign1, ign2, ign3, ign4;
   2.141 -
   2.142 -    __asm__ __volatile__ (
   2.143 -        TRAP_INSTR
   2.144 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   2.145 -	: "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
   2.146 -        "3" (success_count), "4" (domid)
   2.147 -	: "memory" );
   2.148 -
   2.149 -    return ret;
   2.150 +	return _hypercall4(int, mmuext_op, op, count, success_count, domid);
   2.151  }
   2.152  
   2.153  static inline int
   2.154  HYPERVISOR_set_gdt(
   2.155 -    unsigned long *frame_list, int entries)
   2.156 +	unsigned long *frame_list, int entries)
   2.157  {
   2.158 -    int ret;
   2.159 -    unsigned long ign1, ign2;
   2.160 -
   2.161 -    __asm__ __volatile__ (
   2.162 -        TRAP_INSTR
   2.163 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.164 -	: "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
   2.165 -	: "memory" );
   2.166 -
   2.167 -
   2.168 -    return ret;
   2.169 +	return _hypercall2(int, set_gdt, frame_list, entries);
   2.170  }
   2.171  
   2.172  static inline int
   2.173  HYPERVISOR_stack_switch(
   2.174 -    unsigned long ss, unsigned long esp)
   2.175 +	unsigned long ss, unsigned long esp)
   2.176  {
   2.177 -    int ret;
   2.178 -    unsigned long ign1, ign2;
   2.179 -
   2.180 -    __asm__ __volatile__ (
   2.181 -        TRAP_INSTR
   2.182 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.183 -	: "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
   2.184 -	: "memory" );
   2.185 -
   2.186 -    return ret;
   2.187 +	return _hypercall2(int, stack_switch, ss, esp);
   2.188  }
   2.189  
   2.190  static inline int
   2.191  HYPERVISOR_set_callbacks(
   2.192 -    unsigned long event_selector, unsigned long event_address,
   2.193 -    unsigned long failsafe_selector, unsigned long failsafe_address)
   2.194 +	unsigned long event_selector, unsigned long event_address,
   2.195 +	unsigned long failsafe_selector, unsigned long failsafe_address)
   2.196  {
   2.197 -    int ret;
   2.198 -    unsigned long ign1, ign2, ign3, ign4;
   2.199 -
   2.200 -    __asm__ __volatile__ (
   2.201 -        TRAP_INSTR
   2.202 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   2.203 -	: "0" (__HYPERVISOR_set_callbacks), "1" (event_selector),
   2.204 -	  "2" (event_address), "3" (failsafe_selector), "4" (failsafe_address)
   2.205 -	: "memory" );
   2.206 -
   2.207 -    return ret;
   2.208 +	return _hypercall4(int, set_callbacks,
   2.209 +			   event_selector, event_address,
   2.210 +			   failsafe_selector, failsafe_address);
   2.211  }
   2.212  
   2.213  static inline int
   2.214  HYPERVISOR_fpu_taskswitch(
   2.215 -    int set)
   2.216 -{
   2.217 -    int ret;
   2.218 -    unsigned long ign;
   2.219 -
   2.220 -    __asm__ __volatile__ (
   2.221 -        TRAP_INSTR
   2.222 -        : "=a" (ret), "=b" (ign)
   2.223 -        : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
   2.224 -        : "memory" );
   2.225 -
   2.226 -    return ret;
   2.227 -}
   2.228 -
   2.229 -static inline int
   2.230 -HYPERVISOR_yield(
   2.231 -    void)
   2.232 +	int set)
   2.233  {
   2.234 -    int ret;
   2.235 -    unsigned long ign;
   2.236 -
   2.237 -    __asm__ __volatile__ (
   2.238 -        TRAP_INSTR
   2.239 -        : "=a" (ret), "=b" (ign)
   2.240 -	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_yield)
   2.241 -	: "memory", "ecx" );
   2.242 -
   2.243 -    return ret;
   2.244 -}
   2.245 -
   2.246 -static inline int
   2.247 -HYPERVISOR_block(
   2.248 -    void)
   2.249 -{
   2.250 -    int ret;
   2.251 -    unsigned long ign1;
   2.252 -    __asm__ __volatile__ (
   2.253 -        TRAP_INSTR
   2.254 -        : "=a" (ret), "=b" (ign1)
   2.255 -	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_block)
   2.256 -	: "memory", "ecx" );
   2.257 -
   2.258 -    return ret;
   2.259 +	return _hypercall1(int, fpu_taskswitch, set);
   2.260  }
   2.261  
   2.262  static inline int
   2.263 -HYPERVISOR_shutdown(
   2.264 -    void)
   2.265 -{
   2.266 -    int ret;
   2.267 -    unsigned long ign1;
   2.268 -    __asm__ __volatile__ (
   2.269 -        TRAP_INSTR
   2.270 -        : "=a" (ret), "=b" (ign1)
   2.271 -	: "0" (__HYPERVISOR_sched_op),
   2.272 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
   2.273 -        : "memory", "ecx" );
   2.274 -
   2.275 -    return ret;
   2.276 -}
   2.277 -
   2.278 -static inline int
   2.279 -HYPERVISOR_reboot(
   2.280 -    void)
   2.281 +HYPERVISOR_sched_op(
   2.282 +	int cmd, unsigned long arg)
   2.283  {
   2.284 -    int ret;
   2.285 -    unsigned long ign1;
   2.286 -    __asm__ __volatile__ (
   2.287 -        TRAP_INSTR
   2.288 -        : "=a" (ret), "=b" (ign1)
   2.289 -	: "0" (__HYPERVISOR_sched_op),
   2.290 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
   2.291 -        : "memory", "ecx" );
   2.292 -
   2.293 -    return ret;
   2.294 -}
   2.295 -
   2.296 -static inline int
   2.297 -HYPERVISOR_suspend(
   2.298 -    unsigned long srec)
   2.299 -{
   2.300 -    int ret;
   2.301 -    unsigned long ign1, ign2;
   2.302 -
   2.303 -    /* NB. On suspend, control software expects a suspend record in %esi. */
   2.304 -    __asm__ __volatile__ (
   2.305 -        TRAP_INSTR
   2.306 -        : "=a" (ret), "=b" (ign1), "=S" (ign2)
   2.307 -	: "0" (__HYPERVISOR_sched_op),
   2.308 -        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
   2.309 -        "S" (srec) : "memory", "ecx");
   2.310 -
   2.311 -    return ret;
   2.312 -}
   2.313 -
   2.314 -static inline int
   2.315 -HYPERVISOR_crash(
   2.316 -    void)
   2.317 -{
   2.318 -    int ret;
   2.319 -    unsigned long ign1;
   2.320 -    __asm__ __volatile__ (
   2.321 -        TRAP_INSTR
   2.322 -        : "=a" (ret), "=b" (ign1)
   2.323 -	: "0" (__HYPERVISOR_sched_op),
   2.324 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift))
   2.325 -        : "memory", "ecx" );
   2.326 -
   2.327 -    return ret;
   2.328 +	return _hypercall2(int, sched_op, cmd, arg);
   2.329  }
   2.330  
   2.331  static inline long
   2.332  HYPERVISOR_set_timer_op(
   2.333 -    u64 timeout)
   2.334 +	u64 timeout)
   2.335  {
   2.336 -    int ret;
   2.337 -    unsigned long timeout_hi = (unsigned long)(timeout>>32);
   2.338 -    unsigned long timeout_lo = (unsigned long)timeout;
   2.339 -    unsigned long ign1, ign2;
   2.340 -
   2.341 -    __asm__ __volatile__ (
   2.342 -        TRAP_INSTR
   2.343 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.344 -	: "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
   2.345 -	: "memory");
   2.346 -
   2.347 -    return ret;
   2.348 +	unsigned long timeout_hi = (unsigned long)(timeout>>32);
   2.349 +	unsigned long timeout_lo = (unsigned long)timeout;
   2.350 +	return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
   2.351  }
   2.352  
   2.353 -#if 0
   2.354  static inline int
   2.355  HYPERVISOR_dom0_op(
   2.356 -    dom0_op_t *dom0_op)
   2.357 +	dom0_op_t *dom0_op)
   2.358  {
   2.359 -    int ret;
   2.360 -    unsigned long ign1;
   2.361 -
   2.362 -    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
   2.363 -    __asm__ __volatile__ (
   2.364 -        TRAP_INSTR
   2.365 -        : "=a" (ret), "=b" (ign1)
   2.366 -	: "0" (__HYPERVISOR_dom0_op), "1" (dom0_op)
   2.367 -	: "memory");
   2.368 -
   2.369 -    return ret;
   2.370 +	dom0_op->interface_version = DOM0_INTERFACE_VERSION;
   2.371 +	return _hypercall1(int, dom0_op, dom0_op);
   2.372  }
   2.373 -#endif
   2.374  
   2.375  static inline int
   2.376  HYPERVISOR_set_debugreg(
   2.377 -    int reg, unsigned long value)
   2.378 +	int reg, unsigned long value)
   2.379  {
   2.380 -    int ret;
   2.381 -    unsigned long ign1, ign2;
   2.382 -    __asm__ __volatile__ (
   2.383 -        TRAP_INSTR
   2.384 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.385 -	: "0" (__HYPERVISOR_set_debugreg), "1" (reg), "2" (value)
   2.386 -	: "memory" );
   2.387 -
   2.388 -    return ret;
   2.389 +	return _hypercall2(int, set_debugreg, reg, value);
   2.390  }
   2.391  
   2.392  static inline unsigned long
   2.393  HYPERVISOR_get_debugreg(
   2.394 -    int reg)
   2.395 +	int reg)
   2.396  {
   2.397 -    unsigned long ret;
   2.398 -    unsigned long ign;
   2.399 -    __asm__ __volatile__ (
   2.400 -        TRAP_INSTR
   2.401 -        : "=a" (ret), "=b" (ign)
   2.402 -	: "0" (__HYPERVISOR_get_debugreg), "1" (reg)
   2.403 -	: "memory" );
   2.404 -
   2.405 -    return ret;
   2.406 +	return _hypercall1(unsigned long, get_debugreg, reg);
   2.407  }
   2.408  
   2.409  static inline int
   2.410  HYPERVISOR_update_descriptor(
   2.411 -    u64 ma, u64 desc)
   2.412 +	u64 ma, u64 desc)
   2.413  {
   2.414 -    int ret;
   2.415 -    unsigned long ign1, ign2, ign3, ign4;
   2.416 -
   2.417 -    __asm__ __volatile__ (
   2.418 -        TRAP_INSTR
   2.419 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   2.420 -	: "0" (__HYPERVISOR_update_descriptor),
   2.421 -	  "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
   2.422 -	  "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
   2.423 -	: "memory" );
   2.424 -
   2.425 -    return ret;
   2.426 +	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
   2.427  }
   2.428  
   2.429  static inline int
   2.430 -HYPERVISOR_dom_mem_op(
   2.431 -    unsigned int op, unsigned long *extent_list,
   2.432 -    unsigned long nr_extents, unsigned int extent_order)
   2.433 +HYPERVISOR_memory_op(
   2.434 +	unsigned int cmd, void *arg)
   2.435  {
   2.436 -    int ret;
   2.437 -    unsigned long ign1, ign2, ign3, ign4, ign5;
   2.438 -
   2.439 -    __asm__ __volatile__ (
   2.440 -        TRAP_INSTR
   2.441 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4),
   2.442 -	  "=D" (ign5)
   2.443 -	: "0" (__HYPERVISOR_dom_mem_op), "1" (op), "2" (extent_list),
   2.444 -	  "3" (nr_extents), "4" (extent_order), "5" (DOMID_SELF)
   2.445 -        : "memory" );
   2.446 -
   2.447 -    return ret;
   2.448 +	return _hypercall2(int, memory_op, cmd, arg);
   2.449  }
   2.450  
   2.451  static inline int
   2.452  HYPERVISOR_multicall(
   2.453 -    void *call_list, int nr_calls)
   2.454 +	void *call_list, int nr_calls)
   2.455  {
   2.456 -    int ret;
   2.457 -    unsigned long ign1, ign2;
   2.458 -
   2.459 -    __asm__ __volatile__ (
   2.460 -        TRAP_INSTR
   2.461 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.462 -	: "0" (__HYPERVISOR_multicall), "1" (call_list), "2" (nr_calls)
   2.463 -	: "memory" );
   2.464 -
   2.465 -    return ret;
   2.466 +	return _hypercall2(int, multicall, call_list, nr_calls);
   2.467  }
   2.468  
   2.469  static inline int
   2.470  HYPERVISOR_update_va_mapping(
   2.471 -    unsigned long va, pte_t new_val, unsigned long flags)
   2.472 +	unsigned long va, pte_t new_val, unsigned long flags)
   2.473  {
   2.474 -    int ret;
   2.475 -    unsigned long ign1, ign2, ign3, ign4;
   2.476 -
   2.477 -    __asm__ __volatile__ (
   2.478 -        TRAP_INSTR
   2.479 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   2.480 -	: "0" (__HYPERVISOR_update_va_mapping), 
   2.481 -          "1" (va), "2" ((new_val).pte_low),
   2.482 +	unsigned long pte_hi = 0;
   2.483  #ifdef CONFIG_X86_PAE
   2.484 -	  "3" ((new_val).pte_high),
   2.485 -#else
   2.486 -	  "3" (0),
   2.487 +	pte_hi = new_val.pte_high;
   2.488  #endif
   2.489 -	  "4" (flags)
   2.490 -	: "memory" );
   2.491 -
   2.492 -    return ret;
   2.493 +	return _hypercall4(int, update_va_mapping, va,
   2.494 +			   new_val.pte_low, pte_hi, flags);
   2.495  }
   2.496  
   2.497  static inline int
   2.498  HYPERVISOR_event_channel_op(
   2.499 -    void *op)
   2.500 +	void *op)
   2.501  {
   2.502 -    int ret;
   2.503 -    unsigned long ignore;
   2.504 -    __asm__ __volatile__ (
   2.505 -        TRAP_INSTR
   2.506 -        : "=a" (ret), "=b" (ignore)
   2.507 -	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
   2.508 -	: "memory" );
   2.509 -
   2.510 -    return ret;
   2.511 +	return _hypercall1(int, event_channel_op, op);
   2.512  }
   2.513  
   2.514  static inline int
   2.515  HYPERVISOR_xen_version(
   2.516 -    int cmd, void *arg)
   2.517 +	int cmd, void *arg)
   2.518  {
   2.519 -    int ret;
   2.520 -    unsigned long ignore, ign2;
   2.521 -
   2.522 -    __asm__ __volatile__ (
   2.523 -        TRAP_INSTR
   2.524 -        : "=a" (ret), "=b" (ignore), "=c" (ign2)
   2.525 -	: "0" (__HYPERVISOR_xen_version), "1" (cmd), "2" (arg)
   2.526 -	: "memory" );
   2.527 -
   2.528 -    return ret;
   2.529 +	return _hypercall2(int, xen_version, cmd, arg);
   2.530  }
   2.531  
   2.532  static inline int
   2.533  HYPERVISOR_console_io(
   2.534 -    int cmd, int count, char *str)
   2.535 +	int cmd, int count, char *str)
   2.536  {
   2.537 -    int ret;
   2.538 -    unsigned long ign1, ign2, ign3;
   2.539 -    __asm__ __volatile__ (
   2.540 -        TRAP_INSTR
   2.541 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
   2.542 -	: "0" (__HYPERVISOR_console_io), "1" (cmd), "2" (count), "3" (str)
   2.543 -	: "memory" );
   2.544 -
   2.545 -    return ret;
   2.546 +	return _hypercall3(int, console_io, cmd, count, str);
   2.547  }
   2.548  
   2.549  static inline int
   2.550  HYPERVISOR_physdev_op(
   2.551 -    void *physdev_op)
   2.552 +	void *physdev_op)
   2.553  {
   2.554 -    int ret;
   2.555 -    unsigned long ign;
   2.556 -
   2.557 -    __asm__ __volatile__ (
   2.558 -        TRAP_INSTR
   2.559 -        : "=a" (ret), "=b" (ign)
   2.560 -	: "0" (__HYPERVISOR_physdev_op), "1" (physdev_op)
   2.561 -	: "memory" );
   2.562 -
   2.563 -    return ret;
   2.564 +	return _hypercall1(int, physdev_op, physdev_op);
   2.565  }
   2.566  
   2.567  static inline int
   2.568  HYPERVISOR_grant_table_op(
   2.569 -    unsigned int cmd, void *uop, unsigned int count)
   2.570 +	unsigned int cmd, void *uop, unsigned int count)
   2.571  {
   2.572 -    int ret;
   2.573 -    unsigned long ign1, ign2, ign3;
   2.574 -
   2.575 -    __asm__ __volatile__ (
   2.576 -        TRAP_INSTR
   2.577 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
   2.578 -	: "0" (__HYPERVISOR_grant_table_op), "1" (cmd), "2" (uop), "3" (count)
   2.579 -	: "memory" );
   2.580 -
   2.581 -    return ret;
   2.582 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
   2.583  }
   2.584  
   2.585  static inline int
   2.586  HYPERVISOR_update_va_mapping_otherdomain(
   2.587 -    unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
   2.588 +	unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
   2.589  {
   2.590 -    int ret;
   2.591 -    unsigned long ign1, ign2, ign3, ign4, ign5;
   2.592 -
   2.593 -    __asm__ __volatile__ (
   2.594 -        TRAP_INSTR
   2.595 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3),
   2.596 -	  "=S" (ign4), "=D" (ign5)
   2.597 -	: "0" (__HYPERVISOR_update_va_mapping_otherdomain),
   2.598 -          "1" (va), "2" ((new_val).pte_low),
   2.599 +	unsigned long pte_hi = 0;
   2.600  #ifdef CONFIG_X86_PAE
   2.601 -	  "3" ((new_val).pte_high),
   2.602 -#else
   2.603 -	  "3" (0),
   2.604 +	pte_hi = new_val.pte_high;
   2.605  #endif
   2.606 -	  "4" (flags), "5" (domid) :
   2.607 -        "memory" );
   2.608 -    
   2.609 -    return ret;
   2.610 +	return _hypercall5(int, update_va_mapping_otherdomain, va,
   2.611 +			   new_val.pte_low, pte_hi, flags, domid);
   2.612  }
   2.613  
   2.614  static inline int
   2.615  HYPERVISOR_vm_assist(
   2.616 -    unsigned int cmd, unsigned int type)
   2.617 +	unsigned int cmd, unsigned int type)
   2.618  {
   2.619 -    int ret;
   2.620 -    unsigned long ign1, ign2;
   2.621 -
   2.622 -    __asm__ __volatile__ (
   2.623 -        TRAP_INSTR
   2.624 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.625 -	: "0" (__HYPERVISOR_vm_assist), "1" (cmd), "2" (type)
   2.626 -	: "memory" );
   2.627 -
   2.628 -    return ret;
   2.629 -}
   2.630 -
   2.631 -static inline int
   2.632 -HYPERVISOR_boot_vcpu(
   2.633 -    unsigned long vcpu, vcpu_guest_context_t *ctxt)
   2.634 -{
   2.635 -    int ret;
   2.636 -    unsigned long ign1, ign2;
   2.637 -
   2.638 -    __asm__ __volatile__ (
   2.639 -        TRAP_INSTR
   2.640 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.641 -	: "0" (__HYPERVISOR_boot_vcpu), "1" (vcpu), "2" (ctxt)
   2.642 -	: "memory");
   2.643 -
   2.644 -    return ret;
   2.645 +	return _hypercall2(int, vm_assist, cmd, type);
   2.646  }
   2.647  
   2.648  static inline int
   2.649 -HYPERVISOR_vcpu_down(
   2.650 -    int vcpu)
   2.651 +HYPERVISOR_vcpu_op(
   2.652 +	int cmd, int vcpuid, void *extra_args)
   2.653  {
   2.654 -    int ret;
   2.655 -    unsigned long ign1;
   2.656 -    /* Yes, I really do want to clobber edx here: when we resume a
   2.657 -       vcpu after unpickling a multi-processor domain, it returns
   2.658 -       here, but clobbers all of the call clobbered registers. */
   2.659 -    __asm__ __volatile__ (
   2.660 -        TRAP_INSTR
   2.661 -        : "=a" (ret), "=b" (ign1)
   2.662 -	: "0" (__HYPERVISOR_sched_op),
   2.663 -	  "1" (SCHEDOP_vcpu_down | (vcpu << SCHEDOP_vcpushift))
   2.664 -        : "memory", "ecx", "edx" );
   2.665 -
   2.666 -    return ret;
   2.667 +	return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
   2.668  }
   2.669  
   2.670  static inline int
   2.671 -HYPERVISOR_vcpu_up(
   2.672 -    int vcpu)
   2.673 +HYPERVISOR_suspend(
   2.674 +	unsigned long srec)
   2.675  {
   2.676 -    int ret;
   2.677 -    unsigned long ign1;
   2.678 -    __asm__ __volatile__ (
   2.679 -        TRAP_INSTR
   2.680 -        : "=a" (ret), "=b" (ign1)
   2.681 -	: "0" (__HYPERVISOR_sched_op),
   2.682 -	  "1" (SCHEDOP_vcpu_up | (vcpu << SCHEDOP_vcpushift))
   2.683 -        : "memory", "ecx" );
   2.684 -
   2.685 -    return ret;
   2.686 +	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
   2.687 +			   SHUTDOWN_suspend, srec);
   2.688  }
   2.689  
   2.690 -static inline int
   2.691 -HYPERVISOR_vcpu_pickle(
   2.692 -    int vcpu, vcpu_guest_context_t *ctxt)
   2.693 -{
   2.694 -    int ret;
   2.695 -    unsigned long ign1, ign2;
   2.696 -    __asm__ __volatile__ (
   2.697 -        TRAP_INSTR
   2.698 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   2.699 -	: "0" (__HYPERVISOR_sched_op),
   2.700 -	  "1" (SCHEDOP_vcpu_pickle | (vcpu << SCHEDOP_vcpushift)),
   2.701 -	  "2" (ctxt)
   2.702 -        : "memory" );
   2.703 -
   2.704 -    return ret;
   2.705 -}
   2.706 +#endif /* __HYPERCALL_H__ */
   2.707  #elif defined(__x86_64__)
   2.708  
   2.709  #define __syscall_clobber "r11","rcx","memory"
   2.710 @@ -792,106 +526,4 @@ HYPERVISOR_set_timer_op(
   2.711  }
   2.712  #endif
   2.713  
   2.714 -
   2.715 -static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
   2.716 -{
   2.717 -    int ret;
   2.718 -    __asm__ __volatile__ (
   2.719 -        TRAP_INSTR
   2.720 -        : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
   2.721 -        _a1 (dom0_op) : "memory" );
   2.722 -
   2.723 -    return ret;
   2.724 -}
   2.725 -
   2.726 -static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
   2.727 -{
   2.728 -    int ret;
   2.729 -    __asm__ __volatile__ (
   2.730 -        TRAP_INSTR
   2.731 -        : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
   2.732 -        _a1 (reg), _a2 (value) : "memory" );
   2.733 -
   2.734 -    return ret;
   2.735 -}
   2.736 -
   2.737 -static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
   2.738 -{
   2.739 -    unsigned long ret;
   2.740 -    __asm__ __volatile__ (
   2.741 -        TRAP_INSTR
   2.742 -        : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
   2.743 -        _a1 (reg) : "memory" );
   2.744 -
   2.745 -    return ret;
   2.746 -}
   2.747 -
   2.748 -static __inline__ int HYPERVISOR_update_descriptor(
   2.749 -    unsigned long pa, unsigned long word1, unsigned long word2)
   2.750 -{
   2.751 -    int ret;
   2.752 -    __asm__ __volatile__ (
   2.753 -        TRAP_INSTR
   2.754 -        : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor), 
   2.755 -        _a1 (pa), _a2 (word1), _a3 (word2) : "memory" );
   2.756 -
   2.757 -    return ret;
   2.758 -}
   2.759 -
   2.760 -static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
   2.761 -{
   2.762 -    int ret;
   2.763 -    __asm__ __volatile__ (
   2.764 -        TRAP_INSTR
   2.765 -        : "=a" (ret) : "0" (__HYPERVISOR_memory_op),
   2.766 -        _a1 (dom_mem_op) : "memory" );
   2.767 -
   2.768 -    return ret;
   2.769 -}
   2.770 -
   2.771 -static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
   2.772 -{
   2.773 -    int ret;
   2.774 -    __asm__ __volatile__ (
   2.775 -        TRAP_INSTR
   2.776 -        : "=a" (ret) : "0" (__HYPERVISOR_multicall),
   2.777 -        _a1 (call_list), _a2 (nr_calls) : "memory" );
   2.778 -
   2.779 -    return ret;
   2.780 -}
   2.781 -
   2.782 -static __inline__ int HYPERVISOR_update_va_mapping(
   2.783 -    unsigned long page_nr, unsigned long new_val, unsigned long flags)
   2.784 -{
   2.785 -    int ret;
   2.786 -    __asm__ __volatile__ (
   2.787 -        TRAP_INSTR
   2.788 -        : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping), 
   2.789 -        _a1 (page_nr), _a2 (new_val), _a3 (flags) : "memory" );
   2.790 -
   2.791 -    return ret;
   2.792 -}
   2.793 -
   2.794 -static __inline__ int HYPERVISOR_xen_version(int cmd)
   2.795 -{
   2.796 -    int ret;
   2.797 -    __asm__ __volatile__ (
   2.798 -        TRAP_INSTR
   2.799 -        : "=a" (ret) : "0" (__HYPERVISOR_xen_version), 
   2.800 -        _a1 (cmd) : "memory" );
   2.801 -
   2.802 -    return ret;
   2.803 -}
   2.804 -
   2.805 -static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
   2.806 -{
   2.807 -    int ret;
   2.808 -    __asm__ __volatile__ (
   2.809 -        TRAP_INSTR
   2.810 -        : "=a" (ret) : "0" (__HYPERVISOR_console_io),
   2.811 -        _a1 (cmd), _a2 (count), _a3 (str) : "memory" );
   2.812 -
   2.813 -    return ret;
   2.814 -}
   2.815 -
   2.816  #endif /* __HYPERVISOR_H__ */
     3.1 --- a/extras/mini-os/include/os.h	Thu Oct 27 17:29:39 2005 +0100
     3.2 +++ b/extras/mini-os/include/os.h	Thu Oct 27 17:43:29 2005 +0100
     3.3 @@ -24,7 +24,7 @@
     3.4  #include <xen/xen.h>
     3.5  
     3.6  
     3.7 -#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
     3.8 +#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0, 0))
     3.9  
    3.10  #define __KERNEL_CS  FLAT_KERNEL_CS
    3.11  #define __KERNEL_DS  FLAT_KERNEL_DS
    3.12 @@ -55,6 +55,8 @@
    3.13  /* Everything below this point is not included by assembler (.S) files. */
    3.14  #ifndef __ASSEMBLY__
    3.15  
    3.16 +extern shared_info_t *HYPERVISOR_shared_info;
    3.17 +
    3.18  void trap_init(void);
    3.19  
    3.20  /* 
     4.1 --- a/extras/mini-os/include/types.h	Thu Oct 27 17:29:39 2005 +0100
     4.2 +++ b/extras/mini-os/include/types.h	Thu Oct 27 17:43:29 2005 +0100
     4.3 @@ -54,7 +54,14 @@ typedef unsigned long       uintptr_t;
     4.4  typedef struct { unsigned long pte; } pte_t;
     4.5  #endif
     4.6  
     4.7 -
     4.8 +typedef  u8 uint8_t;
     4.9 +typedef  s8 int8_t;
    4.10 +typedef u16 uint16_t;
    4.11 +typedef s16 int16_t;
    4.12 +typedef u32 uint32_t;
    4.13 +typedef s32 int32_t;
    4.14 +typedef u64 uint64_t;
    4.15 +typedef s64 int64_t;
    4.16  
    4.17  
    4.18  #define INT_MAX         ((int)(~0U>>1))
     5.1 --- a/extras/mini-os/kernel.c	Thu Oct 27 17:29:39 2005 +0100
     5.2 +++ b/extras/mini-os/kernel.c	Thu Oct 27 17:43:29 2005 +0100
     5.3 @@ -61,7 +61,7 @@ void failsafe_callback(void);
     5.4  
     5.5  extern char shared_info[PAGE_SIZE];
     5.6  
     5.7 -#define __pte(x) ((pte_t) { (0) } )
     5.8 +#define __pte(x) ((pte_t) { (x) } )
     5.9  
    5.10  static shared_info_t *map_shared_info(unsigned long pa)
    5.11  {
    5.12 @@ -150,5 +150,5 @@ void start_kernel(start_info_t *si)
    5.13  void do_exit(void)
    5.14  {
    5.15      printk("do_exit called!\n");
    5.16 -    for ( ;; ) HYPERVISOR_shutdown();
    5.17 +    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
    5.18  }
     6.1 --- a/extras/mini-os/time.c	Thu Oct 27 17:29:39 2005 +0100
     6.2 +++ b/extras/mini-os/time.c	Thu Oct 27 17:43:29 2005 +0100
     6.3 @@ -208,7 +208,7 @@ void block_domain(u32 millisecs)
     6.4      struct timeval tv;
     6.5      gettimeofday(&tv);
     6.6      HYPERVISOR_set_timer_op(monotonic_clock() + 1000000LL * (s64) millisecs);
     6.7 -    HYPERVISOR_block();
     6.8 +    HYPERVISOR_sched_op(SCHEDOP_block, 0);
     6.9  }
    6.10  
    6.11  
     7.1 --- a/extras/mini-os/xenbus/xenbus_xs.c	Thu Oct 27 17:29:39 2005 +0100
     7.2 +++ b/extras/mini-os/xenbus/xenbus_xs.c	Thu Oct 27 17:43:29 2005 +0100
     7.3 @@ -39,7 +39,7 @@
     7.4  #include <wait.h>
     7.5  #include <sched.h>
     7.6  #include <semaphore.h>
     7.7 -#include "xenstored.h"
     7.8 +#include <xen/io/xs_wire.h>
     7.9  #include "xenbus_comms.h"
    7.10  
    7.11  #define streq(a, b) (strcmp((a), (b)) == 0)
    7.12 @@ -408,7 +408,12 @@ static char *xs_read_watch(char **token)
    7.13  
    7.14  static int xs_acknowledge_watch(const char *token)
    7.15  {
    7.16 +#if 0
    7.17  	return xs_error(xs_single(XS_WATCH_ACK, token, NULL));
    7.18 +#else
    7.19 +	/* XS_WATCH_ACK is no longer available */
    7.20 +	return 0;
    7.21 +#endif
    7.22  }
    7.23  
    7.24  static int xs_unwatch(const char *path, const char *token)