From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRJHF-0006Lc-LY for qemu-devel@nongnu.org; Tue, 09 Sep 2014 07:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRJHA-0000is-7S for qemu-devel@nongnu.org; Tue, 09 Sep 2014 07:08:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRJHA-0000ic-0D for qemu-devel@nongnu.org; Tue, 09 Sep 2014 07:07:56 -0400 Message-ID: <540EDF38.8020807@redhat.com> Date: Tue, 09 Sep 2014 13:06:32 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1410249273-6063-1-git-send-email-eric.auger@linaro.org> <1410249273-6063-6-git-send-email-eric.auger@linaro.org> In-Reply-To: <1410249273-6063-6-git-send-email-eric.auger@linaro.org> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 5/6] hw/arm/virt: new add_fdt_*_node functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Auger , eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, kim.phillips@freescale.com, marc.zyngier@arm.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com, agraf@suse.de, peter.maydell@linaro.org, afaerber@suse.de Cc: patches@linaro.org, will.deacon@arm.com, stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com, alex.williamson@redhat.com, a.motakis@virtualopensystems.com, kvmarm@lists.cs.columbia.edu Il 09/09/2014 09:54, Eric Auger ha scritto: > Create new functions: > - add_fdt_uart_node > - add_fdt_rtc_node > - add_fdt_virtio_nodes Actually they are fdt_add_uart_node etc. > They will be used for dynamic sysbus instantiation. > > Signed-off-by: Eric Auger > > --- > > v2 -> v3: > reword title to avoid content violation > --- > hw/arm/virt.c | 67 +++++++++++++++++++++++++++++++++++++++-------------------- > 1 file changed, 44 insertions(+), 23 deletions(-) > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index d6fffc7..9085b88 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -351,18 +351,15 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic) > fdt_add_gic_node(vbi); > } > > -static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) > +static void fdt_add_uart_node(const VirtBoardInfo *vbi) > { > - char *nodename; > hwaddr base = vbi->memmap[VIRT_UART].base; > hwaddr size = vbi->memmap[VIRT_UART].size; > int irq = vbi->irqmap[VIRT_UART]; > const char compat[] = "arm,pl011\0arm,primecell"; > const char clocknames[] = "uartclk\0apb_pclk"; > + char *nodename = g_strdup_printf("/pl011@%" PRIx64, base); > > - sysbus_create_simple("pl011", base, pic[irq]); > - > - nodename = g_strdup_printf("/pl011@%" PRIx64, base); > qemu_fdt_add_subnode(vbi->fdt, nodename); > /* Note that we can't use setprop_string because of the embedded NUL */ > qemu_fdt_setprop(vbi->fdt, nodename, "compatible", > @@ -379,17 +376,23 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) > g_free(nodename); > } > > -static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) > +static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) > +{ > + hwaddr base = vbi->memmap[VIRT_UART].base; > + int irq = vbi->irqmap[VIRT_UART]; > + > + sysbus_create_simple("pl011", base, pic[irq]); > + fdt_add_uart_node(vbi); > +} > + > +static void fdt_add_rtc_node(const VirtBoardInfo *vbi) > { > - char *nodename; > hwaddr base = vbi->memmap[VIRT_RTC].base; > hwaddr size = vbi->memmap[VIRT_RTC].size; > int irq = vbi->irqmap[VIRT_RTC]; > const char compat[] = "arm,pl031\0arm,primecell"; > + char *nodename = g_strdup_printf("/pl031@%" PRIx64, base); > > - sysbus_create_simple("pl031", base, pic[irq]); > - > - nodename = g_strdup_printf("/pl031@%" PRIx64, base); > qemu_fdt_add_subnode(vbi->fdt, nodename); > qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat)); > qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", > @@ -402,22 +405,20 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) > g_free(nodename); > } > > -static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) > +static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) > { > - int i; > - hwaddr size = vbi->memmap[VIRT_MMIO].size; > + hwaddr base = vbi->memmap[VIRT_RTC].base; > + int irq = vbi->irqmap[VIRT_RTC]; > > - /* Note that we have to create the transports in forwards order > - * so that command line devices are inserted lowest address first, > - * and then add dtb nodes in reverse order so that they appear in > - * the finished device tree lowest address first. > - */ > - for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) { > - int irq = vbi->irqmap[VIRT_MMIO] + i; > - hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size; > + sysbus_create_simple("pl031", base, pic[irq]); > > - sysbus_create_simple("virtio-mmio", base, pic[irq]); > - } > + fdt_add_rtc_node(vbi); > +} > + > +static void fdt_add_virtio_nodes(const VirtBoardInfo *vbi) > +{ > + int i; > + hwaddr size = vbi->memmap[VIRT_MMIO].size; > > for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) { > char *nodename; > @@ -437,6 +438,26 @@ static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) > } > } > > +static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) > +{ > + int i; > + hwaddr size = vbi->memmap[VIRT_MMIO].size; > + > + /* Note that we have to create the transports in forwards order > + * so that command line devices are inserted lowest address first, > + * and then add dtb nodes in reverse order so that they appear in > + * the finished device tree lowest address first. > + */ > + for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) { > + int irq = vbi->irqmap[VIRT_MMIO] + i; > + hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size; > + > + sysbus_create_simple("virtio-mmio", base, pic[irq]); > + } > + > + fdt_add_virtio_nodes(vbi); > +} > + > static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) > { > const VirtBoardInfo *board = (const VirtBoardInfo *)binfo; >