From nobody Tue Apr 30 17:25:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576234353; cv=none; d=zohomail.com; s=zohoarc; b=OJ5OGO48tbo/7QvLUP63LUu7S0xOKtnOcic7DgWk0OJyh9SpXjeE4QSVPitv6bC4K7aHYzQBv3OWO7upjHDPmD5rgWjYFmFYhMW+Byzc7jmg1NFle4UtpwsE4PcVHi3out+y5ecrokN7jR3sE8TEVkGNpVfWWm9fQlBSrpAKd08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576234353; 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=X5K7ONr2rRKoOKjnPt4dYZ5TprIjSuVC0cOky3wXTxE=; b=JQHVloI12YzytAk4qca8IYRE2kvNiLFAIRf4OrDClvVukjMTx1TJaB8rshhYWPLkW7Ys2sC56H+bLru1xZllcRYkLde14o1yHRuWeglO3/yb+PJ/Arm6JgXP9yfhZNN7iGot7hQ1FKJ9HURlBwgz87ErSvCZneybKl1OuWAphj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1576234353904223.37907206014097; Fri, 13 Dec 2019 02:52:33 -0800 (PST) Received: from localhost ([::1]:45980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiYi-0006UM-Dy for importer@patchew.org; Fri, 13 Dec 2019 05:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiXZ-0005Xv-5K for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifiXY-0001Xi-2u for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36542 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ifiXX-0001VO-VQ for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:20 -0500 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-141-X08GZLzuMcqwU-pRKg3hyQ-1; Fri, 13 Dec 2019 05:51:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FC45DB60; Fri, 13 Dec 2019 10:51:14 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-134.brq.redhat.com [10.40.204.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8974210013A1; Fri, 13 Dec 2019 10:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576234278; 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=X5K7ONr2rRKoOKjnPt4dYZ5TprIjSuVC0cOky3wXTxE=; b=V9jqgMqLbVO7+SZWN7d6RiYUdv7mIES7PW5m3IlmPZQuUjyj3KTkg1uqYH9j37p48F17de +RLgU44sI98rUf2d5o+pxm+f5nTZ0z/RwM8dHos35PYaRH3yiMn3yS5dzy0P1vxwRoOx8G nEEAgUZzGlSmhsa9epdb9sfWRcRO8jk= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/4] hw/i386/pc: Convert DPRINTF() to trace events Date: Fri, 13 Dec 2019 11:50:57 +0100 Message-Id: <20191213105100.8173-2-philmd@redhat.com> In-Reply-To: <20191213105100.8173-1-philmd@redhat.com> References: <20191213105100.8173-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: X08GZLzuMcqwU-pRKg3hyQ-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: 207.211.31.120 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson 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" Convert the deprecated DPRINTF() macro to trace events. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 19 +++++-------------- hw/i386/trace-events | 6 ++++++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ac08e63604..66a30cfdf5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -90,16 +90,7 @@ #include "config-devices.h" #include "e820_memory_layout.h" #include "fw_cfg.h" - -/* debug PC/ISA interrupts */ -//#define DEBUG_IRQ - -#ifdef DEBUG_IRQ -#define DPRINTF(fmt, ...) \ - do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) -#endif +#include "trace.h" =20 struct hpet_fw_config hpet_cfg =3D {.count =3D UINT8_MAX}; =20 @@ -348,7 +339,7 @@ void gsi_handler(void *opaque, int n, int level) { GSIState *s =3D opaque; =20 - DPRINTF("pc: %s GSI %d\n", level ? "raising" : "lowering", n); + trace_pc_gsi_interrupt(n, level); if (n < ISA_NUM_IRQS) { qemu_set_irq(s->i8259_irq[n], level); } @@ -426,7 +417,7 @@ static void pic_irq_request(void *opaque, int irq, int = level) CPUState *cs =3D first_cpu; X86CPU *cpu =3D X86_CPU(cs); =20 - DPRINTF("pic_irqs: %s irq %d\n", level? "raise" : "lower", irq); + trace_pc_pic_interrupt(irq, level); if (cpu->apic_state && !kvm_irqchip_in_kernel()) { CPU_FOREACH(cs) { cpu =3D X86_CPU(cs); @@ -760,7 +751,7 @@ static void port92_write(void *opaque, hwaddr addr, uin= t64_t val, Port92State *s =3D opaque; int oldval =3D s->outport; =20 - DPRINTF("port92: write 0x%02" PRIx64 "\n", val); + trace_port92_write(val); s->outport =3D val; qemu_set_irq(s->a20_out, (val >> 1) & 1); if ((val & 1) && !(oldval & 1)) { @@ -775,7 +766,7 @@ static uint64_t port92_read(void *opaque, hwaddr addr, uint32_t ret; =20 ret =3D s->outport; - DPRINTF("port92: read 0x%02x\n", ret); + trace_port92_read(ret); return ret; } =20 diff --git a/hw/i386/trace-events b/hw/i386/trace-events index c8bc464bc5..43f33cf7e2 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -111,3 +111,9 @@ amdvi_ir_irte_ga_val(uint64_t hi, uint64_t lo) "hi 0x%"= PRIx64" lo 0x%"PRIx64 # vmport.c vmport_register(unsigned char command, void *func, void *opaque) "command:= 0x%02x func: %p opaque: %p" vmport_command(unsigned char command) "command: 0x%02x" + +# pc.c +pc_gsi_interrupt(int irqn, int level) "GSI interrupt #%d level:%d" +pc_pic_interrupt(int irqn, int level) "PIC interrupt #%d level:%d" +port92_read(uint8_t val) "port92: read 0x%02x" +port92_write(uint8_t val) "port92: write 0x%02x" --=20 2.21.0 From nobody Tue Apr 30 17:25:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576234452; cv=none; d=zohomail.com; s=zohoarc; b=FqqE58JlZmtnDjWWhTHlDKge0+VFpLgzl9zc3T5NXUcmWf+56Vf4ed9RBGKMz2jaL3wWsuCIZcaZC0ncQz/XIkWuR1lVaMoFIp4kMA339MpirWTzpFfczdWGnrtiqkeEYXIV8EaPws60Ire0sgrmECRMIK/ufKqUWUHGnSXSH+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576234452; 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=qldGLiiIvORkmocMy3ZfZ/9V4HJH7IaEKp8UIxpLO4E=; b=iTUQ5ZfER33zjxJEEKawZNcAOfMNb69MRgqTw7uxr4c0/kBV9s4NuQEHz++M/sIrLkT9wFcKvZsprFfXesQzwHVxPiDYE7U1g8WDQ1P3Zl9N+riEDmlNm37hWctZUnIQcSQc8Xe9GCFMdKIL+MCyjpMEea1yrJbbVQg/ew2eX44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 157623445291854.92640386762821; Fri, 13 Dec 2019 02:54:12 -0800 (PST) Received: from localhost ([::1]:46056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiaJ-0008EF-5y for importer@patchew.org; Fri, 13 Dec 2019 05:54:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiXY-0005Xu-V3 for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifiXY-0001XP-10 for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36755 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ifiXX-0001WZ-T1 for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:19 -0500 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-61-0UTCnE0HMZKOPAo3aeUShw-1; Fri, 13 Dec 2019 05:51:18 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45039107ACC5; Fri, 13 Dec 2019 10:51:17 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-134.brq.redhat.com [10.40.204.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD27C1001901; Fri, 13 Dec 2019 10:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576234279; 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=qldGLiiIvORkmocMy3ZfZ/9V4HJH7IaEKp8UIxpLO4E=; b=SmhfqhXw2AoFCz6bXwZEs1oK6ztDoA0cN1lhoLgmXHTw555F7tzPxkqLZuktiTgenCBTCF b26UIWyErSfAwDHePfotA6KFh3i6U0f2EwoxH7/aQgLNzXljyztT+Z4NMwMiyepnbszG0o LuRaArRoRwdK+8cr1lGv02rEdDHak5M= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/4] hw/i386/pc: Use TYPE_PORT92 instead of hardcoded string Date: Fri, 13 Dec 2019 11:50:58 +0100 Message-Id: <20191213105100.8173-3-philmd@redhat.com> In-Reply-To: <20191213105100.8173-1-philmd@redhat.com> References: <20191213105100.8173-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 0UTCnE0HMZKOPAo3aeUShw-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: 207.211.31.120 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson 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" By using the TYPE_* definitions for devices, we can: - quickly find where devices are used with 'git-grep' - easily rename a device (one-line change). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 66a30cfdf5..2c2ae27447 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1353,7 +1353,7 @@ static void pc_superio_init(ISABus *isa_bus, bool cre= ate_fdctrl, bool no_vmport) qdev_prop_set_ptr(dev, "ps2_mouse", i8042); qdev_init_nofail(dev); } - port92 =3D isa_create_simple(isa_bus, "port92"); + port92 =3D isa_create_simple(isa_bus, TYPE_PORT92); =20 a20_line =3D qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042_setup_a20_line(i8042, a20_line[0]); --=20 2.21.0 From nobody Tue Apr 30 17:25:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576234458; cv=none; d=zohomail.com; s=zohoarc; b=Bfa5YC6T0Jv07SFBoFPQLNWn14o92KXqY5scNHZ3nxiEUv/G0KuisBPWJc6FZykOT+JQB67pZOBDdqj7l4OHYdUhBmxgliXwqD58p4l3tmJt9hXY682KzZDSBzk4GqWsgejp5CQjwKxW3hD8oNEebybcVh7yIFfCfgWdr8zIu+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576234458; 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=fuaHjo1osoo+HyN1f6x75XkJZhp6BiU6x58L5nuSaoA=; b=eVwtoDArU4PSr28SP0si0ce+gqj9i6RRRuG+J+wRXMUDtDmGwKco4YNdIvhlP7YHHOwbMfdryJLIWEoz6kgD9JpiWDMMgvKMQvVTlDRltoM9qVlJQ7G8GUSzjDPCSYhjEM808D2Jv4reHwNeqfzCJgHYBu2si4KRElIPbp/wnv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 157623445854261.66814236876576; Fri, 13 Dec 2019 02:54:18 -0800 (PST) Received: from localhost ([::1]:46058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiaO-0008JP-KN for importer@patchew.org; Fri, 13 Dec 2019 05:54:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60871) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiXd-0005cP-UH for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifiXc-0001fp-KA for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:25 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:41375 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 1ifiXc-0001f2-FS for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:24 -0500 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-418--rjuketLMBipZWq6YeNk2w-1; Fri, 13 Dec 2019 05:51:20 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D876ADB62; Fri, 13 Dec 2019 10:51:19 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-134.brq.redhat.com [10.40.204.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B12911001B00; Fri, 13 Dec 2019 10:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576234284; 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=fuaHjo1osoo+HyN1f6x75XkJZhp6BiU6x58L5nuSaoA=; b=YdWyQRzn07Iy/EVfywxys4PiZZfFvcBfrTEq2/b5uoITZKlH8baTiolBZcrn7rUWBzKR2o BAYgzWk0XgI3o00pgI4a7iuHY1t+sOikCa4sTJp0+W4jmstxYPDoH+Yex1XM4zdIK8jPW6 u9CpFnJa2jN7AYq4/p5gSFj+85r/S1U= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/4] hw/i386/pc: Inline port92_init() Date: Fri, 13 Dec 2019 11:50:59 +0100 Message-Id: <20191213105100.8173-4-philmd@redhat.com> In-Reply-To: <20191213105100.8173-1-philmd@redhat.com> References: <20191213105100.8173-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: -rjuketLMBipZWq6YeNk2w-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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson 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" This one-line function is not very helpful, so remove it by inlining the call to qdev_connect_gpio_out_named(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2c2ae27447..2e8992c7d0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -770,11 +770,6 @@ static uint64_t port92_read(void *opaque, hwaddr addr, return ret; } =20 -static void port92_init(ISADevice *dev, qemu_irq a20_out) -{ - qdev_connect_gpio_out_named(DEVICE(dev), PORT92_A20_LINE, 0, a20_out); -} - static const VMStateDescription vmstate_port92_isa =3D { .name =3D "port92", .version_id =3D 1, @@ -830,8 +825,8 @@ static void port92_class_initfn(ObjectClass *klass, voi= d *data) dc->vmsd =3D &vmstate_port92_isa; /* * Reason: unlike ordinary ISA devices, this one needs additional - * wiring: its A20 output line needs to be wired up by - * port92_init(). + * wiring: its A20 output line needs to be wired up with + * qdev_connect_gpio_out_named(). */ dc->user_creatable =3D false; } @@ -1357,7 +1352,8 @@ static void pc_superio_init(ISABus *isa_bus, bool cre= ate_fdctrl, bool no_vmport) =20 a20_line =3D qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042_setup_a20_line(i8042, a20_line[0]); - port92_init(port92, a20_line[1]); + qdev_connect_gpio_out_named(DEVICE(port92), + PORT92_A20_LINE, 0, a20_line[1]); g_free(a20_line); } =20 --=20 2.21.0 From nobody Tue Apr 30 17:25:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576234546; cv=none; d=zohomail.com; s=zohoarc; b=N6NLvA8b1F7TtNmk2bef9rh/foKqOku5iromRom0bBjR98sKrUr3dmXpne5wbshJ1S3YuWPgjG1MazF2NYO/IsXpmyplKqOIVmSV9jZoI7J2sI78JCKoaD5p9nXqOZ982RhcgW2oxKBcZnel1GXkMmM3dHXxPdZ5tLsZUAmPzng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576234546; 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=Iok79135t8UJIBP3cWJW/bFu9vu/QOQwEdhbenwqCbs=; b=PersOty/rAPQoxpOkWx17GCiB1XJH6EiiH936PV9ggYTveW0pe5uiCxUKxct2cnJio0k+H/w1MCcBoicqMyYdA7t9+/vC1Mhh+UZwyvPGl25ay9qZ6L2LsRPaq4XjYBDueK8OJbPGxvV6wJhwqCe9umbf5BIxp2GyEfLCNNxrZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1576234546623945.7284499286571; Fri, 13 Dec 2019 02:55:46 -0800 (PST) Received: from localhost ([::1]:46148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifibp-0002Hy-DY for importer@patchew.org; Fri, 13 Dec 2019 05:55:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33328) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifiXh-0005jG-WB for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifiXg-0001m6-8l for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:29 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51387 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ifiXg-0001lL-4Y for qemu-devel@nongnu.org; Fri, 13 Dec 2019 05:51:28 -0500 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-46-cI1F1EIENJi4USwfkbKgdg-1; Fri, 13 Dec 2019 05:51:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41366100550E; Fri, 13 Dec 2019 10:51:23 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-134.brq.redhat.com [10.40.204.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93B9C10016E8; Fri, 13 Dec 2019 10:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576234287; 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=Iok79135t8UJIBP3cWJW/bFu9vu/QOQwEdhbenwqCbs=; b=Igc2VhL71eLQnuypcX0zl/GTVJ1YldXKpLabYrrrF5taArtOzG+Ot2Y7dYl4qmzVCR0gCB pXE8V88bgAIrF3Faz05GaZG/rAq+nopwhaElRihwkTuK55ZR8ZL+XR5iQWbBuM6uXXlySN Ep6Ez7CXmZ48/wWMILP9xB9vnfHQcCM= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/4] hw/i386/pc: Extract the port92 device Date: Fri, 13 Dec 2019 11:51:00 +0100 Message-Id: <20191213105100.8173-5-philmd@redhat.com> In-Reply-To: <20191213105100.8173-1-philmd@redhat.com> References: <20191213105100.8173-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: cI1F1EIENJi4USwfkbKgdg-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.120 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson 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" This device is only used by the PC machines. The pc.c file is already big enough, with 2255 lines. By removing 113 lines of it, we reduced it by 5%. It is now a bit easier to navigate the file. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- checkpatch warning: WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #142: new file mode 100644 is harmless because MAINTAINERS PC entry matches the directory: PC ... F: hw/i386/ --- include/hw/i386/pc.h | 3 + hw/i386/pc.c | 113 ------------------------------------- hw/i386/port92.c | 126 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + hw/i386/trace-events | 2 + 5 files changed, 132 insertions(+), 113 deletions(-) create mode 100644 hw/i386/port92.c diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 1f86eba3f9..7e8d18d6fa 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -224,8 +224,11 @@ int cmos_get_fd_drive_type(FloppyDriveType fd0); =20 #define FW_CFG_IO_BASE 0x510 =20 +/* port92.c */ #define PORT92_A20_LINE "a20" =20 +#define TYPE_PORT92 "port92" + /* hpet.c */ extern int no_hpet; =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2e8992c7d0..15efcb29d5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -733,119 +733,6 @@ void pc_cmos_init(PCMachineState *pcms, qemu_register_reset(pc_cmos_init_late, &arg); } =20 -#define TYPE_PORT92 "port92" -#define PORT92(obj) OBJECT_CHECK(Port92State, (obj), TYPE_PORT92) - -/* port 92 stuff: could be split off */ -typedef struct Port92State { - ISADevice parent_obj; - - MemoryRegion io; - uint8_t outport; - qemu_irq a20_out; -} Port92State; - -static void port92_write(void *opaque, hwaddr addr, uint64_t val, - unsigned size) -{ - Port92State *s =3D opaque; - int oldval =3D s->outport; - - trace_port92_write(val); - s->outport =3D val; - qemu_set_irq(s->a20_out, (val >> 1) & 1); - if ((val & 1) && !(oldval & 1)) { - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - } -} - -static uint64_t port92_read(void *opaque, hwaddr addr, - unsigned size) -{ - Port92State *s =3D opaque; - uint32_t ret; - - ret =3D s->outport; - trace_port92_read(ret); - return ret; -} - -static const VMStateDescription vmstate_port92_isa =3D { - .name =3D "port92", - .version_id =3D 1, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_UINT8(outport, Port92State), - VMSTATE_END_OF_LIST() - } -}; - -static void port92_reset(DeviceState *d) -{ - Port92State *s =3D PORT92(d); - - s->outport &=3D ~1; -} - -static const MemoryRegionOps port92_ops =3D { - .read =3D port92_read, - .write =3D port92_write, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 1, - }, - .endianness =3D DEVICE_LITTLE_ENDIAN, -}; - -static void port92_initfn(Object *obj) -{ - Port92State *s =3D PORT92(obj); - - memory_region_init_io(&s->io, OBJECT(s), &port92_ops, s, "port92", 1); - - s->outport =3D 0; - - qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, PORT92_A20_LINE, 1); -} - -static void port92_realizefn(DeviceState *dev, Error **errp) -{ - ISADevice *isadev =3D ISA_DEVICE(dev); - Port92State *s =3D PORT92(dev); - - isa_register_ioport(isadev, &s->io, 0x92); -} - -static void port92_class_initfn(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - dc->realize =3D port92_realizefn; - dc->reset =3D port92_reset; - dc->vmsd =3D &vmstate_port92_isa; - /* - * Reason: unlike ordinary ISA devices, this one needs additional - * wiring: its A20 output line needs to be wired up with - * qdev_connect_gpio_out_named(). - */ - dc->user_creatable =3D false; -} - -static const TypeInfo port92_info =3D { - .name =3D TYPE_PORT92, - .parent =3D TYPE_ISA_DEVICE, - .instance_size =3D sizeof(Port92State), - .instance_init =3D port92_initfn, - .class_init =3D port92_class_initfn, -}; - -static void port92_register_types(void) -{ - type_register_static(&port92_info); -} - -type_init(port92_register_types) - static void handle_a20_line_change(void *opaque, int irq, int level) { X86CPU *cpu =3D opaque; diff --git a/hw/i386/port92.c b/hw/i386/port92.c new file mode 100644 index 0000000000..19866c44ef --- /dev/null +++ b/hw/i386/port92.c @@ -0,0 +1,126 @@ +/* + * QEMU I/O port 0x92 (System Control Port A, to handle Fast Gate A20) + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * SPDX-License-Identifier: MIT + */ + +#include "qemu/osdep.h" +#include "sysemu/runstate.h" +#include "migration/vmstate.h" +#include "hw/irq.h" +#include "hw/i386/pc.h" +#include "trace.h" + +#define PORT92(obj) OBJECT_CHECK(Port92State, (obj), TYPE_PORT92) + +typedef struct Port92State { + ISADevice parent_obj; + + MemoryRegion io; + uint8_t outport; + qemu_irq a20_out; +} Port92State; + +static void port92_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + Port92State *s =3D opaque; + int oldval =3D s->outport; + + trace_port92_write(val); + s->outport =3D val; + qemu_set_irq(s->a20_out, (val >> 1) & 1); + if ((val & 1) && !(oldval & 1)) { + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + } +} + +static uint64_t port92_read(void *opaque, hwaddr addr, + unsigned size) +{ + Port92State *s =3D opaque; + uint32_t ret; + + ret =3D s->outport; + trace_port92_read(ret); + + return ret; +} + +static const VMStateDescription vmstate_port92_isa =3D { + .name =3D "port92", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(outport, Port92State), + VMSTATE_END_OF_LIST() + } +}; + +static void port92_reset(DeviceState *d) +{ + Port92State *s =3D PORT92(d); + + s->outport &=3D ~1; +} + +static const MemoryRegionOps port92_ops =3D { + .read =3D port92_read, + .write =3D port92_write, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +static void port92_initfn(Object *obj) +{ + Port92State *s =3D PORT92(obj); + + memory_region_init_io(&s->io, OBJECT(s), &port92_ops, s, "port92", 1); + + s->outport =3D 0; + + qdev_init_gpio_out_named(DEVICE(obj), &s->a20_out, PORT92_A20_LINE, 1); +} + +static void port92_realizefn(DeviceState *dev, Error **errp) +{ + ISADevice *isadev =3D ISA_DEVICE(dev); + Port92State *s =3D PORT92(dev); + + isa_register_ioport(isadev, &s->io, 0x92); +} + +static void port92_class_initfn(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D port92_realizefn; + dc->reset =3D port92_reset; + dc->vmsd =3D &vmstate_port92_isa; + /* + * Reason: unlike ordinary ISA devices, this one needs additional + * wiring: its A20 output line needs to be wired up with + * qdev_connect_gpio_out_named(). + */ + dc->user_creatable =3D false; +} + +static const TypeInfo port92_info =3D { + .name =3D TYPE_PORT92, + .parent =3D TYPE_ISA_DEVICE, + .instance_size =3D sizeof(Port92State), + .instance_init =3D port92_initfn, + .class_init =3D port92_class_initfn, +}; + +static void port92_register_types(void) +{ + type_register_static(&port92_info); +} + +type_init(port92_register_types) diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 0d195b5210..b317e7eee0 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -12,6 +12,7 @@ obj-$(CONFIG_AMD_IOMMU) +=3D amd_iommu.o obj-$(CONFIG_XEN) +=3D ../xenpv/ xen/ obj-$(CONFIG_VMPORT) +=3D vmport.o obj-$(CONFIG_VMMOUSE) +=3D vmmouse.o +obj-$(CONFIG_PC) +=3D port92.o =20 obj-y +=3D kvmvapic.o obj-y +=3D acpi-build.o diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 43f33cf7e2..076ea5dcfb 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -115,5 +115,7 @@ vmport_command(unsigned char command) "command: 0x%02x" # pc.c pc_gsi_interrupt(int irqn, int level) "GSI interrupt #%d level:%d" pc_pic_interrupt(int irqn, int level) "PIC interrupt #%d level:%d" + +# port92.c port92_read(uint8_t val) "port92: read 0x%02x" port92_write(uint8_t val) "port92: write 0x%02x" --=20 2.21.0