1
/******************************************************************************
4
* A nice interface for passing asynchronous events to guest OSes.
6
* Copyright (c) 2002, K A Fraser
9
#include <xeno/config.h>
10
#include <xeno/sched.h>
11
#include <asm/bitops.h>
17
* @p: Domain to which event should be passed
18
* @event: Event number
19
* RETURNS: "Bitmask" of CPU on which process is currently running
21
* Idea is that caller may loop on task_list, looking for domains
22
* to pass events to (using this function). The caller accumulates the
23
* bits returned by this function (ORing them together) then calls
26
* Guest_events are per-domain events passed directly to the guest OS
29
static inline unsigned long mark_guest_event(struct task_struct *p, int event)
31
unsigned long flags, cpu_mask;
33
if ( test_and_set_bit(event, &p->shared_info->events) )
36
spin_lock_irqsave(&schedule_lock[p->processor], flags);
37
if ( p->state == TASK_INTERRUPTIBLE )
39
cpu_mask = __reschedule(p);
41
cpu_mask |= 1 << p->processor;
42
spin_unlock_irqrestore(&schedule_lock[p->processor], flags);
47
/* As above, but hyp_events are handled within the hypervisor. */
48
static inline unsigned long mark_hyp_event(struct task_struct *p, int event)
50
unsigned long flags, cpu_mask;
52
if ( test_and_set_bit(event, &p->hyp_events) )
55
spin_lock_irqsave(&schedule_lock[p->processor], flags);
56
if ( p->state == TASK_INTERRUPTIBLE )
58
cpu_mask = __reschedule(p);
60
cpu_mask |= 1 << p->processor;
61
spin_unlock_irqrestore(&schedule_lock[p->processor], flags);
66
/* Notify the given set of CPUs that guest events may be outstanding. */
67
static inline void guest_event_notify(unsigned long cpu_mask)
69
cpu_mask &= ~(1 << smp_processor_id());
70
if ( cpu_mask != 0 ) smp_send_event_check_mask(cpu_mask);
75
static inline unsigned long mark_guest_event(struct task_struct *p, int event)
77
if ( !test_and_set_bit(event, &p->shared_info->events) )
79
if ( p->state == TASK_INTERRUPTIBLE ) wake_up(p);
85
static inline unsigned long mark_hyp_event(struct task_struct *p, int event)
87
if ( !test_and_set_bit(event, &p->hyp_events) )
89
if ( p->state == TASK_INTERRUPTIBLE ) wake_up(p);
95
#define guest_event_notify(_mask) ((void)0)
99
/* Notify hypervisor events in thesame way as for guest OS events. */
100
#define hyp_event_notify(_mask) guest_event_notify(_mask)
102
/* Clear a guest-OS event from a per-domain mask. */
103
static inline void clear_guest_event(struct task_struct *p, int event)
105
clear_bit(event, &p->shared_info->events);
108
/* Clear a hypervisor event from a per-domain mask. */
109
static inline void clear_hyp_event(struct task_struct *p, int event)
111
clear_bit(event, &p->hyp_events);
114
/* Called on return from (architecture-dependent) entry.S. */
115
void do_hyp_events(void);