From patchwork Thu Jun 2 11:57:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 98614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3F0ADB6F98 for ; Sat, 4 Jun 2011 03:44:18 +1000 (EST) Received: from localhost ([::1]:53715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSYPv-0001Gl-3P for incoming@patchwork.ozlabs.org; Fri, 03 Jun 2011 13:44:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSXZ8-0007rA-4m for qemu-devel@nongnu.org; Fri, 03 Jun 2011 12:49:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSXZ6-0006Oh-0S for qemu-devel@nongnu.org; Fri, 03 Jun 2011 12:49:41 -0400 Received: from cantor.suse.de ([195.135.220.2]:45653 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSXZ5-0006Oc-Gm for qemu-devel@nongnu.org; Fri, 03 Jun 2011 12:49:39 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 3146290847; Fri, 3 Jun 2011 18:49:38 +0200 (CEST) From: Alexander Graf To: "qemu-devel@nongnu.org Developers" Date: Thu, 2 Jun 2011 13:57:50 +0200 Message-Id: <1307015870-22191-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.2 Cc: Scott Wood Subject: [Qemu-devel] [PATCH] PPC: E500: Implement reboot controller 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 When Linux reboots an e500 VM, it writes to a magic register in the "global-utilities" device indicated by the device tree. We were not emulating that device so far, renedering the VM reboot-less. This patch implements that device with only the reboot functionality implemented and adds it to the device tree. With this patch applied, I can successfully reboot a -M mpc8544ds VM. Signed-off-by: Alexander Graf --- Makefile.target | 2 +- hw/ppce500_mpc8544ds.c | 4 ++ hw/ppce500_util.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ pc-bios/mpc8544ds.dtb | Bin 12288 -> 2257 bytes pc-bios/mpc8544ds.dts | 6 +++ 5 files changed, 105 insertions(+), 1 deletions(-) create mode 100644 hw/ppce500_util.c diff --git a/Makefile.target b/Makefile.target index 602d50d..3c99bf8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -258,7 +258,7 @@ endif obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o obj-ppc-y += ppc440.o ppc440_bamboo.o # PowerPC E500 boards -obj-ppc-y += ppce500_mpc8544ds.o +obj-ppc-y += ppce500_mpc8544ds.o ppce500_util.o # PowerPC 440 Xilinx ML507 reference board. obj-ppc-y += virtex_ml507.o obj-ppc-$(CONFIG_KVM) += kvm_ppc.o diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index 6b57fbf..8bcce15 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -50,6 +50,7 @@ #define MPC8544_PCI_REGS_SIZE 0x1000 #define MPC8544_PCI_IO 0xE1000000 #define MPC8544_PCI_IOLEN 0x10000 +#define MPC8544_UTIL_BASE (MPC8544_CCSRBAR_BASE + 0xe0000) struct boot_info { @@ -270,6 +271,9 @@ static void mpc8544ds_init(ram_addr_t ram_size, serial_hds[0], 1, 1); } + /* General Utility device */ + sysbus_create_simple("e500-util", MPC8544_UTIL_BASE, NULL); + /* PCI */ dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE, mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]], diff --git a/hw/ppce500_util.c b/hw/ppce500_util.c new file mode 100644 index 0000000..4440c21 --- /dev/null +++ b/hw/ppce500_util.c @@ -0,0 +1,94 @@ +/* + * QEMU PowerPC E500 global util pseudo-device + * + * Copyright (C) 2011 Freescale Semiconductor, Inc. All rights reserved. + * + * Author: Alexander Graf, + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "hw.h" +#include "sysemu.h" +#include "sysbus.h" + +#define E500_UTIL_MMIO_SIZE 0x1000 +#define E500_UTIL_ADDR_RSTCR 0xb0 +#define E500_UTIL_RSTCR_RESET 0x02 + +struct PPCE500UtilState { + SysBusDevice busdev; + int mmio_map; +}; + +typedef struct PPCE500UtilState PPCE500UtilState; + +static uint32_t e500_util_read32(void *opaque, target_phys_addr_t addr) +{ + uint32_t value = 0; + + addr &= 0xfff; + switch (addr) { + default: + break; + } + + return value; +} + +static CPUReadMemoryFunc * const e500_util_read[] = { + NULL, + NULL, + &e500_util_read32, +}; + +static void e500_util_write32(void *opaque, target_phys_addr_t addr, + uint32_t value) +{ + addr &= 0xfff; + + switch (addr) { + case E500_UTIL_ADDR_RSTCR: + if (value & E500_UTIL_RSTCR_RESET) { + qemu_system_reset_request(); + } + break; + default: + break; + } +} + +static CPUWriteMemoryFunc * const e500_util_write[] = { + NULL, + NULL, + &e500_util_write32, +}; + +static int e500_util_initfn(SysBusDevice *dev) +{ + PPCE500UtilState *s; + int iomem; + + s = FROM_SYSBUS(PPCE500UtilState, sysbus_from_qdev(dev)); + + iomem = cpu_register_io_memory(e500_util_read, e500_util_write, s, + DEVICE_BIG_ENDIAN); + sysbus_init_mmio(dev, E500_UTIL_MMIO_SIZE, iomem); + + return 0; +} + +static SysBusDeviceInfo e500_util_info = { + .init = e500_util_initfn, + .qdev.name = "e500-util", + .qdev.size = sizeof(PPCE500UtilState), +}; + +static void e500_pci_register(void) +{ + sysbus_register_withprop(&e500_util_info); +} +device_init(e500_pci_register); diff --git a/pc-bios/mpc8544ds.dtb b/pc-bios/mpc8544ds.dtb index 3299546696bf21f53f8ce2c9eba7fcb740c547da..9a1eba0019ca6eada134650fb0866342fa0066e3 100644 GIT binary patch delta 254 zcmZojxG1P`f%o5A1_q9c3=9kw3=HfkKw1Nc1%X%qh=G7H7bvbX(NK8fZXcFgBs)q$VJkovDTp5sUCx{MlzVY^28Sx5qJ!T+ zNtKd0PEYG{D@_IA$pB`MM&G$W079^cH)ez$l2eEs)#rP_+*gHo3YTJMqG zBwZpUakiCed@SvM>esQ;EYNxd_U6{cdbiVg__RzQev7m*jT>t`E)mFIB*j_Li~Xkc z9WM;LT<7GP+#On5D|zB$lb&vuvXbj8@WNiF+cqptv7NKAYqQuJ)c3(k>IbIhI<>`) zN?jmz{B&dnAe-kqZC>D=t>lHywl-R3zOo6|^r;Up>~F#$VgCu)%^BaX`BZ#Jp$h-1 z=D$Ibg!{cK-O4|*KF(y$73nC+4onm^mq`1y*ky|GoB*1-I{iqH@V=*UGy81&RL}UU zWHj<1N<;1LSeDV}8tE~qn&4*%Kc>H#XJT9vUI1>d1eH(GU zy4LNQhsH5F`y)!3YtFrxN5*_1zpNKajOD$+n+q*5c!wJPFiTrWs$-XSFey{NNM?UNT=m8G z0X(3$;p^mU$XGS|9G3{+*v-RMl;U&HcBzg+6}CU)6V|z_)KBDDz&Xw|pZPvoXU;JqM=H)9PC?E8)1UpUd%nwtg?SFOXZglP8AL7SI9mACdrzzN&0PY5^G&jOf8cTV zkb|1LHc^LUE|D6X;}4Tu$8ZgX{ui9hv%mG#{{r@aE=I{fhssZ))GLCWP^)EcFvxVC zyS@&?TrKCpOKt7)ThUhKx~k}2wbejB4}85{9Hd%hdQS~p-}8ss4TD&_C|1FV2xI2b z#wmhG@6aEeyPN4}BOUt(iav)ko*yRu{*0e_@gDsxVpunb2YRf6xX@WPN{f7Ix~Z4x zxR?p}NnB(}80t(dR~7c0H2P@VN{3!NAVQ|u$V=VG%lGF)W; + fsl,has-rstcr; + }; }; pci0: pci@e0008000 {