~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/xeno/event.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************************************
2
 
 * event.h
3
 
 * 
4
 
 * A nice interface for passing asynchronous events to guest OSes.
5
 
 * 
6
 
 * Copyright (c) 2002, K A Fraser
7
 
 */
8
 
 
9
 
#include <xeno/config.h>
10
 
#include <xeno/sched.h>
11
 
#include <asm/bitops.h>
12
 
 
13
 
#ifdef CONFIG_SMP
14
 
 
15
 
/*
16
 
 * mark_guest_event:
17
 
 *  @p:        Domain to which event should be passed
18
 
 *  @event:    Event number
19
 
 *  RETURNS:   "Bitmask" of CPU on which process is currently running
20
 
 * 
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
24
 
 * event_notify().
25
 
 * 
26
 
 * Guest_events are per-domain events passed directly to the guest OS
27
 
 * in ring 1. 
28
 
 */
29
 
static inline unsigned long mark_guest_event(struct task_struct *p, int event)
30
 
{
31
 
    unsigned long flags, cpu_mask;
32
 
 
33
 
    if ( test_and_set_bit(event, &p->shared_info->events) )
34
 
        return 0;
35
 
 
36
 
    spin_lock_irqsave(&schedule_lock[p->processor], flags);
37
 
    if ( p->state == TASK_INTERRUPTIBLE )
38
 
        __wake_up(p);
39
 
    cpu_mask = __reschedule(p);
40
 
    if ( p->has_cpu )
41
 
        cpu_mask |= 1 << p->processor;
42
 
    spin_unlock_irqrestore(&schedule_lock[p->processor], flags);
43
 
 
44
 
    return cpu_mask;
45
 
}
46
 
 
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)
49
 
{
50
 
    unsigned long flags, cpu_mask;
51
 
 
52
 
    if ( test_and_set_bit(event, &p->hyp_events) )
53
 
        return 0;
54
 
 
55
 
    spin_lock_irqsave(&schedule_lock[p->processor], flags);
56
 
    if ( p->state == TASK_INTERRUPTIBLE )
57
 
        __wake_up(p);
58
 
    cpu_mask = __reschedule(p);
59
 
    if ( p->has_cpu )
60
 
        cpu_mask |= 1 << p->processor;
61
 
    spin_unlock_irqrestore(&schedule_lock[p->processor], flags);
62
 
 
63
 
    return cpu_mask;
64
 
}
65
 
 
66
 
/* Notify the given set of CPUs that guest events may be outstanding. */
67
 
static inline void guest_event_notify(unsigned long cpu_mask)
68
 
{
69
 
    cpu_mask &= ~(1 << smp_processor_id());
70
 
    if ( cpu_mask != 0 ) smp_send_event_check_mask(cpu_mask);
71
 
}
72
 
 
73
 
#else
74
 
 
75
 
static inline unsigned long mark_guest_event(struct task_struct *p, int event)
76
 
{
77
 
    if ( !test_and_set_bit(event, &p->shared_info->events) )
78
 
    {
79
 
        if ( p->state == TASK_INTERRUPTIBLE ) wake_up(p);
80
 
        reschedule(p);
81
 
    }
82
 
    return 0;
83
 
}
84
 
 
85
 
static inline unsigned long mark_hyp_event(struct task_struct *p, int event)
86
 
{
87
 
    if ( !test_and_set_bit(event, &p->hyp_events) )
88
 
    {
89
 
        if ( p->state == TASK_INTERRUPTIBLE ) wake_up(p);
90
 
        reschedule(p);
91
 
    }
92
 
    return 0;
93
 
}
94
 
 
95
 
#define guest_event_notify(_mask) ((void)0)
96
 
 
97
 
#endif
98
 
 
99
 
/* Notify hypervisor events in thesame way as for guest OS events. */
100
 
#define hyp_event_notify(_mask) guest_event_notify(_mask)
101
 
 
102
 
/* Clear a guest-OS event from a per-domain mask. */
103
 
static inline void clear_guest_event(struct task_struct *p, int event)
104
 
{
105
 
    clear_bit(event, &p->shared_info->events);
106
 
}
107
 
 
108
 
/* Clear a hypervisor event from a per-domain mask. */
109
 
static inline void clear_hyp_event(struct task_struct *p, int event)
110
 
{
111
 
    clear_bit(event, &p->hyp_events);
112
 
}
113
 
 
114
 
/* Called on return from (architecture-dependent) entry.S. */
115
 
void do_hyp_events(void);