[SeaBIOS] [RFC PATCH v4 21/30] Implement dimm-info
Vasilis Liaskovitis
vasilis.liaskovitis at profitbricks.com
Tue Dec 18 13:41:49 CET 2012
"query-dimm-info" and "info dimm" will give current state of all dimms in the
system e.g.
dimm0: on
dimm1: off
dimm2: off
dimm3: on
etc.
Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis at profitbricks.com>
---
hmp-commands.hx | 2 ++
hmp.c | 17 +++++++++++++++++
hmp.h | 1 +
hw/dimm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
monitor.c | 7 +++++++
qapi-schema.json | 26 ++++++++++++++++++++++++++
6 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3fbd975..65d799e 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1572,6 +1572,8 @@ show qdev device model list
show roms
@item info memory-total
show memory-total
+ at item info dimm
+show dimm
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index fb39b0d..f8456fd 100644
--- a/hmp.c
+++ b/hmp.c
@@ -635,6 +635,23 @@ void hmp_info_memory_total(Monitor *mon)
monitor_printf(mon, "MemTotal: %lu\n", ram_total);
}
+void hmp_info_dimm(Monitor *mon)
+{
+ DimmInfoList *info;
+ DimmInfoList *item;
+ DimmInfo *dimm;
+
+ info = qmp_query_dimm_info(NULL);
+ for (item = info; item; item = item->next) {
+ dimm = item->value;
+ monitor_printf(mon, "dimm %s : %s\n", dimm->dimm,
+ dimm->state ? "on" : "off");
+ dimm->dimm = NULL;
+ }
+
+ qapi_free_DimmInfoList(info);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index 25a3a70..74ac061 100644
--- a/hmp.h
+++ b/hmp.h
@@ -37,6 +37,7 @@ void hmp_info_balloon(Monitor *mon);
void hmp_info_pci(Monitor *mon);
void hmp_info_block_jobs(Monitor *mon);
void hmp_info_memory_total(Monitor *mon);
+void hmp_info_dimm(Monitor *mon);
void hmp_quit(Monitor *mon, const QDict *qdict);
void hmp_stop(Monitor *mon, const QDict *qdict);
void hmp_system_reset(Monitor *mon, const QDict *qdict);
diff --git a/hw/dimm.c b/hw/dimm.c
index f181e54..e79f23d 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -174,6 +174,18 @@ static DimmConfig *dimmcfg_find_from_name(DimmBus *bus, const char *name)
return NULL;
}
+static DimmDevice *dimm_find_from_name(DimmBus *bus, const char *name)
+{
+ DimmDevice *slot;
+
+ QTAILQ_FOREACH(slot, &bus->dimmlist, nextdimm) {
+ if (!strcmp(slot->qdev.id, name)) {
+ return slot;
+ }
+ }
+ return NULL;
+}
+
void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots)
{
DimmConfig *slot;
@@ -203,6 +215,37 @@ uint64_t get_hp_memory_total(void)
return info;
}
+DimmInfoList *qmp_query_dimm_info(Error **errp)
+{
+ DimmBus *bus;
+ DimmConfig *slot;
+ DimmInfoList *head = NULL, *info, *cur_item = NULL;
+
+ QLIST_FOREACH(bus, &memory_buses, next) {
+ QTAILQ_FOREACH(slot, &bus->dimmconfig_list, nextdimmcfg) {
+
+ info = g_malloc0(sizeof(*info));
+ info->value = g_malloc0(sizeof(*info->value));
+ info->value->dimm = g_malloc0(sizeof(char) * 32);
+ strcpy(info->value->dimm, slot->name);
+ if (dimm_find_from_name(bus, slot->name)) {
+ info->value->state = 1;
+ } else {
+ info->value->state = 0;
+ }
+ /* XXX: waiting for the qapi to support GSList */
+ if (!cur_item) {
+ head = cur_item = info;
+ } else {
+ cur_item->next = info;
+ cur_item = info;
+ }
+ }
+ }
+
+ return head;
+}
+
static int dimm_init(DeviceState *s)
{
DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(s));
diff --git a/monitor.c b/monitor.c
index 6e87d0d..de1dcf1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2743,6 +2743,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.info = do_trace_print_events,
},
{
+ .name = "dimm",
+ .args_type = "",
+ .params = "",
+ .help = "show active and non active dimms",
+ .mhandler.info = hmp_info_dimm,
+ },
+ {
.name = NULL,
},
};
diff --git a/qapi-schema.json b/qapi-schema.json
index 33f88d6..5a20577 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2914,6 +2914,32 @@
{ 'command': 'query-memory-total', 'returns': 'int' }
##
+# @DimmInfo:
+#
+# Information about status of a memory hotplug command
+#
+# @dimm: the Dimm associated with the result
+#
+# @result: the result of the hotplug command
+#
+# Since: 1.4
+#
+##
+{ 'type': 'DimmInfo',
+ 'data': {'dimm': 'str', 'state': 'bool'} }
+
+##
+# @query-dimm-info:
+#
+# Returns total memory in bytes, including hotplugged dimms
+#
+# Returns: int
+#
+# Since: 1.4
+##
+{ 'command': 'query-dimm-info', 'returns': ['DimmInfo'] }
+
+##
# @QKeyCode:
#
# An enumeration of key name.
--
1.7.9
More information about the SeaBIOS
mailing list