7 * Definition of the generic fault handling class as well as
8 * specific sub-classes.
10 * (c) 2011-2013 Björn Döbel <doebel@os.inf.tu-dresden.de>,
11 * economic rights: Technische Universität Dresden (Germany)
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
20 //#include "emulation"
21 #include <l4/sys/kdebug.h>
30 /* Make this a macro because every sub-class will have to define
31 * these two virtual functions.
33 #define DECLARE_OBSERVER(_name_) \
35 virtual void startup_notify(Romain::App_instance *i, \
36 Romain::App_thread *t, \
37 Romain::Thread_group *tg, \
38 Romain::App_model *a); \
39 virtual ObserverReturnVal notify(Romain::App_instance *i, \
40 Romain::App_thread *t, \
41 Romain::Thread_group *tg, \
42 Romain::App_model *a); \
43 virtual char const * name() const { return _name_; } \
44 virtual void status() const;
47 #define DEFINE_EMPTY_STARTUP(name) \
48 void Romain::name::startup_notify(Romain::App_instance*, Romain::App_thread*, \
49 Romain::Thread_group*, Romain::App_model*) { }
52 * Generic observer class.
59 * Return values for the observers' notify() functions.
61 enum ObserverReturnVal {
64 * A fault handler has "Finished" handling the fault,
65 * if it modified the VCPU/UTCB state in a way that
66 * allows returning to the replica and other handlers
67 * may not touch this state anymore.
71 /* The story of Finished_{wait,step,wakeup}
72 * ==============================================
74 * The fault injection handler needs a mechanism that allows
75 * it to inject a fault into one replica while all other replicas
76 * don't do anything and simply wait until the injection (including
77 * potential further faults) has been completed.
81 * tl;dr: Tell redundancy handler that execution has been
82 * completed and that the replica should wait for an
83 * explicit wakeup before resuming.
87 * tl;dr: Execution completed. You are now the only replica
92 * tl;dr: Tell redundancy handler that execution has been
93 * completed and it should now also wake up all other
94 * replicas that have been stopped by 'Finished_wait'
100 * Handling produced the same result as 'Finished'.
102 * In contrast to the 'Finished' result, this result
103 * may be applied to replicas by simply copying UTCB
104 * and VCPU state to all of them.
108 * The fault was handled. However, VCPU/UTCB were not
109 * modified and other observers can be invoked before
110 * resuming the replica.
114 * This handler could not handle the fault and
121 * This function is called once the observed instance has
124 virtual void startup_notify(Romain::App_instance *i = 0,
125 Romain::App_thread *t = 0,
126 Romain::Thread_group *tg = 0,
127 Romain::App_model *a = 0) = 0;
130 * This function is called whenever an observed instance
133 virtual ObserverReturnVal notify(Romain::App_instance *i = 0,
134 Romain::App_thread *t = 0,
135 Romain::Thread_group *tg = 0,
136 Romain::App_model *a = 0) = 0;
139 * Check if we came to this point through a
142 static bool entry_reason_is_int3(L4vcpu::Vcpu* vcpu,
143 Romain::App_instance *i,
144 Romain::App_model *am);
147 virtual char const * name() const = 0;
148 virtual void status() const = 0;
151 * Determine if this fault was caused by an INT1 trap.
153 static bool entry_reason_is_int1(L4vcpu::Vcpu *vcpu)
154 { return vcpu->r()->trapno == 1; }
158 class ObserverFactory
161 static Observer* CreateObserver(char const*);