From patchwork Wed Jun 10 21:18:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Poussineau?= X-Patchwork-Id: 482920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D1232140293 for ; Thu, 11 Jun 2015 07:23:06 +1000 (AEST) Received: from localhost ([::1]:42369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2nSi-0005FM-PB for incoming@patchwork.ozlabs.org; Wed, 10 Jun 2015 17:23:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2nSF-0004PX-Ty for qemu-devel@nongnu.org; Wed, 10 Jun 2015 17:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2nSD-0001LG-0Z for qemu-devel@nongnu.org; Wed, 10 Jun 2015 17:22:35 -0400 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:48285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2nSC-0001Kv-NW; Wed, 10 Jun 2015 17:22:32 -0400 Received: from localhost.localdomain (unknown [82.227.227.196]) by smtp2-g21.free.fr (Postfix) with ESMTP id D560B4B01FF; Wed, 10 Jun 2015 23:20:12 +0200 (CEST) From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: qemu-devel@nongnu.org Date: Wed, 10 Jun 2015 23:18:55 +0200 Message-Id: <1433971135-24587-5-git-send-email-hpoussin@reactos.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433971135-24587-1-git-send-email-hpoussin@reactos.org> References: <1433971135-24587-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::11 Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-ppc@nongnu.org, Alexander Graf , Artyom Tarasenko Subject: [Qemu-devel] [PATCH 4/4] prep: add IBM RS/6000 7020 (40p) machine emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Machine is very simple (only one PCI host bridge and an ISA bridge). Provide a ibm_40p.cfg file to add more devices to this machine. Syntax is: qemu-system-ppc -M 40p -readconfig ibm_40p.cfg Signed-off-by: Hervé Poussineau --- default-configs/ppc-softmmu.mak | 2 + docs/ibm_40p.cfg | 42 +++++++++++++++++ hw/ppc/prep.c | 99 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 docs/ibm_40p.cfg diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak index 070803c..260dfb9 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -19,6 +19,7 @@ CONFIG_I82378=y CONFIG_PC87312=y CONFIG_MACIO=y CONFIG_PCSPK=y +CONFIG_CS4231A=y CONFIG_CUDA=y CONFIG_ADB=y CONFIG_MAC_NVRAM=y @@ -46,6 +47,7 @@ CONFIG_PLATFORM_BUS=y CONFIG_ETSEC=y CONFIG_LIBDECNUMBER=y # For PReP +CONFIG_VGA_S3=y CONFIG_MC146818RTC=y CONFIG_RS6000_DEBUG=y CONFIG_RS6000_MC=y diff --git a/docs/ibm_40p.cfg b/docs/ibm_40p.cfg new file mode 100644 index 0000000..a7e21b5 --- /dev/null +++ b/docs/ibm_40p.cfg @@ -0,0 +1,42 @@ +############################################################################ +# +# qemu-system-ppc -M 40 creates a bare machine with just the very essential +# chipset devices being present: +# +# 00.0 - Host bridge +# 0b.0 - ISA bridge +# +# This config file documents the other devices and how they are +# created. You can simply use "-readconfig $thisfile" to create +# them all. +[device] + driver = "i8042" + +[device] + driver = "cs4231a" + iobase = "0x830" + irq = "10" + +[device] + driver = "pc87312" + config = "12" + +[device] + driver = "lsi53c810" + addr = "01.0" + +[device] + driver = "pcnet" + addr = "03.0" + +[device] + driver = "isa-m48t59" + iobase = "0x74" + +[device] + driver = "prep-systemio" + ibm-planar-id = "0xfc" + equipment = "0xc0" + +[device] + driver = "rs6000-debug" diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 998ee2d..d051fba 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -699,6 +699,97 @@ static void ppc_prep_init(MachineState *machine) graphic_width, graphic_height, graphic_depth); } +static int prep_set_cmos_checksum(DeviceState *dev, void *opaque) +{ + uint16_t checksum = *(uint16_t *)opaque; + ISADevice *rtc; + + rtc = ISA_DEVICE(object_dynamic_cast(OBJECT(dev), "mc146818rtc")); + if (rtc) { + rtc_set_memory(rtc, 0x2e, checksum & 0xff); + rtc_set_memory(rtc, 0x3e, checksum & 0xff); + rtc_set_memory(rtc, 0x2f, checksum >> 8); + rtc_set_memory(rtc, 0x3f, checksum >> 8); + } + return 0; +} + +static void ibm_40p_init(MachineState *machine) +{ + CPUPPCState *env = NULL; + uint16_t cmos_checksum; + PowerPCCPU *cpu; + DeviceState *dev; + SysBusDevice *pcihost; + PCIBus *pci_bus; + BusState *isa_bus; + + /* init CPU */ + if (!machine->cpu_model) { + machine->cpu_model = "604"; + } + cpu = cpu_ppc_init(machine->cpu_model); + if (cpu == NULL) { + fprintf(stderr, "Unable to find PowerPC CPU definition\n"); + exit(1); + } + env = &cpu->env; + + if (env->flags & POWERPC_FLAG_RTC_CLK) { + /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */ + cpu_ppc_tb_init(env, 7812500UL); + } else { + /* Set time-base frequency to 100 Mhz */ + cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); + } + qemu_register_reset(ppc_prep_reset, cpu); + if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { + hw_error("Only 6xx bus is supported on PREP machine\n"); + } + + /* PCI host */ + dev = qdev_create(NULL, "raven-pcihost"); + if (bios_name == NULL) { + bios_name = "P12H0456.IMG"; + } + qdev_prop_set_string(dev, "bios-name", bios_name); + qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE); + pcihost = SYS_BUS_DEVICE(dev); + object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); + qdev_init_nofail(dev); + pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0")); + if (pci_bus == NULL) { + fprintf(stderr, "Couldn't create PCI host controller.\n"); + exit(1); + } + + /* PCI -> ISA bridge */ + dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378")); + cpu = POWERPC_CPU(first_cpu); + qdev_connect_gpio_out(dev, 0, + cpu->env.irq_inputs[PPC6xx_INPUT_INT]); + qdev_connect_gpio_out(dev, 1, + qemu_allocate_irq(cpu_request_exit, NULL, 0)); + sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15)); + sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13)); + sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15)); + sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13)); + isa_bus = qdev_get_child_bus(dev, "isa.0"); + + /* Memory controller */ + dev = DEVICE(isa_create(ISA_BUS(isa_bus), "rs6000-mc")); + qdev_prop_set_uint32(dev, "ram-size", machine->ram_size); + qdev_init_nofail(dev); + + /* initialize CMOS checksums */ + cmos_checksum = 0x6aa9; + qbus_walk_children(isa_bus, prep_set_cmos_checksum, NULL, NULL, NULL, + &cmos_checksum); + + /* initialize audio subsystem */ + audio_init(); +} + static QEMUMachine prep_machine = { .name = "prep", .desc = "PowerPC PREP platform", @@ -707,9 +798,17 @@ static QEMUMachine prep_machine = { .default_boot_order = "cad", }; +static QEMUMachine ibm_40p_machine = { + .name = "40p", + .desc = "IBM RS/6000 7020 (40p)", + .init = ibm_40p_init, + .max_cpus = 1, +}; + static void prep_machine_init(void) { qemu_register_machine(&prep_machine); + qemu_register_machine(&ibm_40p_machine); } machine_init(prep_machine_init);