summaryrefslogtreecommitdiff
path: root/hw/hw.h
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-12-02 12:36:38 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-03 10:04:54 -0600
commite61a1e0a1147018d26f894c17f56f08117c0ba7b (patch)
tree52aa322e7c1db506e1717b0ffde3f5b793cc3e28 /hw/hw.h
parent8595387e3e08cae5ae1caef5633b551f09ba4211 (diff)
vmstate: Add support for VBUFFERS
Support for buffer that are pointed by a pointer (i.e. not embedded) where the size that we want to use is a field in the state. We also need a new place to store where to start in the middle of the buffer, as now it is a pointer, not the offset of the 1st field. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/hw.h')
-rw-r--r--hw/hw.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/hw.h b/hw/hw.h
index c3c0c9fe3e..47fb12b143 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -294,14 +294,17 @@ enum VMStateFlags {
VMS_BUFFER = 0x020, /* static sized buffer */
VMS_ARRAY_OF_POINTER = 0x040,
VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */
+ VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */
};
typedef struct {
const char *name;
size_t offset;
size_t size;
+ size_t start;
int num;
size_t num_offset;
+ size_t size_offset;
const VMStateInfo *info;
enum VMStateFlags flags;
const VMStateDescription *vmsd;
@@ -490,6 +493,17 @@ extern const VMStateInfo vmstate_info_unused_buffer;
.offset = vmstate_offset_buffer(_state, _field) + _start, \
}
+#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
+ .name = (stringify(_field)), \
+ .version_id = (_version), \
+ .field_exists = (_test), \
+ .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\
+ .info = &vmstate_info_buffer, \
+ .flags = VMS_VBUFFER|VMS_POINTER, \
+ .offset = offsetof(_state, _field), \
+ .start = (_start), \
+}
+
#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
.name = (stringify(_field)), \
.version_id = (_version), \
@@ -683,6 +697,12 @@ extern const VMStateDescription vmstate_i2c_slave;
#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
+#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \
+ VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
+
+#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \
+ VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
+
#define VMSTATE_BUFFER_TEST(_f, _s, _test) \
VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))