From: Hao Wu <wuhaotsh@google.com>
To: minyard@acm.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com,
venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com,
hskinnemoen@google.com, titusr@google.com,
peter.maydell@linaro.org
Subject: [PATCH 6/8] hw/ipmi: Move handle_command to IPMICoreClass
Date: Thu, 9 Sep 2021 16:06:18 -0700 [thread overview]
Message-ID: <20210909230620.511815-7-wuhaotsh@google.com> (raw)
In-Reply-To: <20210909230620.511815-1-wuhaotsh@google.com>
Move the function handle_command to IPMICoreClass. This function is
shared between BMC-side emulation and Host-side emulation.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
---
hw/ipmi/ipmi_bmc_extern.c | 4 ++--
hw/ipmi/ipmi_bmc_sim.c | 6 +++---
hw/ipmi/ipmi_bt.c | 4 ++--
hw/ipmi/ipmi_extern.c | 6 +++---
hw/ipmi/ipmi_kcs.c | 6 +++---
hw/ipmi/smbus_ipmi.c | 6 +++---
include/hw/ipmi/ipmi.h | 16 ++++++++--------
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 24979ecfd5..f7b88763c1 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -117,7 +117,7 @@ static void ipmi_bmc_handle_hw_op(IPMICore *ic, unsigned char hw_op,
}
}
-static void ipmi_bmc_extern_handle_command(IPMIBmc *b,
+static void ipmi_bmc_extern_handle_command(IPMICore *b,
uint8_t *cmd, unsigned int cmd_len,
unsigned int max_cmd_len,
uint8_t msg_id)
@@ -185,8 +185,8 @@ static void ipmi_bmc_extern_class_init(ObjectClass *oc, void *data)
IPMIBmcClass *bk = IPMI_BMC_CLASS(oc);
IPMICoreClass *ck = IPMI_CORE_CLASS(oc);
- bk->handle_command = ipmi_bmc_extern_handle_command;
bk->handle_reset = ipmi_bmc_extern_handle_reset;
+ ck->handle_command = ipmi_bmc_extern_handle_command;
ck->handle_hw_op = ipmi_bmc_handle_hw_op;
dc->hotpluggable = false;
dc->realize = ipmi_bmc_extern_realize;
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 7cc4a22456..ddbf150e78 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -640,7 +640,7 @@ static void next_timeout(IPMIBmcSim *ibs)
timer_mod_ns(ibs->timer, next);
}
-static void ipmi_sim_handle_command(IPMIBmc *b,
+static void ipmi_sim_handle_command(IPMICore *b,
uint8_t *cmd, unsigned int cmd_len,
unsigned int max_cmd_len,
uint8_t msg_id)
@@ -2222,12 +2222,12 @@ static Property ipmi_sim_properties[] = {
static void ipmi_sim_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
- IPMIBmcClass *bk = IPMI_BMC_CLASS(oc);
+ IPMICoreClass *ck = IPMI_CORE_CLASS(oc);
dc->hotpluggable = false;
dc->realize = ipmi_sim_realize;
device_class_set_props(dc, ipmi_sim_properties);
- bk->handle_command = ipmi_sim_handle_command;
+ ck->handle_command = ipmi_sim_handle_command;
}
static const TypeInfo ipmi_sim_type = {
diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c
index f76c369e4a..60a04f2a65 100644
--- a/hw/ipmi/ipmi_bt.c
+++ b/hw/ipmi/ipmi_bt.c
@@ -141,8 +141,8 @@ static void ipmi_bt_handle_event(IPMIInterface *ii)
ib->waiting_seq = ib->inmsg[2];
ib->inmsg[2] = ib->inmsg[1];
{
- IPMIBmcClass *bk = IPMI_BMC_GET_CLASS(ib->bmc);
- bk->handle_command(ib->bmc, ib->inmsg + 2, ib->inlen - 2,
+ IPMICoreClass *ck = IPMI_CORE_GET_CLASS(ib->bmc);
+ ck->handle_command(IPMI_CORE(ib->bmc), ib->inmsg + 2, ib->inlen - 2,
sizeof(ib->inmsg), ib->waiting_rsp);
}
out:
diff --git a/hw/ipmi/ipmi_extern.c b/hw/ipmi/ipmi_extern.c
index f139eaef24..97dfed085f 100644
--- a/hw/ipmi/ipmi_extern.c
+++ b/hw/ipmi/ipmi_extern.c
@@ -119,9 +119,9 @@ static void addchar(IPMIExtern *ibe, unsigned char ch)
}
void ipmi_extern_handle_command(IPMIExtern *ibe,
- uint8_t *cmd, unsigned int cmd_len,
- unsigned int max_cmd_len,
- uint8_t msg_id)
+ uint8_t *cmd, unsigned int cmd_len,
+ unsigned int max_cmd_len,
+ uint8_t msg_id)
{
IPMIInterface *s = ibe->core->intf;
uint8_t err = 0, csum;
diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c
index e0f870e13a..4a77dbb7e7 100644
--- a/hw/ipmi/ipmi_kcs.c
+++ b/hw/ipmi/ipmi_kcs.c
@@ -162,12 +162,12 @@ static void ipmi_kcs_handle_event(IPMIInterface *ii)
ik->inlen++;
}
if (ik->write_end) {
- IPMIBmcClass *bk = IPMI_BMC_GET_CLASS(ik->bmc);
+ IPMICoreClass *ck = IPMI_CORE_GET_CLASS(ik->bmc);
ik->outlen = 0;
ik->write_end = 0;
ik->outpos = 0;
- bk->handle_command(ik->bmc, ik->inmsg, ik->inlen, sizeof(ik->inmsg),
- ik->waiting_rsp);
+ ck->handle_command(IPMI_CORE(ik->bmc), ik->inmsg, ik->inlen,
+ sizeof(ik->inmsg), ik->waiting_rsp);
goto out_noibf;
} else if (ik->cmd_reg == IPMI_KCS_WRITE_END_CMD) {
ik->cmd_reg = -1;
diff --git a/hw/ipmi/smbus_ipmi.c b/hw/ipmi/smbus_ipmi.c
index a2383f1212..e0248ac45f 100644
--- a/hw/ipmi/smbus_ipmi.c
+++ b/hw/ipmi/smbus_ipmi.c
@@ -107,7 +107,7 @@ static void smbus_ipmi_send_msg(SMBusIPMIDevice *sid)
{
uint8_t *msg = sid->inmsg;
uint32_t len = sid->inlen;
- IPMIBmcClass *bk = IPMI_BMC_GET_CLASS(sid->bmc);
+ IPMICoreClass *ck = IPMI_CORE_GET_CLASS(sid->bmc);
sid->outlen = 0;
sid->outpos = 0;
@@ -135,8 +135,8 @@ static void smbus_ipmi_send_msg(SMBusIPMIDevice *sid)
return;
}
- bk->handle_command(sid->bmc, sid->inmsg, sid->inlen, sizeof(sid->inmsg),
- sid->waiting_rsp);
+ ck->handle_command(IPMI_CORE(sid->bmc), sid->inmsg, sid->inlen,
+ sizeof(sid->inmsg), sid->waiting_rsp);
}
static uint8_t ipmi_receive_byte(SMBusDevice *dev)
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 1fa8cd12e5..0083c73e4b 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -196,6 +196,14 @@ struct IPMICoreClass {
* Handle a hardware command.
*/
void (*handle_hw_op)(struct IPMICore *s, uint8_t hw_op, uint8_t operand);
+
+ /*
+ * Handle a command to the bmc.
+ */
+ void (*handle_command)(struct IPMICore *s,
+ uint8_t *cmd, unsigned int cmd_len,
+ unsigned int max_cmd_len,
+ uint8_t msg_id);
};
/*
@@ -216,14 +224,6 @@ struct IPMIBmcClass {
/* Called when the system resets to report to the bmc. */
void (*handle_reset)(struct IPMIBmc *s);
-
- /*
- * Handle a command to the bmc.
- */
- void (*handle_command)(struct IPMIBmc *s,
- uint8_t *cmd, unsigned int cmd_len,
- unsigned int max_cmd_len,
- uint8_t msg_id);
};
/*
--
2.33.0.309.g3052b89438-goog
next prev parent reply other threads:[~2021-09-09 23:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 23:06 [PATCH 0/8] Handing IPMI for emulating BMC Hao Wu
2021-09-09 23:06 ` [PATCH 1/8] docs: enable sphinx blockdiag extension Hao Wu
2021-09-09 23:40 ` Corey Minyard
2021-09-09 23:06 ` [PATCH 2/8] docs/specs: IPMI device emulation: main processor Hao Wu
2021-09-09 23:48 ` Corey Minyard
2021-09-09 23:06 ` [PATCH 3/8] docs/specs: IPMI device emulation: BMC Hao Wu
2021-09-09 23:06 ` [PATCH 4/8] hw/ipmi: Refactor IPMI interface Hao Wu
2021-09-10 0:26 ` Corey Minyard
2021-09-09 23:06 ` [PATCH 5/8] hw/ipmi: Take out common from ipmi_bmc_extern.c Hao Wu
2021-09-10 0:27 ` Corey Minyard
2021-09-09 23:06 ` Hao Wu [this message]
2021-09-09 23:06 ` [PATCH 7/8] hw/ipmi: Add an IPMI external host device Hao Wu
2021-09-10 0:53 ` Corey Minyard
2021-09-09 23:06 ` [PATCH 8/8] hw/ipmi: Add a KCS Module for NPCM7XX Hao Wu
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=20210909230620.511815-7-wuhaotsh@google.com \
--to=wuhaotsh@google.com \
--cc=Avi.Fishman@nuvoton.com \
--cc=hskinnemoen@google.com \
--cc=kfting@nuvoton.com \
--cc=minyard@acm.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=titusr@google.com \
--cc=venture@google.com \
/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).