hw/core/resettable: add support for changing parent

Add a function resettable_change_parent() to do the required
plumbing when changing the parent a of Resettable object.

We need to make sure that the reset state of the object remains
coherent with the reset state of the new parent.

We make the 2 following hypothesis:
+ when an object is put in a parent under reset, the object goes in
reset.
+ when an object is removed from a parent under reset, the object
leaves reset.

The added function avoids any glitch if both old and new parent are
already in reset.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200123132823.1117486-6-damien.hedde@greensocs.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Damien Hedde 2020-01-30 16:02:04 +00:00 committed by Peter Maydell
parent c11256aa6f
commit 614f731adb
3 changed files with 77 additions and 2 deletions

View file

@ -194,6 +194,22 @@ void resettable_release_reset(Object *obj, ResetType type);
*/
bool resettable_is_in_reset(Object *obj);
/**
* resettable_change_parent:
* Indicate that the parent of Ressettable @obj is changing from @oldp to @newp.
* All 3 objects must implement resettable interface. @oldp or @newp may be
* NULL.
*
* This function will adapt the reset state of @obj so that it is coherent
* with the reset state of @newp. It may trigger @resettable_assert_reset()
* or @resettable_release_reset(). It will do such things only if the reset
* state of @newp and @oldp are different.
*
* When using this function during reset, it must only be called during
* a hold phase method. Calling this during enter or exit phase is an error.
*/
void resettable_change_parent(Object *obj, Object *newp, Object *oldp);
/**
* resettable_class_set_parent_phases:
*