Revision ff06108b

b/hw/fw_cfg.c
39 39
#define FW_CFG_SIZE 2
40 40

  
41 41
typedef struct _FWCfgEntry {
42
    uint16_t len;
42
    uint32_t len;
43 43
    uint8_t *data;
44 44
    void *callback_opaque;
45 45
    FWCfgCallback callback;
......
48 48
typedef struct _FWCfgState {
49 49
    FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
50 50
    uint16_t cur_entry;
51
    uint16_t cur_offset;
51
    uint32_t cur_offset;
52 52
} FWCfgState;
53 53

  
54 54
static void fw_cfg_write(FWCfgState *s, uint8_t value)
......
164 164
    fw_cfg_select(s, 0);
165 165
}
166 166

  
167
/* Save restore 32 bit int as uint16_t
168
   This is a Big hack, but it is how the old state did it.
169
   Or we broke compatibility in the state, or we can't use struct tm
170
 */
171

  
172
static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size)
173
{
174
    uint32_t *v = pv;
175
    *v = qemu_get_be16(f);
176
    return 0;
177
}
178

  
179
static void put_unused(QEMUFile *f, void *pv, size_t size)
180
{
181
    fprintf(stderr, "uint32_as_uint16 is only used for backward compatibilty.\n");
182
    fprintf(stderr, "This functions shouldn't be called.\n");
183
}
184

  
185
const VMStateInfo vmstate_hack_uint32_as_uint16 = {
186
    .name = "int32_as_uint16",
187
    .get  = get_uint32_as_uint16,
188
    .put  = put_unused,
189
};
190

  
191
#define VMSTATE_UINT16_HACK(_f, _s, _t)                                    \
192
    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t)
193

  
194

  
195
static bool is_version_1(void *opaque, int version_id)
196
{
197
    return version_id == 1;
198
}
199

  
167 200
static const VMStateDescription vmstate_fw_cfg = {
168 201
    .name = "fw_cfg",
169
    .version_id = 1,
202
    .version_id = 2,
170 203
    .minimum_version_id = 1,
171 204
    .minimum_version_id_old = 1,
172 205
    .fields      = (VMStateField []) {
173 206
        VMSTATE_UINT16(cur_entry, FWCfgState),
174
        VMSTATE_UINT16(cur_offset, FWCfgState),
207
        VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
208
        VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
175 209
        VMSTATE_END_OF_LIST()
176 210
    }
177 211
};
178 212

  
179
int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint16_t len)
213
int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len)
180 214
{
181 215
    FWCfgState *s = opaque;
182 216
    int arch = !!(key & FW_CFG_ARCH_LOCAL);
b/hw/fw_cfg.h
28 28
#ifndef NO_QEMU_PROTOS
29 29
typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
30 30

  
31
int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint16_t len);
31
int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len);
32 32
int fw_cfg_add_i16(void *opaque, uint16_t key, uint16_t value);
33 33
int fw_cfg_add_i32(void *opaque, uint16_t key, uint32_t value);
34 34
int fw_cfg_add_i64(void *opaque, uint16_t key, uint64_t value);

Also available in: Unified diff