From patchwork Sun Jun 26 17:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 12895827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A6F3C433EF for ; Sun, 26 Jun 2022 17:55:28 +0000 (UTC) Received: from localhost ([::1]:60110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5WTm-0007iU-B4 for qemu-devel@archiver.kernel.org; Sun, 26 Jun 2022 13:55:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5WKk-0001R2-Qk for qemu-devel@nongnu.org; Sun, 26 Jun 2022 13:46:07 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:45006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5WKj-0008Ls-70 for qemu-devel@nongnu.org; Sun, 26 Jun 2022 13:46:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BZml7I+V+rWrg5ez6I5ApogNyKuRqt18HAY3/rRCWZg=; b=ZPTYiGO0ma8vJkMUfTcIppznT7 cjKf4/914qivygR0nYi8MIklXEUMZfuqsEnu0IbGJ3ITiBQYnGf1n/cX3biWWykmRtGpXB9AoODiP rroEczvFsTMBrR49xrAlsnj4jp0CNh7mKYW8BBbCRPFldI9bpCVwBPmDalWsea5KXLYNcz0En6uqU FM7OEwaBz9xsLsG8F/6ppZoyqluFV9ABiZQcB6DGMC4phP7LEK4zFTGT/AtZimTH3R5bLRj50jVJV gpuy0wEGF/kVU4/9u1zo5mg93pzCCJa7KzvA94PqKFTE59OuCvp17n5+0QHsIyeTLfugxemn6gob0 ceJR6+hRFzrpNW9eW2ifRYt8+zuYWAGXQEFJqfBmCqrGXdvinZW8I5h0BZA2btV+pLwSqnfyKmrRL 0vBRjjIt7camtKBVgzLfY4Lfxx+WpfvX58x+k1RP1+XBxm4rxJTX+TIDjta8lhu6owryj4BNIXdj4 pO/zMEiz+oOGJkDxA7oG0m6Xrqjpzy1w6apTG96143uEo7JJaExrb6LBC/oQJH32Z+RUxdOmcmrzw Rzy0Q2SKYisDm0qRp3BCEQW+yEOcGn+t6Ay77fCWgKk6lu/oaJ41B1pFqsGTGEjfohJTU86ZhDYQW 1lyf9quF1N22KxvrN+h1v/5HyZyQq8Jzk/S/UAAeU=; Received: from [2a00:23c4:8ba4:e500:b82f:56f9:46d7:80ab] (helo=kentang.home) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o5WJU-0007KY-RM; Sun, 26 Jun 2022 18:44:53 +0100 From: Mark Cave-Ayland To: richard.henderson@linaro.org, qemu-devel@nongnu.org Date: Sun, 26 Jun 2022 18:44:41 +0100 Message-Id: <20220626174531.969187-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220626174531.969187-1-mark.cave-ayland@ilande.co.uk> References: <20220626174531.969187-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8ba4:e500:b82f:56f9:46d7:80ab X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 05/55] ps2: move QOM type definitions from ps2.c to ps2.h X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move the QOM type definitions into the ps2.h header file to allow the new QOM types to be used by other devices. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-6-mark.cave-ayland@ilande.co.uk> --- hw/input/ps2.c | 55 --------------------------------------- include/hw/input/ps2.h | 58 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index ee7c36d4f2..f4bad9876a 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -76,11 +76,6 @@ #define MOUSE_STATUS_ENABLED 0x20 #define MOUSE_STATUS_SCALE21 0x10 -/* - * PS/2 buffer size. Keep 256 bytes for compatibility with - * older QEMU versions. - */ -#define PS2_BUFFER_SIZE 256 #define PS2_QUEUE_SIZE 16 /* Queue size required by PS/2 protocol */ #define PS2_QUEUE_HEADROOM 8 /* Queue size for keyboard command replies */ @@ -92,56 +87,6 @@ #define MOD_SHIFT_R (1 << 4) #define MOD_ALT_R (1 << 5) -typedef struct { - uint8_t data[PS2_BUFFER_SIZE]; - int rptr, wptr, cwptr, count; -} PS2Queue; - -struct PS2State { - SysBusDevice parent_obj; - - PS2Queue queue; - int32_t write_cmd; - void (*update_irq)(void *, int); - void *update_arg; -}; - -#define TYPE_PS2_DEVICE "ps2-device" -OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE) - -struct PS2KbdState { - PS2State parent_obj; - - int scan_enabled; - int translate; - int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */ - int ledstate; - bool need_high_bit; - unsigned int modifiers; /* bitmask of MOD_* constants above */ -}; - -#define TYPE_PS2_KBD_DEVICE "ps2-kbd" -OBJECT_DECLARE_SIMPLE_TYPE(PS2KbdState, PS2_KBD_DEVICE) - -struct PS2MouseState { - PS2State parent_obj; - - uint8_t mouse_status; - uint8_t mouse_resolution; - uint8_t mouse_sample_rate; - uint8_t mouse_wrap; - uint8_t mouse_type; /* 0 = PS2, 3 = IMPS/2, 4 = IMEX */ - uint8_t mouse_detect_state; - int mouse_dx; /* current values, needed for 'poll' mode */ - int mouse_dy; - int mouse_dz; - int mouse_dw; - uint8_t mouse_buttons; -}; - -#define TYPE_PS2_MOUSE_DEVICE "ps2-mouse" -OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE) - static uint8_t translate_table[256] = { 0xff, 0x43, 0x41, 0x3f, 0x3d, 0x3b, 0x3c, 0x58, 0x64, 0x44, 0x42, 0x40, 0x3e, 0x0f, 0x29, 0x59, diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 35d983897a..7f2c3f6090 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -25,13 +25,69 @@ #ifndef HW_PS2_H #define HW_PS2_H +#include "hw/sysbus.h" + #define PS2_MOUSE_BUTTON_LEFT 0x01 #define PS2_MOUSE_BUTTON_RIGHT 0x02 #define PS2_MOUSE_BUTTON_MIDDLE 0x04 #define PS2_MOUSE_BUTTON_SIDE 0x08 #define PS2_MOUSE_BUTTON_EXTRA 0x10 -typedef struct PS2State PS2State; +/* + * PS/2 buffer size. Keep 256 bytes for compatibility with + * older QEMU versions. + */ +#define PS2_BUFFER_SIZE 256 + +typedef struct { + uint8_t data[PS2_BUFFER_SIZE]; + int rptr, wptr, cwptr, count; +} PS2Queue; + +struct PS2State { + SysBusDevice parent_obj; + + PS2Queue queue; + int32_t write_cmd; + void (*update_irq)(void *, int); + void *update_arg; +}; + +#define TYPE_PS2_DEVICE "ps2-device" +OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE) + +struct PS2KbdState { + PS2State parent_obj; + + int scan_enabled; + int translate; + int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */ + int ledstate; + bool need_high_bit; + unsigned int modifiers; /* bitmask of MOD_* constants above */ +}; + +#define TYPE_PS2_KBD_DEVICE "ps2-kbd" +OBJECT_DECLARE_SIMPLE_TYPE(PS2KbdState, PS2_KBD_DEVICE) + +struct PS2MouseState { + PS2State parent_obj; + + uint8_t mouse_status; + uint8_t mouse_resolution; + uint8_t mouse_sample_rate; + uint8_t mouse_wrap; + uint8_t mouse_type; /* 0 = PS2, 3 = IMPS/2, 4 = IMEX */ + uint8_t mouse_detect_state; + int mouse_dx; /* current values, needed for 'poll' mode */ + int mouse_dy; + int mouse_dz; + int mouse_dw; + uint8_t mouse_buttons; +}; + +#define TYPE_PS2_MOUSE_DEVICE "ps2-mouse" +OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE) /* ps2.c */ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);