From nobody Fri Nov 14 00:55:29 2025 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=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1584033134; cv=none; d=zohomail.com; s=zohoarc; b=bKpWutxqmwCGyRRo1LgmYE/oaHpx1O1DCHdn+bqSknobrvek7GTrO05r+72iU3rnVYDGU3AG98AjpAXin8tiwxIg/CdfkxwViwEQ6U91JvvZAFUDodxDYYBqPHxsgyFVQEiJ0XmYeeaHOBhd6ENfSVvPPAjkW0/7v5gps1Mi/t8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584033134; h=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=2kx96PJyCWaObAe/S9ZZZsHhJgQc5nCYZyC7qimTRZs=; b=N4T/tKQ1KoCW6tlzo9Wleg8nSkjupuIiNeauGI+X6TGrNUA/5XIdZWEedkjy8Cr6dPYraHmXAU2eNkakM1G/T8LB9MaDJ1K02faBu/5snSB9BWe8ce/MQGYKCcZKLm+VE39ea2eSHxhgfQkrbfPXTN/G+cty25N/lkMCUe/NabA= 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 1584033134415724.1780490741082; Thu, 12 Mar 2020 10:12:14 -0700 (PDT) Received: from localhost ([::1]:46266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCRNV-0004t8-CI for importer@patchew.org; Thu, 12 Mar 2020 13:12:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37028) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCR4l-0002rZ-Ji for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCR4g-0000Or-Jy for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:47 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:57220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCR4g-0000Mw-AL for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGmthB012070; Thu, 12 Mar 2020 16:52:44 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ym31utt3c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:52:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGoIUB122283; Thu, 12 Mar 2020 16:52:44 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2yp8r0snpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:52:44 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02CGqhbh030522; Thu, 12 Mar 2020 16:52:43 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Mar 2020 09:52:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=2kx96PJyCWaObAe/S9ZZZsHhJgQc5nCYZyC7qimTRZs=; b=Kpjx/6ZSnNWtFJm3yKrtdxAgRAUUhGUDCbkN31GuIo4eMWMD5qMCf3ReH9pKqa1BQhK6 6+bkw9JSOApRkyVtc8fa6CGDxcqEXBiiqqLB1gLC9tebIcw29ClVAQ/Zwl7y3/uv9YJQ 60sHbhWhI0HlXgMI/z9ksoFLF08xq+8/mmaVv4pZBe7V6KH2vNGXx53gTJWNxbb6wGSB tyVLxDGvM6dYLVXqfOWgzgceyaGZyb0MKxRv3oCY36ElMR+HGX82cRimq6xeuTFlqPoI /Et8LC4JndKuTiBcZAw2DTaLDLVIKcMCr/fL7kuN0P+6ELh5V5UbrszB09fPzncgBzEL hQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v3 08/16] hw/i386/vmport: Define enum for all commands Date: Thu, 12 Mar 2020 18:54:23 +0200 Message-Id: <20200312165431.82118-9-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312165431.82118-1-liran.alon@oracle.com> References: <20200312165431.82118-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9558 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=1 bulkscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9558 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003120085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net 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" No functional change. Defining an enum for all VMPort commands have the following advantages: * It gets rid of the error-prone requirement to update VMPORT_ENTRIES when new VMPort commands are added to QEMU. * It makes it clear to know by looking at one place at the source, what are all the VMPort commands supported by QEMU. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/vmmouse.c | 18 ++++++------------ hw/i386/vmport.c | 11 ++--------- include/hw/i386/vmport.h | 11 ++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 49a546fd3bb6..afb8e9e09a30 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -34,12 +34,6 @@ /* debug only vmmouse */ //#define DEBUG_VMMOUSE =20 -/* VMMouse Commands */ -#define VMMOUSE_GETVERSION 10 -#define VMMOUSE_DATA 39 -#define VMMOUSE_STATUS 40 -#define VMMOUSE_COMMAND 41 - #define VMMOUSE_READ_ID 0x45414552 #define VMMOUSE_DISABLE 0x000000f5 #define VMMOUSE_REQUEST_RELATIVE 0x4c455252 @@ -197,10 +191,10 @@ static uint32_t vmmouse_ioport_read(void *opaque, uin= t32_t addr) command =3D data[2] & 0xFFFF; =20 switch (command) { - case VMMOUSE_STATUS: + case VMPORT_CMD_VMMOUSE_STATUS: data[0] =3D vmmouse_get_status(s); break; - case VMMOUSE_COMMAND: + case VMPORT_CMD_VMMOUSE_COMMAND: switch (data[1]) { case VMMOUSE_DISABLE: vmmouse_disable(s); @@ -219,7 +213,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint3= 2_t addr) break; } break; - case VMMOUSE_DATA: + case VMPORT_CMD_VMMOUSE_DATA: vmmouse_data(s, data, data[1]); break; default: @@ -276,9 +270,9 @@ static void vmmouse_realizefn(DeviceState *dev, Error *= *errp) return; } =20 - vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_STATUS, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_COMMAND, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_DATA, vmmouse_ioport_read, s); } =20 static Property vmmouse_properties[] =3D { diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index e9ea5fe7f765..6ab094311d6c 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -38,10 +38,6 @@ #include "qemu/log.h" #include "trace.h" =20 -#define VMPORT_CMD_GETVERSION 0x0a -#define VMPORT_CMD_GETRAMSIZE 0x14 - -#define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 =20 /* Compatibility flags for migration */ @@ -72,12 +68,9 @@ typedef struct VMPortState { =20 static VMPortState *port_state; =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque) +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque) { - if (command >=3D VMPORT_ENTRIES) { - return; - } - + assert(command < VMPORT_ENTRIES); trace_vmport_register(command, func, opaque); port_state->func[command] =3D func; port_state->opaque[command] =3D opaque; diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index f0c1e985ca08..0501ccac6ddf 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -4,12 +4,21 @@ #define TYPE_VMPORT "vmport" typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); =20 +typedef enum { + VMPORT_CMD_GETVERSION =3D 10, + VMPORT_CMD_GETRAMSIZE =3D 20, + VMPORT_CMD_VMMOUSE_DATA =3D 39, + VMPORT_CMD_VMMOUSE_STATUS =3D 40, + VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_ENTRIES +} VMPortCommand; + static inline void vmport_init(ISABus *bus) { isa_create_simple(bus, TYPE_VMPORT); } =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque); void vmmouse_get_data(uint32_t *data); void vmmouse_set_data(const uint32_t *data); =20 --=20 2.20.1