aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x/sclp.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>2016-09-05 10:52:27 +0200
committerCornelia Huck <cornelia.huck@de.ibm.com>2016-09-06 17:06:50 +0200
commit026546e6c362278db7c14d4cd5165fa5214c18fa (patch)
tree78cf783316e1689b8c4a0705d79648041dd28b61 /hw/s390x/sclp.c
parent80560137cfbb88ba40eb3b933741c63bd43b5fe3 (diff)
s390x/sclp: factor out preparation of cpu entries
Let's factor out the common code of "read cpu info" and "read scp info". This will make the introduction of new cpu entry fields easier. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Message-Id: <20160905085244.99980-14-dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'hw/s390x/sclp.c')
-rw-r--r--hw/s390x/sclp.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 540226c6df..e88521c08f 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -34,6 +34,16 @@ static inline SCLPDevice *get_sclp_device(void)
return sclp;
}
+static void prepare_cpu_entries(SCLPDevice *sclp, CPUEntry *entry, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ entry[i].address = i;
+ entry[i].type = 0;
+ }
+}
+
/* Provide information about the configuration, CPUs and storage */
static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)
{
@@ -42,7 +52,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)
sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev();
CPUState *cpu;
int cpu_count = 0;
- int i = 0;
int rnsize, rnmax;
int slots = MIN(machine->ram_slots, s390_get_memslot_count(kvm_state));
@@ -55,10 +64,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)
read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
read_info->highest_cpu = cpu_to_be16(max_cpus);
- for (i = 0; i < cpu_count; i++) {
- read_info->entries[i].address = i;
- read_info->entries[i].type = 0;
- }
+ prepare_cpu_entries(sclp, read_info->entries, cpu_count);
read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO |
SCLP_HAS_PCI_RECONFIG);
@@ -309,7 +315,6 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb)
ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
CPUState *cpu;
int cpu_count = 0;
- int i = 0;
CPU_FOREACH(cpu) {
cpu_count++;
@@ -323,10 +328,7 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb)
cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured
+ cpu_info->nr_configured*sizeof(CPUEntry));
- for (i = 0; i < cpu_count; i++) {
- cpu_info->entries[i].address = i;
- cpu_info->entries[i].type = 0;
- }
+ prepare_cpu_entries(sclp, cpu_info->entries, cpu_count);
sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
}