Skip to contentSkip to conversation

split hw/hw.h

PATCH In review Paolo Bonzini 2 participants 4 messages Dec 6, 2011 – Dec 12, 2011 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

cover split hw/hw.h

Extract qemu-file.h and vmstate.h from it. Last for this week, promised.

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/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 ++++++++++++++++++++++++++++++++++
 27 files changed, 972 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.7.1
#1 lore raw

PATCH 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 518bad2..3abeb82 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 319cee1..2dfdb30 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 62bdb03..f8a64e1 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 5645054..9c98a83 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 #include "trace.h"
 
hw/lan9118.c +1 -0
index ee8b2ea..93be4a7 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 445847f..115e1e9 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 7b6d501..5110d83 100644
@@ -8,6 +8,7 @@
 #include "hw.h"
 #include "mcf.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 #include "sysemu.h"
 #include "exec-memory.h"
 
hw/mcf5208.c +1 -0
index ec608a1..4d5874f 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 6326b70..bd2a298 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 3c6cefe..ddab817 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 d2c0cec..64bf604 100644
@@ -12,6 +12,7 @@
 #include "sh.h"
 #include "qemu-timer.h"
 #include "exec-memory.h"
+#include "ptimer.h"
 
 //#define DEBUG_TIMER
 
hw/slavio_timer.c +1 -0
index 2353c43..44b500a 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 1498f01..921e048 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 596ec0e..0da20d9 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 0b2f32a..adca53b 100644
@@ -24,6 +24,7 @@
 
 #include "sysbus.h"
 #include "qemu-timer.h"
+#include "ptimer.h"
 
 #define D(x)
 
qemu-timer.h +0 -13
index 67ca72e..de17f3b 100644
@@ -139,19 +139,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 cpu_get_icount(void);
 int64_t cpu_get_clock(void);
Signature · 1 line
1.7.7.1
#2 lore raw

PATCH 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/pcie.h   |   11 +
 hw/ptimer.h |   12 +
 hw/usb.h    |   12 +
 net.h       |   13 +
 qemu-file.h |  232 ++++++++++++++++
 vmstate.h   |  613 +++++++++++++++++++++++++++++++++++++++++
 9 files changed, 928 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/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 c6e1870..7ea90e4 100644
@@ -392,3 +392,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.7.1
#3 lore raw
In reply to Paolo Bonzini
Quoted 1 line · Paolo Bonzini

Extract qemu-file.h and vmstate.h from it. Last for this week, promised.

This conflicts badly for me. Can you rebase?

Regards,

Anthony Liguori

Quoted 37 lines

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/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 ++++++++++++++++++++++++++++++++++
  27 files changed, 972 insertions(+), 893 deletions(-)

create mode 100644 hw/ptimer.h
create mode 100644 qemu-file.h
create mode 100644 vmstate.h