All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>,
	"Andreas Färber" <andreas.faerber@web.de>,
	qemu-ppc@nongnu.org, "Alexander Graf" <agraf@suse.de>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>
Subject: [Qemu-devel] [PATCH 4/4] prep: add IBM RS/6000 7020 (40p) machine emulation
Date: Wed, 10 Jun 2015 23:18:55 +0200	[thread overview]
Message-ID: <1433971135-24587-5-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <1433971135-24587-1-git-send-email-hpoussin@reactos.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 <hpoussin@reactos.org>
---
 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);
-- 
2.1.4

  parent reply	other threads:[~2015-06-10 21:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 21:18 [Qemu-devel] [PATCH 0/4] PPC IBM 40p PReP emulation Hervé Poussineau
2015-06-10 21:18 ` [Qemu-devel] [PATCH 1/4] prep: QOM'ify System I/O Hervé Poussineau
2015-06-10 21:18 ` [Qemu-devel] [PATCH 2/4] prep: add RS/6000 debug device Hervé Poussineau
2015-06-10 21:18 ` [Qemu-devel] [PATCH 3/4] prep: add IBM RS/6000 7020 (40p) memory controller Hervé Poussineau
2015-06-10 21:18 ` Hervé Poussineau [this message]
2015-06-11  8:02 ` [Qemu-devel] [PATCH 0/4] PPC IBM 40p PReP emulation Artyom Tarasenko
2015-06-11 19:00   ` Hervé Poussineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433971135-24587-5-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=agraf@suse.de \
    --cc=andreas.faerber@web.de \
    --cc=atar4qemu@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.