Revert r5274 which breaks savevm/loadvm

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5321 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2008-09-25 20:24:19 +00:00
parent 59e0fbf8e9
commit 2ca83a8dd6
12 changed files with 78 additions and 183 deletions

View File

@ -102,8 +102,8 @@ typedef struct E1000State_st {
uint32_t paylen;
uint16_t tso_frames;
char tse;
int8_t ip;
int8_t tcp;
char ip;
char tcp;
char cptse; // current packet tse bit
} tx;
@ -824,8 +824,8 @@ nic_save(QEMUFile *f, void *opaque)
qemu_put_be16s(f, &s->tx.size);
qemu_put_be16s(f, &s->tx.tso_frames);
qemu_put_8s(f, &s->tx.sum_needed);
qemu_put_s8s(f, &s->tx.ip);
qemu_put_s8s(f, &s->tx.tcp);
qemu_put_8s(f, &s->tx.ip);
qemu_put_8s(f, &s->tx.tcp);
qemu_put_buffer(f, s->tx.header, sizeof s->tx.header);
qemu_put_buffer(f, s->tx.data, sizeof s->tx.data);
for (i = 0; i < 64; i++)
@ -849,7 +849,7 @@ nic_load(QEMUFile *f, void *opaque, int version_id)
if ((ret = pci_device_load(&s->dev, f)) < 0)
return ret;
if (version_id == 1)
qemu_get_sbe32s(f, &i); /* once some unused instance id */
qemu_get_be32s(f, &i); /* once some unused instance id */
qemu_get_be32s(f, &s->mmio_base);
qemu_get_be32s(f, &s->rxbuf_size);
qemu_get_be32s(f, &s->rxbuf_min_shift);
@ -870,8 +870,8 @@ nic_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_be16s(f, &s->tx.size);
qemu_get_be16s(f, &s->tx.tso_frames);
qemu_get_8s(f, &s->tx.sum_needed);
qemu_get_s8s(f, &s->tx.ip);
qemu_get_s8s(f, &s->tx.tcp);
qemu_get_8s(f, &s->tx.ip);
qemu_get_8s(f, &s->tx.tcp);
qemu_get_buffer(f, s->tx.header, sizeof s->tx.header);
qemu_get_buffer(f, s->tx.data, sizeof s->tx.data);
for (i = 0; i < 64; i++)

View File

@ -578,7 +578,7 @@ static void esp_save(QEMUFile *f, void *opaque)
qemu_put_buffer(f, s->rregs, ESP_REGS);
qemu_put_buffer(f, s->wregs, ESP_REGS);
qemu_put_sbe32s(f, &s->ti_size);
qemu_put_be32s(f, (uint32_t *)&s->ti_size);
qemu_put_be32s(f, &s->ti_rptr);
qemu_put_be32s(f, &s->ti_wptr);
qemu_put_buffer(f, s->ti_buf, TI_BUFSZ);
@ -600,7 +600,7 @@ static int esp_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_buffer(f, s->rregs, ESP_REGS);
qemu_get_buffer(f, s->wregs, ESP_REGS);
qemu_get_sbe32s(f, &s->ti_size);
qemu_get_be32s(f, (uint32_t *)&s->ti_size);
qemu_get_be32s(f, &s->ti_rptr);
qemu_get_be32s(f, &s->ti_wptr);
qemu_get_buffer(f, s->ti_buf, TI_BUFSZ);

121
hw/hw.h
View File

@ -10,31 +10,15 @@
QEMUFile *qemu_fopen(const char *filename, const char *mode);
void qemu_fflush(QEMUFile *f);
void qemu_fclose(QEMUFile *f);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
void qemu_put_byte(QEMUFile *f, int8_t v);
static inline void qemu_put_ubyte(QEMUFile *f, uint8_t v)
{
qemu_put_byte(f, (int8_t)v);
}
#define qemu_put_sbyte qemu_put_byte
void qemu_put_be16(QEMUFile *f, uint16_t v);
void qemu_put_be32(QEMUFile *f, uint32_t v);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
void qemu_put_byte(QEMUFile *f, int v);
void qemu_put_be16(QEMUFile *f, unsigned int v);
void qemu_put_be32(QEMUFile *f, unsigned int v);
void qemu_put_be64(QEMUFile *f, uint64_t v);
size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
int8_t qemu_get_byte(QEMUFile *f);
static inline uint8_t qemu_get_ubyte(QEMUFile *f)
{
return (uint8_t)qemu_get_byte(f);
}
#define qemu_get_sbyte qemu_get_byte
uint16_t qemu_get_be16(QEMUFile *f);
uint32_t qemu_get_be32(QEMUFile *f);
int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
int qemu_get_byte(QEMUFile *f);
unsigned int qemu_get_be16(QEMUFile *f);
unsigned int qemu_get_be32(QEMUFile *f);
uint64_t qemu_get_be64(QEMUFile *f);
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
@ -77,106 +61,17 @@ static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
*pv = qemu_get_byte(f);
}
// Signed versions for type safety
static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, size_t size)
{
qemu_put_buffer(f, (const uint8_t *)buf, size);
}
static inline void qemu_put_sbe16(QEMUFile *f, int16_t v)
{
qemu_put_be16(f, (uint16_t)v);
}
static inline void qemu_put_sbe32(QEMUFile *f, int32_t v)
{
qemu_put_be32(f, (uint32_t)v);
}
static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
{
qemu_put_be64(f, (uint64_t)v);
}
static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, size_t size)
{
return qemu_get_buffer(f, (uint8_t *)buf, size);
}
static inline int16_t qemu_get_sbe16(QEMUFile *f)
{
return (int16_t)qemu_get_be16(f);
}
static inline int32_t qemu_get_sbe32(QEMUFile *f)
{
return (int32_t)qemu_get_be32(f);
}
static inline int64_t qemu_get_sbe64(QEMUFile *f)
{
return (int64_t)qemu_get_be64(f);
}
static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
{
qemu_put_8s(f, (const uint8_t *)pv);
}
static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
{
qemu_put_be16s(f, (const uint16_t *)pv);
}
static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
{
qemu_put_be32s(f, (const uint32_t *)pv);
}
static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
{
qemu_put_be64s(f, (const uint64_t *)pv);
}
static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
{
qemu_get_8s(f, (uint8_t *)pv);
}
static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
{
qemu_get_be16s(f, (uint16_t *)pv);
}
static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
{
qemu_get_be32s(f, (uint32_t *)pv);
}
static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
{
qemu_get_be64s(f, (uint64_t *)pv);
}
#ifdef NEED_CPU_H
#if TARGET_LONG_BITS == 64
#define qemu_put_betl qemu_put_be64
#define qemu_get_betl qemu_get_be64
#define qemu_put_betls qemu_put_be64s
#define qemu_get_betls qemu_get_be64s
#define qemu_put_sbetl qemu_put_sbe64
#define qemu_get_sbetl qemu_get_sbe64
#define qemu_put_sbetls qemu_put_sbe64s
#define qemu_get_sbetls qemu_get_sbe64s
#else
#define qemu_put_betl qemu_put_be32
#define qemu_get_betl qemu_get_be32
#define qemu_put_betls qemu_put_be32s
#define qemu_get_betls qemu_get_be32s
#define qemu_put_sbetl qemu_put_sbe32
#define qemu_get_sbetl qemu_get_sbe32
#define qemu_put_sbetls qemu_put_sbe32s
#define qemu_get_sbetls qemu_get_sbe32s
#endif
#endif

View File

@ -1877,9 +1877,9 @@ static void pcnet_save(QEMUFile *f, void *opaque)
if (s->pci_dev)
pci_device_save(s->pci_dev, f);
qemu_put_sbe32(f, s->rap);
qemu_put_sbe32(f, s->isr);
qemu_put_sbe32(f, s->lnkst);
qemu_put_be32(f, s->rap);
qemu_put_be32(f, s->isr);
qemu_put_be32(f, s->lnkst);
qemu_put_be32s(f, &s->rdra);
qemu_put_be32s(f, &s->tdra);
qemu_put_buffer(f, s->prom, 16);
@ -1888,10 +1888,10 @@ static void pcnet_save(QEMUFile *f, void *opaque)
for (i = 0; i < 32; i++)
qemu_put_be16s(f, &s->bcr[i]);
qemu_put_be64s(f, &s->timer);
qemu_put_sbe32(f, s->xmit_pos);
qemu_put_sbe32(f, s->recv_pos);
qemu_put_be32(f, s->xmit_pos);
qemu_put_be32(f, s->recv_pos);
qemu_put_buffer(f, s->buffer, 4096);
qemu_put_sbe32(f, s->tx_busy);
qemu_put_be32(f, s->tx_busy);
qemu_put_timer(f, s->poll_timer);
}
@ -1909,9 +1909,9 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id)
return ret;
}
qemu_get_sbe32s(f, &s->rap);
qemu_get_sbe32s(f, &s->isr);
qemu_get_sbe32s(f, &s->lnkst);
qemu_get_be32s(f, (uint32_t*)&s->rap);
qemu_get_be32s(f, (uint32_t*)&s->isr);
qemu_get_be32s(f, (uint32_t*)&s->lnkst);
qemu_get_be32s(f, &s->rdra);
qemu_get_be32s(f, &s->tdra);
qemu_get_buffer(f, s->prom, 16);
@ -1920,10 +1920,10 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id)
for (i = 0; i < 32; i++)
qemu_get_be16s(f, &s->bcr[i]);
qemu_get_be64s(f, &s->timer);
qemu_get_sbe32s(f, &s->xmit_pos);
qemu_get_sbe32s(f, &s->recv_pos);
qemu_get_be32s(f, (uint32_t*)&s->xmit_pos);
qemu_get_be32s(f, (uint32_t*)&s->recv_pos);
qemu_get_buffer(f, s->buffer, 4096);
qemu_get_sbe32s(f, &s->tx_busy);
qemu_get_be32s(f, (uint32_t*)&s->tx_busy);
qemu_get_timer(f, s->poll_timer);
return 0;

View File

@ -165,9 +165,9 @@ void qemu_put_ptimer(QEMUFile *f, ptimer_state *s)
qemu_put_be64s(f, &s->limit);
qemu_put_be64s(f, &s->delta);
qemu_put_be32s(f, &s->period_frac);
qemu_put_sbe64s(f, &s->period);
qemu_put_sbe64s(f, &s->last_event);
qemu_put_sbe64s(f, &s->next_event);
qemu_put_be64s(f, &s->period);
qemu_put_be64s(f, &s->last_event);
qemu_put_be64s(f, &s->next_event);
qemu_put_timer(f, s->timer);
}
@ -177,9 +177,9 @@ void qemu_get_ptimer(QEMUFile *f, ptimer_state *s)
qemu_get_be64s(f, &s->limit);
qemu_get_be64s(f, &s->delta);
qemu_get_be32s(f, &s->period_frac);
qemu_get_sbe64s(f, &s->period);
qemu_get_sbe64s(f, &s->last_event);
qemu_get_sbe64s(f, &s->next_event);
qemu_get_be64s(f, &s->period);
qemu_get_be64s(f, &s->last_event);
qemu_get_be64s(f, &s->next_event);
qemu_get_timer(f, s->timer);
}

View File

@ -1233,9 +1233,9 @@ static void pxa2xx_rtc_save(QEMUFile *f, void *opaque)
qemu_put_be32s(f, &s->last_rycr);
qemu_put_be32s(f, &s->last_swcr);
qemu_put_be32s(f, &s->last_rtcpicr);
qemu_put_sbe64s(f, &s->last_hz);
qemu_put_sbe64s(f, &s->last_sw);
qemu_put_sbe64s(f, &s->last_pi);
qemu_put_be64s(f, (uint64_t *) &s->last_hz);
qemu_put_be64s(f, (uint64_t *) &s->last_sw);
qemu_put_be64s(f, (uint64_t *) &s->last_pi);
}
static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id)
@ -1257,9 +1257,9 @@ static int pxa2xx_rtc_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_be32s(f, &s->last_rycr);
qemu_get_be32s(f, &s->last_swcr);
qemu_get_be32s(f, &s->last_rtcpicr);
qemu_get_sbe64s(f, &s->last_hz);
qemu_get_sbe64s(f, &s->last_sw);
qemu_get_sbe64s(f, &s->last_pi);
qemu_get_be64s(f, (uint64_t *) &s->last_hz);
qemu_get_be64s(f, (uint64_t *) &s->last_sw);
qemu_get_be64s(f, (uint64_t *) &s->last_pi);
pxa2xx_rtc_alarm_update(s, s->rtsr);

View File

@ -384,8 +384,8 @@ static void pxa2xx_timer_save(QEMUFile *f, void *opaque)
for (i = 0; i < 8; i ++) {
qemu_put_be32s(f, &s->tm4[i].tm.value);
qemu_put_be32(f, s->tm4[i].tm.level);
qemu_put_sbe32s(f, &s->tm4[i].oldclock);
qemu_put_sbe32s(f, &s->tm4[i].clock);
qemu_put_be32s(f, (uint32_t *) &s->tm4[i].oldclock);
qemu_put_be32s(f, (uint32_t *) &s->tm4[i].clock);
qemu_put_be64s(f, &s->tm4[i].lastload);
qemu_put_be32s(f, &s->tm4[i].freq);
qemu_put_be32s(f, &s->tm4[i].control);
@ -418,8 +418,8 @@ static int pxa2xx_timer_load(QEMUFile *f, void *opaque, int version_id)
for (i = 0; i < 8; i ++) {
qemu_get_be32s(f, &s->tm4[i].tm.value);
s->tm4[i].tm.level = qemu_get_be32(f);
qemu_get_sbe32s(f, &s->tm4[i].oldclock);
qemu_get_sbe32s(f, &s->tm4[i].clock);
qemu_get_be32s(f, (uint32_t *) &s->tm4[i].oldclock);
qemu_get_be32s(f, (uint32_t *) &s->tm4[i].clock);
qemu_get_be64s(f, &s->tm4[i].lastload);
qemu_get_be32s(f, &s->tm4[i].freq);
qemu_get_be32s(f, &s->tm4[i].control);

View File

@ -372,9 +372,9 @@ static void tcx_save(QEMUFile *f, void *opaque)
{
TCXState *s = opaque;
qemu_put_be16s(f, &s->height);
qemu_put_be16s(f, &s->width);
qemu_put_be16s(f, &s->depth);
qemu_put_be16s(f, (uint16_t *)&s->height);
qemu_put_be16s(f, (uint16_t *)&s->width);
qemu_put_be16s(f, (uint16_t *)&s->depth);
qemu_put_buffer(f, s->r, 256);
qemu_put_buffer(f, s->g, 256);
qemu_put_buffer(f, s->b, 256);
@ -391,13 +391,13 @@ static int tcx_load(QEMUFile *f, void *opaque, int version_id)
return -EINVAL;
if (version_id == 3) {
qemu_get_be32s(f, &dummy);
qemu_get_be32s(f, &dummy);
qemu_get_be32s(f, &dummy);
qemu_get_be32s(f, (uint32_t *)&dummy);
qemu_get_be32s(f, (uint32_t *)&dummy);
qemu_get_be32s(f, (uint32_t *)&dummy);
}
qemu_get_be16s(f, &s->height);
qemu_get_be16s(f, &s->width);
qemu_get_be16s(f, &s->depth);
qemu_get_be16s(f, (uint16_t *)&s->height);
qemu_get_be16s(f, (uint16_t *)&s->width);
qemu_get_be16s(f, (uint16_t *)&s->depth);
qemu_get_buffer(f, s->r, 256);
qemu_get_buffer(f, s->g, 256);
qemu_get_buffer(f, s->b, 256);

View File

@ -185,9 +185,9 @@ static void tmp105_save(QEMUFile *f, void *opaque)
qemu_put_8s(f, &s->pointer);
qemu_put_8s(f, &s->config);
qemu_put_sbe16s(f, &s->temperature);
qemu_put_sbe16s(f, &s->limit[0]);
qemu_put_sbe16s(f, &s->limit[1]);
qemu_put_be16s(f, (uint16_t *) &s->temperature);
qemu_put_be16s(f, (uint16_t *) &s->limit[0]);
qemu_put_be16s(f, (uint16_t *) &s->limit[1]);
qemu_put_byte(f, s->alarm);
s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
@ -204,9 +204,9 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->pointer);
qemu_get_8s(f, &s->config);
qemu_get_sbe16s(f, &s->temperature);
qemu_get_sbe16s(f, &s->limit[0]);
qemu_get_sbe16s(f, &s->limit[1]);
qemu_get_be16s(f, (uint16_t *) &s->temperature);
qemu_get_be16s(f, (uint16_t *) &s->limit[0]);
qemu_get_be16s(f, (uint16_t *) &s->limit[1]);
s->alarm = qemu_get_byte(f);
tmp105_interrupt_update(s);

View File

@ -1046,8 +1046,8 @@ static void tsc210x_save(QEMUFile *f, void *opaque)
qemu_put_be16s(f, &s->pll[0]);
qemu_put_be16s(f, &s->pll[1]);
qemu_put_be16s(f, &s->volume);
qemu_put_sbe64(f, (s->volume_change - now));
qemu_put_sbe64(f, (s->powerdown - now));
qemu_put_be64(f, (uint64_t) (s->volume_change - now));
qemu_put_be64(f, (uint64_t) (s->powerdown - now));
qemu_put_byte(f, s->softstep);
qemu_put_be16s(f, &s->dac_power);
@ -1092,8 +1092,8 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_be16s(f, &s->pll[0]);
qemu_get_be16s(f, &s->pll[1]);
qemu_get_be16s(f, &s->volume);
s->volume_change = qemu_get_sbe64(f) + now;
s->powerdown = qemu_get_sbe64(f) + now;
s->volume_change = (int64_t) qemu_get_be64(f) + now;
s->powerdown = (int64_t) qemu_get_be64(f) + now;
s->softstep = qemu_get_byte(f);
qemu_get_be16s(f, &s->dac_power);

View File

@ -102,7 +102,7 @@ void cpu_save(QEMUFile *f, void *opaque)
/* MMU */
a20_mask = (int32_t) env->a20_mask;
qemu_put_sbe32s(f, &a20_mask);
qemu_put_be32s(f, &a20_mask);
/* XMM */
qemu_put_be32s(f, &env->mxcsr);
@ -261,7 +261,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_betls(f, &env->dr[i]);
/* MMU */
qemu_get_sbe32s(f, &a20_mask);
qemu_get_be32s(f, &a20_mask);
env->a20_mask = a20_mask;
qemu_get_be32s(f, &env->mxcsr);

24
vl.c
View File

@ -6247,9 +6247,9 @@ void qemu_fclose(QEMUFile *f)
qemu_free(f);
}
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size)
{
size_t l;
int l;
while (size > 0) {
l = IO_BUF_SIZE - f->buf_index;
if (l > size)
@ -6263,16 +6263,16 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size)
}
}
void qemu_put_byte(QEMUFile *f, int8_t v)
void qemu_put_byte(QEMUFile *f, int v)
{
f->buf[f->buf_index++] = v;
if (f->buf_index >= IO_BUF_SIZE)
qemu_fflush(f);
}
size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size1)
int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1)
{
size_t size, l;
int size, l;
size = size1;
while (size > 0) {
@ -6293,7 +6293,7 @@ size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size1)
return size1 - size;
}
int8_t qemu_get_byte(QEMUFile *f)
int qemu_get_byte(QEMUFile *f)
{
if (f->buf_index >= f->buf_size) {
qemu_fill_buffer(f);
@ -6329,13 +6329,13 @@ int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence)
return pos;
}
void qemu_put_be16(QEMUFile *f, uint16_t v)
void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}
void qemu_put_be32(QEMUFile *f, uint32_t v)
void qemu_put_be32(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 24);
qemu_put_byte(f, v >> 16);
@ -6349,17 +6349,17 @@ void qemu_put_be64(QEMUFile *f, uint64_t v)
qemu_put_be32(f, v);
}
uint16_t qemu_get_be16(QEMUFile *f)
unsigned int qemu_get_be16(QEMUFile *f)
{
uint16_t v;
unsigned int v;
v = qemu_get_byte(f) << 8;
v |= qemu_get_byte(f);
return v;
}
uint32_t qemu_get_be32(QEMUFile *f)
unsigned int qemu_get_be32(QEMUFile *f)
{
uint32_t v;
unsigned int v;
v = qemu_get_byte(f) << 24;
v |= qemu_get_byte(f) << 16;
v |= qemu_get_byte(f) << 8;