Received: from eggs.gnu.org ([208.118.235.92]:53958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVlrM-0008RL-CP for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:50:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVlrL-0006CM-5I for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:50:56 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35968 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVlrK-0006C7-Hu for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:50:54 -0400 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <1366978377-16823-4-git-send-email-dingel@linux.vnet.ibm.com> Date: Fri, 26 Apr 2013 18:50:52 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <28582A46-8E35-4DA1-BBC2-B9AFDB040F1E@suse.de> References: <1366978377-16823-1-git-send-email-dingel@linux.vnet.ibm.com> <1366978377-16823-4-git-send-email-dingel@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 03/10] S390: Check Bootdevice Type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dominik Dingel Cc: Christian Paro , Christian Borntraeger , qemu-devel@nongnu.org On 26.04.2013, at 14:12, Dominik Dingel wrote: > Check for a kernel IPL entry and load kernel image if one was > specified. > If no kernel image was supplied and the first boot device > is not a virtio-ccw-blk device, print error message and exit. >=20 > In case it is a virtio-ccw-blk device store the dev_no in reg[7] >=20 > Signed-off-by: Christian Paro > Signed-off-by: Dominik Dingel >=20 > diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c > index ace5ff5..9758529 100644 > --- a/hw/s390x/ipl.c > +++ b/hw/s390x/ipl.c > @@ -16,6 +16,8 @@ > #include "elf.h" > #include "hw/loader.h" > #include "hw/sysbus.h" > +#include "hw/s390x/virtio-ccw.h" > +#include "hw/s390x/css.h" >=20 > #define KERN_IMAGE_START 0x010000UL > #define KERN_PARM_AREA 0x010480UL > @@ -56,14 +58,25 @@ typedef struct S390IPLState { > char *firmware; > } S390IPLState; >=20 > +static void s390_ipl_kernel(uint64_t pswaddr) > +{ > + S390CPU *cpu =3D S390_CPU(qemu_get_cpu(0)); > + CPUS390XState *env =3D &cpu->env; > + > + env->psw.addr =3D pswaddr; > + env->psw.mask =3D IPL_PSW_MASK; > + s390_add_running_cpu(cpu); > +} >=20 > -static void s390_ipl_cpu(uint64_t pswaddr) > +static void s390_ipl_from_disk(VirtIOBlkCcw *dev, uint64_t pswaddr) > { > S390CPU *cpu =3D S390_CPU(qemu_get_cpu(0)); > CPUS390XState *env =3D &cpu->env; > + VirtioCcwDevice *ccw_dev =3D &(dev->parent_obj); >=20 > env->psw.addr =3D pswaddr; > env->psw.mask =3D IPL_PSW_MASK; > + env->regs[7] =3D ccw_dev->sch->devno; > s390_add_running_cpu(cpu); > } >=20 > @@ -152,7 +165,18 @@ static void s390_ipl_reset(DeviceState *dev) > { > S390IPLState *ipl =3D S390_IPL(dev); >=20 > - s390_ipl_cpu(ipl->start_addr); > + if (ipl->kernel) { > + return s390_ipl_kernel(ipl->start_addr); The kernel/bootloader split is too high level. Please reuse more code. = The flow should be something like if (ipl_from_disk) { regs[7] =3D devno; } env->psw.addr =3D pswaddr; mask =3D IPL_PSW_MASK; add_running_cpu(); Whether you split any of these into functions is your thing, but I don't = want to have the PSW reset logic duplicated. Alex > + } > + > + DeviceState *boot_device =3D get_boot_device(0); > + if (object_dynamic_cast(OBJECT(boot_device), TYPE_VIRTIO_BLK) !=3D = NULL) { > + = s390_ipl_from_disk(VIRTIO_BLK_CCW(boot_device->parent_obj.parent), > + ipl->start_addr); > + } else { > + fprintf(stderr, "qemu: s390x only supports boot from = virtio-ccw-blk\n"); > + exit(1); > + } > } >=20 > static void s390_ipl_class_init(ObjectClass *klass, void *data) > --=20 > 1.7.9.5 >=20