qdev: add IOThreadVirtQueueMappingList property type
[qemu/ar7.git] / hw / core / clock-vmstate.c
blob7eccb6d4eaa354cd782c3191a33344561e8248d6
1 /*
2 * Clock migration structure
4 * Copyright GreenSocs 2019-2020
6 * Authors:
7 * Damien Hedde
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "migration/vmstate.h"
15 #include "hw/clock.h"
17 static bool muldiv_needed(void *opaque)
19 Clock *clk = opaque;
21 return clk->multiplier != 1 || clk->divider != 1;
24 static int clock_pre_load(void *opaque)
26 Clock *clk = opaque;
28 * The initial out-of-reset settings of the Clock might have been
29 * configured by the device to be different from what we set
30 * in clock_initfn(), so we must here set the default values to
31 * be used if they are not in the inbound migration state.
33 clk->multiplier = 1;
34 clk->divider = 1;
36 return 0;
39 const VMStateDescription vmstate_muldiv = {
40 .name = "clock/muldiv",
41 .version_id = 1,
42 .minimum_version_id = 1,
43 .needed = muldiv_needed,
44 .fields = (VMStateField[]) {
45 VMSTATE_UINT32(multiplier, Clock),
46 VMSTATE_UINT32(divider, Clock),
47 VMSTATE_END_OF_LIST()
51 const VMStateDescription vmstate_clock = {
52 .name = "clock",
53 .version_id = 0,
54 .minimum_version_id = 0,
55 .pre_load = clock_pre_load,
56 .fields = (VMStateField[]) {
57 VMSTATE_UINT64(period, Clock),
58 VMSTATE_END_OF_LIST()
60 .subsections = (const VMStateDescription*[]) {
61 &vmstate_muldiv,
62 NULL