From nobody Sun May 5 12:06:07 2024 Delivered-To: importer2@patchew.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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=poolhem.se Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673697111031696.9114061242917; Sat, 14 Jan 2023 03:51:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGf3n-000639-JU; Sat, 14 Jan 2023 06:50:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGf3l-00062x-Lk for qemu-devel@nongnu.org; Sat, 14 Jan 2023 06:50:53 -0500 Received: from mailout12.inleed.net ([2a0b:dc80:cafe:112::1] helo=ns12.inleed.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGf3h-0001fH-Qa for qemu-devel@nongnu.org; Sat, 14 Jan 2023 06:50:53 -0500 Received: from [213.115.245.47] (helo=balrog.lkp.se) by ns12.inleed.net with esmtpa (Exim 4.96) (envelope-from ) id 1pGf3f-00Dlvy-0m; Sat, 14 Jan 2023 12:50:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=poolhem.se; s=x; h=Content-Transfer-Encoding:Content-Type:Mime-Version:Message-Id:Subject :Cc:To:From:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=WuAOjwqbzw/fRzAwNzwKXHLnXIQX7H00ynkfLb8HBzM=; b=c FD3hAdxRBngr+1oFBMsnSyPv0MCq0NwYQ8jOYcDK6fRm02ceZHc2W3HX4QUEkvGdnTyjeJPxv8QUq z4OrDpDGhLyGfeNZs/p4DfEfVWBUxUFMC+7hSUf3MD0nTsr6SV1mBAjcUodhd7oLvGdm3SFtGnKUb AEejBqXG10JZIkqkLd9XvRhxWuPzCnBoGbUZLCHrygznV730tTonI/SYZsmiiEPawYCbmZQmsEFYW uzdzo8lxVGDyzy0KeUkBh0IJH5GE7oQGgOh5WbnGE9vOvnhloUozLEQP6zBLatecq8/EB97huP+IO nxhK275xhMnltrVhAbGcNI32wiqTuvmGw==; Date: Sat, 14 Jan 2023 12:50:29 +0100 From: Henrik Carlqvist To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, atar4qemu@gmail.com, marcandre.lureau@redhat.com Subject: [PATCH v4] Emulate dip switch language layout settings on SUN keyboard Message-Id: <20230114125029.7395a547.hc981@poolhem.se> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Id: henrik@poolhem.se 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a0b:dc80:cafe:112::1; envelope-from=hc981@poolhem.se; helo=ns12.inleed.net X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 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_SOFTFAIL=0.732, SPF_NONE=0.001 autolearn=no 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1673697114564100003 Content-Type: text/plain; charset="utf-8" This is my fourth attempt to contribute the patch which allows the emulation of different keyboard layouts on sparc which uses a dip switch on the keybo= ard for those settings. After my third attempt I falsely thought that sourcehut stripped off my=20 signed-off line, but it was me who forgot to call git with the -s switch at commit. regards Henrik From 46233aaf57e27207c6d32cdf263b878edeea6263 Mon Sep 17 00:00:00 2001 From: Henrik Carlqvist Date: Fri, 6 Jan 2023 22:33:03 +0100 Subject: [PATCH] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu. SUN Type 4, 5 and 5c keyboards have dip switches to choose the language layout of the keyboard. Solaris makes an ioctl to query the value of the dipswitches and uses that value to select keyboard layout. Also the SUN bios like the one in the file ss5.bin uses this value to support at least some keyboard layouts. However, the OpenBIOS provided with qemu is hardcoded to always use an US keyboard layout. Before this patch, qemu allways gave dip switch value 0x21 (US keyboard), this patch uses the command line switch "-k" (keyboard layout) to select dip switch value. A table is used to lookup values from arguments like: -k fr -k es But the patch also accepts numeric dip switch values directly to the -k switch: -k 0x2b -k 43 Both values above are the same and select swedish keyboard as explained in table 3-15 at https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html Unless you want to do a full Solaris installation but happen to have access to a bios file, the easiest way to test that the patch works is to: qemu-system-sparc -k sv -bios /path/to/ss5.bin If you already happen to have a Solaris installation in a qemu disk image file you can easily try different keyboard layouts after this patch is applied. Signed-off-by: Henrik Carlqvist --- hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/hw/char/escc.c b/hw/char/escc.c index 17a908c59b..53022ccf39 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -31,6 +31,8 @@ #include "qemu/module.h" #include "hw/char/escc.h" #include "ui/console.h" +#include "sysemu/sysemu.h" +#include "qemu/cutils.h" #include "trace.h" =20 /* @@ -190,6 +192,7 @@ #define R_MISC1I 14 #define R_EXTINT 15 =20 +static unsigned char sun_keyboard_layout_dip_switch(void); static void handle_kbd_command(ESCCChannelState *s, int val); static int serial_can_receive(void *opaque); static void serial_receive_byte(ESCCChannelState *s, int ch); @@ -846,6 +849,75 @@ static QemuInputHandler sunkbd_handler =3D { .event =3D sunkbd_handle_event, }; =20 +static unsigned char sun_keyboard_layout_dip_switch(void) +{ + /* Return the value of the dip-switches in a SUN Type 5 keyboard */ + static unsigned char ret =3D 0xff; + + if ((ret =3D=3D 0xff) && keyboard_layout) { + int i; + struct layout_values { + const char *lang; + unsigned char dip; + } languages[] =3D + /* Dip values from table 3-16 Layouts for Type 4, 5, and 5c Keyboards = */ + { + {"en-us", 0x21}, /* U.S.A. (US5.kt) */ + /* 0x22 is some other US (US_UNIX5.kt)*/ + {"fr", 0x23}, /* France (France5.kt) */ + {"da", 0x24}, /* Denmark (Denmark5.kt) */ + {"de", 0x25}, /* Germany (Germany5.kt) */ + {"it", 0x26}, /* Italy (Italy5.kt) */ + {"nl", 0x27}, /* The Netherlands (Netherland5.kt) */ + {"no", 0x28}, /* Norway (Norway.kt) */ + {"pt", 0x29}, /* Portugal (Portugal5.kt) */ + {"es", 0x2a}, /* Spain (Spain5.kt) */ + {"sv", 0x2b}, /* Sweden (Sweden5.kt) */ + {"fr-ch", 0x2c}, /* Switzerland/French (Switzer_Fr5.kt) */ + {"de-ch", 0x2d}, /* Switzerland/German (Switzer_Ge5.kt) */ + {"en-gb", 0x2e}, /* Great Britain (UK5.kt) */ + {"ko", 0x2f}, /* Korea (Korea5.kt) */ + {"tw", 0x30}, /* Taiwan (Taiwan5.kt) */ + {"ja", 0x31}, /* Japan (Japan5.kt) */ + {"fr-ca", 0x32}, /* Canada/French (Canada_Fr5.kt) */ + {"hu", 0x33}, /* Hungary (Hungary5.kt) */ + {"pl", 0x34}, /* Poland (Poland5.kt) */ + {"cz", 0x35}, /* Czech (Czech5.kt) */ + {"ru", 0x36}, /* Russia (Russia5.kt) */ + {"lv", 0x37}, /* Latvia (Latvia5.kt) */ + {"tr", 0x38}, /* Turkey-Q5 (TurkeyQ5.kt) */ + {"gr", 0x39}, /* Greece (Greece5.kt) */ + {"ar", 0x3a}, /* Arabic (Arabic5.kt) */ + {"lt", 0x3b}, /* Lithuania (Lithuania5.kt) */ + {"nl-be", 0x3c}, /* Belgium (Belgian5.kt) */ + {"be", 0x3c}, /* Belgium (Belgian5.kt) */ + }; + + for (i =3D 0; + i < sizeof(languages) / sizeof(struct layout_values); + i++) { + if (!strcmp(keyboard_layout, languages[i].lang)) { + ret =3D languages[i].dip; + return ret; + } + } + /* Found no known language code */ + + if ((keyboard_layout[0] >=3D '0') && (keyboard_layout[0] <=3D '9')= ) { + unsigned int tmp; + /* As a fallback we also accept numeric dip switch value */ + if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) { + ret =3D (unsigned char)tmp; + } + } + } + if (ret =3D=3D 0xff) { + /* Final fallback if keyboard_layout was not set or recognized */ + ret =3D 0x21; /* en-us layout */ + } + return ret; +} + static void handle_kbd_command(ESCCChannelState *s, int val) { trace_escc_kbd_command(val); @@ -867,7 +939,7 @@ static void handle_kbd_command(ESCCChannelState *s, int= val) case 0xf: clear_queue(s); put_queue(s, 0xfe); - put_queue(s, 0x21); /* en-us layout */ + put_queue(s, sun_keyboard_layout_dip_switch()); break; default: break; --=20 2.35.1