From nobody Tue Dec 16 07:06:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510920430385665.4232988878285; Fri, 17 Nov 2017 04:07:10 -0800 (PST) Received: from localhost ([::1]:45439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFfQ1-0005CC-Jt for importer@patchew.org; Fri, 17 Nov 2017 07:06:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFfOJ-00046K-Cv for qemu-devel@nongnu.org; Fri, 17 Nov 2017 07:05:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFfOH-0006Xc-Us for qemu-devel@nongnu.org; Fri, 17 Nov 2017 07:05:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFfOH-0006Wt-N3 for qemu-devel@nongnu.org; Fri, 17 Nov 2017 07:05:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4437C04AC5D for ; Fri, 17 Nov 2017 12:05:00 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77A177D03E; Fri, 17 Nov 2017 12:04:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AB34931FD5; Fri, 17 Nov 2017 13:04:54 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 Nov 2017 13:04:52 +0100 Message-Id: <20171117120454.13507-3-kraxel@redhat.com> In-Reply-To: <20171117120454.13507-1-kraxel@redhat.com> References: <20171117120454.13507-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Nov 2017 12:05:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/4] ramfb: simple boot framebuffer living in guest ram X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Williamson , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" --- include/hw/display/ramfb.h | 8 ++++ hw/display/ramfb.c | 94 ++++++++++++++++++++++++++++++++++++++++++= ++++ hw/display/Makefile.objs | 2 + 3 files changed, 104 insertions(+) create mode 100644 include/hw/display/ramfb.h create mode 100644 hw/display/ramfb.c diff --git a/include/hw/display/ramfb.h b/include/hw/display/ramfb.h new file mode 100644 index 0000000000..f3a772e99e --- /dev/null +++ b/include/hw/display/ramfb.h @@ -0,0 +1,8 @@ +#ifndef RAMFB_H +#define RAMFB_H + +typedef struct RAMFBState RAMFBState; +void ramfb_display_update(QemuConsole *con, RAMFBState *s); +RAMFBState *ramfb_setup(Error **errp); + +#endif /* RAMFB_H */ diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c new file mode 100644 index 0000000000..bed5964ed8 --- /dev/null +++ b/hw/display/ramfb.c @@ -0,0 +1,94 @@ +/* + * early boot framebuffer in guest ram + * configured using fw_cfg + * + * Copyright Red Hat, Inc. 2017 + * + * Author: + * Gerd Hoffmann + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/loader.h" +#include "hw/display/ramfb.h" +#include "ui/console.h" +#include "sysemu/sysemu.h" + +struct RAMFBCfg { + uint64_t addr; + uint32_t fourcc; + uint32_t flags; + uint32_t width; + uint32_t height; + uint32_t stride; +}; + +struct RAMFBState { + DisplaySurface *ds; + uint32_t width, height; + struct RAMFBCfg cfg; +}; + +static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len) +{ + RAMFBState *s =3D dev; + void *framebuffer; + uint32_t stride; + hwaddr addr, length; + + s->width =3D be32_to_cpu(s->cfg.width); + s->height =3D be32_to_cpu(s->cfg.height); + stride =3D be32_to_cpu(s->cfg.stride); + addr =3D be64_to_cpu(s->cfg.addr); + length =3D stride * s->height; + + fprintf(stderr, "%s: %dx%d @ 0x%" PRIx64 "\n", __func__, + s->width, s->height, addr); + framebuffer =3D address_space_map(&address_space_memory, + addr, &length, false); + if (!framebuffer || length < stride * s->height) { + s->width =3D 0; + s->height =3D 0; + return; + } + s->ds =3D qemu_create_displaysurface_from(s->width, s->height, + PIXMAN_x8r8g8b8 /* FIXME */, + stride, framebuffer); +} + +void ramfb_display_update(QemuConsole *con, RAMFBState *s) +{ + if (!s->width || !s->height) { + return; + } + + if (s->ds) { + dpy_gfx_replace_surface(con, s->ds); + s->ds =3D NULL; + } + + /* simple full screen update */ + dpy_gfx_update(con, 0, 0, s->width, s->height); +} + +RAMFBState *ramfb_setup(Error **errp) +{ + FWCfgState *fw_cfg =3D fw_cfg_find(); + RAMFBState *s; + + if (!fw_cfg || !fw_cfg->dma_enabled) { + error_setg(errp, "ramfb device requires fw_cfg with DMA"); + return NULL; + } + + s =3D g_new0(RAMFBState, 1); + + rom_add_vga("vgabios-ramfb.bin"); + fw_cfg_add_file_callback(fw_cfg, "etc/ramfb", + NULL, ramfb_fw_cfg_write, s, + &s->cfg, sizeof(s->cfg), false); + return s; +} diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index 551c050a6a..4e8ff48b55 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -1,3 +1,5 @@ +common-obj-y +=3D ramfb.o + common-obj-$(CONFIG_ADS7846) +=3D ads7846.o common-obj-$(CONFIG_VGA_CIRRUS) +=3D cirrus_vga.o common-obj-$(CONFIG_G364FB) +=3D g364fb.o --=20 2.9.3