ia64/xen-unstable

changeset 10856:1fb835267a50

Merge.
author kfraser@localhost.localdomain
date Fri Jul 28 16:54:17 2006 +0100 (2006-07-28)
parents 03c8002068d9 fc0040fd13d8
children 762ae310d878
files
line diff
     1.1 --- a/extras/mini-os/console/xencons_ring.c	Fri Jul 28 16:53:58 2006 +0100
     1.2 +++ b/extras/mini-os/console/xencons_ring.c	Fri Jul 28 16:54:17 2006 +0100
     1.3 @@ -53,7 +53,7 @@ int xencons_ring_send(const char *data, 
     1.4  
     1.5  
     1.6  
     1.7 -static void handle_input(int port, struct pt_regs *regs, void *ign)
     1.8 +static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *ign)
     1.9  {
    1.10  	struct xencons_interface *intf = xencons_interface();
    1.11  	XENCONS_RING_IDX cons, prod;
     2.1 --- a/extras/mini-os/events.c	Fri Jul 28 16:53:58 2006 +0100
     2.2 +++ b/extras/mini-os/events.c	Fri Jul 28 16:54:17 2006 +0100
     2.3 @@ -26,20 +26,20 @@
     2.4  
     2.5  /* this represents a event handler. Chaining or sharing is not allowed */
     2.6  typedef struct _ev_action_t {
     2.7 -	void (*handler)(int, struct pt_regs *, void *);
     2.8 +	evtchn_handler_t handler;
     2.9  	void *data;
    2.10      u32 count;
    2.11  } ev_action_t;
    2.12  
    2.13  
    2.14  static ev_action_t ev_actions[NR_EVS];
    2.15 -void default_handler(int port, struct pt_regs *regs, void *data);
    2.16 +void default_handler(evtchn_port_t port, struct pt_regs *regs, void *data);
    2.17  
    2.18  
    2.19  /*
    2.20   * Demux events to different handlers.
    2.21   */
    2.22 -int do_event(u32 port, struct pt_regs *regs)
    2.23 +int do_event(evtchn_port_t port, struct pt_regs *regs)
    2.24  {
    2.25      ev_action_t  *action;
    2.26      if (port >= NR_EVS) {
    2.27 @@ -60,8 +60,8 @@ int do_event(u32 port, struct pt_regs *r
    2.28  
    2.29  }
    2.30  
    2.31 -int bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *, void *),
    2.32 -				 void *data )
    2.33 +evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
    2.34 +						  void *data)
    2.35  {
    2.36   	if(ev_actions[port].handler != default_handler)
    2.37          printk("WARN: Handler for port %d already registered, replacing\n",
    2.38 @@ -77,7 +77,7 @@ int bind_evtchn( u32 port, void (*handle
    2.39  	return port;
    2.40  }
    2.41  
    2.42 -void unbind_evtchn( u32 port )
    2.43 +void unbind_evtchn(evtchn_port_t port )
    2.44  {
    2.45  	if (ev_actions[port].handler == default_handler)
    2.46  		printk("WARN: No handler for port %d when unbinding\n", port);
    2.47 @@ -86,8 +86,7 @@ void unbind_evtchn( u32 port )
    2.48  	ev_actions[port].data = NULL;
    2.49  }
    2.50  
    2.51 -int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *, void *data),
    2.52 -			   void *data)
    2.53 +int bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
    2.54  {
    2.55  	evtchn_op_t op;
    2.56  
    2.57 @@ -105,11 +104,6 @@ int bind_virq( u32 virq, void (*handler)
    2.58  	return 0;
    2.59  }
    2.60  
    2.61 -void unbind_virq( u32 port )
    2.62 -{
    2.63 -	unbind_evtchn(port);
    2.64 -}
    2.65 -
    2.66  #if defined(__x86_64__)
    2.67  /* Allocate 4 pages for the irqstack */
    2.68  #define STACK_PAGES 4
    2.69 @@ -142,32 +136,48 @@ void init_events(void)
    2.70      }
    2.71  }
    2.72  
    2.73 -void default_handler(int port, struct pt_regs *regs, void *ignore)
    2.74 +void default_handler(evtchn_port_t port, struct pt_regs *regs, void *ignore)
    2.75  {
    2.76      printk("[Port %d] - event received\n", port);
    2.77  }
    2.78  
    2.79 +/* Create a port available to the pal for exchanging notifications.
    2.80 +   Returns the result of the hypervisor call. */
    2.81 +
    2.82  /* Unfortunate confusion of terminology: the port is unbound as far
    2.83     as Xen is concerned, but we automatically bind a handler to it
    2.84     from inside mini-os. */
    2.85 -int evtchn_alloc_unbound(void (*handler)(int, struct pt_regs *regs,
    2.86 -										 void *data),
    2.87 -						 void *data)
    2.88 +
    2.89 +int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
    2.90 +						 void *data, evtchn_port_t *port)
    2.91  {
    2.92 -	u32 port;
    2.93 -	evtchn_op_t op;
    2.94 -	int err;
    2.95 +    evtchn_op_t op;
    2.96 +    op.cmd = EVTCHNOP_alloc_unbound;
    2.97 +    op.u.alloc_unbound.dom = DOMID_SELF;
    2.98 +    op.u.alloc_unbound.remote_dom = pal;
    2.99 +    int err = HYPERVISOR_event_channel_op(&op);
   2.100 +    if (err)
   2.101 +		return err;
   2.102 +    *port = bind_evtchn(op.u.alloc_unbound.port, handler, data);
   2.103 +    return err;
   2.104 +}
   2.105  
   2.106 -	op.cmd = EVTCHNOP_alloc_unbound;
   2.107 -	op.u.alloc_unbound.dom = DOMID_SELF;
   2.108 -	op.u.alloc_unbound.remote_dom = 0;
   2.109 +/* Connect to a port so as to allow the exchange of notifications with
   2.110 +   the pal. Returns the result of the hypervisor call. */
   2.111  
   2.112 -	err = HYPERVISOR_event_channel_op(&op);
   2.113 -	if (err) {
   2.114 -		printk("Failed to alloc unbound evtchn: %d.\n", err);
   2.115 -		return -1;
   2.116 -	}
   2.117 -	port = op.u.alloc_unbound.port;
   2.118 -	bind_evtchn(port, handler, data);
   2.119 -	return port;
   2.120 +int evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port,
   2.121 +			    evtchn_handler_t handler, void *data,
   2.122 +			    evtchn_port_t *local_port)
   2.123 +{
   2.124 +    evtchn_op_t op;
   2.125 +    op.cmd = EVTCHNOP_bind_interdomain;
   2.126 +    op.u.bind_interdomain.remote_dom = pal;
   2.127 +    op.u.bind_interdomain.remote_port = remote_port;
   2.128 +    int err = HYPERVISOR_event_channel_op(&op);
   2.129 +    if (err)
   2.130 +		return err;
   2.131 +	evtchn_port_t port = op.u.bind_interdomain.local_port;
   2.132 +    clear_evtchn(port);	      /* Without, handler gets invoked now! */
   2.133 +    *local_port = bind_evtchn(port, handler, data);
   2.134 +    return err;
   2.135  }
     3.1 --- a/extras/mini-os/gnttab.c	Fri Jul 28 16:53:58 2006 +0100
     3.2 +++ b/extras/mini-os/gnttab.c	Fri Jul 28 16:54:17 2006 +0100
     3.3 @@ -137,6 +137,18 @@ gnttab_alloc_and_grant(void **map)
     3.4      return gref;
     3.5  }
     3.6  
     3.7 +static const char *gnttabop_error_msgs[] = GNTTABOP_error_msgs;
     3.8 +
     3.9 +const char *
    3.10 +gnttabop_error(int16_t status)
    3.11 +{
    3.12 +    status = -status;
    3.13 +    if (status < 0 || status >= ARRAY_SIZE(gnttabop_error_msgs))
    3.14 +	return "bad status";
    3.15 +    else
    3.16 +        return gnttabop_error_msgs[status];
    3.17 +}
    3.18 +
    3.19  void
    3.20  init_gnttab(void)
    3.21  {
     4.1 --- a/extras/mini-os/include/events.h	Fri Jul 28 16:53:58 2006 +0100
     4.2 +++ b/extras/mini-os/include/events.h	Fri Jul 28 16:54:17 2006 +0100
     4.3 @@ -22,20 +22,22 @@
     4.4  #include<traps.h>
     4.5  #include <xen/event_channel.h>
     4.6  
     4.7 +typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *);
     4.8 +
     4.9  /* prototypes */
    4.10 -int do_event(u32 port, struct pt_regs *regs);
    4.11 -int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *, void *data),
    4.12 -			   void *data);
    4.13 -int bind_evtchn( u32 virq, void (*handler)(int, struct pt_regs *, void *data),
    4.14 -				 void *data );
    4.15 -void unbind_evtchn( u32 port );
    4.16 +int do_event(evtchn_port_t port, struct pt_regs *regs);
    4.17 +int bind_virq(uint32_t virq, evtchn_handler_t handler, void *data);
    4.18 +evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
    4.19 +						  void *data);
    4.20 +void unbind_evtchn(evtchn_port_t port);
    4.21  void init_events(void);
    4.22 -void unbind_virq( u32 port );
    4.23 -int evtchn_alloc_unbound(void (*handler)(int, struct pt_regs *regs,
    4.24 -										 void *data),
    4.25 -						 void *data);
    4.26 +int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
    4.27 +						 void *data, evtchn_port_t *port);
    4.28 +int evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port,
    4.29 +							evtchn_handler_t handler, void *data,
    4.30 +							evtchn_port_t *local_port);
    4.31  
    4.32 -static inline int notify_remote_via_evtchn(int port)
    4.33 +static inline int notify_remote_via_evtchn(evtchn_port_t port)
    4.34  {
    4.35      evtchn_op_t op;
    4.36      op.cmd = EVTCHNOP_send;
     5.1 --- a/extras/mini-os/include/gnttab.h	Fri Jul 28 16:53:58 2006 +0100
     5.2 +++ b/extras/mini-os/include/gnttab.h	Fri Jul 28 16:54:17 2006 +0100
     5.3 @@ -10,5 +10,6 @@ grant_ref_t gnttab_grant_access(domid_t 
     5.4  grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn);
     5.5  unsigned long gnttab_end_transfer(grant_ref_t gref);
     5.6  int gnttab_end_access(grant_ref_t ref);
     5.7 +const char *gnttabop_error(int16_t status);
     5.8  
     5.9  #endif /* !__GNTTAB_H__ */
     6.1 --- a/extras/mini-os/time.c	Fri Jul 28 16:53:58 2006 +0100
     6.2 +++ b/extras/mini-os/time.c	Fri Jul 28 16:54:17 2006 +0100
     6.3 @@ -215,7 +215,7 @@ void block_domain(u32 millisecs)
     6.4  /*
     6.5   * Just a dummy 
     6.6   */
     6.7 -static void timer_handler(int ev, struct pt_regs *regs, void *ign)
     6.8 +static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign)
     6.9  {
    6.10      static int i;
    6.11  
     7.1 --- a/extras/mini-os/xenbus/xenbus.c	Fri Jul 28 16:53:58 2006 +0100
     7.2 +++ b/extras/mini-os/xenbus/xenbus.c	Fri Jul 28 16:54:17 2006 +0100
     7.3 @@ -112,7 +112,8 @@ static void xenbus_thread_func(void *ign
     7.4      }
     7.5  }
     7.6  
     7.7 -static void xenbus_evtchn_handler(int port, struct pt_regs *regs, void *ign)
     7.8 +static void xenbus_evtchn_handler(evtchn_port_t port, struct pt_regs *regs,
     7.9 +				  void *ign)
    7.10  {
    7.11      wake_up(&xb_waitq);
    7.12  }