xref: /qemu/docs/devel/reset.rst (revision 06b40d250ecfa1633209c2e431a7a38acfd03a98)
1d66cc84cSDamien Hedde
2d66cc84cSDamien Hedde=======================================
3d66cc84cSDamien HeddeReset in QEMU: the Resettable interface
4d66cc84cSDamien Hedde=======================================
5d66cc84cSDamien Hedde
6d66cc84cSDamien HeddeThe reset of qemu objects is handled using the resettable interface declared
7d66cc84cSDamien Heddein ``include/hw/resettable.h``.
8d66cc84cSDamien Hedde
9d66cc84cSDamien HeddeThis interface allows objects to be grouped (on a tree basis); so that the
10d66cc84cSDamien Heddewhole group can be reset consistently. Each individual member object does not
11d66cc84cSDamien Heddehave to care about others; in particular, problems of order (which object is
12d66cc84cSDamien Heddereset first) are addressed.
13d66cc84cSDamien Hedde
14a365572bSPeter MaydellThe main object types which implement this interface are DeviceClass
15a365572bSPeter Maydelland BusClass.
16d66cc84cSDamien Hedde
17d66cc84cSDamien HeddeTriggering reset
18d66cc84cSDamien Hedde----------------
19d66cc84cSDamien Hedde
20d66cc84cSDamien HeddeThis section documents the APIs which "users" of a resettable object should use
21d66cc84cSDamien Heddeto control it. All resettable control functions must be called while holding
22a4a411fbSStefan Hajnoczithe BQL.
23d66cc84cSDamien Hedde
24d66cc84cSDamien HeddeYou can apply a reset to an object using ``resettable_assert_reset()``. You need
25d66cc84cSDamien Heddeto call ``resettable_release_reset()`` to release the object from reset. To
26d66cc84cSDamien Heddeinstantly reset an object, without keeping it in reset state, just call
27d66cc84cSDamien Hedde``resettable_reset()``. These functions take two parameters: a pointer to the
28d66cc84cSDamien Heddeobject to reset and a reset type.
29d66cc84cSDamien Hedde
30631f46d4SPeter MaydellThe Resettable interface handles reset types with an enum ``ResetType``:
31d66cc84cSDamien Hedde
32d66cc84cSDamien Hedde``RESET_TYPE_COLD``
33d66cc84cSDamien Hedde  Cold reset is supported by every resettable object. In QEMU, it means we reset
34d66cc84cSDamien Hedde  to the initial state corresponding to the start of QEMU; this might differ
35d66cc84cSDamien Hedde  from what is a real hardware cold reset. It differs from other resets (like
36d66cc84cSDamien Hedde  warm or bus resets) which may keep certain parts untouched.
37d66cc84cSDamien Hedde
38631f46d4SPeter Maydell``RESET_TYPE_SNAPSHOT_LOAD``
39631f46d4SPeter Maydell  This is called for a reset which is being done to put the system into a
40631f46d4SPeter Maydell  clean state prior to loading a snapshot. (This corresponds to a reset
41631f46d4SPeter Maydell  with ``SHUTDOWN_CAUSE_SNAPSHOT_LOAD``.) Almost all devices should treat
42631f46d4SPeter Maydell  this the same as ``RESET_TYPE_COLD``. The main exception is devices which
43631f46d4SPeter Maydell  have some non-deterministic state they want to reinitialize to a different
44631f46d4SPeter Maydell  value on each cold reset, such as RNG seed information, and which they
45631f46d4SPeter Maydell  must not reinitialize on a snapshot-load reset.
46631f46d4SPeter Maydell
47759cbb4eSJuraj Marcin``RESET_TYPE_WAKEUP``
48759cbb4eSJuraj Marcin  If the machine supports waking up from a suspended state and needs to reset
49759cbb4eSJuraj Marcin  its devices during wake-up (from the ``MachineClass::wakeup()`` method), this
50759cbb4eSJuraj Marcin  reset type should be used for such a request. Devices can utilize this reset
51759cbb4eSJuraj Marcin  type to differentiate the reset requested during machine wake-up from other
52759cbb4eSJuraj Marcin  reset requests. For example, RAM content must not be lost during wake-up, and
53759cbb4eSJuraj Marcin  memory devices like virtio-mem that provide additional RAM must not reset
54759cbb4eSJuraj Marcin  such state during wake-ups, but might do so during cold resets. However, this
55759cbb4eSJuraj Marcin  reset type should not be used for wake-up detection, as not every machine
56759cbb4eSJuraj Marcin  type issues a device reset request during wake-up.
57759cbb4eSJuraj Marcin
58cf7f61d1SPeter Maydell``RESET_TYPE_S390_CPU_NORMAL``
59cf7f61d1SPeter Maydell  This is only used for S390 CPU objects; it clears interrupts, stops
60cf7f61d1SPeter Maydell  processing, and clears the TLB, but does not touch register contents.
61cf7f61d1SPeter Maydell
62cf7f61d1SPeter Maydell``RESET_TYPE_S390_CPU_INITIAL``
63cf7f61d1SPeter Maydell  This is only used for S390 CPU objects; it does everything
64cf7f61d1SPeter Maydell  ``RESET_TYPE_S390_CPU_NORMAL`` does and also clears the PSW, prefix,
65cf7f61d1SPeter Maydell  FPC, timer and control registers. It does not touch gprs, fprs or acrs.
66cf7f61d1SPeter Maydell
67631f46d4SPeter MaydellDevices which implement reset methods must treat any unknown ``ResetType``
68631f46d4SPeter Maydellas equivalent to ``RESET_TYPE_COLD``; this will reduce the amount of
69631f46d4SPeter Maydellexisting code we need to change if we add more types in future.
70631f46d4SPeter Maydell
71d66cc84cSDamien HeddeCalling ``resettable_reset()`` is equivalent to calling
72d66cc84cSDamien Hedde``resettable_assert_reset()`` then ``resettable_release_reset()``. It is
73d66cc84cSDamien Heddepossible to interleave multiple calls to these three functions. There may
74d66cc84cSDamien Heddebe several reset sources/controllers of a given object. The interface handles
75d66cc84cSDamien Heddeeverything and the different reset controllers do not need to know anything
76d66cc84cSDamien Heddeabout each others. The object will leave reset state only when each other
77d66cc84cSDamien Heddecontrollers end their reset operation. This point is handled internally by
78d66cc84cSDamien Heddemaintaining a count of in-progress resets; it is crucial to call
79d66cc84cSDamien Hedde``resettable_release_reset()`` one time and only one time per
80d66cc84cSDamien Hedde``resettable_assert_reset()`` call.
81d66cc84cSDamien Hedde
82d66cc84cSDamien HeddeFor now migration of a device or bus in reset is not supported. Care must be
83d66cc84cSDamien Heddetaken not to delay ``resettable_release_reset()`` after its
84d66cc84cSDamien Hedde``resettable_assert_reset()`` counterpart.
85d66cc84cSDamien Hedde
86d66cc84cSDamien HeddeNote that, since resettable is an interface, the API takes a simple Object as
87d66cc84cSDamien Heddeparameter. Still, it is a programming error to call a resettable function on a
88d66cc84cSDamien Heddenon-resettable object and it will trigger a run time assert error. Since most
89d66cc84cSDamien Heddecalls to resettable interface are done through base class functions, such an
90d66cc84cSDamien Heddeerror is not likely to happen.
91d66cc84cSDamien Hedde
92d66cc84cSDamien HeddeFor Devices and Buses, the following helper functions exist:
93d66cc84cSDamien Hedde
94d66cc84cSDamien Hedde- ``device_cold_reset()``
95d66cc84cSDamien Hedde- ``bus_cold_reset()``
96d66cc84cSDamien Hedde
97d66cc84cSDamien HeddeThese are simple wrappers around resettable_reset() function; they only cast the
98d66cc84cSDamien HeddeDevice or Bus into an Object and pass the cold reset type. When possible
99d66cc84cSDamien Heddeprefer to use these functions instead of ``resettable_reset()``.
100d66cc84cSDamien Hedde
101d66cc84cSDamien HeddeDevice and bus functions co-exist because there can be semantic differences
102d66cc84cSDamien Heddebetween resetting a bus and resetting the controller bridge which owns it.
103d66cc84cSDamien HeddeFor example, consider a SCSI controller. Resetting the controller puts all
104d66cc84cSDamien Heddeits registers back to what reset state was as well as reset everything on the
105d66cc84cSDamien HeddeSCSI bus, whereas resetting just the SCSI bus only resets everything that's on
106d66cc84cSDamien Heddeit but not the controller.
107d66cc84cSDamien Hedde
108d66cc84cSDamien Hedde
109d66cc84cSDamien HeddeMulti-phase mechanism
110d66cc84cSDamien Hedde---------------------
111d66cc84cSDamien Hedde
112d66cc84cSDamien HeddeThis section documents the internals of the resettable interface.
113d66cc84cSDamien Hedde
114d66cc84cSDamien HeddeThe resettable interface uses a multi-phase system to relieve objects and
115d66cc84cSDamien Heddemachines from reset ordering problems. To address this, the reset operation
116d66cc84cSDamien Heddeof an object is split into three well defined phases.
117d66cc84cSDamien Hedde
118d66cc84cSDamien HeddeWhen resetting several objects (for example the whole machine at simulation
119d66cc84cSDamien Heddestartup), all first phases of all objects are executed, then all second phases
120d66cc84cSDamien Heddeand then all third phases.
121d66cc84cSDamien Hedde
122d66cc84cSDamien HeddeThe three phases are:
123d66cc84cSDamien Hedde
124d66cc84cSDamien Hedde1. The **enter** phase is executed when the object enters reset. It resets only
125d66cc84cSDamien Hedde   local state of the object; it must not do anything that has a side-effect
126d66cc84cSDamien Hedde   on other objects, such as raising or lowering a qemu_irq line or reading or
127d66cc84cSDamien Hedde   writing guest memory.
128d66cc84cSDamien Hedde
129d66cc84cSDamien Hedde2. The **hold** phase is executed for entry into reset, once every object in the
130d66cc84cSDamien Hedde   group which is being reset has had its *enter* phase executed. At this point
131d66cc84cSDamien Hedde   devices can do actions that affect other objects.
132d66cc84cSDamien Hedde
133d66cc84cSDamien Hedde3. The **exit** phase is executed when the object leaves the reset state.
134d66cc84cSDamien Hedde   Actions affecting other objects are permitted.
135d66cc84cSDamien Hedde
136d66cc84cSDamien HeddeAs said in previous section, the interface maintains a count of reset. This
137d66cc84cSDamien Heddecount is used to ensure phases are executed only when required. *enter* and
138d66cc84cSDamien Hedde*hold* phases are executed only when asserting reset for the first time
139d66cc84cSDamien Hedde(if an object is already in reset state when calling
140d66cc84cSDamien Hedde``resettable_assert_reset()`` or ``resettable_reset()``, they are not
141d66cc84cSDamien Heddeexecuted).
142d66cc84cSDamien HeddeThe *exit* phase is executed only when the last reset operation ends. Therefore
143d66cc84cSDamien Heddethe object does not need to care how many of reset controllers it has and how
144d66cc84cSDamien Heddemany of them have started a reset.
145d66cc84cSDamien Hedde
146dd6d545eSEric AugerDMA capable devices are expected to cancel all outstanding DMA operations
147dd6d545eSEric Augerduring either 'enter' or 'hold' phases. IOMMUs are expected to reset during
148dd6d545eSEric Augerthe 'exit' phase and this sequencing makes sure no outstanding DMA request
149dd6d545eSEric Augerwill fault.
150dd6d545eSEric Auger
151d66cc84cSDamien Hedde
152d66cc84cSDamien HeddeHandling reset in a resettable object
153d66cc84cSDamien Hedde-------------------------------------
154d66cc84cSDamien Hedde
155d66cc84cSDamien HeddeThis section documents the APIs that an implementation of a resettable object
156d66cc84cSDamien Heddemust provide and what functions it has access to. It is intended for people
157d66cc84cSDamien Heddewho want to implement or convert a class which has the resettable interface;
158d66cc84cSDamien Heddefor example when specializing an existing device or bus.
159d66cc84cSDamien Hedde
160d66cc84cSDamien HeddeMethods to implement
161d66cc84cSDamien Hedde....................
162d66cc84cSDamien Hedde
163d66cc84cSDamien HeddeThree methods should be defined or left empty. Each method corresponds to a
164d66cc84cSDamien Heddephase of the reset; they are name ``phases.enter()``, ``phases.hold()`` and
165d66cc84cSDamien Hedde``phases.exit()``. They all take the object as parameter. The *enter* method
166d66cc84cSDamien Heddealso take the reset type as second parameter.
167d66cc84cSDamien Hedde
168d66cc84cSDamien HeddeWhen extending an existing class, these methods may need to be extended too.
169d66cc84cSDamien HeddeThe ``resettable_class_set_parent_phases()`` class function may be used to
170d66cc84cSDamien Heddebackup parent class methods.
171d66cc84cSDamien Hedde
172d66cc84cSDamien HeddeHere follows an example to implement reset for a Device which sets an IO while
173d66cc84cSDamien Heddein reset.
174d66cc84cSDamien Hedde
175d66cc84cSDamien Hedde::
176d66cc84cSDamien Hedde
177d66cc84cSDamien Hedde    static void mydev_reset_enter(Object *obj, ResetType type)
178d66cc84cSDamien Hedde    {
179d66cc84cSDamien Hedde        MyDevClass *myclass = MYDEV_GET_CLASS(obj);
180d66cc84cSDamien Hedde        MyDevState *mydev = MYDEV(obj);
181d66cc84cSDamien Hedde        /* call parent class enter phase */
182d66cc84cSDamien Hedde        if (myclass->parent_phases.enter) {
183d66cc84cSDamien Hedde            myclass->parent_phases.enter(obj, type);
184d66cc84cSDamien Hedde        }
185d66cc84cSDamien Hedde        /* initialize local state only */
186d66cc84cSDamien Hedde        mydev->var = 0;
187d66cc84cSDamien Hedde    }
188d66cc84cSDamien Hedde
18941d49ec1SPeter Maydell    static void mydev_reset_hold(Object *obj, ResetType type)
190d66cc84cSDamien Hedde    {
191d66cc84cSDamien Hedde        MyDevClass *myclass = MYDEV_GET_CLASS(obj);
192d66cc84cSDamien Hedde        MyDevState *mydev = MYDEV(obj);
193d66cc84cSDamien Hedde        /* call parent class hold phase */
194d66cc84cSDamien Hedde        if (myclass->parent_phases.hold) {
19541d49ec1SPeter Maydell            myclass->parent_phases.hold(obj, type);
196d66cc84cSDamien Hedde        }
197d66cc84cSDamien Hedde        /* set an IO */
198d66cc84cSDamien Hedde        qemu_set_irq(mydev->irq, 1);
199d66cc84cSDamien Hedde    }
200d66cc84cSDamien Hedde
20141d49ec1SPeter Maydell    static void mydev_reset_exit(Object *obj, ResetType type)
202d66cc84cSDamien Hedde    {
203d66cc84cSDamien Hedde        MyDevClass *myclass = MYDEV_GET_CLASS(obj);
204d66cc84cSDamien Hedde        MyDevState *mydev = MYDEV(obj);
205d66cc84cSDamien Hedde        /* call parent class exit phase */
206d66cc84cSDamien Hedde        if (myclass->parent_phases.exit) {
20741d49ec1SPeter Maydell            myclass->parent_phases.exit(obj, type);
208d66cc84cSDamien Hedde        }
209d66cc84cSDamien Hedde        /* clear an IO */
210d66cc84cSDamien Hedde        qemu_set_irq(mydev->irq, 0);
211d66cc84cSDamien Hedde    }
212d66cc84cSDamien Hedde
213d66cc84cSDamien Hedde    typedef struct MyDevClass {
214d66cc84cSDamien Hedde        MyParentClass parent_class;
215d66cc84cSDamien Hedde        /* to store eventual parent reset methods */
216d66cc84cSDamien Hedde        ResettablePhases parent_phases;
217d66cc84cSDamien Hedde    } MyDevClass;
218d66cc84cSDamien Hedde
219*12d1a768SPhilippe Mathieu-Daudé    static void mydev_class_init(ObjectClass *class, const void *data)
220d66cc84cSDamien Hedde    {
221d66cc84cSDamien Hedde        MyDevClass *myclass = MYDEV_CLASS(class);
222d66cc84cSDamien Hedde        ResettableClass *rc = RESETTABLE_CLASS(class);
223fa365d05SAkihiko Odaki        resettable_class_set_parent_phases(rc,
224d66cc84cSDamien Hedde                                           mydev_reset_enter,
225d66cc84cSDamien Hedde                                           mydev_reset_hold,
226d66cc84cSDamien Hedde                                           mydev_reset_exit,
227d66cc84cSDamien Hedde                                           &myclass->parent_phases);
228d66cc84cSDamien Hedde    }
229d66cc84cSDamien Hedde
230d66cc84cSDamien HeddeIn the above example, we override all three phases. It is possible to override
231d66cc84cSDamien Heddeonly some of them by passing NULL instead of a function pointer to
232fa365d05SAkihiko Odaki``resettable_class_set_parent_phases()``. For example, the following will
233d66cc84cSDamien Heddeonly override the *enter* phase and leave *hold* and *exit* untouched::
234d66cc84cSDamien Hedde
235fa365d05SAkihiko Odaki    resettable_class_set_parent_phases(rc, mydev_reset_enter, NULL, NULL,
236d66cc84cSDamien Hedde                                       &myclass->parent_phases);
237d66cc84cSDamien Hedde
238d66cc84cSDamien HeddeThis is equivalent to providing a trivial implementation of the hold and exit
239d66cc84cSDamien Heddephases which does nothing but call the parent class's implementation of the
240d66cc84cSDamien Heddephase.
241d66cc84cSDamien Hedde
242d66cc84cSDamien HeddePolling the reset state
243d66cc84cSDamien Hedde.......................
244d66cc84cSDamien Hedde
245d66cc84cSDamien HeddeResettable interface provides the ``resettable_is_in_reset()`` function.
246d66cc84cSDamien HeddeThis function returns true if the object parameter is currently under reset.
247d66cc84cSDamien Hedde
248310616d3SDamien HeddeAn object is under reset from the beginning of the *enter* phase (before
249310616d3SDamien Heddeeither its children or its own enter method is called) to the *exit*
250310616d3SDamien Heddephase. During *enter* and *hold* phase only, the function will return that the
251310616d3SDamien Heddeobject is in reset. The state is changed after the *exit* is propagated to
252310616d3SDamien Heddeits children and just before calling the object's own *exit* method.
253d66cc84cSDamien Hedde
254d66cc84cSDamien HeddeThis function may be used if the object behavior has to be adapted
255d66cc84cSDamien Heddewhile in reset state. For example if a device has an irq input,
256d66cc84cSDamien Heddeit will probably need to ignore it while in reset; then it can for
257d66cc84cSDamien Heddeexample check the reset state at the beginning of the irq callback.
258d66cc84cSDamien Hedde
259d66cc84cSDamien HeddeNote that until migration of the reset state is supported, an object
260d66cc84cSDamien Heddeshould not be left in reset. So apart from being currently executing
261d66cc84cSDamien Heddeone of the reset phases, the only cases when this function will return
262d66cc84cSDamien Heddetrue is if an external interaction (like changing an io) is made during
263d66cc84cSDamien Hedde*hold* or *exit* phase of another object in the same reset group.
264d66cc84cSDamien Hedde
265d66cc84cSDamien HeddeHelpers ``device_is_in_reset()`` and ``bus_is_in_reset()`` are also provided
266d66cc84cSDamien Heddefor devices and buses and should be preferred.
267d66cc84cSDamien Hedde
268d66cc84cSDamien Hedde
269d66cc84cSDamien HeddeBase class handling of reset
270d66cc84cSDamien Hedde----------------------------
271d66cc84cSDamien Hedde
272d66cc84cSDamien HeddeThis section documents parts of the reset mechanism that you only need to know
273d66cc84cSDamien Heddeabout if you are extending it to work with a new base class other than
274d66cc84cSDamien HeddeDeviceClass or BusClass, or maintaining the existing code in those classes. Most
275d66cc84cSDamien Heddepeople can ignore it.
276d66cc84cSDamien Hedde
277d66cc84cSDamien HeddeMethods to implement
278d66cc84cSDamien Hedde....................
279d66cc84cSDamien Hedde
280d66cc84cSDamien HeddeThere are two other methods that need to exist in a class implementing the
281d66cc84cSDamien Heddeinterface: ``get_state()`` and ``child_foreach()``.
282d66cc84cSDamien Hedde
283d66cc84cSDamien Hedde``get_state()`` is simple. *resettable* is an interface and, as a consequence,
284d66cc84cSDamien Heddedoes not have any class state structure. But in order to factorize the code, we
285d66cc84cSDamien Heddeneed one. This method must return a pointer to ``ResettableState`` structure.
286d66cc84cSDamien HeddeThe structure must be allocated by the base class; preferably it should be
287d66cc84cSDamien Heddelocated inside the object instance structure.
288d66cc84cSDamien Hedde
289d66cc84cSDamien Hedde``child_foreach()`` is more complex. It should execute the given callback on
290d66cc84cSDamien Heddeevery reset child of the given resettable object. All children must be
291d66cc84cSDamien Hedderesettable too. Additional parameters (a reset type and an opaque pointer) must
292d66cc84cSDamien Heddebe passed to the callback too.
293d66cc84cSDamien Hedde
294361dfa97SPeter MaydellIn ``DeviceClass`` and ``BusClass`` the ``ResettableState`` is located in the
295361dfa97SPeter Maydell``DeviceState`` and ``BusState`` structures. ``child_foreach()`` is implemented
296d66cc84cSDamien Heddeto follow the bus hierarchy; for a bus, it calls the function on every child
297d66cc84cSDamien Heddedevice; for a device, it calls the function on every bus child. When we reset
298d66cc84cSDamien Heddethe main system bus, we reset the whole machine bus tree.
299d66cc84cSDamien Hedde
300d66cc84cSDamien HeddeChanging a resettable parent
301d66cc84cSDamien Hedde............................
302d66cc84cSDamien Hedde
303d66cc84cSDamien HeddeOne thing which should be taken care of by the base class is handling reset
304d66cc84cSDamien Heddehierarchy changes.
305d66cc84cSDamien Hedde
306d66cc84cSDamien HeddeThe reset hierarchy is supposed to be static and built during machine creation.
307d66cc84cSDamien HeddeBut there are actually some exceptions. To cope with this, the resettable API
308d66cc84cSDamien Heddeprovides ``resettable_change_parent()``. This function allows to set, update or
309d66cc84cSDamien Hedderemove the parent of a resettable object after machine creation is done. As
310d66cc84cSDamien Heddeparameters, it takes the object being moved, the old parent if any and the new
311d66cc84cSDamien Heddeparent if any.
312d66cc84cSDamien Hedde
313d66cc84cSDamien HeddeThis function can be used at any time when not in a reset operation. During
314d66cc84cSDamien Heddea reset operation it must be used only in *hold* phase. Using it in *enter* or
315d66cc84cSDamien Hedde*exit* phase is an error.
316d66cc84cSDamien HeddeAlso it should not be used during machine creation, although it is harmless to
317d66cc84cSDamien Heddedo so: the function is a no-op as long as old and new parent are NULL or not
318d66cc84cSDamien Heddein reset.
319d66cc84cSDamien Hedde
320d66cc84cSDamien HeddeThere is currently 2 cases where this function is used:
321d66cc84cSDamien Hedde
322d66cc84cSDamien Hedde1. *device hotplug*; it means a new device is introduced on a live bus.
323d66cc84cSDamien Hedde
324d66cc84cSDamien Hedde2. *hot bus change*; it means an existing live device is added, moved or
325d66cc84cSDamien Hedde   removed in the bus hierarchy. At the moment, it occurs only in the raspi
326d66cc84cSDamien Hedde   machines for changing the sdbus used by sd card.
327a365572bSPeter Maydell
328a365572bSPeter MaydellReset of the complete system
329a365572bSPeter Maydell----------------------------
330a365572bSPeter Maydell
331a365572bSPeter MaydellReset of the complete system is a little complicated. The typical
332a365572bSPeter Maydellflow is:
333a365572bSPeter Maydell
334a365572bSPeter Maydell1. Code which wishes to reset the entire system does so by calling
335a365572bSPeter Maydell   ``qemu_system_reset_request()``. This schedules a reset, but the
336a365572bSPeter Maydell   reset will happen asynchronously after the function returns.
337a365572bSPeter Maydell   That makes this safe to call from, for example, device models.
338a365572bSPeter Maydell
339a365572bSPeter Maydell2. The function which is called to make the reset happen is
340a365572bSPeter Maydell   ``qemu_system_reset()``. Generally only core system code should
341a365572bSPeter Maydell   call this directly.
342a365572bSPeter Maydell
343a365572bSPeter Maydell3. ``qemu_system_reset()`` calls the ``MachineClass::reset`` method of
344a365572bSPeter Maydell   the current machine, if it has one. That method must call
345a365572bSPeter Maydell   ``qemu_devices_reset()``. If the machine has no reset method,
346a365572bSPeter Maydell   ``qemu_system_reset()`` calls ``qemu_devices_reset()`` directly.
347a365572bSPeter Maydell
348a365572bSPeter Maydell4. ``qemu_devices_reset()`` performs a reset of the system, using
349a365572bSPeter Maydell   the three-phase mechanism listed above. It resets all objects
350a365572bSPeter Maydell   that were registered with it using ``qemu_register_resettable()``.
351a365572bSPeter Maydell   It also calls all the functions registered with it using
352a365572bSPeter Maydell   ``qemu_register_reset()``. Those functions are called during the
353a365572bSPeter Maydell   "hold" phase of this reset.
354a365572bSPeter Maydell
355a365572bSPeter Maydell5. The most important object that this reset resets is the
356a365572bSPeter Maydell   'sysbus' bus. The sysbus bus is the root of the qbus tree. This
357a365572bSPeter Maydell   means that all devices on the sysbus are reset, and all their
358a365572bSPeter Maydell   child buses, and all the devices on those child buses.
359a365572bSPeter Maydell
360a365572bSPeter Maydell6. Devices which are not on the qbus tree are *not* automatically
361a365572bSPeter Maydell   reset! (The most obvious example of this is CPU objects, but
362a365572bSPeter Maydell   anything that directly inherits from ``TYPE_OBJECT`` or ``TYPE_DEVICE``
363a365572bSPeter Maydell   rather than from ``TYPE_SYS_BUS_DEVICE`` or some other plugs-into-a-bus
364a365572bSPeter Maydell   type will be in this category.) You need to therefore arrange for these
365a365572bSPeter Maydell   to be reset in some other way (e.g. using ``qemu_register_resettable()``
366a365572bSPeter Maydell   or ``qemu_register_reset()``).
367