From nobody Tue Feb 10 19:49:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571863082; cv=none; d=zoho.com; s=zohoarc; b=HqT+S2NDzBwWnkxlO0Q51H0dJkUu/D78/rSNAH9y8OAEM0J4Bzu2irh2xacTib6BtaG8LDwpxJscJqr4V1vEjZyBCv4axmtpb+r5rgCw7eAVwSsUhLTngFTy3aw4EZo21pYKjj8vAIxAEhlpBAYYRY9U/3xxlT8TOmBPIP77FXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571863082; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SuNuTh9HEsEKkVAfEnTaFjjWEGe/RTOYLDx8IqmZ30E=; b=CJvjE4doyTCdrP+/3nh09tDnStVrvTKye1l3CcsTS3fmP66jpXKNcR/V2Ybq3BGK9uqlSC2X0s7D3ELxSF3a9+I5tYF0iis+p2eG2ZSfSdxOT5nO+NlrH4L+Tr/GKa45L/zwgM/J6ttzWXk2LeibuWd8Pj00DGyoz2zyD9gYdRk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571863082760773.0175517789291; Wed, 23 Oct 2019 13:38:02 -0700 (PDT) Received: from localhost ([::1]:47306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNNOK-0004kG-Ul for importer@patchew.org; Wed, 23 Oct 2019 16:38:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNKWS-0004ev-FJ for qemu-devel@nongnu.org; Wed, 23 Oct 2019 13:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNKWQ-000245-6S for qemu-devel@nongnu.org; Wed, 23 Oct 2019 13:34:12 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:37824 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNKWQ-00023s-3M for qemu-devel@nongnu.org; Wed, 23 Oct 2019 13:34:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-h38LJog8OiuZCqEGQxpX3A-1; Wed, 23 Oct 2019 13:34:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0D5B800D63; Wed, 23 Oct 2019 17:34:03 +0000 (UTC) Received: from localhost (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB775C1D4; Wed, 23 Oct 2019 17:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571852049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SuNuTh9HEsEKkVAfEnTaFjjWEGe/RTOYLDx8IqmZ30E=; b=VOjp/JbQKYDFYYHKV38yhsq5oaMGyzYRwwMzLlWpA0E2EDRNJBk/4xjQqJSX0Ud/zyasVL lNqel2X4iriMuOB+5xKeJvI4vHLsJG1mUSGNQYrwOaWFdsgcKvRPuCkoTFJEcvPnxSSlur SHNgzri24/5l94a0vism6Bj4DbkuigI= From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Subject: [PATCH v3 16/33] serial-mm: use sysbus facilities Date: Wed, 23 Oct 2019 19:31:37 +0200 Message-Id: <20191023173154.30051-17-marcandre.lureau@redhat.com> In-Reply-To: <20191023173154.30051-1-marcandre.lureau@redhat.com> References: <20191023173154.30051-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: h38LJog8OiuZCqEGQxpX3A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , KONRAD Frederic , "Edgar E. Iglesias" , Paul Burton , Aleksandar Rikalo , Magnus Damm , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Artyom Tarasenko , Eduardo Habkost , Fabien Chouteau , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make SerialMM a regular sysbus device, by registering the irq, and the mmio region. Reexport the internal serial properties. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Peter Maydell --- hw/char/serial.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 2f7667c30c..a40bc3ab81 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -1074,21 +1074,18 @@ SerialMM *serial_mm_init(MemoryRegion *address_spac= e, Chardev *chr, enum device_endian end) { SerialMM *self =3D SERIAL_MM(qdev_create(NULL, TYPE_SERIAL_MM)); - SerialState *s =3D &self->serial; + MemoryRegion *mr; =20 qdev_prop_set_uint8(DEVICE(self), "regshift", regshift); - s->irq =3D irq; - qdev_prop_set_uint32(DEVICE(s), "baudbase", baudbase); - qdev_prop_set_chr(DEVICE(s), "chardev", chr); - qdev_prop_set_int32(DEVICE(s), "instance-id", base); - qdev_prop_set_uint8(DEVICE(s), "endianness", end); - - qdev_init_nofail(DEVICE(s)); + qdev_prop_set_uint32(DEVICE(self), "baudbase", baudbase); + qdev_prop_set_chr(DEVICE(self), "chardev", chr); + qdev_prop_set_int32(DEVICE(self), "instance-id", base); + qdev_prop_set_uint8(DEVICE(self), "endianness", end); qdev_init_nofail(DEVICE(self)); =20 - memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], self, - "serial", 8 << regshift); - memory_region_add_subregion(address_space, base, &s->io); + sysbus_connect_irq(SYS_BUS_DEVICE(self), 0, irq); + mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(self), 0); + memory_region_add_subregion(address_space, base, mr); =20 return self; } @@ -1099,6 +1096,8 @@ static void serial_mm_instance_init(Object *o) =20 object_initialize_child(o, "serial", &self->serial, sizeof(self->seria= l), TYPE_SERIAL, &error_abort, NULL); + + qdev_alias_all_properties(DEVICE(&self->serial), o); } =20 static Property serial_mm_properties[] =3D { @@ -1107,11 +1106,25 @@ static Property serial_mm_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void serial_mm_realize(DeviceState *dev, Error **errp) +{ + SerialMM *self =3D SERIAL_MM(dev); + SerialState *s =3D &self->serial; + + qdev_init_nofail(DEVICE(s)); + + memory_region_init_io(&s->io, NULL, &serial_mm_ops[self->endianness], = self, + "serial", 8 << self->regshift); + sysbus_init_mmio(SYS_BUS_DEVICE(self), &s->io); + sysbus_init_irq(SYS_BUS_DEVICE(self), &self->serial.irq); +} + static void serial_mm_class_init(ObjectClass *klass, void* data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->props =3D serial_mm_properties; + dc->realize =3D serial_mm_realize; } =20 static const TypeInfo serial_mm_info =3D { --=20 2.23.0.606.g08da6496b6