summaryrefslogtreecommitdiffstats
path: root/hw/xics.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2011-04-05 15:12:09 +1000
committerAlexander Graf <agraf@suse.de>2011-04-08 11:32:21 +0200
commitc7a5c0c9280c2ddaa875e3cafb3df16a96af809c (patch)
tree5530370b8dab8bd65e177a2bc7a1fdfe854d8b57 /hw/xics.c
parent8804f57b531e4887ad9521c9abb9e0bbbcb1dd4e (diff)
downloadhqemu-c7a5c0c9280c2ddaa875e3cafb3df16a96af809c.zip
hqemu-c7a5c0c9280c2ddaa875e3cafb3df16a96af809c.tar.gz
pseries: Abolish envs array
Currently the pseries machine init code builds up an array, envs, of CPUState pointers for all the cpus in the system. This is kind of pointless, given the generic code already has a perfectly good linked list of the cpus. In addition, there are a number of places which assume that the cpu's cpu_index field is equal to its index in this array. This is true in practice, because cpu_index values are just assigned sequentially, but it's conceptually incorrect and may not always be true. Therefore, this patch abolishes the envs array, and explicitly uses the generic cpu linked list and cpu_index values throughout. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/xics.c')
-rw-r--r--hw/xics.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/hw/xics.c b/hw/xics.c
index 66047a6..13a1d25 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -425,27 +425,39 @@ static void rtas_int_on(sPAPREnvironment *spapr, uint32_t token,
rtas_st(rets, 0, 0); /* Success */
}
-struct icp_state *xics_system_init(int nr_servers, CPUState *servers[],
- int nr_irqs)
+struct icp_state *xics_system_init(int nr_irqs)
{
+ CPUState *env;
+ int max_server_num;
int i;
struct icp_state *icp;
struct ics_state *ics;
+ max_server_num = -1;
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ if (env->cpu_index > max_server_num) {
+ max_server_num = env->cpu_index;
+ }
+ }
+
icp = qemu_mallocz(sizeof(*icp));
- icp->nr_servers = nr_servers;
- icp->ss = qemu_mallocz(nr_servers * sizeof(struct icp_server_state));
+ icp->nr_servers = max_server_num + 1;
+ icp->ss = qemu_mallocz(icp->nr_servers*sizeof(struct icp_server_state));
+
+ for (i = 0; i < icp->nr_servers; i++) {
+ icp->ss[i].mfrr = 0xff;
+ }
- for (i = 0; i < nr_servers; i++) {
- servers[i]->cpu_index = i;
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ struct icp_server_state *ss = &icp->ss[env->cpu_index];
- switch (PPC_INPUT(servers[i])) {
+ switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_POWER7:
- icp->ss[i].output = servers[i]->irq_inputs[POWER7_INPUT_INT];
+ ss->output = env->irq_inputs[POWER7_INPUT_INT];
break;
case PPC_FLAGS_INPUT_970:
- icp->ss[i].output = servers[i]->irq_inputs[PPC970_INPUT_INT];
+ ss->output = env->irq_inputs[PPC970_INPUT_INT];
break;
default:
@@ -453,8 +465,6 @@ struct icp_state *xics_system_init(int nr_servers, CPUState *servers[],
"model\n");
exit(1);
}
-
- icp->ss[i].mfrr = 0xff;
}
ics = qemu_mallocz(sizeof(*ics));
OpenPOWER on IntegriCloud