uint32_t paylen;
uint16_t tso_frames;
char tse;
- char ip;
- char tcp;
+ int8_t ip;
+ int8_t tcp;
char cptse; // current packet tse bit
} tx;
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_8s(f, &s->tx.ip);
- qemu_put_8s(f, &s->tx.tcp);
+ qemu_put_s8s(f, &s->tx.ip);
+ qemu_put_s8s(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++)
if ((ret = pci_device_load(&s->dev, f)) < 0)
return ret;
if (version_id == 1)
- qemu_get_be32s(f, &i); /* once some unused instance id */
+ qemu_get_sbe32s(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);
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_8s(f, &s->tx.ip);
- qemu_get_8s(f, &s->tx.tcp);
+ qemu_get_s8s(f, &s->tx.ip);
+ qemu_get_s8s(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++)
qemu_put_buffer(f, s->rregs, ESP_REGS);
qemu_put_buffer(f, s->wregs, ESP_REGS);
- qemu_put_be32s(f, (uint32_t *)&s->ti_size);
+ qemu_put_sbe32s(f, &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);
qemu_get_buffer(f, s->rregs, ESP_REGS);
qemu_get_buffer(f, s->wregs, ESP_REGS);
- qemu_get_be32s(f, (uint32_t *)&s->ti_size);
+ qemu_get_sbe32s(f, &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);
int qemu_fclose(QEMUFile *f);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
void qemu_put_byte(QEMUFile *f, int v);
+
+static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
+{
+ qemu_put_byte(f, (int)v);
+}
+
+#define qemu_put_sbyte qemu_put_byte
+
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);
int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
int qemu_get_byte(QEMUFile *f);
+
+static inline unsigned int qemu_get_ubyte(QEMUFile *f)
+{
+ return (unsigned int)qemu_get_byte(f);
+}
+
+#define qemu_get_sbyte qemu_get_byte
+
unsigned int qemu_get_be16(QEMUFile *f);
unsigned int qemu_get_be32(QEMUFile *f);
uint64_t qemu_get_be64(QEMUFile *f);
*pv = qemu_get_byte(f);
}
+// Signed versions for type safety
+static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size)
+{
+ qemu_put_buffer(f, (const uint8_t *)buf, size);
+}
+
+static inline void qemu_put_sbe16(QEMUFile *f, int v)
+{
+ qemu_put_be16(f, (unsigned int)v);
+}
+
+static inline void qemu_put_sbe32(QEMUFile *f, int v)
+{
+ qemu_put_be32(f, (unsigned int)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, int size)
+{
+ return qemu_get_buffer(f, (uint8_t *)buf, size);
+}
+
+static inline int qemu_get_sbe16(QEMUFile *f)
+{
+ return (int)qemu_get_be16(f);
+}
+
+static inline int qemu_get_sbe32(QEMUFile *f)
+{
+ return (int)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
if (s->pci_dev)
pci_device_save(s->pci_dev, f);
- qemu_put_be32(f, s->rap);
- qemu_put_be32(f, s->isr);
- qemu_put_be32(f, s->lnkst);
+ qemu_put_sbe32(f, s->rap);
+ qemu_put_sbe32(f, s->isr);
+ qemu_put_sbe32(f, s->lnkst);
qemu_put_be32s(f, &s->rdra);
qemu_put_be32s(f, &s->tdra);
qemu_put_buffer(f, s->prom, 16);
for (i = 0; i < 32; i++)
qemu_put_be16s(f, &s->bcr[i]);
qemu_put_be64s(f, &s->timer);
- qemu_put_be32(f, s->xmit_pos);
- qemu_put_be32(f, s->recv_pos);
+ qemu_put_sbe32(f, s->xmit_pos);
+ qemu_put_sbe32(f, s->recv_pos);
qemu_put_buffer(f, s->buffer, 4096);
- qemu_put_be32(f, s->tx_busy);
+ qemu_put_sbe32(f, s->tx_busy);
qemu_put_timer(f, s->poll_timer);
}
return ret;
}
- 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_sbe32s(f, &s->rap);
+ qemu_get_sbe32s(f, &s->isr);
+ qemu_get_sbe32s(f, &s->lnkst);
qemu_get_be32s(f, &s->rdra);
qemu_get_be32s(f, &s->tdra);
qemu_get_buffer(f, s->prom, 16);
for (i = 0; i < 32; i++)
qemu_get_be16s(f, &s->bcr[i]);
qemu_get_be64s(f, &s->timer);
- qemu_get_be32s(f, (uint32_t*)&s->xmit_pos);
- qemu_get_be32s(f, (uint32_t*)&s->recv_pos);
+ qemu_get_sbe32s(f, &s->xmit_pos);
+ qemu_get_sbe32s(f, &s->recv_pos);
qemu_get_buffer(f, s->buffer, 4096);
- qemu_get_be32s(f, (uint32_t*)&s->tx_busy);
+ qemu_get_sbe32s(f, &s->tx_busy);
qemu_get_timer(f, s->poll_timer);
return 0;
qemu_put_be64s(f, &s->limit);
qemu_put_be64s(f, &s->delta);
qemu_put_be32s(f, &s->period_frac);
- qemu_put_be64s(f, &s->period);
- qemu_put_be64s(f, &s->last_event);
- qemu_put_be64s(f, &s->next_event);
+ qemu_put_sbe64s(f, &s->period);
+ qemu_put_sbe64s(f, &s->last_event);
+ qemu_put_sbe64s(f, &s->next_event);
qemu_put_timer(f, s->timer);
}
qemu_get_be64s(f, &s->limit);
qemu_get_be64s(f, &s->delta);
qemu_get_be32s(f, &s->period_frac);
- qemu_get_be64s(f, &s->period);
- qemu_get_be64s(f, &s->last_event);
- qemu_get_be64s(f, &s->next_event);
+ qemu_get_sbe64s(f, &s->period);
+ qemu_get_sbe64s(f, &s->last_event);
+ qemu_get_sbe64s(f, &s->next_event);
qemu_get_timer(f, s->timer);
}
qemu_put_be32s(f, &s->last_rycr);
qemu_put_be32s(f, &s->last_swcr);
qemu_put_be32s(f, &s->last_rtcpicr);
- 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);
+ qemu_put_sbe64s(f, &s->last_hz);
+ qemu_put_sbe64s(f, &s->last_sw);
+ qemu_put_sbe64s(f, &s->last_pi);
}
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_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);
+ qemu_get_sbe64s(f, &s->last_hz);
+ qemu_get_sbe64s(f, &s->last_sw);
+ qemu_get_sbe64s(f, &s->last_pi);
pxa2xx_rtc_alarm_update(s, s->rtsr);
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_be32s(f, (uint32_t *) &s->tm4[i].oldclock);
- qemu_put_be32s(f, (uint32_t *) &s->tm4[i].clock);
+ qemu_put_sbe32s(f, &s->tm4[i].oldclock);
+ qemu_put_sbe32s(f, &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);
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_be32s(f, (uint32_t *) &s->tm4[i].oldclock);
- qemu_get_be32s(f, (uint32_t *) &s->tm4[i].clock);
+ qemu_get_sbe32s(f, &s->tm4[i].oldclock);
+ qemu_get_sbe32s(f, &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);
{
TCXState *s = opaque;
- 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_be16s(f, &s->height);
+ qemu_put_be16s(f, &s->width);
+ qemu_put_be16s(f, &s->depth);
qemu_put_buffer(f, s->r, 256);
qemu_put_buffer(f, s->g, 256);
qemu_put_buffer(f, s->b, 256);
return -EINVAL;
if (version_id == 3) {
- qemu_get_be32s(f, (uint32_t *)&dummy);
- qemu_get_be32s(f, (uint32_t *)&dummy);
- qemu_get_be32s(f, (uint32_t *)&dummy);
+ qemu_get_be32s(f, &dummy);
+ qemu_get_be32s(f, &dummy);
+ qemu_get_be32s(f, &dummy);
}
- 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_be16s(f, &s->height);
+ qemu_get_be16s(f, &s->width);
+ qemu_get_be16s(f, &s->depth);
qemu_get_buffer(f, s->r, 256);
qemu_get_buffer(f, s->g, 256);
qemu_get_buffer(f, s->b, 256);
qemu_put_8s(f, &s->pointer);
qemu_put_8s(f, &s->config);
- 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_sbe16s(f, &s->temperature);
+ qemu_put_sbe16s(f, &s->limit[0]);
+ qemu_put_sbe16s(f, &s->limit[1]);
qemu_put_byte(f, s->alarm);
s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
qemu_get_8s(f, &s->pointer);
qemu_get_8s(f, &s->config);
- 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]);
+ qemu_get_sbe16s(f, &s->temperature);
+ qemu_get_sbe16s(f, &s->limit[0]);
+ qemu_get_sbe16s(f, &s->limit[1]);
s->alarm = qemu_get_byte(f);
tmp105_interrupt_update(s);
qemu_put_be16s(f, &s->pll[0]);
qemu_put_be16s(f, &s->pll[1]);
qemu_put_be16s(f, &s->volume);
- qemu_put_be64(f, (uint64_t) (s->volume_change - now));
- qemu_put_be64(f, (uint64_t) (s->powerdown - now));
+ qemu_put_sbe64(f, (s->volume_change - now));
+ qemu_put_sbe64(f, (s->powerdown - now));
qemu_put_byte(f, s->softstep);
qemu_put_be16s(f, &s->dac_power);
qemu_get_be16s(f, &s->pll[0]);
qemu_get_be16s(f, &s->pll[1]);
qemu_get_be16s(f, &s->volume);
- s->volume_change = (int64_t) qemu_get_be64(f) + now;
- s->powerdown = (int64_t) qemu_get_be64(f) + now;
+ s->volume_change = qemu_get_sbe64(f) + now;
+ s->powerdown = qemu_get_sbe64(f) + now;
s->softstep = qemu_get_byte(f);
qemu_get_be16s(f, &s->dac_power);
/* MMU */
a20_mask = (int32_t) env->a20_mask;
- qemu_put_be32s(f, &a20_mask);
+ qemu_put_sbe32s(f, &a20_mask);
/* XMM */
qemu_put_be32s(f, &env->mxcsr);
qemu_get_betls(f, &env->dr[i]);
/* MMU */
- qemu_get_be32s(f, &a20_mask);
+ qemu_get_sbe32s(f, &a20_mask);
env->a20_mask = a20_mask;
qemu_get_be32s(f, &env->mxcsr);