Skip to contentSkip to conversation

Extract three more headers out of qemu-timer.h and hw/hw.h

PATCH Superseded Paolo Bonzini 1 participant 3 messages Sep 26, 2011 Arm/Zynq architecture

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Extract three more headers out of qemu-timer.h and hw/hw.h

Third time's a charm.

v1 -> v3: actually make it compile

Paolo Bonzini (2):
ptimer: move declarations to ptimer.h
vmstate: extract declarations out of hw/hw.h

 hw/arm_timer.c        |    1 +
 hw/etraxfs_timer.c    |    1 +
 hw/grlib_apbuart.c    |    1 +
 hw/grlib_gptimer.c    |    1 +
 hw/hid.h              |   23 ++
 hw/hw.h               |  882 +------------------------------------------------
 hw/i2c.h              |   10 +
 hw/lan9118.c          |    1 +
 hw/leon3.c            |    1 +
 hw/lm32_timer.c       |    1 +
 hw/mcf5206.c          |    1 +
 hw/mcf5208.c          |    1 +
 hw/milkymist-sysctl.c |    1 +
 hw/musicpal.c         |    1 +
 hw/pci.h              |   18 +
 hw/pcie.h             |   11 +
 hw/ptimer.c           |    1 +
 hw/ptimer.h           |   39 +++
 hw/sh_timer.c         |    1 +
 hw/slavio_timer.c     |    1 +
 hw/syborg_timer.c     |    1 +
 hw/usb.h              |   12 +
 hw/xilinx_axidma.c    |    1 +
 hw/xilinx_timer.c     |    1 +
 net.h                 |   13 +
 qemu-file.h           |  232 +++++++++++++
 qemu-timer.h          |   13 -
 vmstate.h             |  613 ++++++++++++++++++++++++++++++++++
 28 files changed, 990 insertions(+), 893 deletions(-)
 create mode 100644 hw/ptimer.h
 create mode 100644 qemu-file.h
 create mode 100644 vmstate.h
Signature · 1 line
1.7.6
#1 lore raw

PATCH v3 1/2 ptimer: move declarations to ptimer.h

---
 hw/arm_timer.c        |    1 +
 hw/etraxfs_timer.c    |    1 +
 hw/grlib_apbuart.c    |    1 +
 hw/grlib_gptimer.c    |    1 +
 hw/lan9118.c          |    1 +
 hw/leon3.c            |    1 +
 hw/lm32_timer.c       |    1 +
 hw/mcf5206.c          |    1 +
 hw/mcf5208.c          |    1 +
 hw/milkymist-sysctl.c |    1 +
 hw/musicpal.c         |    1 +
 hw/ptimer.c           |    1 +
 hw/ptimer.h           |   27 +++++++++++++++++++++++++++
 hw/sh_timer.c         |    1 +
 hw/slavio_timer.c     |    1 +
 hw/syborg_timer.c     |    1 +
 hw/xilinx_axidma.c    |    1 +
 hw/xilinx_timer.c     |    1 +
 qemu-timer.h          |   13 -------------
 19 files changed, 44 insertions(+), 13 deletions(-)
 create mode 100644 hw/ptimer.h
hw/arm_timer.c +1 -0
index 09a4b24..63c19d7 100644
@@ -9,6 +9,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 /* Common timer implementation.  */
 
hw/etraxfs_timer.c +1 -0
index b08e574..0a28c4c 100644
@@ -24,6 +24,7 @@
 #include "sysbus.h"
 #include "sysemu.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 #define D(x)
 
hw/grlib_apbuart.c +1 -0
index c90b810..84d3d7a 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-char.h"
+#include "ptimer.h"
 
 #include "trace.h"
 
hw/grlib_gptimer.c +1 -0
index 85869b9..a0ae1c4 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 #include "trace.h"
 
hw/lan9118.c +1 -0
index 73a8661..a562206 100644
@@ -11,6 +11,7 @@
 #include "net.h"
 #include "devices.h"
 #include "sysemu.h"
+#include "ptimer.h"
 /* For crc32 */
 #include <zlib.h>
 
hw/leon3.c +1 -0
index 607ec85..97a68f6 100644
@@ -23,6 +23,7 @@
  */
 #include "hw.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "qemu-char.h"
 #include "sysemu.h"
 #include "boards.h"
hw/lm32_timer.c +1 -0
index 49cbb22..e355d80 100644
@@ -25,6 +25,7 @@
 #include "sysbus.h"
 #include "trace.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "qemu-error.h"
 
 #define DEFAULT_FREQUENCY (50*1000000)
hw/mcf5206.c +1 -0
index 15d6f22..4ad3805 100644
@@ -8,6 +8,7 @@
 #include "hw.h"
 #include "mcf.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "sysemu.h"
 
 /* General purpose timer module.  */
hw/mcf5208.c +1 -0
index 1c2c0c4..83c0c9e 100644
@@ -8,6 +8,7 @@
 #include "hw.h"
 #include "mcf.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "sysemu.h"
 #include "net.h"
 #include "boards.h"
hw/milkymist-sysctl.c +1 -0
index 7b2d544..5f8d4ad 100644
@@ -26,6 +26,7 @@
 #include "sysemu.h"
 #include "trace.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "qemu-error.h"
 
 enum {
hw/musicpal.c +1 -0
index 9b1f380..fd2e2ef 100644
@@ -14,6 +14,7 @@
 #include "boards.h"
 #include "pc.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "block.h"
 #include "flash.h"
 #include "console.h"
hw/ptimer.c +1 -0
index b6cabd5..de7d664 100644
@@ -7,6 +7,7 @@
  */
 #include "hw.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "host-utils.h"
 
 struct ptimer_state
hw/ptimer.h new file +27 -0
new file mode 100644
index 0000000..69cdddc
@@ -0,0 +1,27 @@
+/*
+ * General purpose implementation of a simple periodic countdown timer.
+ *
+ * Copyright (c) 2007 CodeSourcery.
+ *
+ * This code is licensed under the GNU LGPL.
+ */
+#ifndef PTIMER_H
+#define PTIMER_H
+
+#include "qemu-common.h"
+#include "qemu-timer.h"
+
+/* ptimer.c */
+typedef struct ptimer_state ptimer_state;
+typedef void (*ptimer_cb)(void *opaque);
+
+ptimer_state *ptimer_init(QEMUBH *bh);
+void ptimer_set_period(ptimer_state *s, int64_t period);
+void ptimer_set_freq(ptimer_state *s, uint32_t freq);
+void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload);
+uint64_t ptimer_get_count(ptimer_state *s);
+void ptimer_set_count(ptimer_state *s, uint64_t count);
+void ptimer_run(ptimer_state *s, int oneshot);
+void ptimer_stop(ptimer_state *s);
+
+#endif
hw/sh_timer.c +1 -0
index dca3c94..31bf975 100644
@@ -11,6 +11,7 @@
 #include "hw.h"
 #include "sh.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 //#define DEBUG_TIMER
 
hw/slavio_timer.c +1 -0
index 84449ba..b3a6745 100644
@@ -24,6 +24,7 @@
 
 #include "sun4m.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "sysbus.h"
 #include "trace.h"
 
hw/syborg_timer.c +1 -0
index 50c813e..c98484a 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "syborg.h"
 
 //#define DEBUG_SYBORG_TIMER
hw/xilinx_axidma.c +1 -0
index 571a5b0..0bbeae3 100644
@@ -25,6 +25,7 @@
 #include "sysbus.h"
 #include "qemu-char.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "qemu-log.h"
 #include "qdev-addr.h"
 
hw/xilinx_timer.c +1 -0
index 8779c56..a1cf440 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 #define D(x)
 
qemu-timer.h +0 -13
index 0a43469..ea886cf 100644
@@ -136,19 +136,6 @@ static inline int64_t get_clock(void)
 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
 
-/* ptimer.c */
-typedef struct ptimer_state ptimer_state;
-typedef void (*ptimer_cb)(void *opaque);
-
-ptimer_state *ptimer_init(QEMUBH *bh);
-void ptimer_set_period(ptimer_state *s, int64_t period);
-void ptimer_set_freq(ptimer_state *s, uint32_t freq);
-void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload);
-uint64_t ptimer_get_count(ptimer_state *s);
-void ptimer_set_count(ptimer_state *s, uint64_t count);
-void ptimer_run(ptimer_state *s, int oneshot);
-void ptimer_stop(ptimer_state *s);
-
 /* icount */
 int64_t qemu_icount_round(int64_t count);
 extern int64_t qemu_icount;
Signature · 1 line
1.7.6
#2 lore raw

PATCH v3 2/2 vmstate: extract declarations out of hw/hw.h

In reply to Paolo Bonzini
---
 hw/hid.h    |   23 ++
 hw/hw.h     |  882 +----------------------------------------------------------
 hw/i2c.h    |   10 +
 hw/pci.h    |   18 ++
 hw/pcie.h   |   11 +
 hw/ptimer.h |   12 +
 hw/usb.h    |   12 +
 net.h       |   13 +
 qemu-file.h |  232 ++++++++++++++++
 vmstate.h   |  613 +++++++++++++++++++++++++++++++++++++++++
 10 files changed, 946 insertions(+), 880 deletions(-)
 create mode 100644 qemu-file.h
 create mode 100644 vmstate.h
hw/hid.h +23 -0
index 9ce03b1..5315cf7 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_HID_H
 #define QEMU_HID_H
 
+#include "vmstate.h"
+
 #define HID_MOUSE     1
 #define HID_TABLET    2
 #define HID_KEYBOARD  3
@@ -56,4 +58,25 @@ int hid_pointer_poll(HIDState *hs, uint8_t *buf, int len);
 int hid_keyboard_poll(HIDState *hs, uint8_t *buf, int len);
 int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len);
 
+extern const VMStateDescription vmstate_hid_keyboard_device;
+
+#define VMSTATE_HID_KEYBOARD_DEVICE(_field, _state) {                \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(HIDState),                                  \
+    .vmsd       = &vmstate_hid_keyboard_device,                      \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, HIDState),    \
+}
+
+extern const VMStateDescription vmstate_hid_ptr_device;
+
+#define VMSTATE_HID_POINTER_DEVICE(_field, _state) {                 \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(HIDState),                                  \
+    .vmsd       = &vmstate_hid_ptr_device,                           \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, HIDState),    \
+}
+
+
 #endif /* QEMU_HID_H */
hw/hw.h +2 -880

904 lines not on this page · raw message

hw/i2c.h +10 -0
index 9381d01..a3383ff 100644
@@ -74,4 +74,14 @@ void tmp105_set(i2c_slave *i2c, int temp);
 /* lm832x.c */
 void lm832x_key_event(DeviceState *dev, int key, int state);
 
+extern const VMStateDescription vmstate_i2c_slave;
+
+#define VMSTATE_I2C_SLAVE(_field, _state) {                          \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(i2c_slave),                                 \
+    .vmsd       = &vmstate_i2c_slave,                                \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, i2c_slave),   \
+}
+
 #endif
hw/pci.h +18 -0
index 7b62df1..1aca171 100644
@@ -486,4 +486,22 @@ static inline uint32_t pci_config_size(const PCIDevice *d)
     return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE;
 }
 
+extern const VMStateDescription vmstate_pci_device;
+
+#define VMSTATE_PCI_DEVICE(_field, _state) {                         \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(PCIDevice),                                 \
+    .vmsd       = &vmstate_pci_device,                               \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
+}
+
+#define VMSTATE_PCI_DEVICE_POINTER(_field, _state) {                 \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(PCIDevice),                                 \
+    .vmsd       = &vmstate_pci_device,                               \
+    .flags      = VMS_STRUCT|VMS_POINTER,                            \
+    .offset     = vmstate_offset_pointer(_state, _field, PCIDevice), \
+}
+
 #endif
hw/pcie.h +11 -0
index a213fba..b8ab0c7 100644
@@ -129,4 +129,15 @@ void pcie_add_capability(PCIDevice *dev,
 
 void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);
 
+extern const VMStateDescription vmstate_pcie_device;
+
+#define VMSTATE_PCIE_DEVICE(_field, _state) {                        \
+    .name       = (stringify(_field)),                               \
+    .version_id = 2,                                                 \
+    .size       = sizeof(PCIDevice),                                 \
+    .vmsd       = &vmstate_pcie_device,                              \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
+}
+
 #endif /* QEMU_PCIE_H */
hw/ptimer.h +12 -0
index 69cdddc..6638f61 100644
@@ -10,6 +10,7 @@
 
 #include "qemu-common.h"
 #include "qemu-timer.h"
+#include "vmstate.h"
 
 /* ptimer.c */
 typedef struct ptimer_state ptimer_state;
@@ -24,4 +25,15 @@ void ptimer_set_count(ptimer_state *s, uint64_t count);
 void ptimer_run(ptimer_state *s, int oneshot);
 void ptimer_stop(ptimer_state *s);
 
+extern const VMStateDescription vmstate_ptimer;
+
+#define VMSTATE_PTIMER(_field, _state) {                             \
+    .name       = (stringify(_field)),                               \
+    .version_id = (1),                                               \
+    .vmsd       = &vmstate_ptimer,                                   \
+    .size       = sizeof(ptimer_state *),                            \
+    .flags      = VMS_STRUCT|VMS_POINTER,                            \
+    .offset     = vmstate_offset_pointer(_state, _field, ptimer_state), \
+}
+
 #endif
hw/usb.h +12 -0
index c08d469..ffcdb57 100644
@@ -391,3 +391,15 @@ static inline USBBus *usb_bus_from_device(USBDevice *d)
 {
     return DO_UPCAST(USBBus, qbus, d->qdev.parent_bus);
 }
+
+extern const VMStateDescription vmstate_usb_device;
+
+#define VMSTATE_USB_DEVICE(_field, _state) {                         \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(USBDevice),                                 \
+    .vmsd       = &vmstate_usb_device,                               \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, USBDevice),   \
+}
+
+
net.h +13 -0
index 9f633f8..c1b8b7d 100644
@@ -6,6 +6,7 @@
 #include "qdict.h"
 #include "qemu-option.h"
 #include "net/queue.h"
+#include "vmstate.h"
 
 struct MACAddr {
     uint8_t a[6];
@@ -179,4 +180,16 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
 
 int net_handle_fd_param(Monitor *mon, const char *param);
 
+#define vmstate_offset_macaddr(_state, _field)                       \
+    vmstate_offset_array(_state, _field.a, uint8_t,                \
+                         sizeof(typeof_field(_state, _field)))
+
+#define VMSTATE_MACADDR(_field, _state) {                            \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(MACAddr),                                   \
+    .info       = &vmstate_info_buffer,                              \
+    .flags      = VMS_BUFFER,                                        \
+    .offset     = vmstate_offset_macaddr(_state, _field),            \
+}
+
 #endif
qemu-file.h new file +232 -0

232 lines not on this page · raw message

vmstate.h new file +613 -0

613 lines not on this page · raw message

Signature · 1 line
1.7.6