ia64/xen-unstable

changeset 12698:27a5a62552c0

[MINIOS] Improved unbind_all_ports().
Signed-off-by: Jacob Gorm Hansen <jacobg@diku.dk>
author kfraser@localhost.localdomain
date Thu Nov 30 17:17:28 2006 +0000 (2006-11-30)
parents 5adde07b4b8a
children 2c5bed93ffbc
files extras/mini-os/events.c extras/mini-os/include/events.h
line diff
     1.1 --- a/extras/mini-os/events.c	Thu Nov 30 17:14:09 2006 +0000
     1.2 +++ b/extras/mini-os/events.c	Thu Nov 30 17:17:28 2006 +0000
     1.3 @@ -31,26 +31,27 @@ typedef struct _ev_action_t {
     1.4      u32 count;
     1.5  } ev_action_t;
     1.6  
     1.7 -
     1.8  static ev_action_t ev_actions[NR_EVS];
     1.9  void default_handler(evtchn_port_t port, struct pt_regs *regs, void *data);
    1.10  
    1.11 +static unsigned long bound_ports[NR_EVS/(8*sizeof(unsigned long))];
    1.12 +
    1.13  void unbind_all_ports(void)
    1.14  {
    1.15      int i;
    1.16  
    1.17 -	for(i=0;i<NR_EVS;i++)
    1.18 -	{
    1.19 -		if(ev_actions[i].handler != default_handler)
    1.20 -		{
    1.21 -			struct evtchn_close close;
    1.22 -			mask_evtchn(i);
    1.23 -			close.port = i;
    1.24 -			HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
    1.25 -		}
    1.26 -	}
    1.27 +    for (i = 0; i < NR_EVS; i++)
    1.28 +    {
    1.29 +        if (test_and_clear_bit(i, bound_ports))
    1.30 +        {
    1.31 +            struct evtchn_close close;
    1.32 +            mask_evtchn(i);
    1.33 +            close.port = i;
    1.34 +            HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
    1.35 +        }
    1.36 +    }
    1.37  }
    1.38 -
    1.39 +  
    1.40  /*
    1.41   * Demux events to different handlers.
    1.42   */
    1.43 @@ -114,6 +115,7 @@ int bind_virq(uint32_t virq, evtchn_hand
    1.44  		printk("Failed to bind virtual IRQ %d\n", virq);
    1.45  		return 1;
    1.46      }
    1.47 +    set_bit(op.port,bound_ports);
    1.48      bind_evtchn(op.port, handler, data);
    1.49  	return 0;
    1.50  }
    1.51 @@ -188,6 +190,7 @@ int evtchn_bind_interdomain(domid_t pal,
    1.52      int err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
    1.53      if (err)
    1.54  		return err;
    1.55 +    set_bit(op.local_port,bound_ports);
    1.56  	evtchn_port_t port = op.local_port;
    1.57      clear_evtchn(port);	      /* Without, handler gets invoked now! */
    1.58      *local_port = bind_evtchn(port, handler, data);
     2.1 --- a/extras/mini-os/include/events.h	Thu Nov 30 17:14:09 2006 +0000
     2.2 +++ b/extras/mini-os/include/events.h	Thu Nov 30 17:17:28 2006 +0000
     2.3 @@ -36,6 +36,7 @@ int evtchn_alloc_unbound(domid_t pal, ev
     2.4  int evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port,
     2.5  							evtchn_handler_t handler, void *data,
     2.6  							evtchn_port_t *local_port);
     2.7 +void unbind_all_ports(void);
     2.8  
     2.9  static inline int notify_remote_via_evtchn(evtchn_port_t port)
    2.10  {