[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 31/49] ppc/pnv: add a ISA bus
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 31/49] ppc/pnv: add a ISA bus |
Date: |
Wed, 26 Oct 2016 22:42:35 +1100 |
From: Cédric Le Goater <address@hidden>
As Qemu only supports a single instance of the ISA bus, we use the LPC
controller of chip 0 to create one and plug in a couple of useful
devices, like an UART and RTC. An IPMI BT device, which is also an ISA
device, can be defined on the command line to connect an external BMC.
That is for later.
The PowerNV machine now has a console. Skiboot should load a kernel
and jump into it but execution will stop quite early because we lack a
model for the native XICS controller for the moment :
[ 0.000000] NR_IRQS:512 nr_irqs:512 16
[ 0.000000] XICS: Cannot find a Presentation Controller !
[ 0.000000] ------------[ cut here ]------------
[ 0.000000] WARNING: at arch/powerpc/platforms/powernv/setup.c:81
...
[ 0.000000] NIP [c00000000079d65c] pnv_init_IRQ+0x30/0x44
You can still do a few things under xmon.
Based on previous work from :
Benjamin Herrenschmidt <address@hidden>
Signed-off-by: Cédric Le Goater <address@hidden>
Reviewed-by: David Gibson <address@hidden>
[dwg: Trivial fix for a change in the serial_hds_isa_init() interface]
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/pnv.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/pnv.h | 2 ++
2 files changed, 67 insertions(+)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index aa712fd..82276e0 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -35,6 +35,10 @@
#include "hw/ppc/pnv_xscom.h"
+#include "hw/isa/isa.h"
+#include "hw/char/serial.h"
+#include "hw/timer/mc146818rtc.h"
+
#include <libfdt.h>
#define FDT_MAX_SIZE 0x00100000
@@ -301,6 +305,58 @@ static void ppc_powernv_reset(void)
cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
}
+/* If we don't use the built-in LPC interrupt deserializer, we need
+ * to provide a set of qirqs for the ISA bus or things will go bad.
+ *
+ * Most machines using pre-Naples chips (without said deserializer)
+ * have a CPLD that will collect the SerIRQ and shoot them as a
+ * single level interrupt to the P8 chip. So let's setup a hook
+ * for doing just that.
+ *
+ * Note: The actual interrupt input isn't emulated yet, this will
+ * come with the PSI bridge model.
+ */
+static void pnv_lpc_isa_irq_handler_cpld(void *opaque, int n, int level)
+{
+ /* We don't yet emulate the PSI bridge which provides the external
+ * interrupt, so just drop interrupts on the floor
+ */
+}
+
+static void pnv_lpc_isa_irq_handler(void *opaque, int n, int level)
+{
+ /* XXX TODO */
+}
+
+static ISABus *pnv_isa_create(PnvChip *chip)
+{
+ PnvLpcController *lpc = &chip->lpc;
+ ISABus *isa_bus;
+ qemu_irq *irqs;
+ PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
+
+ /* let isa_bus_new() create its own bridge on SysBus otherwise
+ * devices speficied on the command line won't find the bus and
+ * will fail to create.
+ */
+ isa_bus = isa_bus_new(NULL, &lpc->isa_mem, &lpc->isa_io,
+ &error_fatal);
+
+ /* Not all variants have a working serial irq decoder. If not,
+ * handling of LPC interrupts becomes a platform issue (some
+ * platforms have a CPLD to do it).
+ */
+ if (pcc->chip_type == PNV_CHIP_POWER8NVL) {
+ irqs = qemu_allocate_irqs(pnv_lpc_isa_irq_handler, chip, ISA_NUM_IRQS);
+ } else {
+ irqs = qemu_allocate_irqs(pnv_lpc_isa_irq_handler_cpld, chip,
+ ISA_NUM_IRQS);
+ }
+
+ isa_bus_irqs(isa_bus, irqs);
+ return isa_bus;
+}
+
static void ppc_powernv_init(MachineState *machine)
{
PnvMachineState *pnv = POWERNV_MACHINE(machine);
@@ -395,6 +451,15 @@ static void ppc_powernv_init(MachineState *machine)
object_property_set_bool(chip, true, "realized", &error_fatal);
}
g_free(chip_typename);
+
+ /* Instantiate ISA bus on chip 0 */
+ pnv->isa_bus = pnv_isa_create(pnv->chips[0]);
+
+ /* Create serial port */
+ serial_hds_isa_init(pnv->isa_bus, 0, MAX_SERIAL_PORTS);
+
+ /* Create an RTC ISA device too */
+ rtc_init(pnv->isa_bus, 2000, NULL);
}
/*
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index ce16e47..02ac1c5 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -112,6 +112,8 @@ typedef struct PnvMachineState {
uint32_t num_chips;
PnvChip **chips;
+
+ ISABus *isa_bus;
} PnvMachineState;
#define PNV_FDT_ADDR 0x01000000
--
2.7.4
- [Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition, (continued)
- [Qemu-ppc] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 14/49] target-ppc: implement vnegw/d instructions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 20/49] pseries: Remove unused callbacks from sPAPR VIO bus state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 12/49] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch], David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 07/49] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 18/49] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 35/49] pseries: Make spapr_create_fdt_skel() get information from machine state, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 05/49] tests: move QVirtioBus pointer into QVirtioDevice, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 24/49] ppc/pnv: add a PnvChip object, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 33/49] pseries: Split device tree construction from device tree load, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 31/49] ppc/pnv: add a ISA bus,
David Gibson <=
- [Qemu-ppc] [PULL 37/49] pseries: Consolidate RTAS loading, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 16/49] ppc/xics: add a xics_set_nr_servers common routine, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 13/49] nvram: Rename openbios_firmware_abi.h into sun_nvram.h, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 17/49] ppc/xics: add a XICSState backlink in ICPState, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 15/49] target-ppc: implement xxbr[qdwh] instruction, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 29/49] ppc/pnv: add XSCOM handlers to PnvCore, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 34/49] pseries: Remove rtas_addr and fdt_addr fields from machinestate, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 32/49] target-ppc: add vmul10[u, eu, cu, ecu]q instructions, David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 42/49] pseries: Move /hypervisor node construction to fdt_build_fdt(), David Gibson, 2016/10/26
- [Qemu-ppc] [PULL 39/49] pseries: Consolidate construction of /chosen device tree node, David Gibson, 2016/10/26