From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,
Anthony Liguori <anthony@codemonkey.ws>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH v5 05/14] xics: add pre_save/post_load dispatchers
Date: Thu, 26 Sep 2013 16:18:39 +1000 [thread overview]
Message-ID: <1380176328-21320-6-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1380176328-21320-1-git-send-email-aik@ozlabs.ru>
The upcoming support of in-kernel XICS will redefine migration callbacks
for both ICS and ICP so classes and callback pointers are added.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v4:
* xics_cpu_setup() movement moved to a separate patch
* cpu_setup() callback moved to the "xics split" patch
v3:
* fixed local variables names
---
hw/intc/xics.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++---
include/hw/ppc/xics.h | 26 ++++++++++++++++++++++++
2 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 666888d..eeb64f5 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -190,11 +190,35 @@ static void icp_irq(XICSState *icp, int server, int nr, uint8_t priority)
}
}
+static void icp_dispatch_pre_save(void *opaque)
+{
+ ICPState *ss = opaque;
+ ICPStateClass *info = ICP_GET_CLASS(ss);
+
+ if (info->pre_save) {
+ info->pre_save(ss);
+ }
+}
+
+static int icp_dispatch_post_load(void *opaque, int version_id)
+{
+ ICPState *ss = opaque;
+ ICPStateClass *info = ICP_GET_CLASS(ss);
+
+ if (info->post_load) {
+ return info->post_load(ss, version_id);
+ }
+
+ return 0;
+}
+
static const VMStateDescription vmstate_icp_server = {
.name = "icp/server",
.version_id = 1,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
+ .pre_save = icp_dispatch_pre_save,
+ .post_load = icp_dispatch_post_load,
.fields = (VMStateField []) {
/* Sanity check */
VMSTATE_UINT32(xirr, ICPState),
@@ -229,6 +253,7 @@ static TypeInfo icp_info = {
.parent = TYPE_DEVICE,
.instance_size = sizeof(ICPState),
.class_init = icp_class_init,
+ .class_size = sizeof(ICPStateClass),
};
/*
@@ -390,10 +415,9 @@ static void ics_reset(DeviceState *dev)
}
}
-static int ics_post_load(void *opaque, int version_id)
+static int ics_post_load(ICSState *ics, int version_id)
{
int i;
- ICSState *ics = opaque;
for (i = 0; i < ics->icp->nr_servers; i++) {
icp_resend(ics->icp, i);
@@ -402,6 +426,28 @@ static int ics_post_load(void *opaque, int version_id)
return 0;
}
+static void ics_dispatch_pre_save(void *opaque)
+{
+ ICSState *ics = opaque;
+ ICSStateClass *info = ICS_GET_CLASS(ics);
+
+ if (info->pre_save) {
+ info->pre_save(ics);
+ }
+}
+
+static int ics_dispatch_post_load(void *opaque, int version_id)
+{
+ ICSState *ics = opaque;
+ ICSStateClass *info = ICS_GET_CLASS(ics);
+
+ if (info->post_load) {
+ return info->post_load(ics, version_id);
+ }
+
+ return 0;
+}
+
static const VMStateDescription vmstate_ics_irq = {
.name = "ics/irq",
.version_id = 1,
@@ -421,7 +467,8 @@ static const VMStateDescription vmstate_ics = {
.version_id = 1,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
- .post_load = ics_post_load,
+ .pre_save = ics_dispatch_pre_save,
+ .post_load = ics_dispatch_post_load,
.fields = (VMStateField []) {
/* Sanity check */
VMSTATE_UINT32_EQUAL(nr_irqs, ICSState),
@@ -446,10 +493,12 @@ static int ics_realize(DeviceState *dev)
static void ics_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ ICSStateClass *isc = ICS_CLASS(klass);
dc->init = ics_realize;
dc->vmsd = &vmstate_ics;
dc->reset = ics_reset;
+ isc->post_load = ics_post_load;
}
static TypeInfo ics_info = {
@@ -457,6 +506,7 @@ static TypeInfo ics_info = {
.parent = TYPE_DEVICE,
.instance_size = sizeof(ICSState),
.class_init = ics_class_init,
+ .class_size = sizeof(ICSStateClass),
};
/*
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 66364c5..6e3b605 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -42,7 +42,9 @@
* that yet)
*/
typedef struct XICSState XICSState;
+typedef struct ICPStateClass ICPStateClass;
typedef struct ICPState ICPState;
+typedef struct ICSStateClass ICSStateClass;
typedef struct ICSState ICSState;
typedef struct ICSIRQState ICSIRQState;
@@ -59,6 +61,18 @@ struct XICSState {
#define TYPE_ICP "icp"
#define ICP(obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)
+#define ICP_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ICPStateClass, (klass), TYPE_ICP)
+#define ICP_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ICPStateClass, (obj), TYPE_ICP)
+
+struct ICPStateClass {
+ DeviceClass parent_class;
+
+ void (*pre_save)(ICPState *s);
+ int (*post_load)(ICPState *s, int version_id);
+};
+
struct ICPState {
/*< private >*/
DeviceState parent_obj;
@@ -72,6 +86,18 @@ struct ICPState {
#define TYPE_ICS "ics"
#define ICS(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS)
+#define ICS_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ICSStateClass, (klass), TYPE_ICS)
+#define ICS_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ICSStateClass, (obj), TYPE_ICS)
+
+struct ICSStateClass {
+ DeviceClass parent_class;
+
+ void (*pre_save)(ICSState *s);
+ int (*post_load)(ICSState *s, int version_id);
+};
+
struct ICSState {
/*< private >*/
DeviceState parent_obj;
--
1.8.4.rc4
next prev parent reply other threads:[~2013-09-26 6:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-26 6:18 [Qemu-devel] [PATCH v5 00/14] xics: reworks and in-kernel support Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 01/14] target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN Alexey Kardashevskiy
2013-09-27 4:54 ` David Gibson
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 02/14] xics: move reset and cpu_setup Alexey Kardashevskiy
2013-09-27 5:05 ` David Gibson
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 03/14] spapr: move cpu_setup after kvmppc_set_papr Alexey Kardashevskiy
2013-09-27 5:15 ` David Gibson
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 04/14] xics: replace fprintf with error_report Alexey Kardashevskiy
2013-09-27 5:15 ` David Gibson
2013-09-26 6:18 ` Alexey Kardashevskiy [this message]
2013-10-02 8:23 ` [Qemu-devel] [PATCH v5 05/14] xics: add pre_save/post_load dispatchers David Gibson
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 06/14] xics: convert init() to realize() Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 07/14] xics: add missing const specifiers to TypeInfo Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 08/14] xics: split to xics and xics-common Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 09/14] xics: add cpu_setup callback Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 10/14] xics-kvm: Support for in-kernel XICS interrupt controller Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 11/14] xics: Implement H_IPOLL Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 12/14] xics: Implement H_XIRR_X Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 13/14] xics-kvm: enable irqfd for MSI Alexey Kardashevskiy
2013-09-26 6:18 ` [Qemu-devel] [PATCH v5 14/14] spapr-pci: enable irqfd for INTx Alexey Kardashevskiy
2013-09-30 17:31 ` [Qemu-devel] [PATCH v5 00/14] xics: reworks and in-kernel support Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380176328-21320-6-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=anthony@codemonkey.ws \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).