From nobody Tue Feb 10 09:59:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664450824; cv=none; d=zohomail.com; s=zohoarc; b=LAFfybsCOn6cqBcIwcryfZFezi8XngNT3urKZ8lVpNfVGtpeZ+xZ/GK2VIcvw/WLFeICTS60XE8ERWfly3KtSDy6yP24JX36Uf874zmYqBHwcRfKYOOvj+rRQWRGqUk+2Mn6OmOF10nlrUHZyHT5LIqiOab1eusC9GZG1YkPwxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664450824; 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=3mXM23Rs8aZCO5O97Kib6Cw52DXTr/s1fYzMgrROq4g=; b=GxuQRFPmcffEKdqQ/3u7l+m4CyNQ9gBLnO4bGZ5qWCieCfJ9H2pOUxRD5cCXqe8FXcXNsbON3l2cuPK3uwm1ROZEs5PekpQtH0lwrLNrMpDfSZPcfLQfWX7jV4pOMl6yo/6zCFexoU0oVrDIHwpKtWYJkJetVoijopD26HZzOQE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664450824610193.6872857489151; Thu, 29 Sep 2022 04:27:04 -0700 (PDT) Received: from localhost ([::1]:43694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odrgr-0002to-0E for importer@patchew.org; Thu, 29 Sep 2022 07:26:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odrME-0001CF-OF for qemu-devel@nongnu.org; Thu, 29 Sep 2022 07:05:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odrMD-0001xE-2T for qemu-devel@nongnu.org; Thu, 29 Sep 2022 07:05:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-364-l8SjcAAuM-GXNGjEK0heXw-1; Thu, 29 Sep 2022 07:05:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D01D43C01E15; Thu, 29 Sep 2022 11:05:28 +0000 (UTC) Received: from localhost (unknown [10.39.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C890B112132C; Thu, 29 Sep 2022 11:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664449532; 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=3mXM23Rs8aZCO5O97Kib6Cw52DXTr/s1fYzMgrROq4g=; b=FPv4KAT0vqDHKor0J230uxOUwkwBESTB2ZKK2FUTj/fNWkgHa8E4A0ujWvoy2SBrxLcwMY zR/GCE8Iy7Quv0jvup1XJSt3osCg6iwEyK/08JU7lX7P5pC32JojQVz2spvGYMl8OALN3c f0l53Qh4216prwp3aJVds129HO+ErrM= X-MC-Unique: l8SjcAAuM-GXNGjEK0heXw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Arwed Meyer , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PULL 4/8] msmouse: Add pnp data Date: Thu, 29 Sep 2022 15:05:04 +0400 Message-Id: <20220929110508.1323529-5-marcandre.lureau@redhat.com> In-Reply-To: <20220929110508.1323529-1-marcandre.lureau@redhat.com> References: <20220929110508.1323529-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.08, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664450826444100001 From: Arwed Meyer Make msmouse send serial pnp data. Enables you to see nice qemu device name in Win9x. Signed-off-by: Arwed Meyer Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220911181840.8933-5-arwed.meyer@gmx.de> --- chardev/msmouse.c | 58 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/chardev/msmouse.c b/chardev/msmouse.c index 5982c15df6..9006703023 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -35,11 +35,24 @@ #define MSMOUSE_HI2(n) (((n) & 0xc0) >> 6) #define MSMOUSE_PWR(cm) (cm & (CHR_TIOCM_RTS | CHR_TIOCM_DTR)) =20 +/* Serial PnP for 6 bit devices/mice sends all ASCII chars - 0x20 */ +#define M(c) (c - 0x20) /* Serial fifo size. */ #define MSMOUSE_BUF_SZ 64 =20 /* Mouse ID: Send "M3" cause we behave like a 3 button logitech mouse. */ const uint8_t mouse_id[] =3D {'M', '3'}; +/* + * PnP start "(", PnP version (1.0), vendor ID, product ID, '\\', + * serial ID (omitted), '\\', MS class name, '\\', driver ID (omitted), '\= \', + * product description, checksum, ")" + * Missing parts are inserted later. + */ +const uint8_t pnp_data[] =3D {M('('), 1, '$', M('Q'), M('M'), M('U'), + M('0'), M('0'), M('0'), M('1'), + M('\\'), M('\\'), + M('M'), M('O'), M('U'), M('S'), M('E'), + M('\\'), M('\\')}; =20 struct MouseChardev { Chardev parent; @@ -158,11 +171,22 @@ static int msmouse_chr_write(struct Chardev *s, const= uint8_t *buf, int len) return len; } =20 +static QemuInputHandler msmouse_handler =3D { + .name =3D "QEMU Microsoft Mouse", + .mask =3D INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL, + .event =3D msmouse_input_event, + .sync =3D msmouse_input_sync, +}; + static int msmouse_ioctl(Chardev *chr, int cmd, void *arg) { MouseChardev *mouse =3D MOUSE_CHARDEV(chr); - int c; + int c, i, j; + uint8_t bytes[MSMOUSE_BUF_SZ / 2]; int *targ =3D (int *)arg; + const uint8_t hexchr[16] =3D {M('0'), M('1'), M('2'), M('3'), M('4'), = M('5'), + M('6'), M('7'), M('8'), M('9'), M('A'), M('B'= ), + M('C'), M('D'), M('E'), M('F')}; =20 switch (cmd) { case CHR_IOCTL_SERIAL_SET_TIOCM: @@ -171,11 +195,30 @@ static int msmouse_ioctl(Chardev *chr, int cmd, void = *arg) if (MSMOUSE_PWR(mouse->tiocm)) { if (!MSMOUSE_PWR(c)) { /* - * Power on after reset: send "M3" - * cause we behave like a 3 button logitech - * mouse. + * Power on after reset: Send ID and PnP data + * No need to check fifo space as it is empty at this poin= t. */ fifo8_push_all(&mouse->outbuf, mouse_id, sizeof(mouse_id)); + /* Add PnP data: */ + fifo8_push_all(&mouse->outbuf, pnp_data, sizeof(pnp_data)); + /* + * Add device description from qemu handler name. + * Make sure this all fits into the queue beforehand! + */ + c =3D M(')'); + for (i =3D 0; msmouse_handler.name[i]; i++) { + bytes[i] =3D M(msmouse_handler.name[i]); + c +=3D bytes[i]; + } + /* Calc more of checksum */ + for (j =3D 0; j < sizeof(pnp_data); j++) { + c +=3D pnp_data[j]; + } + c &=3D 0xff; + bytes[i++] =3D hexchr[c >> 4]; + bytes[i++] =3D hexchr[c & 0x0f]; + bytes[i++] =3D M(')'); + fifo8_push_all(&mouse->outbuf, bytes, i); /* Start sending data to serial. */ msmouse_chr_accept_input(chr); } @@ -208,13 +251,6 @@ static void char_msmouse_finalize(Object *obj) fifo8_destroy(&mouse->outbuf); } =20 -static QemuInputHandler msmouse_handler =3D { - .name =3D "QEMU Microsoft Mouse", - .mask =3D INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_REL, - .event =3D msmouse_input_event, - .sync =3D msmouse_input_sync, -}; - static void msmouse_chr_open(Chardev *chr, ChardevBackend *backend, bool *be_opened, --=20 2.37.3