Revision fad37673 hw/s390-virtio.c
b/hw/s390-virtio.c | ||
---|---|---|
147 | 147 |
return s390_running_cpus; |
148 | 148 |
} |
149 | 149 |
|
150 |
void s390_init_ipl_dev(const char *kernel_filename, |
|
151 |
const char *kernel_cmdline, |
|
152 |
const char *initrd_filename) |
|
153 |
{ |
|
154 |
DeviceState *dev; |
|
155 |
|
|
156 |
dev = qdev_create(NULL, "s390-ipl"); |
|
157 |
if (kernel_filename) { |
|
158 |
qdev_prop_set_string(dev, "kernel", kernel_filename); |
|
159 |
} |
|
160 |
if (initrd_filename) { |
|
161 |
qdev_prop_set_string(dev, "initrd", initrd_filename); |
|
162 |
} |
|
163 |
qdev_prop_set_string(dev, "cmdline", kernel_cmdline); |
|
164 |
qdev_init_nofail(dev); |
|
165 |
} |
|
166 |
|
|
167 |
void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) |
|
168 |
{ |
|
169 |
int i; |
|
170 |
|
|
171 |
if (cpu_model == NULL) { |
|
172 |
cpu_model = "host"; |
|
173 |
} |
|
174 |
|
|
175 |
ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); |
|
176 |
|
|
177 |
for (i = 0; i < smp_cpus; i++) { |
|
178 |
S390CPU *cpu; |
|
179 |
|
|
180 |
cpu = cpu_s390x_init(cpu_model); |
|
181 |
|
|
182 |
ipi_states[i] = cpu; |
|
183 |
cpu->env.halted = 1; |
|
184 |
cpu->env.exception_index = EXCP_HLT; |
|
185 |
cpu->env.storage_keys = storage_keys; |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
|
|
190 |
void s390_create_virtio_net(BusState *bus, const char *name) |
|
191 |
{ |
|
192 |
int i; |
|
193 |
|
|
194 |
for (i = 0; i < nb_nics; i++) { |
|
195 |
NICInfo *nd = &nd_table[i]; |
|
196 |
DeviceState *dev; |
|
197 |
|
|
198 |
if (!nd->model) { |
|
199 |
nd->model = g_strdup("virtio"); |
|
200 |
} |
|
201 |
|
|
202 |
if (strcmp(nd->model, "virtio")) { |
|
203 |
fprintf(stderr, "S390 only supports VirtIO nics\n"); |
|
204 |
exit(1); |
|
205 |
} |
|
206 |
|
|
207 |
dev = qdev_create(bus, name); |
|
208 |
qdev_set_nic_properties(dev, nd); |
|
209 |
qdev_init_nofail(dev); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
150 | 213 |
/* PC hardware initialisation */ |
151 | 214 |
static void s390_init(QEMUMachineInitArgs *args) |
152 | 215 |
{ |
153 | 216 |
ram_addr_t my_ram_size = args->ram_size; |
154 |
const char *cpu_model = args->cpu_model; |
|
155 |
CPUS390XState *env = NULL; |
|
156 |
DeviceState *dev; |
|
157 | 217 |
MemoryRegion *sysmem = get_system_memory(); |
158 | 218 |
MemoryRegion *ram = g_new(MemoryRegion, 1); |
159 | 219 |
int shift = 0; |
... | ... | |
161 | 221 |
void *virtio_region; |
162 | 222 |
hwaddr virtio_region_len; |
163 | 223 |
hwaddr virtio_region_start; |
164 |
int i; |
|
165 | 224 |
|
166 | 225 |
/* s390x ram size detection needs a 16bit multiplier + an increment. So |
167 | 226 |
guests > 64GB can be specified in 2MB steps etc. */ |
... | ... | |
176 | 235 |
/* get a BUS */ |
177 | 236 |
s390_bus = s390_virtio_bus_init(&my_ram_size); |
178 | 237 |
s390_sclp_init(); |
179 |
dev = qdev_create(NULL, "s390-ipl"); |
|
180 |
if (args->kernel_filename) { |
|
181 |
qdev_prop_set_string(dev, "kernel", args->kernel_filename); |
|
182 |
} |
|
183 |
if (args->initrd_filename) { |
|
184 |
qdev_prop_set_string(dev, "initrd", args->initrd_filename); |
|
185 |
} |
|
186 |
qdev_prop_set_string(dev, "cmdline", args->kernel_cmdline); |
|
187 |
qdev_init_nofail(dev); |
|
238 |
s390_init_ipl_dev(args->kernel_filename, args->kernel_cmdline, |
|
239 |
args->initrd_filename); |
|
188 | 240 |
|
189 | 241 |
/* register hypercalls */ |
190 | 242 |
s390_virtio_register_hcalls(); |
... | ... | |
207 | 259 |
storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE); |
208 | 260 |
|
209 | 261 |
/* init CPUs */ |
210 |
if (cpu_model == NULL) { |
|
211 |
cpu_model = "host"; |
|
212 |
} |
|
213 |
|
|
214 |
ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); |
|
215 |
|
|
216 |
for (i = 0; i < smp_cpus; i++) { |
|
217 |
S390CPU *cpu; |
|
218 |
CPUS390XState *tmp_env; |
|
219 |
|
|
220 |
cpu = cpu_s390x_init(cpu_model); |
|
221 |
tmp_env = &cpu->env; |
|
222 |
if (!env) { |
|
223 |
env = tmp_env; |
|
224 |
} |
|
225 |
ipi_states[i] = cpu; |
|
226 |
tmp_env->halted = 1; |
|
227 |
tmp_env->exception_index = EXCP_HLT; |
|
228 |
tmp_env->storage_keys = storage_keys; |
|
229 |
} |
|
230 |
|
|
262 |
s390_init_cpus(args->cpu_model, storage_keys); |
|
231 | 263 |
|
232 | 264 |
/* Create VirtIO network adapters */ |
233 |
for(i = 0; i < nb_nics; i++) { |
|
234 |
NICInfo *nd = &nd_table[i]; |
|
235 |
DeviceState *dev; |
|
236 |
|
|
237 |
if (!nd->model) { |
|
238 |
nd->model = g_strdup("virtio"); |
|
239 |
} |
|
240 |
|
|
241 |
if (strcmp(nd->model, "virtio")) { |
|
242 |
fprintf(stderr, "S390 only supports VirtIO nics\n"); |
|
243 |
exit(1); |
|
244 |
} |
|
245 |
|
|
246 |
dev = qdev_create((BusState *)s390_bus, "virtio-net-s390"); |
|
247 |
qdev_set_nic_properties(dev, nd); |
|
248 |
qdev_init_nofail(dev); |
|
249 |
} |
|
265 |
s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390"); |
|
250 | 266 |
} |
251 | 267 |
|
252 | 268 |
static QEMUMachine s390_machine = { |
Also available in: Unified diff