2 * QEMU PowerPC PowerNV machine model
4 * Copyright (c) 2016, IBM Corporation.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu/units.h"
22 #include "qapi/error.h"
23 #include "sysemu/sysemu.h"
24 #include "sysemu/numa.h"
25 #include "sysemu/cpus.h"
27 #include "target/ppc/cpu.h"
29 #include "hw/ppc/fdt.h"
30 #include "hw/ppc/ppc.h"
31 #include "hw/ppc/pnv.h"
32 #include "hw/ppc/pnv_core.h"
33 #include "hw/loader.h"
34 #include "exec/address-spaces.h"
35 #include "qapi/visitor.h"
36 #include "monitor/monitor.h"
37 #include "hw/intc/intc.h"
38 #include "hw/ipmi/ipmi.h"
39 #include "target/ppc/mmu-hash64.h"
41 #include "hw/ppc/xics.h"
42 #include "hw/ppc/pnv_xscom.h"
44 #include "hw/isa/isa.h"
45 #include "hw/char/serial.h"
46 #include "hw/timer/mc146818rtc.h"
50 #define FDT_MAX_SIZE (1 * MiB)
52 #define FW_FILE_NAME "skiboot.lid"
53 #define FW_LOAD_ADDR 0x0
54 #define FW_MAX_SIZE (4 * MiB)
56 #define KERNEL_LOAD_ADDR 0x20000000
57 #define KERNEL_MAX_SIZE (256 * MiB)
58 #define INITRD_LOAD_ADDR 0x60000000
59 #define INITRD_MAX_SIZE (256 * MiB)
61 static const char *pnv_chip_core_typename(const PnvChip
*o
)
63 const char *chip_type
= object_class_get_name(object_get_class(OBJECT(o
)));
64 int len
= strlen(chip_type
) - strlen(PNV_CHIP_TYPE_SUFFIX
);
65 char *s
= g_strdup_printf(PNV_CORE_TYPE_NAME("%.*s"), len
, chip_type
);
66 const char *core_type
= object_class_get_name(object_class_by_name(s
));
72 * On Power Systems E880 (POWER8), the max cpus (threads) should be :
73 * 4 * 4 sockets * 12 cores * 8 threads = 1536
79 * Memory nodes are created by hostboot, one for each range of memory
80 * that has a different "affinity". In practice, it means one range
83 static void pnv_dt_memory(void *fdt
, int chip_id
, hwaddr start
, hwaddr size
)
86 uint64_t mem_reg_property
[2];
89 mem_reg_property
[0] = cpu_to_be64(start
);
90 mem_reg_property
[1] = cpu_to_be64(size
);
92 mem_name
= g_strdup_printf("memory@%"HWADDR_PRIx
, start
);
93 off
= fdt_add_subnode(fdt
, 0, mem_name
);
96 _FDT((fdt_setprop_string(fdt
, off
, "device_type", "memory")));
97 _FDT((fdt_setprop(fdt
, off
, "reg", mem_reg_property
,
98 sizeof(mem_reg_property
))));
99 _FDT((fdt_setprop_cell(fdt
, off
, "ibm,chip-id", chip_id
)));
102 static int get_cpus_node(void *fdt
)
104 int cpus_offset
= fdt_path_offset(fdt
, "/cpus");
106 if (cpus_offset
< 0) {
107 cpus_offset
= fdt_add_subnode(fdt
, 0, "cpus");
109 _FDT((fdt_setprop_cell(fdt
, cpus_offset
, "#address-cells", 0x1)));
110 _FDT((fdt_setprop_cell(fdt
, cpus_offset
, "#size-cells", 0x0)));
118 * The PowerNV cores (and threads) need to use real HW ids and not an
119 * incremental index like it has been done on other platforms. This HW
120 * id is stored in the CPU PIR, it is used to create cpu nodes in the
121 * device tree, used in XSCOM to address cores and in interrupt
124 static void pnv_dt_core(PnvChip
*chip
, PnvCore
*pc
, void *fdt
)
126 PowerPCCPU
*cpu
= pc
->threads
[0];
127 CPUState
*cs
= CPU(cpu
);
128 DeviceClass
*dc
= DEVICE_GET_CLASS(cs
);
129 int smt_threads
= CPU_CORE(pc
)->nr_threads
;
130 CPUPPCState
*env
= &cpu
->env
;
131 PowerPCCPUClass
*pcc
= POWERPC_CPU_GET_CLASS(cs
);
132 uint32_t servers_prop
[smt_threads
];
134 uint32_t segs
[] = {cpu_to_be32(28), cpu_to_be32(40),
135 0xffffffff, 0xffffffff};
136 uint32_t tbfreq
= PNV_TIMEBASE_FREQ
;
137 uint32_t cpufreq
= 1000000000;
138 uint32_t page_sizes_prop
[64];
139 size_t page_sizes_prop_size
;
140 const uint8_t pa_features
[] = { 24, 0,
141 0xf6, 0x3f, 0xc7, 0xc0, 0x80, 0xf0,
142 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
144 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 };
147 int cpus_offset
= get_cpus_node(fdt
);
149 nodename
= g_strdup_printf("%s@%x", dc
->fw_name
, pc
->pir
);
150 offset
= fdt_add_subnode(fdt
, cpus_offset
, nodename
);
154 _FDT((fdt_setprop_cell(fdt
, offset
, "ibm,chip-id", chip
->chip_id
)));
156 _FDT((fdt_setprop_cell(fdt
, offset
, "reg", pc
->pir
)));
157 _FDT((fdt_setprop_cell(fdt
, offset
, "ibm,pir", pc
->pir
)));
158 _FDT((fdt_setprop_string(fdt
, offset
, "device_type", "cpu")));
160 _FDT((fdt_setprop_cell(fdt
, offset
, "cpu-version", env
->spr
[SPR_PVR
])));
161 _FDT((fdt_setprop_cell(fdt
, offset
, "d-cache-block-size",
162 env
->dcache_line_size
)));
163 _FDT((fdt_setprop_cell(fdt
, offset
, "d-cache-line-size",
164 env
->dcache_line_size
)));
165 _FDT((fdt_setprop_cell(fdt
, offset
, "i-cache-block-size",
166 env
->icache_line_size
)));
167 _FDT((fdt_setprop_cell(fdt
, offset
, "i-cache-line-size",
168 env
->icache_line_size
)));
170 if (pcc
->l1_dcache_size
) {
171 _FDT((fdt_setprop_cell(fdt
, offset
, "d-cache-size",
172 pcc
->l1_dcache_size
)));
174 warn_report("Unknown L1 dcache size for cpu");
176 if (pcc
->l1_icache_size
) {
177 _FDT((fdt_setprop_cell(fdt
, offset
, "i-cache-size",
178 pcc
->l1_icache_size
)));
180 warn_report("Unknown L1 icache size for cpu");
183 _FDT((fdt_setprop_cell(fdt
, offset
, "timebase-frequency", tbfreq
)));
184 _FDT((fdt_setprop_cell(fdt
, offset
, "clock-frequency", cpufreq
)));
185 _FDT((fdt_setprop_cell(fdt
, offset
, "ibm,slb-size", cpu
->hash64_opts
->slb_size
)));
186 _FDT((fdt_setprop_string(fdt
, offset
, "status", "okay")));
187 _FDT((fdt_setprop(fdt
, offset
, "64-bit", NULL
, 0)));
189 if (env
->spr_cb
[SPR_PURR
].oea_read
) {
190 _FDT((fdt_setprop(fdt
, offset
, "ibm,purr", NULL
, 0)));
193 if (ppc_hash64_has(cpu
, PPC_HASH64_1TSEG
)) {
194 _FDT((fdt_setprop(fdt
, offset
, "ibm,processor-segment-sizes",
195 segs
, sizeof(segs
))));
198 /* Advertise VMX/VSX (vector extensions) if available
199 * 0 / no property == no vector extensions
200 * 1 == VMX / Altivec available
201 * 2 == VSX available */
202 if (env
->insns_flags
& PPC_ALTIVEC
) {
203 uint32_t vmx
= (env
->insns_flags2
& PPC2_VSX
) ? 2 : 1;
205 _FDT((fdt_setprop_cell(fdt
, offset
, "ibm,vmx", vmx
)));
208 /* Advertise DFP (Decimal Floating Point) if available
209 * 0 / no property == no DFP
210 * 1 == DFP available */
211 if (env
->insns_flags2
& PPC2_DFP
) {
212 _FDT((fdt_setprop_cell(fdt
, offset
, "ibm,dfp", 1)));
215 page_sizes_prop_size
= ppc_create_page_sizes_prop(cpu
, page_sizes_prop
,
216 sizeof(page_sizes_prop
));
217 if (page_sizes_prop_size
) {
218 _FDT((fdt_setprop(fdt
, offset
, "ibm,segment-page-sizes",
219 page_sizes_prop
, page_sizes_prop_size
)));
222 _FDT((fdt_setprop(fdt
, offset
, "ibm,pa-features",
223 pa_features
, sizeof(pa_features
))));
225 /* Build interrupt servers properties */
226 for (i
= 0; i
< smt_threads
; i
++) {
227 servers_prop
[i
] = cpu_to_be32(pc
->pir
+ i
);
229 _FDT((fdt_setprop(fdt
, offset
, "ibm,ppc-interrupt-server#s",
230 servers_prop
, sizeof(servers_prop
))));
233 static void pnv_dt_icp(PnvChip
*chip
, void *fdt
, uint32_t pir
,
236 uint64_t addr
= PNV_ICP_BASE(chip
) | (pir
<< 12);
238 const char compat
[] = "IBM,power8-icp\0IBM,ppc-xicp";
239 uint32_t irange
[2], i
, rsize
;
243 irange
[0] = cpu_to_be32(pir
);
244 irange
[1] = cpu_to_be32(nr_threads
);
246 rsize
= sizeof(uint64_t) * 2 * nr_threads
;
247 reg
= g_malloc(rsize
);
248 for (i
= 0; i
< nr_threads
; i
++) {
249 reg
[i
* 2] = cpu_to_be64(addr
| ((pir
+ i
) * 0x1000));
250 reg
[i
* 2 + 1] = cpu_to_be64(0x1000);
253 name
= g_strdup_printf("interrupt-controller@%"PRIX64
, addr
);
254 offset
= fdt_add_subnode(fdt
, 0, name
);
258 _FDT((fdt_setprop(fdt
, offset
, "compatible", compat
, sizeof(compat
))));
259 _FDT((fdt_setprop(fdt
, offset
, "reg", reg
, rsize
)));
260 _FDT((fdt_setprop_string(fdt
, offset
, "device_type",
261 "PowerPC-External-Interrupt-Presentation")));
262 _FDT((fdt_setprop(fdt
, offset
, "interrupt-controller", NULL
, 0)));
263 _FDT((fdt_setprop(fdt
, offset
, "ibm,interrupt-server-ranges",
264 irange
, sizeof(irange
))));
265 _FDT((fdt_setprop_cell(fdt
, offset
, "#interrupt-cells", 1)));
266 _FDT((fdt_setprop_cell(fdt
, offset
, "#address-cells", 0)));
270 static void pnv_chip_power8_dt_populate(PnvChip
*chip
, void *fdt
)
272 const char *typename
= pnv_chip_core_typename(chip
);
273 size_t typesize
= object_type_get_instance_size(typename
);
276 pnv_dt_xscom(chip
, fdt
, 0);
278 for (i
= 0; i
< chip
->nr_cores
; i
++) {
279 PnvCore
*pnv_core
= PNV_CORE(chip
->cores
+ i
* typesize
);
281 pnv_dt_core(chip
, pnv_core
, fdt
);
283 /* Interrupt Control Presenters (ICP). One per core. */
284 pnv_dt_icp(chip
, fdt
, pnv_core
->pir
, CPU_CORE(pnv_core
)->nr_threads
);
287 if (chip
->ram_size
) {
288 pnv_dt_memory(fdt
, chip
->chip_id
, chip
->ram_start
, chip
->ram_size
);
292 static void pnv_chip_power9_dt_populate(PnvChip
*chip
, void *fdt
)
294 const char *typename
= pnv_chip_core_typename(chip
);
295 size_t typesize
= object_type_get_instance_size(typename
);
298 pnv_dt_xscom(chip
, fdt
, 0);
300 for (i
= 0; i
< chip
->nr_cores
; i
++) {
301 PnvCore
*pnv_core
= PNV_CORE(chip
->cores
+ i
* typesize
);
303 pnv_dt_core(chip
, pnv_core
, fdt
);
306 if (chip
->ram_size
) {
307 pnv_dt_memory(fdt
, chip
->chip_id
, chip
->ram_start
, chip
->ram_size
);
311 static void pnv_dt_rtc(ISADevice
*d
, void *fdt
, int lpc_off
)
313 uint32_t io_base
= d
->ioport_id
;
314 uint32_t io_regs
[] = {
316 cpu_to_be32(io_base
),
322 name
= g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d
)), io_base
);
323 node
= fdt_add_subnode(fdt
, lpc_off
, name
);
327 _FDT((fdt_setprop(fdt
, node
, "reg", io_regs
, sizeof(io_regs
))));
328 _FDT((fdt_setprop_string(fdt
, node
, "compatible", "pnpPNP,b00")));
331 static void pnv_dt_serial(ISADevice
*d
, void *fdt
, int lpc_off
)
333 const char compatible
[] = "ns16550\0pnpPNP,501";
334 uint32_t io_base
= d
->ioport_id
;
335 uint32_t io_regs
[] = {
337 cpu_to_be32(io_base
),
343 name
= g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d
)), io_base
);
344 node
= fdt_add_subnode(fdt
, lpc_off
, name
);
348 _FDT((fdt_setprop(fdt
, node
, "reg", io_regs
, sizeof(io_regs
))));
349 _FDT((fdt_setprop(fdt
, node
, "compatible", compatible
,
350 sizeof(compatible
))));
352 _FDT((fdt_setprop_cell(fdt
, node
, "clock-frequency", 1843200)));
353 _FDT((fdt_setprop_cell(fdt
, node
, "current-speed", 115200)));
354 _FDT((fdt_setprop_cell(fdt
, node
, "interrupts", d
->isairq
[0])));
355 _FDT((fdt_setprop_cell(fdt
, node
, "interrupt-parent",
356 fdt_get_phandle(fdt
, lpc_off
))));
358 /* This is needed by Linux */
359 _FDT((fdt_setprop_string(fdt
, node
, "device_type", "serial")));
362 static void pnv_dt_ipmi_bt(ISADevice
*d
, void *fdt
, int lpc_off
)
364 const char compatible
[] = "bt\0ipmi-bt";
366 uint32_t io_regs
[] = {
368 0, /* 'io_base' retrieved from the 'ioport' property of 'isa-ipmi-bt' */
375 io_base
= object_property_get_int(OBJECT(d
), "ioport", &error_fatal
);
376 io_regs
[1] = cpu_to_be32(io_base
);
378 irq
= object_property_get_int(OBJECT(d
), "irq", &error_fatal
);
380 name
= g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d
)), io_base
);
381 node
= fdt_add_subnode(fdt
, lpc_off
, name
);
385 _FDT((fdt_setprop(fdt
, node
, "reg", io_regs
, sizeof(io_regs
))));
386 _FDT((fdt_setprop(fdt
, node
, "compatible", compatible
,
387 sizeof(compatible
))));
389 /* Mark it as reserved to avoid Linux trying to claim it */
390 _FDT((fdt_setprop_string(fdt
, node
, "status", "reserved")));
391 _FDT((fdt_setprop_cell(fdt
, node
, "interrupts", irq
)));
392 _FDT((fdt_setprop_cell(fdt
, node
, "interrupt-parent",
393 fdt_get_phandle(fdt
, lpc_off
))));
396 typedef struct ForeachPopulateArgs
{
399 } ForeachPopulateArgs
;
401 static int pnv_dt_isa_device(DeviceState
*dev
, void *opaque
)
403 ForeachPopulateArgs
*args
= opaque
;
404 ISADevice
*d
= ISA_DEVICE(dev
);
406 if (object_dynamic_cast(OBJECT(dev
), TYPE_MC146818_RTC
)) {
407 pnv_dt_rtc(d
, args
->fdt
, args
->offset
);
408 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_ISA_SERIAL
)) {
409 pnv_dt_serial(d
, args
->fdt
, args
->offset
);
410 } else if (object_dynamic_cast(OBJECT(dev
), "isa-ipmi-bt")) {
411 pnv_dt_ipmi_bt(d
, args
->fdt
, args
->offset
);
413 error_report("unknown isa device %s@i%x", qdev_fw_name(dev
),
420 /* The default LPC bus of a multichip system is on chip 0. It's
421 * recognized by the firmware (skiboot) using a "primary" property.
423 static void pnv_dt_isa(PnvMachineState
*pnv
, void *fdt
)
425 int isa_offset
= fdt_path_offset(fdt
, pnv
->chips
[0]->dt_isa_nodename
);
426 ForeachPopulateArgs args
= {
428 .offset
= isa_offset
,
431 _FDT((fdt_setprop(fdt
, isa_offset
, "primary", NULL
, 0)));
433 /* ISA devices are not necessarily parented to the ISA bus so we
434 * can not use object_child_foreach() */
435 qbus_walk_children(BUS(pnv
->isa_bus
), pnv_dt_isa_device
, NULL
, NULL
, NULL
,
439 static void *pnv_dt_create(MachineState
*machine
)
441 const char plat_compat
[] = "qemu,powernv\0ibm,powernv";
442 PnvMachineState
*pnv
= PNV_MACHINE(machine
);
448 fdt
= g_malloc0(FDT_MAX_SIZE
);
449 _FDT((fdt_create_empty_tree(fdt
, FDT_MAX_SIZE
)));
452 _FDT((fdt_setprop_cell(fdt
, 0, "#address-cells", 0x2)));
453 _FDT((fdt_setprop_cell(fdt
, 0, "#size-cells", 0x2)));
454 _FDT((fdt_setprop_string(fdt
, 0, "model",
455 "IBM PowerNV (emulated by qemu)")));
456 _FDT((fdt_setprop(fdt
, 0, "compatible", plat_compat
,
457 sizeof(plat_compat
))));
459 buf
= qemu_uuid_unparse_strdup(&qemu_uuid
);
460 _FDT((fdt_setprop_string(fdt
, 0, "vm,uuid", buf
)));
462 _FDT((fdt_property_string(fdt
, "system-id", buf
)));
466 off
= fdt_add_subnode(fdt
, 0, "chosen");
467 if (machine
->kernel_cmdline
) {
468 _FDT((fdt_setprop_string(fdt
, off
, "bootargs",
469 machine
->kernel_cmdline
)));
472 if (pnv
->initrd_size
) {
473 uint32_t start_prop
= cpu_to_be32(pnv
->initrd_base
);
474 uint32_t end_prop
= cpu_to_be32(pnv
->initrd_base
+ pnv
->initrd_size
);
476 _FDT((fdt_setprop(fdt
, off
, "linux,initrd-start",
477 &start_prop
, sizeof(start_prop
))));
478 _FDT((fdt_setprop(fdt
, off
, "linux,initrd-end",
479 &end_prop
, sizeof(end_prop
))));
482 /* Populate device tree for each chip */
483 for (i
= 0; i
< pnv
->num_chips
; i
++) {
484 PNV_CHIP_GET_CLASS(pnv
->chips
[i
])->dt_populate(pnv
->chips
[i
], fdt
);
487 /* Populate ISA devices on chip 0 */
488 pnv_dt_isa(pnv
, fdt
);
491 pnv_dt_bmc_sensors(pnv
->bmc
, fdt
);
497 static void pnv_powerdown_notify(Notifier
*n
, void *opaque
)
499 PnvMachineState
*pnv
= PNV_MACHINE(qdev_get_machine());
502 pnv_bmc_powerdown(pnv
->bmc
);
506 static void pnv_reset(void)
508 MachineState
*machine
= MACHINE(qdev_get_machine());
509 PnvMachineState
*pnv
= PNV_MACHINE(machine
);
513 qemu_devices_reset();
515 /* OpenPOWER systems have a BMC, which can be defined on the
518 * -device ipmi-bmc-sim,id=bmc0
520 * This is the internal simulator but it could also be an external
523 obj
= object_resolve_path_type("", "ipmi-bmc-sim", NULL
);
525 pnv
->bmc
= IPMI_BMC(obj
);
528 fdt
= pnv_dt_create(machine
);
530 /* Pack resulting tree */
531 _FDT((fdt_pack(fdt
)));
533 cpu_physical_memory_write(PNV_FDT_ADDR
, fdt
, fdt_totalsize(fdt
));
536 static ISABus
*pnv_chip_power8_isa_create(PnvChip
*chip
, Error
**errp
)
538 Pnv8Chip
*chip8
= PNV8_CHIP(chip
);
539 return pnv_lpc_isa_create(&chip8
->lpc
, true, errp
);
542 static ISABus
*pnv_chip_power8nvl_isa_create(PnvChip
*chip
, Error
**errp
)
544 Pnv8Chip
*chip8
= PNV8_CHIP(chip
);
545 return pnv_lpc_isa_create(&chip8
->lpc
, false, errp
);
548 static ISABus
*pnv_chip_power9_isa_create(PnvChip
*chip
, Error
**errp
)
553 static ISABus
*pnv_isa_create(PnvChip
*chip
, Error
**errp
)
555 return PNV_CHIP_GET_CLASS(chip
)->isa_create(chip
, errp
);
558 static void pnv_chip_power8_pic_print_info(PnvChip
*chip
, Monitor
*mon
)
560 Pnv8Chip
*chip8
= PNV8_CHIP(chip
);
562 ics_pic_print_info(&chip8
->psi
.ics
, mon
);
565 static void pnv_chip_power9_pic_print_info(PnvChip
*chip
, Monitor
*mon
)
567 Pnv9Chip
*chip9
= PNV9_CHIP(chip
);
569 pnv_xive_pic_print_info(&chip9
->xive
, mon
);
570 pnv_psi_pic_print_info(&chip9
->psi
, mon
);
573 static void pnv_init(MachineState
*machine
)
575 PnvMachineState
*pnv
= PNV_MACHINE(machine
);
583 if (machine
->ram_size
< (1 * GiB
)) {
584 warn_report("skiboot may not work with < 1GB of RAM");
587 ram
= g_new(MemoryRegion
, 1);
588 memory_region_allocate_system_memory(ram
, NULL
, "pnv.ram",
590 memory_region_add_subregion(get_system_memory(), 0, ram
);
592 /* load skiboot firmware */
593 if (bios_name
== NULL
) {
594 bios_name
= FW_FILE_NAME
;
597 fw_filename
= qemu_find_file(QEMU_FILE_TYPE_BIOS
, bios_name
);
599 error_report("Could not find OPAL firmware '%s'", bios_name
);
603 fw_size
= load_image_targphys(fw_filename
, FW_LOAD_ADDR
, FW_MAX_SIZE
);
605 error_report("Could not load OPAL firmware '%s'", fw_filename
);
611 if (machine
->kernel_filename
) {
614 kernel_size
= load_image_targphys(machine
->kernel_filename
,
615 KERNEL_LOAD_ADDR
, KERNEL_MAX_SIZE
);
616 if (kernel_size
< 0) {
617 error_report("Could not load kernel '%s'",
618 machine
->kernel_filename
);
624 if (machine
->initrd_filename
) {
625 pnv
->initrd_base
= INITRD_LOAD_ADDR
;
626 pnv
->initrd_size
= load_image_targphys(machine
->initrd_filename
,
627 pnv
->initrd_base
, INITRD_MAX_SIZE
);
628 if (pnv
->initrd_size
< 0) {
629 error_report("Could not load initial ram disk '%s'",
630 machine
->initrd_filename
);
635 /* Create the processor chips */
636 i
= strlen(machine
->cpu_type
) - strlen(POWERPC_CPU_TYPE_SUFFIX
);
637 chip_typename
= g_strdup_printf(PNV_CHIP_TYPE_NAME("%.*s"),
638 i
, machine
->cpu_type
);
639 if (!object_class_by_name(chip_typename
)) {
640 error_report("invalid CPU model '%.*s' for %s machine",
641 i
, machine
->cpu_type
, MACHINE_GET_CLASS(machine
)->name
);
645 pnv
->chips
= g_new0(PnvChip
*, pnv
->num_chips
);
646 for (i
= 0; i
< pnv
->num_chips
; i
++) {
648 Object
*chip
= object_new(chip_typename
);
650 pnv
->chips
[i
] = PNV_CHIP(chip
);
652 /* TODO: put all the memory in one node on chip 0 until we find a
653 * way to specify different ranges for each chip
656 object_property_set_int(chip
, machine
->ram_size
, "ram-size",
660 snprintf(chip_name
, sizeof(chip_name
), "chip[%d]", PNV_CHIP_HWID(i
));
661 object_property_add_child(OBJECT(pnv
), chip_name
, chip
, &error_fatal
);
662 object_property_set_int(chip
, PNV_CHIP_HWID(i
), "chip-id",
664 object_property_set_int(chip
, smp_cores
, "nr-cores", &error_fatal
);
665 object_property_set_bool(chip
, true, "realized", &error_fatal
);
667 g_free(chip_typename
);
669 /* Instantiate ISA bus on chip 0 */
670 pnv
->isa_bus
= pnv_isa_create(pnv
->chips
[0], &error_fatal
);
672 /* Create serial port */
673 serial_hds_isa_init(pnv
->isa_bus
, 0, MAX_ISA_SERIAL_PORTS
);
675 /* Create an RTC ISA device too */
676 mc146818_rtc_init(pnv
->isa_bus
, 2000, NULL
);
678 /* OpenPOWER systems use a IPMI SEL Event message to notify the
679 * host to powerdown */
680 pnv
->powerdown_notifier
.notify
= pnv_powerdown_notify
;
681 qemu_register_powerdown_notifier(&pnv
->powerdown_notifier
);
685 * 0:21 Reserved - Read as zeros
690 static uint32_t pnv_chip_core_pir_p8(PnvChip
*chip
, uint32_t core_id
)
692 return (chip
->chip_id
<< 7) | (core_id
<< 3);
695 static void pnv_chip_power8_intc_create(PnvChip
*chip
, PowerPCCPU
*cpu
,
698 Error
*local_err
= NULL
;
700 PnvCPUState
*pnv_cpu
= pnv_cpu_state(cpu
);
702 obj
= icp_create(OBJECT(cpu
), TYPE_PNV_ICP
, XICS_FABRIC(qdev_get_machine()),
705 error_propagate(errp
, local_err
);
713 * 0:48 Reserved - Read as zeroes
716 * 56 Reserved - Read as zero
720 * We only care about the lower bits. uint32_t is fine for the moment.
722 static uint32_t pnv_chip_core_pir_p9(PnvChip
*chip
, uint32_t core_id
)
724 return (chip
->chip_id
<< 8) | (core_id
<< 2);
727 static void pnv_chip_power9_intc_create(PnvChip
*chip
, PowerPCCPU
*cpu
,
730 Pnv9Chip
*chip9
= PNV9_CHIP(chip
);
731 Error
*local_err
= NULL
;
733 PnvCPUState
*pnv_cpu
= pnv_cpu_state(cpu
);
736 * The core creates its interrupt presenter but the XIVE interrupt
737 * controller object is initialized afterwards. Hopefully, it's
738 * only used at runtime.
740 obj
= xive_tctx_create(OBJECT(cpu
), XIVE_ROUTER(&chip9
->xive
), errp
);
742 error_propagate(errp
, local_err
);
749 /* Allowed core identifiers on a POWER8 Processor Chip :
758 * <EX7,8 reserved> <reserved>
767 #define POWER8E_CORE_MASK (0x7070ull)
768 #define POWER8_CORE_MASK (0x7e7eull)
771 * POWER9 has 24 cores, ids starting at 0x0
773 #define POWER9_CORE_MASK (0xffffffffffffffull)
775 static void pnv_chip_power8_instance_init(Object
*obj
)
777 Pnv8Chip
*chip8
= PNV8_CHIP(obj
);
779 object_initialize_child(obj
, "psi", &chip8
->psi
, sizeof(chip8
->psi
),
780 TYPE_PNV8_PSI
, &error_abort
, NULL
);
781 object_property_add_const_link(OBJECT(&chip8
->psi
), "xics",
782 OBJECT(qdev_get_machine()), &error_abort
);
784 object_initialize_child(obj
, "lpc", &chip8
->lpc
, sizeof(chip8
->lpc
),
785 TYPE_PNV8_LPC
, &error_abort
, NULL
);
786 object_property_add_const_link(OBJECT(&chip8
->lpc
), "psi",
787 OBJECT(&chip8
->psi
), &error_abort
);
789 object_initialize_child(obj
, "occ", &chip8
->occ
, sizeof(chip8
->occ
),
790 TYPE_PNV_OCC
, &error_abort
, NULL
);
791 object_property_add_const_link(OBJECT(&chip8
->occ
), "psi",
792 OBJECT(&chip8
->psi
), &error_abort
);
795 static void pnv_chip_icp_realize(Pnv8Chip
*chip8
, Error
**errp
)
797 PnvChip
*chip
= PNV_CHIP(chip8
);
798 PnvChipClass
*pcc
= PNV_CHIP_GET_CLASS(chip
);
799 const char *typename
= pnv_chip_core_typename(chip
);
800 size_t typesize
= object_type_get_instance_size(typename
);
803 XICSFabric
*xi
= XICS_FABRIC(qdev_get_machine());
805 name
= g_strdup_printf("icp-%x", chip
->chip_id
);
806 memory_region_init(&chip8
->icp_mmio
, OBJECT(chip
), name
, PNV_ICP_SIZE
);
807 sysbus_init_mmio(SYS_BUS_DEVICE(chip
), &chip8
->icp_mmio
);
810 sysbus_mmio_map(SYS_BUS_DEVICE(chip
), 1, PNV_ICP_BASE(chip
));
812 /* Map the ICP registers for each thread */
813 for (i
= 0; i
< chip
->nr_cores
; i
++) {
814 PnvCore
*pnv_core
= PNV_CORE(chip
->cores
+ i
* typesize
);
815 int core_hwid
= CPU_CORE(pnv_core
)->core_id
;
817 for (j
= 0; j
< CPU_CORE(pnv_core
)->nr_threads
; j
++) {
818 uint32_t pir
= pcc
->core_pir(chip
, core_hwid
) + j
;
819 PnvICPState
*icp
= PNV_ICP(xics_icp_get(xi
, pir
));
821 memory_region_add_subregion(&chip8
->icp_mmio
, pir
<< 12,
827 static void pnv_chip_power8_realize(DeviceState
*dev
, Error
**errp
)
829 PnvChipClass
*pcc
= PNV_CHIP_GET_CLASS(dev
);
830 PnvChip
*chip
= PNV_CHIP(dev
);
831 Pnv8Chip
*chip8
= PNV8_CHIP(dev
);
832 Pnv8Psi
*psi8
= &chip8
->psi
;
833 Error
*local_err
= NULL
;
835 pcc
->parent_realize(dev
, &local_err
);
837 error_propagate(errp
, local_err
);
841 /* Processor Service Interface (PSI) Host Bridge */
842 object_property_set_int(OBJECT(&chip8
->psi
), PNV_PSIHB_BASE(chip
),
843 "bar", &error_fatal
);
844 object_property_set_bool(OBJECT(&chip8
->psi
), true, "realized", &local_err
);
846 error_propagate(errp
, local_err
);
849 pnv_xscom_add_subregion(chip
, PNV_XSCOM_PSIHB_BASE
,
850 &PNV_PSI(psi8
)->xscom_regs
);
852 /* Create LPC controller */
853 object_property_set_bool(OBJECT(&chip8
->lpc
), true, "realized",
855 pnv_xscom_add_subregion(chip
, PNV_XSCOM_LPC_BASE
, &chip8
->lpc
.xscom_regs
);
857 chip
->dt_isa_nodename
= g_strdup_printf("/xscom@%" PRIx64
"/isa@%x",
858 (uint64_t) PNV_XSCOM_BASE(chip
),
861 /* Interrupt Management Area. This is the memory region holding
862 * all the Interrupt Control Presenter (ICP) registers */
863 pnv_chip_icp_realize(chip8
, &local_err
);
865 error_propagate(errp
, local_err
);
869 /* Create the simplified OCC model */
870 object_property_set_bool(OBJECT(&chip8
->occ
), true, "realized", &local_err
);
872 error_propagate(errp
, local_err
);
875 pnv_xscom_add_subregion(chip
, PNV_XSCOM_OCC_BASE
, &chip8
->occ
.xscom_regs
);
878 static void pnv_chip_power8e_class_init(ObjectClass
*klass
, void *data
)
880 DeviceClass
*dc
= DEVICE_CLASS(klass
);
881 PnvChipClass
*k
= PNV_CHIP_CLASS(klass
);
883 k
->chip_type
= PNV_CHIP_POWER8E
;
884 k
->chip_cfam_id
= 0x221ef04980000000ull
; /* P8 Murano DD2.1 */
885 k
->cores_mask
= POWER8E_CORE_MASK
;
886 k
->core_pir
= pnv_chip_core_pir_p8
;
887 k
->intc_create
= pnv_chip_power8_intc_create
;
888 k
->isa_create
= pnv_chip_power8_isa_create
;
889 k
->dt_populate
= pnv_chip_power8_dt_populate
;
890 k
->pic_print_info
= pnv_chip_power8_pic_print_info
;
891 k
->xscom_base
= 0x003fc0000000000ull
;
892 dc
->desc
= "PowerNV Chip POWER8E";
894 device_class_set_parent_realize(dc
, pnv_chip_power8_realize
,
898 static void pnv_chip_power8_class_init(ObjectClass
*klass
, void *data
)
900 DeviceClass
*dc
= DEVICE_CLASS(klass
);
901 PnvChipClass
*k
= PNV_CHIP_CLASS(klass
);
903 k
->chip_type
= PNV_CHIP_POWER8
;
904 k
->chip_cfam_id
= 0x220ea04980000000ull
; /* P8 Venice DD2.0 */
905 k
->cores_mask
= POWER8_CORE_MASK
;
906 k
->core_pir
= pnv_chip_core_pir_p8
;
907 k
->intc_create
= pnv_chip_power8_intc_create
;
908 k
->isa_create
= pnv_chip_power8_isa_create
;
909 k
->dt_populate
= pnv_chip_power8_dt_populate
;
910 k
->pic_print_info
= pnv_chip_power8_pic_print_info
;
911 k
->xscom_base
= 0x003fc0000000000ull
;
912 dc
->desc
= "PowerNV Chip POWER8";
914 device_class_set_parent_realize(dc
, pnv_chip_power8_realize
,
918 static void pnv_chip_power8nvl_class_init(ObjectClass
*klass
, void *data
)
920 DeviceClass
*dc
= DEVICE_CLASS(klass
);
921 PnvChipClass
*k
= PNV_CHIP_CLASS(klass
);
923 k
->chip_type
= PNV_CHIP_POWER8NVL
;
924 k
->chip_cfam_id
= 0x120d304980000000ull
; /* P8 Naples DD1.0 */
925 k
->cores_mask
= POWER8_CORE_MASK
;
926 k
->core_pir
= pnv_chip_core_pir_p8
;
927 k
->intc_create
= pnv_chip_power8_intc_create
;
928 k
->isa_create
= pnv_chip_power8nvl_isa_create
;
929 k
->dt_populate
= pnv_chip_power8_dt_populate
;
930 k
->pic_print_info
= pnv_chip_power8_pic_print_info
;
931 k
->xscom_base
= 0x003fc0000000000ull
;
932 dc
->desc
= "PowerNV Chip POWER8NVL";
934 device_class_set_parent_realize(dc
, pnv_chip_power8_realize
,
938 static void pnv_chip_power9_instance_init(Object
*obj
)
940 Pnv9Chip
*chip9
= PNV9_CHIP(obj
);
942 object_initialize_child(obj
, "xive", &chip9
->xive
, sizeof(chip9
->xive
),
943 TYPE_PNV_XIVE
, &error_abort
, NULL
);
944 object_property_add_const_link(OBJECT(&chip9
->xive
), "chip", obj
,
947 object_initialize_child(obj
, "psi", &chip9
->psi
, sizeof(chip9
->psi
),
948 TYPE_PNV9_PSI
, &error_abort
, NULL
);
949 object_property_add_const_link(OBJECT(&chip9
->psi
), "chip", obj
,
953 static void pnv_chip_power9_realize(DeviceState
*dev
, Error
**errp
)
955 PnvChipClass
*pcc
= PNV_CHIP_GET_CLASS(dev
);
956 Pnv9Chip
*chip9
= PNV9_CHIP(dev
);
957 PnvChip
*chip
= PNV_CHIP(dev
);
958 Pnv9Psi
*psi9
= &chip9
->psi
;
959 Error
*local_err
= NULL
;
961 pcc
->parent_realize(dev
, &local_err
);
963 error_propagate(errp
, local_err
);
967 /* XIVE interrupt controller (POWER9) */
968 object_property_set_int(OBJECT(&chip9
->xive
), PNV9_XIVE_IC_BASE(chip
),
969 "ic-bar", &error_fatal
);
970 object_property_set_int(OBJECT(&chip9
->xive
), PNV9_XIVE_VC_BASE(chip
),
971 "vc-bar", &error_fatal
);
972 object_property_set_int(OBJECT(&chip9
->xive
), PNV9_XIVE_PC_BASE(chip
),
973 "pc-bar", &error_fatal
);
974 object_property_set_int(OBJECT(&chip9
->xive
), PNV9_XIVE_TM_BASE(chip
),
975 "tm-bar", &error_fatal
);
976 object_property_set_bool(OBJECT(&chip9
->xive
), true, "realized",
979 error_propagate(errp
, local_err
);
982 pnv_xscom_add_subregion(chip
, PNV9_XSCOM_XIVE_BASE
,
983 &chip9
->xive
.xscom_regs
);
985 /* Processor Service Interface (PSI) Host Bridge */
986 object_property_set_int(OBJECT(&chip9
->psi
), PNV9_PSIHB_BASE(chip
),
987 "bar", &error_fatal
);
988 object_property_set_bool(OBJECT(&chip9
->psi
), true, "realized", &local_err
);
990 error_propagate(errp
, local_err
);
993 pnv_xscom_add_subregion(chip
, PNV9_XSCOM_PSIHB_BASE
,
994 &PNV_PSI(psi9
)->xscom_regs
);
997 static void pnv_chip_power9_class_init(ObjectClass
*klass
, void *data
)
999 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1000 PnvChipClass
*k
= PNV_CHIP_CLASS(klass
);
1002 k
->chip_type
= PNV_CHIP_POWER9
;
1003 k
->chip_cfam_id
= 0x220d104900008000ull
; /* P9 Nimbus DD2.0 */
1004 k
->cores_mask
= POWER9_CORE_MASK
;
1005 k
->core_pir
= pnv_chip_core_pir_p9
;
1006 k
->intc_create
= pnv_chip_power9_intc_create
;
1007 k
->isa_create
= pnv_chip_power9_isa_create
;
1008 k
->dt_populate
= pnv_chip_power9_dt_populate
;
1009 k
->pic_print_info
= pnv_chip_power9_pic_print_info
;
1010 k
->xscom_base
= 0x00603fc00000000ull
;
1011 dc
->desc
= "PowerNV Chip POWER9";
1013 device_class_set_parent_realize(dc
, pnv_chip_power9_realize
,
1014 &k
->parent_realize
);
1017 static void pnv_chip_core_sanitize(PnvChip
*chip
, Error
**errp
)
1019 PnvChipClass
*pcc
= PNV_CHIP_GET_CLASS(chip
);
1023 * No custom mask for this chip, let's use the default one from *
1026 if (!chip
->cores_mask
) {
1027 chip
->cores_mask
= pcc
->cores_mask
;
1030 /* filter alien core ids ! some are reserved */
1031 if ((chip
->cores_mask
& pcc
->cores_mask
) != chip
->cores_mask
) {
1032 error_setg(errp
, "warning: invalid core mask for chip Ox%"PRIx64
" !",
1036 chip
->cores_mask
&= pcc
->cores_mask
;
1038 /* now that we have a sane layout, let check the number of cores */
1039 cores_max
= ctpop64(chip
->cores_mask
);
1040 if (chip
->nr_cores
> cores_max
) {
1041 error_setg(errp
, "warning: too many cores for chip ! Limit is %d",
1047 static void pnv_chip_instance_init(Object
*obj
)
1049 PNV_CHIP(obj
)->xscom_base
= PNV_CHIP_GET_CLASS(obj
)->xscom_base
;
1052 static void pnv_chip_core_realize(PnvChip
*chip
, Error
**errp
)
1054 Error
*error
= NULL
;
1055 PnvChipClass
*pcc
= PNV_CHIP_GET_CLASS(chip
);
1056 const char *typename
= pnv_chip_core_typename(chip
);
1057 size_t typesize
= object_type_get_instance_size(typename
);
1060 if (!object_class_by_name(typename
)) {
1061 error_setg(errp
, "Unable to find PowerNV CPU Core '%s'", typename
);
1066 pnv_chip_core_sanitize(chip
, &error
);
1068 error_propagate(errp
, error
);
1072 chip
->cores
= g_malloc0(typesize
* chip
->nr_cores
);
1074 for (i
= 0, core_hwid
= 0; (core_hwid
< sizeof(chip
->cores_mask
) * 8)
1075 && (i
< chip
->nr_cores
); core_hwid
++) {
1077 void *pnv_core
= chip
->cores
+ i
* typesize
;
1078 uint64_t xscom_core_base
;
1080 if (!(chip
->cores_mask
& (1ull << core_hwid
))) {
1084 object_initialize(pnv_core
, typesize
, typename
);
1085 snprintf(core_name
, sizeof(core_name
), "core[%d]", core_hwid
);
1086 object_property_add_child(OBJECT(chip
), core_name
, OBJECT(pnv_core
),
1088 object_property_set_int(OBJECT(pnv_core
), smp_threads
, "nr-threads",
1090 object_property_set_int(OBJECT(pnv_core
), core_hwid
,
1091 CPU_CORE_PROP_CORE_ID
, &error_fatal
);
1092 object_property_set_int(OBJECT(pnv_core
),
1093 pcc
->core_pir(chip
, core_hwid
),
1094 "pir", &error_fatal
);
1095 object_property_add_const_link(OBJECT(pnv_core
), "chip",
1096 OBJECT(chip
), &error_fatal
);
1097 object_property_set_bool(OBJECT(pnv_core
), true, "realized",
1099 object_unref(OBJECT(pnv_core
));
1101 /* Each core has an XSCOM MMIO region */
1102 if (!pnv_chip_is_power9(chip
)) {
1103 xscom_core_base
= PNV_XSCOM_EX_BASE(core_hwid
);
1105 xscom_core_base
= PNV_XSCOM_P9_EC_BASE(core_hwid
);
1108 pnv_xscom_add_subregion(chip
, xscom_core_base
,
1109 &PNV_CORE(pnv_core
)->xscom_regs
);
1114 static void pnv_chip_realize(DeviceState
*dev
, Error
**errp
)
1116 PnvChip
*chip
= PNV_CHIP(dev
);
1117 Error
*error
= NULL
;
1120 pnv_xscom_realize(chip
, &error
);
1122 error_propagate(errp
, error
);
1125 sysbus_mmio_map(SYS_BUS_DEVICE(chip
), 0, PNV_XSCOM_BASE(chip
));
1128 pnv_chip_core_realize(chip
, &error
);
1130 error_propagate(errp
, error
);
1135 static Property pnv_chip_properties
[] = {
1136 DEFINE_PROP_UINT32("chip-id", PnvChip
, chip_id
, 0),
1137 DEFINE_PROP_UINT64("ram-start", PnvChip
, ram_start
, 0),
1138 DEFINE_PROP_UINT64("ram-size", PnvChip
, ram_size
, 0),
1139 DEFINE_PROP_UINT32("nr-cores", PnvChip
, nr_cores
, 1),
1140 DEFINE_PROP_UINT64("cores-mask", PnvChip
, cores_mask
, 0x0),
1141 DEFINE_PROP_END_OF_LIST(),
1144 static void pnv_chip_class_init(ObjectClass
*klass
, void *data
)
1146 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1148 set_bit(DEVICE_CATEGORY_CPU
, dc
->categories
);
1149 dc
->realize
= pnv_chip_realize
;
1150 dc
->props
= pnv_chip_properties
;
1151 dc
->desc
= "PowerNV Chip";
1154 static ICSState
*pnv_ics_get(XICSFabric
*xi
, int irq
)
1156 PnvMachineState
*pnv
= PNV_MACHINE(xi
);
1159 for (i
= 0; i
< pnv
->num_chips
; i
++) {
1160 Pnv8Chip
*chip8
= PNV8_CHIP(pnv
->chips
[i
]);
1162 if (ics_valid_irq(&chip8
->psi
.ics
, irq
)) {
1163 return &chip8
->psi
.ics
;
1169 static void pnv_ics_resend(XICSFabric
*xi
)
1171 PnvMachineState
*pnv
= PNV_MACHINE(xi
);
1174 for (i
= 0; i
< pnv
->num_chips
; i
++) {
1175 Pnv8Chip
*chip8
= PNV8_CHIP(pnv
->chips
[i
]);
1176 ics_resend(&chip8
->psi
.ics
);
1180 static ICPState
*pnv_icp_get(XICSFabric
*xi
, int pir
)
1182 PowerPCCPU
*cpu
= ppc_get_vcpu_by_pir(pir
);
1184 return cpu
? ICP(pnv_cpu_state(cpu
)->intc
) : NULL
;
1187 static void pnv_pic_print_info(InterruptStatsProvider
*obj
,
1190 PnvMachineState
*pnv
= PNV_MACHINE(obj
);
1195 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1197 if (pnv_chip_is_power9(pnv
->chips
[0])) {
1198 xive_tctx_pic_print_info(XIVE_TCTX(pnv_cpu_state(cpu
)->intc
), mon
);
1200 icp_pic_print_info(ICP(pnv_cpu_state(cpu
)->intc
), mon
);
1204 for (i
= 0; i
< pnv
->num_chips
; i
++) {
1205 PNV_CHIP_GET_CLASS(pnv
->chips
[i
])->pic_print_info(pnv
->chips
[i
], mon
);
1209 static void pnv_get_num_chips(Object
*obj
, Visitor
*v
, const char *name
,
1210 void *opaque
, Error
**errp
)
1212 visit_type_uint32(v
, name
, &PNV_MACHINE(obj
)->num_chips
, errp
);
1215 static void pnv_set_num_chips(Object
*obj
, Visitor
*v
, const char *name
,
1216 void *opaque
, Error
**errp
)
1218 PnvMachineState
*pnv
= PNV_MACHINE(obj
);
1220 Error
*local_err
= NULL
;
1222 visit_type_uint32(v
, name
, &num_chips
, &local_err
);
1224 error_propagate(errp
, local_err
);
1229 * TODO: should we decide on how many chips we can create based
1230 * on #cores and Venice vs. Murano vs. Naples chip type etc...,
1232 if (!is_power_of_2(num_chips
) || num_chips
> 4) {
1233 error_setg(errp
, "invalid number of chips: '%d'", num_chips
);
1237 pnv
->num_chips
= num_chips
;
1240 static void pnv_machine_instance_init(Object
*obj
)
1242 PnvMachineState
*pnv
= PNV_MACHINE(obj
);
1246 static void pnv_machine_class_props_init(ObjectClass
*oc
)
1248 object_class_property_add(oc
, "num-chips", "uint32",
1249 pnv_get_num_chips
, pnv_set_num_chips
,
1251 object_class_property_set_description(oc
, "num-chips",
1252 "Specifies the number of processor chips",
1256 static void pnv_machine_class_init(ObjectClass
*oc
, void *data
)
1258 MachineClass
*mc
= MACHINE_CLASS(oc
);
1259 XICSFabricClass
*xic
= XICS_FABRIC_CLASS(oc
);
1260 InterruptStatsProviderClass
*ispc
= INTERRUPT_STATS_PROVIDER_CLASS(oc
);
1262 mc
->desc
= "IBM PowerNV (Non-Virtualized)";
1263 mc
->init
= pnv_init
;
1264 mc
->reset
= pnv_reset
;
1265 mc
->max_cpus
= MAX_CPUS
;
1266 mc
->default_cpu_type
= POWERPC_CPU_TYPE_NAME("power8_v2.0");
1267 mc
->block_default_type
= IF_IDE
; /* Pnv provides a AHCI device for
1269 mc
->no_parallel
= 1;
1270 mc
->default_boot_order
= NULL
;
1271 mc
->default_ram_size
= 1 * GiB
;
1272 xic
->icp_get
= pnv_icp_get
;
1273 xic
->ics_get
= pnv_ics_get
;
1274 xic
->ics_resend
= pnv_ics_resend
;
1275 ispc
->print_info
= pnv_pic_print_info
;
1277 pnv_machine_class_props_init(oc
);
1280 #define DEFINE_PNV8_CHIP_TYPE(type, class_initfn) \
1283 .class_init = class_initfn, \
1284 .parent = TYPE_PNV8_CHIP, \
1287 #define DEFINE_PNV9_CHIP_TYPE(type, class_initfn) \
1290 .class_init = class_initfn, \
1291 .parent = TYPE_PNV9_CHIP, \
1294 static const TypeInfo types
[] = {
1296 .name
= TYPE_PNV_MACHINE
,
1297 .parent
= TYPE_MACHINE
,
1298 .instance_size
= sizeof(PnvMachineState
),
1299 .instance_init
= pnv_machine_instance_init
,
1300 .class_init
= pnv_machine_class_init
,
1301 .interfaces
= (InterfaceInfo
[]) {
1302 { TYPE_XICS_FABRIC
},
1303 { TYPE_INTERRUPT_STATS_PROVIDER
},
1308 .name
= TYPE_PNV_CHIP
,
1309 .parent
= TYPE_SYS_BUS_DEVICE
,
1310 .class_init
= pnv_chip_class_init
,
1311 .instance_init
= pnv_chip_instance_init
,
1312 .instance_size
= sizeof(PnvChip
),
1313 .class_size
= sizeof(PnvChipClass
),
1318 * P9 chip and variants
1321 .name
= TYPE_PNV9_CHIP
,
1322 .parent
= TYPE_PNV_CHIP
,
1323 .instance_init
= pnv_chip_power9_instance_init
,
1324 .instance_size
= sizeof(Pnv9Chip
),
1326 DEFINE_PNV9_CHIP_TYPE(TYPE_PNV_CHIP_POWER9
, pnv_chip_power9_class_init
),
1329 * P8 chip and variants
1332 .name
= TYPE_PNV8_CHIP
,
1333 .parent
= TYPE_PNV_CHIP
,
1334 .instance_init
= pnv_chip_power8_instance_init
,
1335 .instance_size
= sizeof(Pnv8Chip
),
1337 DEFINE_PNV8_CHIP_TYPE(TYPE_PNV_CHIP_POWER8
, pnv_chip_power8_class_init
),
1338 DEFINE_PNV8_CHIP_TYPE(TYPE_PNV_CHIP_POWER8E
, pnv_chip_power8e_class_init
),
1339 DEFINE_PNV8_CHIP_TYPE(TYPE_PNV_CHIP_POWER8NVL
,
1340 pnv_chip_power8nvl_class_init
),