qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Emulate dip switch language layout settings on SUN keyboard
@ 2020-07-10 18:19 Henrik Carlqvist
  2020-08-03 17:26 ` Ping: " Henrik Carlqvist
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Carlqvist @ 2020-07-10 18:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, pbonzini

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 allways 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.

Unfortunately my glib version is too old to compile later versions of qemu
so even though this patch is made from latest git I have only been able to
test it myself with qemu version 4.1.1. I think and hope that this patch will
compile and work also with the latest version of git as it only affects one
file and there hasn't been much changes to that file since tested version
4.1.1.

Best regards Henrik

From 2f86bd60750d44206b9181f76115e77b58dff544 Mon Sep 17 00:00:00 2001
From: Henrik Carlqvist <hc1245@poolhem.se>
Date: Fri, 10 Jul 2020 19:21:08 +0200
Subject: [PATCH] Emulating sun keyboard languate layout dip switches, taking
 the value for the dip switches from the "-k" option to qemu.

Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
---
 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 7d16ee8688..7287056b5f 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -30,6 +30,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"
 
 /*
@@ -175,6 +177,7 @@
 #define R_MISC1I 14
 #define R_EXTINT 15
 
+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);
@@ -730,6 +733,75 @@ static QemuInputHandler sunkbd_handler = {
     .event = sunkbd_handle_event,
 };
 
+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 = 0xff;
+
+    if ((ret == 0xff) && keyboard_layout) {
+        int i;
+        struct layout_values {
+            const char *lang;
+            unsigned char dip;
+        } languages[] =
+    /* 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 = 0;
+             i < sizeof(languages) / sizeof(struct layout_values);
+             i++) {
+            if (!strcmp(keyboard_layout, languages[i].lang)) {
+                ret = languages[i].dip;
+                return ret;
+            }
+        }
+        /* Found no known language code */
+
+        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
+            unsigned int tmp;
+            /* As a fallback we also accept numeric dip switch value */
+            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
+                ret = (unsigned char)tmp;
+            }
+        }
+    }
+    if (ret == 0xff) {
+        /* Final fallback if keyboard_layout was not set or recognized */
+        ret = 0x21; /* en-us layout */
+    }
+    return ret;
+}
+
 static void handle_kbd_command(ESCCChannelState *s, int val)
 {
     trace_escc_kbd_command(val);
@@ -751,7 +823,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;
-- 
2.14.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Ping: [PATCH] Emulate dip switch language layout settings on SUN keyboard
  2020-07-10 18:19 [PATCH] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
@ 2020-08-03 17:26 ` Henrik Carlqvist
  2020-08-03 17:52   ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Carlqvist @ 2020-08-03 17:26 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: marcandre.lureau, kraxel, qemu-devel, pbonzini

Would you please consider my patch which implements the honor of the -k switch
for sparc as a sun keyboard language dip switch setting instead of a hard
coded en-us keyboard layout?

The initial patch mail was sent to the mailing list and the listed maintainers
of escc.c and is also available at
http://patchwork.ozlabs.org/project/qemu-devel/patch/20200710201911.3a3e336c.hc981@poolhem.se/

This ping email is also sent to Gerd Hoffmann who many years ago
(2014) selected the en-us keyboard layout as a hardcoded value in escc.c with
commit 59e7a130054b55fe15cdfdebf284332b04d990ef.

Best regards Henrik

On Fri, 10 Jul 2020 20:19:11 +0200
Henrik Carlqvist <hc981@poolhem.se> wrote:

> 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 allways 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.
> 
> Unfortunately my glib version is too old to compile later versions of qemu
> so even though this patch is made from latest git I have only been able to
> test it myself with qemu version 4.1.1. I think and hope that this patch
> will compile and work also with the latest version of git as it only affects
> one file and there hasn't been much changes to that file since tested
> version 4.1.1.
> 
> Best regards Henrik
> 
> From 2f86bd60750d44206b9181f76115e77b58dff544 Mon Sep 17 00:00:00 2001
> From: Henrik Carlqvist <hc1245@poolhem.se>
> Date: Fri, 10 Jul 2020 19:21:08 +0200
> Subject: [PATCH] Emulating sun keyboard languate layout dip switches, taking
>  the value for the dip switches from the "-k" option to qemu.
> 
> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
> ---
>  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 7d16ee8688..7287056b5f 100644
> --- a/hw/char/escc.c
> +++ b/hw/char/escc.c
> @@ -30,6 +30,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"
>  
>  /*
> @@ -175,6 +177,7 @@
>  #define R_MISC1I 14
>  #define R_EXTINT 15
>  
> +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);
> @@ -730,6 +733,75 @@ static QemuInputHandler sunkbd_handler = {
>      .event = sunkbd_handle_event,
>  };
>  
> +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 = 0xff;
> +
> +    if ((ret == 0xff) && keyboard_layout) {
> +        int i;
> +        struct layout_values {
> +            const char *lang;
> +            unsigned char dip;
> +        } languages[] =
> +    /* 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 = 0;
> +             i < sizeof(languages) / sizeof(struct layout_values);
> +             i++) {
> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
> +                ret = languages[i].dip;
> +                return ret;
> +            }
> +        }
> +        /* Found no known language code */
> +
> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
> +            unsigned int tmp;
> +            /* As a fallback we also accept numeric dip switch value */
> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
> +                ret = (unsigned char)tmp;
> +            }
> +        }
> +    }
> +    if (ret == 0xff) {
> +        /* Final fallback if keyboard_layout was not set or recognized */
> +        ret = 0x21; /* en-us layout */
> +    }
> +    return ret;
> +}
> +
>  static void handle_kbd_command(ESCCChannelState *s, int val)
>  {
>      trace_escc_kbd_command(val);
> @@ -751,7 +823,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;
> -- 
> 2.14.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping: [PATCH] Emulate dip switch language layout settings on SUN keyboard
  2020-08-03 17:26 ` Ping: " Henrik Carlqvist
@ 2020-08-03 17:52   ` Paolo Bonzini
  2020-08-03 18:16     ` Artyom Tarasenko
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2020-08-03 17:52 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: marcandre.lureau, qemu-devel, Artyom Tarasenko, kraxel

On 03/08/20 19:26, Henrik Carlqvist wrote:
> Would you please consider my patch which implements the honor of the -k switch
> for sparc as a sun keyboard language dip switch setting instead of a hard
> coded en-us keyboard layout?
> 
> The initial patch mail was sent to the mailing list and the listed maintainers
> of escc.c and is also available at
> http://patchwork.ozlabs.org/project/qemu-devel/patch/20200710201911.3a3e336c.hc981@poolhem.se/
> 
> This ping email is also sent to Gerd Hoffmann who many years ago
> (2014) selected the en-us keyboard layout as a hardcoded value in escc.c with
> commit 59e7a130054b55fe15cdfdebf284332b04d990ef.

Artyom, can you review?

Paolo

> Best regards Henrik
> 
> On Fri, 10 Jul 2020 20:19:11 +0200
> Henrik Carlqvist <hc981@poolhem.se> wrote:
> 
>> 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 allways 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.
>>
>> Unfortunately my glib version is too old to compile later versions of qemu
>> so even though this patch is made from latest git I have only been able to
>> test it myself with qemu version 4.1.1. I think and hope that this patch
>> will compile and work also with the latest version of git as it only affects
>> one file and there hasn't been much changes to that file since tested
>> version 4.1.1.
>>
>> Best regards Henrik
>>
>> From 2f86bd60750d44206b9181f76115e77b58dff544 Mon Sep 17 00:00:00 2001
>> From: Henrik Carlqvist <hc1245@poolhem.se>
>> Date: Fri, 10 Jul 2020 19:21:08 +0200
>> Subject: [PATCH] Emulating sun keyboard languate layout dip switches, taking
>>  the value for the dip switches from the "-k" option to qemu.
>>
>> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
>> ---
>>  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 7d16ee8688..7287056b5f 100644
>> --- a/hw/char/escc.c
>> +++ b/hw/char/escc.c
>> @@ -30,6 +30,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"
>>  
>>  /*
>> @@ -175,6 +177,7 @@
>>  #define R_MISC1I 14
>>  #define R_EXTINT 15
>>  
>> +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);
>> @@ -730,6 +733,75 @@ static QemuInputHandler sunkbd_handler = {
>>      .event = sunkbd_handle_event,
>>  };
>>  
>> +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 = 0xff;
>> +
>> +    if ((ret == 0xff) && keyboard_layout) {
>> +        int i;
>> +        struct layout_values {
>> +            const char *lang;
>> +            unsigned char dip;
>> +        } languages[] =
>> +    /* 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 = 0;
>> +             i < sizeof(languages) / sizeof(struct layout_values);
>> +             i++) {
>> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
>> +                ret = languages[i].dip;
>> +                return ret;
>> +            }
>> +        }
>> +        /* Found no known language code */
>> +
>> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
>> +            unsigned int tmp;
>> +            /* As a fallback we also accept numeric dip switch value */
>> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
>> +                ret = (unsigned char)tmp;
>> +            }
>> +        }
>> +    }
>> +    if (ret == 0xff) {
>> +        /* Final fallback if keyboard_layout was not set or recognized */
>> +        ret = 0x21; /* en-us layout */
>> +    }
>> +    return ret;
>> +}
>> +
>>  static void handle_kbd_command(ESCCChannelState *s, int val)
>>  {
>>      trace_escc_kbd_command(val);
>> @@ -751,7 +823,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;
>> -- 
>> 2.14.5
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping: [PATCH] Emulate dip switch language layout settings on SUN keyboard
  2020-08-03 17:52   ` Paolo Bonzini
@ 2020-08-03 18:16     ` Artyom Tarasenko
  2020-08-03 18:36       ` Henrik Carlqvist
  0 siblings, 1 reply; 6+ messages in thread
From: Artyom Tarasenko @ 2020-08-03 18:16 UTC (permalink / raw)
  To: Henrik Carlqvist
  Cc: Marc-André Lureau, Paolo Bonzini, qemu-devel, Gerd Hoffmann

On Mon, Aug 3, 2020 at 7:52 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 03/08/20 19:26, Henrik Carlqvist wrote:
> > Would you please consider my patch which implements the honor of the -k switch
> > for sparc as a sun keyboard language dip switch setting instead of a hard
> > coded en-us keyboard layout?
> >
> > The initial patch mail was sent to the mailing list and the listed maintainers
> > of escc.c and is also available at
> > http://patchwork.ozlabs.org/project/qemu-devel/patch/20200710201911.3a3e336c.hc981@poolhem.se/
> >
> > This ping email is also sent to Gerd Hoffmann who many years ago
> > (2014) selected the en-us keyboard layout as a hardcoded value in escc.c with
> > commit 59e7a130054b55fe15cdfdebf284332b04d990ef.
>
> Artyom, can you review?
>
> Paolo
>
> > Best regards Henrik
> >
> > On Fri, 10 Jul 2020 20:19:11 +0200
> > Henrik Carlqvist <hc981@poolhem.se> wrote:
> >
> >> 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 allways 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

Can you please move this description to the commit message? (Fixing
typo in "always" ;-) )

> >>
> >> 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.
> >>
> >> Unfortunately my glib version is too old to compile later versions of qemu
> >> so even though this patch is made from latest git I have only been able to
> >> test it myself with qemu version 4.1.1. I think and hope that this patch
> >> will compile and work also with the latest version of git as it only affects
> >> one file and there hasn't been much changes to that file since tested
> >> version 4.1.1.
> >>
> >> Best regards Henrik
> >>
> >> From 2f86bd60750d44206b9181f76115e77b58dff544 Mon Sep 17 00:00:00 2001
> >> From: Henrik Carlqvist <hc1245@poolhem.se>
> >> Date: Fri, 10 Jul 2020 19:21:08 +0200
> >> Subject: [PATCH] Emulating sun keyboard languate layout dip switches, taking

typo: language

> >>  the value for the dip switches from the "-k" option to qemu.
> >>
> >> Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se>
> >> ---
> >>  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 7d16ee8688..7287056b5f 100644
> >> --- a/hw/char/escc.c
> >> +++ b/hw/char/escc.c
> >> @@ -30,6 +30,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"
> >>
> >>  /*
> >> @@ -175,6 +177,7 @@
> >>  #define R_MISC1I 14
> >>  #define R_EXTINT 15
> >>
> >> +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);
> >> @@ -730,6 +733,75 @@ static QemuInputHandler sunkbd_handler = {
> >>      .event = sunkbd_handle_event,
> >>  };
> >>
> >> +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 = 0xff;
> >> +
> >> +    if ((ret == 0xff) && keyboard_layout) {
> >> +        int i;
> >> +        struct layout_values {
> >> +            const char *lang;
> >> +            unsigned char dip;
> >> +        } languages[] =
> >> +    /* 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 = 0;
> >> +             i < sizeof(languages) / sizeof(struct layout_values);
> >> +             i++) {
> >> +            if (!strcmp(keyboard_layout, languages[i].lang)) {
> >> +                ret = languages[i].dip;
> >> +                return ret;
> >> +            }
> >> +        }
> >> +        /* Found no known language code */
> >> +
> >> +        if ((keyboard_layout[0] >= '0') && (keyboard_layout[0] <= '9')) {
> >> +            unsigned int tmp;
> >> +            /* As a fallback we also accept numeric dip switch value */
> >> +            if (!qemu_strtoui(keyboard_layout, NULL, 0, &tmp)) {
> >> +                ret = (unsigned char)tmp;
> >> +            }
> >> +        }
> >> +    }
> >> +    if (ret == 0xff) {
> >> +        /* Final fallback if keyboard_layout was not set or recognized */
> >> +        ret = 0x21; /* en-us layout */
> >> +    }
> >> +    return ret;
> >> +}
> >> +
> >>  static void handle_kbd_command(ESCCChannelState *s, int val)
> >>  {
> >>      trace_escc_kbd_command(val);
> >> @@ -751,7 +823,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;
> >> --
> >> 2.14.5
> >
Looks good otherwise. For the v2:
Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>



--
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping: [PATCH] Emulate dip switch language layout settings on SUN keyboard
  2020-08-03 18:16     ` Artyom Tarasenko
@ 2020-08-03 18:36       ` Henrik Carlqvist
  2020-08-03 19:26         ` Artyom Tarasenko
  0 siblings, 1 reply; 6+ messages in thread
From: Henrik Carlqvist @ 2020-08-03 18:36 UTC (permalink / raw)
  To: Artyom Tarasenko; +Cc: pbonzini, qemu-devel

Thanks for finding my typos!

On Mon, 3 Aug 2020 20:16:43 +0200
Artyom Tarasenko <atar4qemu@gmail.com> wrote:

> > > On Fri, 10 Jul 2020 20:19:11 +0200
> > > Henrik Carlqvist <hc981@poolhem.se> wrote:
> > >> hardcoded to allways use an US keyboard layout.

> Can you please move this description to the commit message? (Fixing
> typo in "always" ;-) )

I don't think I have access to push commits to the git repo, or did you mean
that Paolo should make the commit?

> >> Subject: [PATCH] Emulating sun keyboard languate layout dip switches,

> typo: language

> Looks good otherwise. For the v2:
> Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>

Do you want me to post the same patch again to the mailing list with corrected
typos in subject and description?

Best regards Henrik


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping: [PATCH] Emulate dip switch language layout settings on SUN keyboard
  2020-08-03 18:36       ` Henrik Carlqvist
@ 2020-08-03 19:26         ` Artyom Tarasenko
  0 siblings, 0 replies; 6+ messages in thread
From: Artyom Tarasenko @ 2020-08-03 19:26 UTC (permalink / raw)
  To: Henrik Carlqvist; +Cc: Paolo Bonzini, qemu-devel

On Mon, Aug 3, 2020 at 8:36 PM Henrik Carlqvist <hc981@poolhem.se> wrote:
>
> Thanks for finding my typos!

:-)

> On Mon, 3 Aug 2020 20:16:43 +0200
> Artyom Tarasenko <atar4qemu@gmail.com> wrote:
>
> > > > On Fri, 10 Jul 2020 20:19:11 +0200
> > > > Henrik Carlqvist <hc981@poolhem.se> wrote:
> > > >> hardcoded to allways use an US keyboard layout.
>
> > Can you please move this description to the commit message? (Fixing
> > typo in "always" ;-) )
>
> I don't think I have access to push commits to the git repo, or did you mean
> that Paolo should make the commit?

I mean the part of the commit message before "From 2f86bd..." will be
lost after committing, and I would like to preserve the link to the
documentation and the invocation command.

>
> > >> Subject: [PATCH] Emulating sun keyboard languate layout dip switches,
>
> > typo: language
>
> > Looks good otherwise. For the v2:
> > Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>
>
> Do you want me to post the same patch again to the mailing list with corrected
> typos in subject and description?
>

Yes, please.



-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-03 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 18:19 [PATCH] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist
2020-08-03 17:26 ` Ping: " Henrik Carlqvist
2020-08-03 17:52   ` Paolo Bonzini
2020-08-03 18:16     ` Artyom Tarasenko
2020-08-03 18:36       ` Henrik Carlqvist
2020-08-03 19:26         ` Artyom Tarasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).