* [PATCH qemu v3 0/1] [PATCH v3] Emulate dip switch language layout settings on SUN keyboard @ 2023-01-07 2:37 ~henca 2023-01-06 21:33 ` [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu ~henca 0 siblings, 1 reply; 37+ messages in thread From: ~henca @ 2023-01-07 2:37 UTC (permalink / raw) To: qemu-devel; +Cc: atar4qemu Year 2020 I made 2 attempts to contribute this patch. Unfortunately "git format-patch" produced crippled patches which were not possible to apply. Some @@-lines got extra code that didn't belong in those lines. Now I am instead trying to send my patch using sourcehut. Unfortunately, it seems as if the patch created by sourcehut is still crippled, but my commit has been pushed to the git repo at https://git.sr.ht/~henca/qemu and it builds and works fine from there. Henrik Carlqvist (1): Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu. hw/char/escc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) -- 2.34.5 ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu. 2023-01-07 2:37 [PATCH qemu v3 0/1] [PATCH v3] Emulate dip switch language layout settings on SUN keyboard ~henca @ 2023-01-06 21:33 ` ~henca 2023-01-10 23:08 ` Mark Cave-Ayland 0 siblings, 1 reply; 37+ messages in thread From: ~henca @ 2023-01-06 21:33 UTC (permalink / raw) To: qemu-devel; +Cc: atar4qemu From: Henrik Carlqvist <hc1245@poolhem.se> 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. --- 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" /* @@ -190,6 +192,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); @@ -846,6 +849,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); @@ -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; -- 2.34.5 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu. 2023-01-06 21:33 ` [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu ~henca @ 2023-01-10 23:08 ` Mark Cave-Ayland 2023-01-23 19:09 ` [PATCH v5] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Mark Cave-Ayland @ 2023-01-10 23:08 UTC (permalink / raw) To: ~henca, qemu-devel; +Cc: atar4qemu On 06/01/2023 21:33, ~henca wrote: > From: Henrik Carlqvist <hc1245@poolhem.se> > > 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. > --- > 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" > > /* > @@ -190,6 +192,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); > @@ -846,6 +849,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); > @@ -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; Thanks for the patch. I think what you're effectively doing here is equivalent to creating a qdev property that is used to set the keyboard layout, which is a nicer approach because it enables better control from the command line and also handles the default value. Does changing the keyboard layout work with other OSs? It may also be that OpenBIOS will be difficult to use if the layout defaults to anything other than en-us since I suspect it will be hardcoded there too. ATB, Mark. ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-01-10 23:08 ` Mark Cave-Ayland @ 2023-01-23 19:09 ` Henrik Carlqvist 2023-03-04 21:07 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-01-23 19:09 UTC (permalink / raw) To: Mark Cave-Ayland; +Cc: hc1245, qemu-devel, atar4qemu On Sun, 22 Jan 2023 18:07:47 +0000 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > Did you see my comments re: OpenBIOS for the earlier version of this patch? Thanks for your replies! Sorry, I missed that reply... To make sure that I wouldn't miss any reply I subscribed to the mailing list, but that made many mails to me drown in mails from the list... On Tue, 10 Jan 2023 23:08:27 +0000 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > Thanks for the patch. I think what you're effectively doing here is > equivalent to creating a qdev property that is used to set the keyboard > layout, which is a nicer approach because it enables better control from the > command line and also handles the default value. I must admit that I am not very familiar with "qdev properties", to me it seemed like a rather intuitive solution to use the existing -k switch for this purpose as it is intended to use for keyboard layouts. Would you prefer some other implementation? > Does changing the keyboard layout work with other OSs? To my knowledge only Solaris and the SUN sparc openboot bios cares about those dip switch settings in the 32 bit SUN sparc machine keyboards. This post on a forum makes me think that it doesn't work with NetBSD: https://www.linuxquestions.org/questions/%2Absd-17/netbsd-sparc-non-us-keyboard-layout-issue-367601/ It does seem as if the Linux kernel supports those layout dip switches, however I don't know if it is used in any Linux distribution. I have never run any Linux distribution on sparc myself. From the Linux kernel source file sunkbd.c: -8<-------------------- if (sunkbd->type == 4) { /* Type 4 keyboard */ sunkbd->layout = -2; serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT); wait_event_interruptible_timeout(sunkbd->wait, sunkbd->layout >= 0, HZ / 4); if (sunkbd->layout < 0) return -1; if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) sunkbd->type = 5; } -8<-------------------- > It may also be that OpenBIOS will be difficult to use if the layout > defaults to anything other than en-us since I suspect it will be hardcoded > there too. Today qemu is hardcoded to emulate dip switch setting 0x21 (en-us layout). My patch keeps 0x21 (en-us layout) as default value, but also makes it possible to give other values with the -k option. From may experience it seems as if OpenBIOS does not care about the settings of the dip switch and allways uses en-us layout. Suns openboot bios (which is possible to find for download and use with qemu) supports some, but not all layout dip switch settings which are supported by Solaris. regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-01-23 19:09 ` [PATCH v5] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist @ 2023-03-04 21:07 ` Henrik Carlqvist 2023-03-28 14:01 ` Daniel P. Berrangé 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-03-04 21:07 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel On Wed, 1 Mar 2023 11:52:42 +0000 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > I've done a quick grep for similar examples for serial devices that use > keyboard_layout but it looks like this would be the first. Thanks again for your reply! It is probably not a very common solution with hardware in the keyboard telling the computer about its language layout. Maybe it is even less common with such hardware possible to adjust with a dip switch to choose language layout. But that was the solution Sun selected for their keybords back in the days and back then (and even still today) it was common for keyboards to communicate with the computer by some kind of serial interface. > My first instinct is that you'd want to make this a device property that is > configured during machine init using keyboard_layout (rather than using > keyboard_layout directly), If it does matter in any way, my patch will only at first call to the sun_keyboard_layout_dip_switch function look at the keyboard_layout variable. Once the static "ret" variable has gotten a valid value (the initial value 0xff is not valid for a 6-bit dip swithc) the ret value assigned at the initial call will be immediately returned without any more evaluations of the keyboard_layout string. > but I'd be interested to hear what Paolo and Marc-André think about what the > best approach should be. As I found your latest reply only on https://lists.nongnu.org/archive/html/qemu-devel/2023-03/msg00097.html and can't see the email addresses of any receiver of that post this reply does not go to Paolo or Marc-André, only to you and the mailing list. I must admit that I am not very failiar with qemu programming and device properties. > Another aspect to consider is whether keyboard_layout should just use > standard strings, in which case it may not make sense to accept numeric hex > values. I agree that those standard strings will make most sense to most people. However, as the choices of valid keyboard layouts are limited by the 64 values allowed by the 6 bits on the dip switch I initially did choose to also truly emulate the dip switch value as decimal or hexadecimal number to the -k option. It might also be worth noting that the sun keyboard layouts have multiple dip switch settings for a single language, probably with some minor differences in keyboard layout or keyboard type. So both value 8 and 40 (0x28) will give some norwegian keyboard layout. if someone, for some reason, would want to emulate for example one of the four possible US keyboard layouts (0x0, 0x1, 0x21 or 0x22) it would be harder to do without being able to give those numerical values to the -k switch. best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-03-04 21:07 ` Henrik Carlqvist @ 2023-03-28 14:01 ` Daniel P. Berrangé 2023-03-28 17:19 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Daniel P. Berrangé @ 2023-03-28 14:01 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel On Sat, Mar 04, 2023 at 10:07:54PM +0100, Henrik Carlqvist wrote: > On Wed, 1 Mar 2023 11:52:42 +0000 > Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > > Another aspect to consider is whether keyboard_layout should just use > > standard strings, in which case it may not make sense to accept numeric hex > > values. > > I agree that those standard strings will make most sense to most people. > > However, as the choices of valid keyboard layouts are limited by the 64 values > allowed by the 6 bits on the dip switch I initially did choose to also truly > emulate the dip switch value as decimal or hexadecimal number to the -k > option. It might also be worth noting that the sun keyboard layouts have > multiple dip switch settings for a single language, probably with some minor > differences in keyboard layout or keyboard type. So both value 8 and 40 (0x28) > will give some norwegian keyboard layout. if someone, for some reason, would > want to emulate for example one of the four possible US keyboard layouts (0x0, > 0x1, 0x21 or 0x22) it would be harder to do without being able to give those > numerical values to the -k switch. This is another reason why use of the '-k' switch is a bad idea. Its range of permissible values / vocabulary does not match the range of values / vocabulary needed for this hardware device. In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html the keyboard layouts have distinct names "Norway4" vs "Norway5" and "US4" vs "US5" vs "US_UNIX5" I'd suggest a property to the escc device should take the names given by that reference page above. eg -global escc.sunkbd_layout=Norway4 the only ambguity I see is that 0x0 and 0x1 both have the same name (US4), which could be resolved by handling 0x0 as the default with an empty string perhaps. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-03-28 14:01 ` Daniel P. Berrangé @ 2023-03-28 17:19 ` Henrik Carlqvist 2023-03-28 17:59 ` Daniel P. Berrangé 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-03-28 17:19 UTC (permalink / raw) To: Daniel P. Berrangé; +Cc: mark.cave-ayland, hc1245, qemu-devel Thanks for your feedback! On Tue, 28 Mar 2023 15:01:55 +0100 Daniel P. Berrangé <berrange@redhat.com> wrote: > This is another reason why use of the '-k' switch is a bad idea. Its > range of permissible values / vocabulary does not match the range of > values / vocabulary needed for this hardware device. > > In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html > the keyboard layouts have distinct names > > "Norway4" vs "Norway5" and "US4" vs "US5" vs "US_UNIX5" Those distinct names are names of files in the OS filesystem. This is a link to a description of a patch which gives those keyboard layouts support for the euro sign: http://download.nust.na/pub3/solaris/patches/106839.readme > I'd suggest a property to the escc device should take the names > given by that reference page above. eg > > -global escc.sunkbd_layout=Norway4 Would you mind if such an assignment could also be given in multiple ways, that is: -global escc.sunkbd_layout=33 -global escc.sunkbd_layout=0x21 -global escc.sunkbd_layout=US5 -global escc.sunkbd_layout=en_us would all result in the same dip switch setting 0x21? The nice thing with being able to assign keyboard layouts with a string like "en_us" is that it does not require the user to read reference documentation from Oracle to see which odd named layouts to choose from. The nice thing to also being able to give numerical values like 33 or 0x21 is that some possible dip switch settings (like 0x20) are not mentioned in the Oracle reference documentation, but of course they would be possible to set with physical dip switches even though they might not be supported by the OS. > the only ambguity I see is that 0x0 and 0x1 both have the same > name (US4), which could be resolved by handling 0x0 as the default > with an empty string perhaps. With multiple ways to give the values as I suggest it would be possible to give 0x0 and 0x1 as values but "US4" would allways result in one of them, probably 0x0. The default value when no value is given or when some invalid value is given to escc.sunkbd_layout would preferably be 0x21 for backwards compability as that is the only value you can get from the dip switch in qemu today. Once we find a method we all agree on I am willing to rewrite my patch, but maybe I will not be able to do it before summer when I get my vacation. best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-03-28 17:19 ` Henrik Carlqvist @ 2023-03-28 17:59 ` Daniel P. Berrangé 2023-03-28 20:16 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Daniel P. Berrangé @ 2023-03-28 17:59 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel On Tue, Mar 28, 2023 at 07:19:58PM +0200, Henrik Carlqvist wrote: > Thanks for your feedback! > > On Tue, 28 Mar 2023 15:01:55 +0100 > Daniel P. Berrangé <berrange@redhat.com> wrote: > > > This is another reason why use of the '-k' switch is a bad idea. Its > > range of permissible values / vocabulary does not match the range of > > values / vocabulary needed for this hardware device. > > > > In https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html > > the keyboard layouts have distinct names > > > > "Norway4" vs "Norway5" and "US4" vs "US5" vs "US_UNIX5" > > Those distinct names are names of files in the OS filesystem. This is a link > to a description of a patch which gives those keyboard layouts support for > the euro sign: > > http://download.nust.na/pub3/solaris/patches/106839.readme > > > I'd suggest a property to the escc device should take the names > > given by that reference page above. eg > > > > -global escc.sunkbd_layout=Norway4 > > Would you mind if such an assignment could also be given in multiple ways, > that is: > > -global escc.sunkbd_layout=33 > -global escc.sunkbd_layout=0x21 > -global escc.sunkbd_layout=US5 > -global escc.sunkbd_layout=en_us > > would all result in the same dip switch setting 0x21? I'm generally not in favour of creating many different ways to set the same thing, especially not multiple string based names, but if a single vocabulary for strings is insufficient, then having support for numbers feels reasonable. > The nice thing with being able to assign keyboard layouts with a string like > "en_us" is that it does not require the user to read reference documentation > from Oracle to see which odd named layouts to choose from. > > The nice thing to also being able to give numerical values like 33 or 0x21 is > that some possible dip switch settings (like 0x20) are not mentioned in the > Oracle reference documentation, but of course they would be possible to set > with physical dip switches even though they might not be supported by the OS. If you care about documentation then I think there ought to be docs added in QEMU for it, as out of the 33 currrent keymap names supported by QEMU, only 28 seem to be supported by this device. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v5] Emulate dip switch language layout settings on SUN keyboard 2023-03-28 17:59 ` Daniel P. Berrangé @ 2023-03-28 20:16 ` Henrik Carlqvist 2023-04-30 20:55 ` [PATCH v6] " Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-03-28 20:16 UTC (permalink / raw) To: Daniel P. Berrangé; +Cc: mark.cave-ayland, hc1245, qemu-devel On Tue, 28 Mar 2023 18:59:26 +0100 Daniel P. Berrangé <berrange@redhat.com> wrote: > I'm generally not in favour of creating many different ways to set > the same thing, especially not multiple string based names, but if > a single vocabulary for strings is insufficient, then having support > for numbers feels reasonable. If only a single way to set them would be allowed, I think that the hexadecimal number would make most sense as we are emulating dip-switches. However, it would be nice to also allow more easy to remember strings where applicable. > If you care about documentation then I think there ought to be docs > added in QEMU for it, as out of the 33 currrent keymap names supported > by QEMU, only 28 seem to be supported by this device. Maybe it could be documented by printing some text if given -global escc.sunkbd_layout=help or -global escc.sunkbd_layout=list Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-03-28 20:16 ` Henrik Carlqvist @ 2023-04-30 20:55 ` Henrik Carlqvist 2023-06-08 16:14 ` Ping: " Henrik Carlqvist 2023-06-08 16:22 ` [PATCH v6] Emulate dip switch language layout settings on SUN keyboard Daniel P. Berrangé 0 siblings, 2 replies; 37+ messages in thread From: Henrik Carlqvist @ 2023-04-30 20:55 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: berrange, mark.cave-ayland, hc1245, qemu-devel I have now changed the patch to instead of using the -k switch use -global escc.sunkbd_layout= to select keyboard layout. It would be nice to somehow document this. Yes, in the monitor, you can type "info qtree" and see something like: dev: escc, id "" gpio-out "sysbus-irq" 2 frequency = 4915200 (0x4b0000) it_shift = 1 (0x1) bit_swap = false disabled = 0 (0x0) chnBtype = 2 (0x2) chnAtype = 1 (0x1) chrB = "" chrA = "" sunkbd_layout = "43" mmio 0000000071000000/0000000000000008 but that information is not easy to find and it does not say anything about possible values. What is the best way to document this kind of global parameters? Please cc me any reply as I am no longer subscribed to the mailing list. best regards Henrik 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 a command line switch like "-global escc.sunkbd_layout=de" to select dip switch value. A table is used to lookup values from arguments like: -global escc.sunkbd_layout=fr -global escc.sunkbd_layout=es But the patch also accepts numeric dip switch values directly to the -k switch: -global escc.sunkbd_layout=0x2b -global escc.sunkbd_layout=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 -global escc.sunkbd_layout=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 <hc1245@poolhem.se> --- hw/char/escc.c | 81 +++++++++++++++++++++++++++++++++++++++--- include/hw/char/escc.h | 1 + 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/hw/char/escc.c b/hw/char/escc.c index 17a908c59b..0aac4f0f92 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 "qemu/cutils.h" #include "trace.h" /* @@ -190,7 +192,8 @@ #define R_MISC1I 14 #define R_EXTINT 15 -static void handle_kbd_command(ESCCChannelState *s, int val); +static unsigned char sun_keyboard_layout_dip_switch(const char *keyboard_layout); +static void handle_kbd_command(ESCCChannelState *s, int val, ESCCState *k); static int serial_can_receive(void *opaque); static void serial_receive_byte(ESCCChannelState *s, int ch); @@ -657,7 +660,7 @@ static void escc_mem_write(void *opaque, hwaddr addr, */ qemu_chr_fe_write_all(&s->chr, &s->tx, 1); } else if (s->type == escc_kbd && !s->disabled) { - handle_kbd_command(s, val); + handle_kbd_command(s, val, serial); } } s->rregs[R_STATUS] |= STATUS_TXEMPTY; /* Tx buffer empty */ @@ -846,7 +849,76 @@ static QemuInputHandler sunkbd_handler = { .event = sunkbd_handle_event, }; -static void handle_kbd_command(ESCCChannelState *s, int val) +static unsigned char sun_keyboard_layout_dip_switch(const char *keyboard_layout) +{ + /* 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, ESCCState *k) { trace_escc_kbd_command(val); if (s->led_mode) { /* Ignore led byte */ @@ -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(k->keyboard_layout)); break; default: break; @@ -976,6 +1048,7 @@ static Property escc_properties[] = { DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), + DEFINE_PROP_STRING("sunkbd_layout", ESCCState, keyboard_layout), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h index 7e9482dee2..2830876a17 100644 --- a/include/hw/char/escc.h +++ b/include/hw/char/escc.h @@ -56,6 +56,7 @@ struct ESCCState { MemoryRegion mmio; uint32_t disabled; uint32_t frequency; + char *keyboard_layout; }; #endif -- 2.30.4 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Ping: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-04-30 20:55 ` [PATCH v6] " Henrik Carlqvist @ 2023-06-08 16:14 ` Henrik Carlqvist 2023-06-10 7:06 ` Mark Cave-Ayland 2023-06-08 16:22 ` [PATCH v6] Emulate dip switch language layout settings on SUN keyboard Daniel P. Berrangé 1 sibling, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-08 16:14 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: berrange, mark.cave-ayland, hc1245, qemu-devel I didn't get much response to my last version of the patch to implement emulation of language selection dip switch on SUN keyboards. By request, I changed the patch to listen for -global escc.sunkbd_layout= instead of using the -k switch to select keyboard layout. What do you think about this patch? Would you like to apply it as is, or do you want any more changes? Best regards Henrik On Sun, 30 Apr 2023 22:55:33 +0200 Henrik Carlqvist <hc981@poolhem.se> wrote: > I have now changed the patch to instead of using the -k switch use > > -global escc.sunkbd_layout= > > to select keyboard layout. It would be nice to somehow document this. Yes, > in the monitor, you can type "info qtree" and see something like: > > dev: escc, id "" > gpio-out "sysbus-irq" 2 > frequency = 4915200 (0x4b0000) > it_shift = 1 (0x1) > bit_swap = false > disabled = 0 (0x0) > chnBtype = 2 (0x2) > chnAtype = 1 (0x1) > chrB = "" > chrA = "" > sunkbd_layout = "43" > mmio 0000000071000000/0000000000000008 > > but that information is not easy to find and it does not say anything about > possible values. What is the best way to document this kind of global > parameters? > > Please cc me any reply as I am no longer subscribed to the mailing list. > > best regards Henrik > > 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 a command line switch like "-global escc.sunkbd_layout=de" > to select dip switch value. A table is used to lookup values from arguments > like: > > -global escc.sunkbd_layout=fr > -global escc.sunkbd_layout=es > > But the patch also accepts numeric dip switch values directly to the -k > switch: > > -global escc.sunkbd_layout=0x2b > -global escc.sunkbd_layout=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 -global escc.sunkbd_layout=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 <hc1245@poolhem.se> > --- > hw/char/escc.c | 81 +++++++++++++++++++++++++++++++++++++++--- > include/hw/char/escc.h | 1 + > 2 files changed, 78 insertions(+), 4 deletions(-) > > diff --git a/hw/char/escc.c b/hw/char/escc.c > index 17a908c59b..0aac4f0f92 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 "qemu/cutils.h" > #include "trace.h" > > /* > @@ -190,7 +192,8 @@ > #define R_MISC1I 14 > #define R_EXTINT 15 > > -static void handle_kbd_command(ESCCChannelState *s, int val); > +static unsigned char sun_keyboard_layout_dip_switch(const char > *keyboard_layout);+static void handle_kbd_command(ESCCChannelState *s, int > val, ESCCState *k); > static int serial_can_receive(void *opaque); > static void serial_receive_byte(ESCCChannelState *s, int ch); > > @@ -657,7 +660,7 @@ static void escc_mem_write(void *opaque, hwaddr addr, > */ > qemu_chr_fe_write_all(&s->chr, &s->tx, 1); > } else if (s->type == escc_kbd && !s->disabled) { > - handle_kbd_command(s, val); > + handle_kbd_command(s, val, serial); > } > } > s->rregs[R_STATUS] |= STATUS_TXEMPTY; /* Tx buffer empty */ > @@ -846,7 +849,76 @@ static QemuInputHandler sunkbd_handler = { > .event = sunkbd_handle_event, > }; > > -static void handle_kbd_command(ESCCChannelState *s, int val) > +static unsigned char sun_keyboard_layout_dip_switch(const char > *keyboard_layout)+{ > + /* 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, ESCCState *k) > { > trace_escc_kbd_command(val); > if (s->led_mode) { /* Ignore led byte */ > @@ -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(k->keyboard_layout)); > break; > default: > break; > @@ -976,6 +1048,7 @@ static Property escc_properties[] = { > DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), > DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), > DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), > + DEFINE_PROP_STRING("sunkbd_layout", ESCCState, keyboard_layout), > DEFINE_PROP_END_OF_LIST(), > }; > > diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h > index 7e9482dee2..2830876a17 100644 > --- a/include/hw/char/escc.h > +++ b/include/hw/char/escc.h > @@ -56,6 +56,7 @@ struct ESCCState { > MemoryRegion mmio; > uint32_t disabled; > uint32_t frequency; > + char *keyboard_layout; > }; > > #endif > -- > 2.30.4 > ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: Ping: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-06-08 16:14 ` Ping: " Henrik Carlqvist @ 2023-06-10 7:06 ` Mark Cave-Ayland 2023-06-10 10:29 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Mark Cave-Ayland @ 2023-06-10 7:06 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: berrange, hc1245, qemu-devel On 08/06/2023 17:14, Henrik Carlqvist wrote: > I didn't get much response to my last version of the patch to implement > emulation of language selection dip switch on SUN keyboards. By request, I > changed the patch to listen for -global escc.sunkbd_layout= instead of using > the -k switch to select keyboard layout. > > What do you think about this patch? Would you like to apply it as is, or do > you want any more changes? Apologies for the delay in getting to this, let me add a few comments below. > Best regards Henrik > > On Sun, 30 Apr 2023 22:55:33 +0200 > Henrik Carlqvist <hc981@poolhem.se> wrote: > >> I have now changed the patch to instead of using the -k switch use >> >> -global escc.sunkbd_layout= >> >> to select keyboard layout. It would be nice to somehow document this. Yes, >> in the monitor, you can type "info qtree" and see something like: >> >> dev: escc, id "" >> gpio-out "sysbus-irq" 2 >> frequency = 4915200 (0x4b0000) >> it_shift = 1 (0x1) >> bit_swap = false >> disabled = 0 (0x0) >> chnBtype = 2 (0x2) >> chnAtype = 1 (0x1) >> chrB = "" >> chrA = "" >> sunkbd_layout = "43" >> mmio 0000000071000000/0000000000000008 >> >> but that information is not easy to find and it does not say anything about >> possible values. What is the best way to document this kind of global >> parameters? >> >> Please cc me any reply as I am no longer subscribed to the mailing list. >> >> best regards Henrik >> >> 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 a command line switch like "-global escc.sunkbd_layout=de" >> to select dip switch value. A table is used to lookup values from arguments >> like: >> >> -global escc.sunkbd_layout=fr >> -global escc.sunkbd_layout=es >> >> But the patch also accepts numeric dip switch values directly to the -k >> switch: >> >> -global escc.sunkbd_layout=0x2b >> -global escc.sunkbd_layout=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 -global escc.sunkbd_layout=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 <hc1245@poolhem.se> >> --- >> hw/char/escc.c | 81 +++++++++++++++++++++++++++++++++++++++--- >> include/hw/char/escc.h | 1 + >> 2 files changed, 78 insertions(+), 4 deletions(-) >> >> diff --git a/hw/char/escc.c b/hw/char/escc.c >> index 17a908c59b..0aac4f0f92 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 "qemu/cutils.h" >> #include "trace.h" >> >> /* >> @@ -190,7 +192,8 @@ >> #define R_MISC1I 14 >> #define R_EXTINT 15 >> >> -static void handle_kbd_command(ESCCChannelState *s, int val); >> +static unsigned char sun_keyboard_layout_dip_switch(const char >> *keyboard_layout);+static void handle_kbd_command(ESCCChannelState *s, int >> val, ESCCState *k); >> static int serial_can_receive(void *opaque); >> static void serial_receive_byte(ESCCChannelState *s, int ch); >> >> @@ -657,7 +660,7 @@ static void escc_mem_write(void *opaque, hwaddr addr, >> */ >> qemu_chr_fe_write_all(&s->chr, &s->tx, 1); >> } else if (s->type == escc_kbd && !s->disabled) { >> - handle_kbd_command(s, val); >> + handle_kbd_command(s, val, serial); >> } >> } >> s->rregs[R_STATUS] |= STATUS_TXEMPTY; /* Tx buffer empty */ >> @@ -846,7 +849,76 @@ static QemuInputHandler sunkbd_handler = { >> .event = sunkbd_handle_event, >> }; >> >> -static void handle_kbd_command(ESCCChannelState *s, int val) >> +static unsigned char sun_keyboard_layout_dip_switch(const char >> *keyboard_layout)+{ >> + /* 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, ESCCState *k) This feels like your keyboard_layout variable should be in ESCCChannelState rather than ESCCState, which makes sense since the keyboard is a device plugged into one of the serial ports. I see that there are 2 different naming conventions here: in some places you use keyboard, others kbd. I think you should standardise on sunkbd_layout since it emphasises that this is a Sun-specific feature. >> { >> trace_escc_kbd_command(val); >> if (s->led_mode) { /* Ignore led byte */ >> @@ -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(k->keyboard_layout)); sunkbd_layout_dip_switch() >> break; >> default: >> break; >> @@ -976,6 +1048,7 @@ static Property escc_properties[] = { >> DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), >> DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), >> DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), >> + DEFINE_PROP_STRING("sunkbd_layout", ESCCState, keyboard_layout), DEFINE_PROP_STRING("chrA-sunkbd-layout", ESCCState, chn[1].sunkbd_layout), Our qdev property naming guidelines did state that hyphens should be used in preference to underscores. >> DEFINE_PROP_END_OF_LIST(), >> }; >> >> diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h >> index 7e9482dee2..2830876a17 100644 >> --- a/include/hw/char/escc.h >> +++ b/include/hw/char/escc.h >> @@ -56,6 +56,7 @@ struct ESCCState { >> MemoryRegion mmio; >> uint32_t disabled; >> uint32_t frequency; >> + char *keyboard_layout; >> }; >> >> #endif >> -- >> 2.30.4 ATB, Mark. ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: Ping: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-06-10 7:06 ` Mark Cave-Ayland @ 2023-06-10 10:29 ` Henrik Carlqvist 2023-06-10 23:47 ` [PATCH v7] " Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-10 10:29 UTC (permalink / raw) To: Mark Cave-Ayland; +Cc: berrange, hc1245, qemu-devel Thanks for your thoughts on this! Getting the variable in ESCCChannelState instead of ESCCState is nice as it means that I don't have to add the ESCCState variable to the handle_kbd_command. So I will rewrite the patch to use argumetns like "-global escc.chrA-sunkbd-layout=sv" (or do we want it to be called "-global escc.chnA-sunkbd-layout=sv" with chn for channel A instead of chr?) I will also rename functions and variables to sunkbd and add documentation to docs/system/target-sparc.rst (possibly as a link to a file of its own as describing all the keyboards to choose from might create a bigger page than the current sparc32 page). Best regards Henrik On Sat, 10 Jun 2023 08:06:47 +0100 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > On 08/06/2023 17:14, Henrik Carlqvist wrote: > > > I didn't get much response to my last version of the patch to implement > > emulation of language selection dip switch on SUN keyboards. By request, I > > changed the patch to listen for -global escc.sunkbd_layout= instead of > > using the -k switch to select keyboard layout. > > > > What do you think about this patch? Would you like to apply it as is, or > > do you want any more changes? > > Apologies for the delay in getting to this, let me add a few comments below. > > > Best regards Henrik > > > > On Sun, 30 Apr 2023 22:55:33 +0200 > > Henrik Carlqvist <hc981@poolhem.se> wrote: > > > >> I have now changed the patch to instead of using the -k switch use > >> > >> -global escc.sunkbd_layout= > >> > >> to select keyboard layout. It would be nice to somehow document this. > >Yes,> in the monitor, you can type "info qtree" and see something like: > >> > >> dev: escc, id "" > >> gpio-out "sysbus-irq" 2 > >> frequency = 4915200 (0x4b0000) > >> it_shift = 1 (0x1) > >> bit_swap = false > >> disabled = 0 (0x0) > >> chnBtype = 2 (0x2) > >> chnAtype = 1 (0x1) > >> chrB = "" > >> chrA = "" > >> sunkbd_layout = "43" > >> mmio 0000000071000000/0000000000000008 > >> > >> but that information is not easy to find and it does not say anything > >about> possible values. What is the best way to document this kind of > >global> parameters? > >> > >> Please cc me any reply as I am no longer subscribed to the mailing list. > >> > >> best regards Henrik > >> > >> 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 a command line switch like "-global > >escc.sunkbd_layout=de"> to select dip switch value. A table is used to > >lookup values from arguments> like: > >> > >> -global escc.sunkbd_layout=fr > >> -global escc.sunkbd_layout=es > >> > >> But the patch also accepts numeric dip switch values directly to the -k > >> switch: > >> > >> -global escc.sunkbd_layout=0x2b > >> -global escc.sunkbd_layout=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 -global escc.sunkbd_layout=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 <hc1245@poolhem.se> > >> --- > >> hw/char/escc.c | 81 +++++++++++++++++++++++++++++++++++++++--- > >> include/hw/char/escc.h | 1 + > >> 2 files changed, 78 insertions(+), 4 deletions(-) > >> > >> diff --git a/hw/char/escc.c b/hw/char/escc.c > >> index 17a908c59b..0aac4f0f92 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 "qemu/cutils.h" > >> #include "trace.h" > >> > >> /* > >> @@ -190,7 +192,8 @@ > >> #define R_MISC1I 14 > >> #define R_EXTINT 15 > >> > >> -static void handle_kbd_command(ESCCChannelState *s, int val); > >> +static unsigned char sun_keyboard_layout_dip_switch(const char > >> *keyboard_layout);+static void handle_kbd_command(ESCCChannelState *s, > >int> val, ESCCState *k); > >> static int serial_can_receive(void *opaque); > >> static void serial_receive_byte(ESCCChannelState *s, int ch); > >> > >> @@ -657,7 +660,7 @@ static void escc_mem_write(void *opaque, hwaddr addr, > >> */ > >> qemu_chr_fe_write_all(&s->chr, &s->tx, 1); > >> } else if (s->type == escc_kbd && !s->disabled) { > >> - handle_kbd_command(s, val); > >> + handle_kbd_command(s, val, serial); > >> } > >> } > >> s->rregs[R_STATUS] |= STATUS_TXEMPTY; /* Tx buffer empty */ > >> @@ -846,7 +849,76 @@ static QemuInputHandler sunkbd_handler = { > >> .event = sunkbd_handle_event, > >> }; > >> > >> -static void handle_kbd_command(ESCCChannelState *s, int val) > >> +static unsigned char sun_keyboard_layout_dip_switch(const char > >> *keyboard_layout)+{ > >> + /* 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, ESCCState > >*k) > > This feels like your keyboard_layout variable should be in ESCCChannelState > rather than ESCCState, which makes sense since the keyboard is a device > plugged into one of the serial ports. > > I see that there are 2 different naming conventions here: in some places you > use keyboard, others kbd. I think you should standardise on sunkbd_layout > since it emphasises that this is a Sun-specific feature. > > >> { > >> trace_escc_kbd_command(val); > >> if (s->led_mode) { /* Ignore led byte */ > >> @@ -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(k->keyboard_layout)); > > sunkbd_layout_dip_switch() > > >> break; > >> default: > >> break; > >> @@ -976,6 +1048,7 @@ static Property escc_properties[] = { > >> DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), > >> DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), > >> DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), > >> + DEFINE_PROP_STRING("sunkbd_layout", ESCCState, keyboard_layout), > > DEFINE_PROP_STRING("chrA-sunkbd-layout", ESCCState, chn[1].sunkbd_layout), > > Our qdev property naming guidelines did state that hyphens should be used in > > preference to underscores. > > >> DEFINE_PROP_END_OF_LIST(), > >> }; > >> > >> diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h > >> index 7e9482dee2..2830876a17 100644 > >> --- a/include/hw/char/escc.h > >> +++ b/include/hw/char/escc.h > >> @@ -56,6 +56,7 @@ struct ESCCState { > >> MemoryRegion mmio; > >> uint32_t disabled; > >> uint32_t frequency; > >> + char *keyboard_layout; > >> }; > >> > >> #endif > >> -- > >> 2.30.4 > > > ATB, > > Mark. ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v7] Emulate dip switch language layout settings on SUN keyboard 2023-06-10 10:29 ` Henrik Carlqvist @ 2023-06-10 23:47 ` Henrik Carlqvist 2023-06-20 9:22 ` Daniel P. Berrangé 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-10 23:47 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, berrange, qemu-devel, hc981 I have now changed the patch to instead use -global escc.chnA-sunkbd-layout= and documented in docs/system/keyboard.rst which I have linked from target-sparc.rst. Unfortunately, I am not very used to these .rst files and have not found out how to create html files from them, so I don't know for sure if my formatting is correct. Typing "make help" seems to indicate that it should be possible to type "make html", but that did not seem to work. 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 a command line switch like "-global escc.chnA-sunkbd-layout=de" to select dip switch value. A table is used to lookup values from arguments like: -global escc.chnA-sunkbd-layout=fr -global escc.chnA-sunkbd-layout=es But the patch also accepts numeric dip switch values directly: -global escc.chnA-sunkbd-layout=0x2b -global escc.chnA-sunkbd-layout=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 Sun bios file, the easiest way to test that the patch works is to: qemu-system-sparc -global escc.chnA-sunkbd-layout=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 <hc1245@poolhem.se> --- docs/system/keyboard.rst | 127 +++++++++++++++++++++++++++++++++++ docs/system/target-sparc.rst | 2 +- hw/char/escc.c | 76 ++++++++++++++++++++- include/hw/char/escc.h | 1 + 4 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 docs/system/keyboard.rst diff --git a/docs/system/keyboard.rst b/docs/system/keyboard.rst new file mode 100644 index 0000000000..b489c607f8 --- /dev/null +++ b/docs/system/keyboard.rst @@ -0,0 +1,127 @@ +.. _keyboard: + +Sparc32 keyboard +---------------- +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. + +With the escc.chnA-sunkbd-layout driver property it is possible to select +keyboard layout. Example: + +"-global escc.chnA-sunkbd-layout=de" + +Depending on type of keyboard, the keyboard can have 6 or 5 dip-switches to +select keyboard layout, giving up to 64 different layouts. Not all +combinations are supported by Solaris and even less by Sun OpenBoot BIOS. + +The dip switch settings can be given as hexadecimal number, decimal number +or in some cases as a language string. Examples: + +-global escc.chnA-sunkbd-layout=0x2b +-global escc.chnA-sunkbd-layout=43 +-global escc.chnA-sunkbd-layout=sv + +The above 3 examples all select a swedish keyboard layout. Table 3-15 at +https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html explains which +keytable file is used for different dip switch settings. The information +in that table can be summarized in this table: + +.. list-table:: Language selection values for escc.chnA-sunkbd-layout + :widths: 10 10 10 + :header-rows: 1 + + * - Hexadecimal value + - Decimal value + - Language code + * - 0x21 + - 33 + - en-us + * - 0x23 + - 35 + - fr + * - 0x24 + - 36 + - da + * - 0x25 + - 37 + - de + * - 0x26 + - 38 + - it + * - 0x27 + - 39 + - nl + * - 0x28 + - 40 + - no + * - 0x29 + - 41 + - pt + * - 0x2a + - 42 + - es + * - 0x2b + - 43 + - sv + * - 0x2c + - 44 + - fr-ch + * - 0x2d + - 45 + - de-ch + * - 0x2e + - 46 + - en-gb + * - 0x2f + - 47 + - ko + * - 0x30 + - 48 + - tw + * - 0x31 + - 49 + - ja + * - 0x32 + - 50 + - fr-ca + * - 0x33 + - 51 + - hu + * - 0x34 + - 52 + - pl + * - 0x35 + - 53 + - cz + * - 0x36 + - 54 + - ru + * - 0x37 + - 55 + - lv + * - 0x38 + - 56 + - tr + * - 0x39 + - 57 + - gr + * - 0x3a + - 58 + - ar + * - 0x3b + - 59 + - lt + * - 0x3c + - 60 + - nl-be + * - 0x3c + - 60 + - be + +Not all dip switch values have a corresponding language code and both "be" and +"nl-be" correspond to the same dip switch value. By default, if no value is +given to escc.chnA-sunkbd-layout 0x21 (en-us) will be used. diff --git a/docs/system/target-sparc.rst b/docs/system/target-sparc.rst index b55f8d09e9..d5418c32d0 100644 --- a/docs/system/target-sparc.rst +++ b/docs/system/target-sparc.rst @@ -38,7 +38,7 @@ QEMU emulates the following sun4m peripherals: - Non Volatile RAM M48T02/M48T08 - Slave I/O: timers, interrupt controllers, Zilog serial ports, - keyboard and power/reset logic + :ref: `keyboard` and power/reset logic - ESP SCSI controller with hard disk and CD-ROM support diff --git a/hw/char/escc.c b/hw/char/escc.c index 17a908c59b..463b3d2e93 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 "qemu/cutils.h" #include "trace.h" /* @@ -190,6 +192,7 @@ #define R_MISC1I 14 #define R_EXTINT 15 +static unsigned char sunkbd_layout_dip_switch(const char *sunkbd_layout); 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 = { .event = sunkbd_handle_event, }; +static unsigned char sunkbd_layout_dip_switch(const char *kbd_layout) +{ + /* Return the value of the dip-switches in a SUN Type 5 keyboard */ + static unsigned char ret = 0xff; + + if ((ret == 0xff) && kbd_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(kbd_layout, languages[i].lang)) { + ret = languages[i].dip; + return ret; + } + } + /* Found no known language code */ + + if ((kbd_layout[0] >= '0') && (kbd_layout[0] <= '9')) { + unsigned int tmp; + /* As a fallback we also accept numeric dip switch value */ + if (!qemu_strtoui(kbd_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); @@ -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, sunkbd_layout_dip_switch(s->sunkbd_layout)); break; default: break; @@ -976,6 +1048,8 @@ static Property escc_properties[] = { DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), + DEFINE_PROP_STRING("chnA-sunkbd-layout", ESCCState, + chn[1].sunkbd_layout), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h index 7e9482dee2..5669a5b811 100644 --- a/include/hw/char/escc.h +++ b/include/hw/char/escc.h @@ -45,6 +45,7 @@ typedef struct ESCCChannelState { ESCCChnType type; uint8_t rx, tx; QemuInputHandlerState *hs; + char *sunkbd_layout; } ESCCChannelState; struct ESCCState { -- 2.30.4 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v7] Emulate dip switch language layout settings on SUN keyboard 2023-06-10 23:47 ` [PATCH v7] " Henrik Carlqvist @ 2023-06-20 9:22 ` Daniel P. Berrangé 2023-06-20 19:50 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Daniel P. Berrangé @ 2023-06-20 9:22 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: Henrik Carlqvist, mark.cave-ayland, qemu-devel On Sun, Jun 11, 2023 at 01:47:51AM +0200, Henrik Carlqvist wrote: > I have now changed the patch to instead use > > -global escc.chnA-sunkbd-layout= > > and documented in docs/system/keyboard.rst which I have linked from > target-sparc.rst. Unfortunately, I am not very used to these .rst files > and have not found out how to create html files from them, so I don't know > for sure if my formatting is correct. Typing "make help" seems to indicate > that it should be possible to type "make html", but that did not seem to work. Assuming you have docutils installed, QEMU will build the manual by default and print any issues on console during build. You can point your browser to $BUILD/docs/manual/system/index.html to see the result. For future reference, if you want to put some questions/notes in the submission, it is best to keep them separate from the commit message text, as the questions/notes shouldn't end up in git history. To separate them, put questions immediately after the '---' that separate the commit message from the diffstat > > 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 a command line switch like > "-global escc.chnA-sunkbd-layout=de" to select dip switch value. A table is > used to lookup values from arguments like: > > -global escc.chnA-sunkbd-layout=fr > -global escc.chnA-sunkbd-layout=es > > But the patch also accepts numeric dip switch values directly: > > -global escc.chnA-sunkbd-layout=0x2b > -global escc.chnA-sunkbd-layout=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 Sun bios file, the easiest way to test that the patch works > is to: > > qemu-system-sparc -global escc.chnA-sunkbd-layout=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 <hc1245@poolhem.se> > --- ....notes/questions go here.... > docs/system/keyboard.rst | 127 +++++++++++++++++++++++++++++++++++ > docs/system/target-sparc.rst | 2 +- > hw/char/escc.c | 76 ++++++++++++++++++++- > include/hw/char/escc.h | 1 + > 4 files changed, 204 insertions(+), 2 deletions(-) > create mode 100644 docs/system/keyboard.rst > > diff --git a/docs/system/keyboard.rst b/docs/system/keyboard.rst > new file mode 100644 > index 0000000000..b489c607f8 > --- /dev/null > +++ b/docs/system/keyboard.rst > @@ -0,0 +1,127 @@ > +.. _keyboard: > + > +Sparc32 keyboard > +---------------- > +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. > + > +With the escc.chnA-sunkbd-layout driver property it is possible to select > +keyboard layout. Example: > + > +"-global escc.chnA-sunkbd-layout=de" > + > +Depending on type of keyboard, the keyboard can have 6 or 5 dip-switches to > +select keyboard layout, giving up to 64 different layouts. Not all > +combinations are supported by Solaris and even less by Sun OpenBoot BIOS. > + > +The dip switch settings can be given as hexadecimal number, decimal number > +or in some cases as a language string. Examples: > + > +-global escc.chnA-sunkbd-layout=0x2b > +-global escc.chnA-sunkbd-layout=43 > +-global escc.chnA-sunkbd-layout=sv > + > +The above 3 examples all select a swedish keyboard layout. Table 3-15 at > +https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html explains which > +keytable file is used for different dip switch settings. The information > +in that table can be summarized in this table: > + > +.. list-table:: Language selection values for escc.chnA-sunkbd-layout > + :widths: 10 10 10 > + :header-rows: 1 > + > + * - Hexadecimal value > + - Decimal value > + - Language code > + * - 0x21 > + - 33 > + - en-us > + * - 0x23 > + - 35 > + - fr > + * - 0x24 > + - 36 > + - da > + * - 0x25 > + - 37 > + - de > + * - 0x26 > + - 38 > + - it > + * - 0x27 > + - 39 > + - nl > + * - 0x28 > + - 40 > + - no > + * - 0x29 > + - 41 > + - pt > + * - 0x2a > + - 42 > + - es > + * - 0x2b > + - 43 > + - sv > + * - 0x2c > + - 44 > + - fr-ch > + * - 0x2d > + - 45 > + - de-ch > + * - 0x2e > + - 46 > + - en-gb > + * - 0x2f > + - 47 > + - ko > + * - 0x30 > + - 48 > + - tw > + * - 0x31 > + - 49 > + - ja > + * - 0x32 > + - 50 > + - fr-ca > + * - 0x33 > + - 51 > + - hu > + * - 0x34 > + - 52 > + - pl > + * - 0x35 > + - 53 > + - cz > + * - 0x36 > + - 54 > + - ru > + * - 0x37 > + - 55 > + - lv > + * - 0x38 > + - 56 > + - tr > + * - 0x39 > + - 57 > + - gr > + * - 0x3a > + - 58 > + - ar > + * - 0x3b > + - 59 > + - lt > + * - 0x3c > + - 60 > + - nl-be > + * - 0x3c > + - 60 > + - be > + > +Not all dip switch values have a corresponding language code and both "be" and > +"nl-be" correspond to the same dip switch value. By default, if no value is > +given to escc.chnA-sunkbd-layout 0x21 (en-us) will be used. > diff --git a/docs/system/target-sparc.rst b/docs/system/target-sparc.rst > index b55f8d09e9..d5418c32d0 100644 > --- a/docs/system/target-sparc.rst > +++ b/docs/system/target-sparc.rst > @@ -38,7 +38,7 @@ QEMU emulates the following sun4m peripherals: > - Non Volatile RAM M48T02/M48T08 > > - Slave I/O: timers, interrupt controllers, Zilog serial ports, > - keyboard and power/reset logic > + :ref: `keyboard` and power/reset logic You need to remove the space between :ref: and `keyboard`. You'll also need to add it to a ToC (table of contents) otherwise the build system complains. I'd suggest putting the new file at docs/system/devices/keyboards.rst and adding to the ToC in docs/system/device-emulation.rst > - ESP SCSI controller with hard disk and CD-ROM support > > diff --git a/hw/char/escc.c b/hw/char/escc.c > index 17a908c59b..463b3d2e93 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 "qemu/cutils.h" > #include "trace.h" > > /* > @@ -190,6 +192,7 @@ > #define R_MISC1I 14 > #define R_EXTINT 15 > > +static unsigned char sunkbd_layout_dip_switch(const char *sunkbd_layout); > 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 = { > .event = sunkbd_handle_event, > }; > > +static unsigned char sunkbd_layout_dip_switch(const char *kbd_layout) > +{ > + /* Return the value of the dip-switches in a SUN Type 5 keyboard */ > + static unsigned char ret = 0xff; > + > + if ((ret == 0xff) && kbd_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(kbd_layout, languages[i].lang)) { > + ret = languages[i].dip; > + return ret; > + } > + } > + /* Found no known language code */ > + > + if ((kbd_layout[0] >= '0') && (kbd_layout[0] <= '9')) { > + unsigned int tmp; > + /* As a fallback we also accept numeric dip switch value */ > + if (!qemu_strtoui(kbd_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); > @@ -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, sunkbd_layout_dip_switch(s->sunkbd_layout)); > break; > default: > break; > @@ -976,6 +1048,8 @@ static Property escc_properties[] = { > DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), > DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), > DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), > + DEFINE_PROP_STRING("chnA-sunkbd-layout", ESCCState, > + chn[1].sunkbd_layout), > DEFINE_PROP_END_OF_LIST(), > }; > > diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h > index 7e9482dee2..5669a5b811 100644 > --- a/include/hw/char/escc.h > +++ b/include/hw/char/escc.h > @@ -45,6 +45,7 @@ typedef struct ESCCChannelState { > ESCCChnType type; > uint8_t rx, tx; > QemuInputHandlerState *hs; > + char *sunkbd_layout; > } ESCCChannelState; > > struct ESCCState { > -- > 2.30.4 > With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v7] Emulate dip switch language layout settings on SUN keyboard 2023-06-20 9:22 ` Daniel P. Berrangé @ 2023-06-20 19:50 ` Henrik Carlqvist 2023-06-21 7:09 ` Daniel P. Berrangé 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-20 19:50 UTC (permalink / raw) To: Daniel P. Berrangé; +Cc: hc981, mark.cave-ayland, qemu-devel On Tue, 20 Jun 2023 10:22:40 +0100 Daniel P. Berrangé <berrange@redhat.com> wrote: Thanks for your feedback! > Assuming you have docutils installed, QEMU will build the manual by > default and print any issues on console during build. You can point > your browser to $BUILD/docs/manual/system/index.html to see the result. It seems as if I have docutils version 0.17.1 installed. However the build/docs directory only contains a symlink to the config directory in ../../docs after make is completed. > For future reference, if you want to put some questions/notes in the > submission, it is best to keep them separate from the commit message > text, as the questions/notes shouldn't end up in git history. To > separate them, put questions immediately after the '---' that separate > the commit message from the diffstat Thanks! Will do... > You need to remove the space between :ref: and `keyboard`. > > You'll also need to add it to a ToC (table of contents) otherwise > the build system complains. > > I'd suggest putting the new file at docs/system/devices/keyboards.rst > and adding to the ToC in docs/system/device-emulation.rst I will update the .rst files and placements, hopefully the coming weekend and come back with an updated patch. However, until I am able to build something from those .rst files, I can only follow your instructions to finally get them right. Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v7] Emulate dip switch language layout settings on SUN keyboard 2023-06-20 19:50 ` Henrik Carlqvist @ 2023-06-21 7:09 ` Daniel P. Berrangé 2023-06-21 18:14 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Daniel P. Berrangé @ 2023-06-21 7:09 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: hc981, mark.cave-ayland, qemu-devel On Tue, Jun 20, 2023 at 09:50:43PM +0200, Henrik Carlqvist wrote: > On Tue, 20 Jun 2023 10:22:40 +0100 > Daniel P. Berrangé <berrange@redhat.com> wrote: > > Thanks for your feedback! > > > Assuming you have docutils installed, QEMU will build the manual by > > default and print any issues on console during build. You can point > > your browser to $BUILD/docs/manual/system/index.html to see the result. > > It seems as if I have docutils version 0.17.1 installed. However the > build/docs directory only contains a symlink to the config directory in > ../../docs after make is completed. > > > For future reference, if you want to put some questions/notes in the > > submission, it is best to keep them separate from the commit message > > text, as the questions/notes shouldn't end up in git history. To > > separate them, put questions immediately after the '---' that separate > > the commit message from the diffstat > > Thanks! Will do... > > > You need to remove the space between :ref: and `keyboard`. > > > > You'll also need to add it to a ToC (table of contents) otherwise > > the build system complains. > > > > I'd suggest putting the new file at docs/system/devices/keyboards.rst > > and adding to the ToC in docs/system/device-emulation.rst > > I will update the .rst files and placements, hopefully the coming weekend and > come back with an updated patch. However, until I am able to build something > from those .rst files, I can only follow your instructions to finally get them > right. If you're using one of the common Linux distros, you'll find a list of the full set of packages you need to enable QEMU feuatres in the dockerfiles at tests/docker/dockerfiles/. Those all have enough to enable the docs build. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v7] Emulate dip switch language layout settings on SUN keyboard 2023-06-21 7:09 ` Daniel P. Berrangé @ 2023-06-21 18:14 ` Henrik Carlqvist 2023-06-23 18:30 ` [PATCH v8] " Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-21 18:14 UTC (permalink / raw) To: Daniel P. Berrangé; +Cc: hc981, mark.cave-ayland, qemu-devel On Wed, 21 Jun 2023 08:09:12 +0100 Daniel P. Berrangé <berrange@redhat.com> wrote: > If you're using one of the common Linux distros, you'll find a list of > the full set of packages you need to enable QEMU feuatres in the > dockerfiles at tests/docker/dockerfiles/. Those all have enough to > enable the docs build. Thanks for your support! I am using Slackware 15.0 as my build system which wasn't among those container configurations, but studying those files and the output from "./configure" made me realize that I needed to install Sphinx with all its dependencies and a rather recent version of sphinx-rtd-theme. Now I am able to do "make html" and as expected with my broken files I get -8<--------------------------- Warning, treated as error: /tmp/qemu/docs/system/keyboard.rst:document isn't included in any toctree ninja: build stopped: subcommand failed. -8<--------------------------- It will be a lot easier to work from here when I get feedback on any typos in the .rst files and then also get to read the content in a formatted way. I hope to be able to produce an updated patch the next weekend. Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v8] Emulate dip switch language layout settings on SUN keyboard 2023-06-21 18:14 ` Henrik Carlqvist @ 2023-06-23 18:30 ` Henrik Carlqvist 2023-06-26 9:42 ` Daniel P. Berrangé ` (2 more replies) 0 siblings, 3 replies; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-23 18:30 UTC (permalink / raw) To: berrange, qemu-devel; +Cc: hc981, mark.cave-ayland 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 a command line switch like "-global escc.chnA-sunkbd-layout=de" to select dip switch value. A table is used to lookup values from arguments like: -global escc.chnA-sunkbd-layout=fr -global escc.chnA-sunkbd-layout=es But the patch also accepts numeric dip switch values directly: -global escc.chnA-sunkbd-layout=0x2b -global escc.chnA-sunkbd-layout=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 Sun bios file, the easiest way to test that the patch works is to: qemu-system-sparc -global escc.chnA-sunkbd-layout=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 <hc1245@poolhem.se> --- In this version 8 of my patch I have fixed and moved some .rst files as suggested. Best regards Henrik docs/system/device-emulation.rst | 1 + docs/system/devices/keyboard.rst | 129 +++++++++++++++++++++++++++++++ docs/system/target-sparc.rst | 2 +- hw/char/escc.c | 76 +++++++++++++++++- include/hw/char/escc.h | 1 + 5 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 docs/system/devices/keyboard.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 8d4a1821fa..4491c4cbf7 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -86,6 +86,7 @@ Emulated Devices devices/ccid.rst devices/cxl.rst devices/ivshmem.rst + devices/keyboard.rst devices/net.rst devices/nvme.rst devices/usb.rst diff --git a/docs/system/devices/keyboard.rst b/docs/system/devices/keyboard.rst new file mode 100644 index 0000000000..84ea660d50 --- /dev/null +++ b/docs/system/devices/keyboard.rst @@ -0,0 +1,129 @@ +.. _keyboard: + +Sparc32 keyboard +---------------- +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. + +With the escc.chnA-sunkbd-layout driver property it is possible to select +keyboard layout. Example: + +-global escc.chnA-sunkbd-layout=de + +Depending on type of keyboard, the keyboard can have 6 or 5 dip-switches to +select keyboard layout, giving up to 64 different layouts. Not all +combinations are supported by Solaris and even less by Sun OpenBoot BIOS. + +The dip switch settings can be given as hexadecimal number, decimal number +or in some cases as a language string. Examples: + +-global escc.chnA-sunkbd-layout=0x2b + +-global escc.chnA-sunkbd-layout=43 + +-global escc.chnA-sunkbd-layout=sv + +The above 3 examples all select a swedish keyboard layout. Table 3-15 at +https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html explains which +keytable file is used for different dip switch settings. The information +in that table can be summarized in this table: + +.. list-table:: Language selection values for escc.chnA-sunkbd-layout + :widths: 10 10 10 + :header-rows: 1 + + * - Hexadecimal value + - Decimal value + - Language code + * - 0x21 + - 33 + - en-us + * - 0x23 + - 35 + - fr + * - 0x24 + - 36 + - da + * - 0x25 + - 37 + - de + * - 0x26 + - 38 + - it + * - 0x27 + - 39 + - nl + * - 0x28 + - 40 + - no + * - 0x29 + - 41 + - pt + * - 0x2a + - 42 + - es + * - 0x2b + - 43 + - sv + * - 0x2c + - 44 + - fr-ch + * - 0x2d + - 45 + - de-ch + * - 0x2e + - 46 + - en-gb + * - 0x2f + - 47 + - ko + * - 0x30 + - 48 + - tw + * - 0x31 + - 49 + - ja + * - 0x32 + - 50 + - fr-ca + * - 0x33 + - 51 + - hu + * - 0x34 + - 52 + - pl + * - 0x35 + - 53 + - cz + * - 0x36 + - 54 + - ru + * - 0x37 + - 55 + - lv + * - 0x38 + - 56 + - tr + * - 0x39 + - 57 + - gr + * - 0x3a + - 58 + - ar + * - 0x3b + - 59 + - lt + * - 0x3c + - 60 + - nl-be + * - 0x3c + - 60 + - be + +Not all dip switch values have a corresponding language code and both "be" and +"nl-be" correspond to the same dip switch value. By default, if no value is +given to escc.chnA-sunkbd-layout 0x21 (en-us) will be used. diff --git a/docs/system/target-sparc.rst b/docs/system/target-sparc.rst index b55f8d09e9..9ec8c90c14 100644 --- a/docs/system/target-sparc.rst +++ b/docs/system/target-sparc.rst @@ -38,7 +38,7 @@ QEMU emulates the following sun4m peripherals: - Non Volatile RAM M48T02/M48T08 - Slave I/O: timers, interrupt controllers, Zilog serial ports, - keyboard and power/reset logic + :ref:`keyboard` and power/reset logic - ESP SCSI controller with hard disk and CD-ROM support diff --git a/hw/char/escc.c b/hw/char/escc.c index 17a908c59b..463b3d2e93 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 "qemu/cutils.h" #include "trace.h" /* @@ -190,6 +192,7 @@ #define R_MISC1I 14 #define R_EXTINT 15 +static unsigned char sunkbd_layout_dip_switch(const char *sunkbd_layout); 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 = { .event = sunkbd_handle_event, }; +static unsigned char sunkbd_layout_dip_switch(const char *kbd_layout) +{ + /* Return the value of the dip-switches in a SUN Type 5 keyboard */ + static unsigned char ret = 0xff; + + if ((ret == 0xff) && kbd_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(kbd_layout, languages[i].lang)) { + ret = languages[i].dip; + return ret; + } + } + /* Found no known language code */ + + if ((kbd_layout[0] >= '0') && (kbd_layout[0] <= '9')) { + unsigned int tmp; + /* As a fallback we also accept numeric dip switch value */ + if (!qemu_strtoui(kbd_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); @@ -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, sunkbd_layout_dip_switch(s->sunkbd_layout)); break; default: break; @@ -976,6 +1048,8 @@ static Property escc_properties[] = { DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), + DEFINE_PROP_STRING("chnA-sunkbd-layout", ESCCState, + chn[1].sunkbd_layout), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h index 7e9482dee2..5669a5b811 100644 --- a/include/hw/char/escc.h +++ b/include/hw/char/escc.h @@ -45,6 +45,7 @@ typedef struct ESCCChannelState { ESCCChnType type; uint8_t rx, tx; QemuInputHandlerState *hs; + char *sunkbd_layout; } ESCCChannelState; struct ESCCState { -- 2.35.1 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v8] Emulate dip switch language layout settings on SUN keyboard 2023-06-23 18:30 ` [PATCH v8] " Henrik Carlqvist @ 2023-06-26 9:42 ` Daniel P. Berrangé 2023-06-27 6:33 ` Mark Cave-Ayland 2023-08-01 21:27 ` [PATCH v1] Allowing setting and overriding parameters in smb.conf Henrik Carlqvist 2 siblings, 0 replies; 37+ messages in thread From: Daniel P. Berrangé @ 2023-06-26 9:42 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: qemu-devel, mark.cave-ayland On Fri, Jun 23, 2023 at 08:30:07PM +0200, Henrik Carlqvist 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 always use an US > keyboard layout. > > Before this patch, qemu allways gave dip switch value 0x21 (US keyboard), > this patch uses a command line switch like > "-global escc.chnA-sunkbd-layout=de" to select dip switch value. A table is > used to lookup values from arguments like: > > -global escc.chnA-sunkbd-layout=fr > -global escc.chnA-sunkbd-layout=es > > But the patch also accepts numeric dip switch values directly: > > -global escc.chnA-sunkbd-layout=0x2b > -global escc.chnA-sunkbd-layout=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 Sun bios file, the easiest way to test that the patch works > is to: > > qemu-system-sparc -global escc.chnA-sunkbd-layout=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 <hc1245@poolhem.se> > --- Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v8] Emulate dip switch language layout settings on SUN keyboard 2023-06-23 18:30 ` [PATCH v8] " Henrik Carlqvist 2023-06-26 9:42 ` Daniel P. Berrangé @ 2023-06-27 6:33 ` Mark Cave-Ayland 2023-06-27 17:18 ` Henrik Carlqvist 2023-08-01 21:27 ` [PATCH v1] Allowing setting and overriding parameters in smb.conf Henrik Carlqvist 2 siblings, 1 reply; 37+ messages in thread From: Mark Cave-Ayland @ 2023-06-27 6:33 UTC (permalink / raw) To: Henrik Carlqvist, berrange, qemu-devel On 23/06/2023 19:30, Henrik Carlqvist 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 always use an US > keyboard layout. > > Before this patch, qemu allways gave dip switch value 0x21 (US keyboard), > this patch uses a command line switch like > "-global escc.chnA-sunkbd-layout=de" to select dip switch value. A table is > used to lookup values from arguments like: > > -global escc.chnA-sunkbd-layout=fr > -global escc.chnA-sunkbd-layout=es > > But the patch also accepts numeric dip switch values directly: > > -global escc.chnA-sunkbd-layout=0x2b > -global escc.chnA-sunkbd-layout=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 Sun bios file, the easiest way to test that the patch works > is to: > > qemu-system-sparc -global escc.chnA-sunkbd-layout=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 <hc1245@poolhem.se> > --- > > In this version 8 of my patch I have fixed and moved some .rst files as > suggested. > > Best regards Henrik > > docs/system/device-emulation.rst | 1 + > docs/system/devices/keyboard.rst | 129 +++++++++++++++++++++++++++++++ > docs/system/target-sparc.rst | 2 +- > hw/char/escc.c | 76 +++++++++++++++++- > include/hw/char/escc.h | 1 + > 5 files changed, 207 insertions(+), 2 deletions(-) > create mode 100644 docs/system/devices/keyboard.rst > > diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst > index 8d4a1821fa..4491c4cbf7 100644 > --- a/docs/system/device-emulation.rst > +++ b/docs/system/device-emulation.rst > @@ -86,6 +86,7 @@ Emulated Devices > devices/ccid.rst > devices/cxl.rst > devices/ivshmem.rst > + devices/keyboard.rst > devices/net.rst > devices/nvme.rst > devices/usb.rst > diff --git a/docs/system/devices/keyboard.rst b/docs/system/devices/keyboard.rst > new file mode 100644 > index 0000000000..84ea660d50 > --- /dev/null > +++ b/docs/system/devices/keyboard.rst > @@ -0,0 +1,129 @@ > +.. _keyboard: > + > +Sparc32 keyboard > +---------------- > +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. > + > +With the escc.chnA-sunkbd-layout driver property it is possible to select > +keyboard layout. Example: > + > +-global escc.chnA-sunkbd-layout=de > + > +Depending on type of keyboard, the keyboard can have 6 or 5 dip-switches to > +select keyboard layout, giving up to 64 different layouts. Not all > +combinations are supported by Solaris and even less by Sun OpenBoot BIOS. > + > +The dip switch settings can be given as hexadecimal number, decimal number > +or in some cases as a language string. Examples: > + > +-global escc.chnA-sunkbd-layout=0x2b > + > +-global escc.chnA-sunkbd-layout=43 > + > +-global escc.chnA-sunkbd-layout=sv > + > +The above 3 examples all select a swedish keyboard layout. Table 3-15 at > +https://docs.oracle.com/cd/E19683-01/806-6642/new-43/index.html explains which > +keytable file is used for different dip switch settings. The information > +in that table can be summarized in this table: > + > +.. list-table:: Language selection values for escc.chnA-sunkbd-layout > + :widths: 10 10 10 > + :header-rows: 1 > + > + * - Hexadecimal value > + - Decimal value > + - Language code > + * - 0x21 > + - 33 > + - en-us > + * - 0x23 > + - 35 > + - fr > + * - 0x24 > + - 36 > + - da > + * - 0x25 > + - 37 > + - de > + * - 0x26 > + - 38 > + - it > + * - 0x27 > + - 39 > + - nl > + * - 0x28 > + - 40 > + - no > + * - 0x29 > + - 41 > + - pt > + * - 0x2a > + - 42 > + - es > + * - 0x2b > + - 43 > + - sv > + * - 0x2c > + - 44 > + - fr-ch > + * - 0x2d > + - 45 > + - de-ch > + * - 0x2e > + - 46 > + - en-gb > + * - 0x2f > + - 47 > + - ko > + * - 0x30 > + - 48 > + - tw > + * - 0x31 > + - 49 > + - ja > + * - 0x32 > + - 50 > + - fr-ca > + * - 0x33 > + - 51 > + - hu > + * - 0x34 > + - 52 > + - pl > + * - 0x35 > + - 53 > + - cz > + * - 0x36 > + - 54 > + - ru > + * - 0x37 > + - 55 > + - lv > + * - 0x38 > + - 56 > + - tr > + * - 0x39 > + - 57 > + - gr > + * - 0x3a > + - 58 > + - ar > + * - 0x3b > + - 59 > + - lt > + * - 0x3c > + - 60 > + - nl-be > + * - 0x3c > + - 60 > + - be > + > +Not all dip switch values have a corresponding language code and both "be" and > +"nl-be" correspond to the same dip switch value. By default, if no value is > +given to escc.chnA-sunkbd-layout 0x21 (en-us) will be used. > diff --git a/docs/system/target-sparc.rst b/docs/system/target-sparc.rst > index b55f8d09e9..9ec8c90c14 100644 > --- a/docs/system/target-sparc.rst > +++ b/docs/system/target-sparc.rst > @@ -38,7 +38,7 @@ QEMU emulates the following sun4m peripherals: > - Non Volatile RAM M48T02/M48T08 > > - Slave I/O: timers, interrupt controllers, Zilog serial ports, > - keyboard and power/reset logic > + :ref:`keyboard` and power/reset logic > > - ESP SCSI controller with hard disk and CD-ROM support > > diff --git a/hw/char/escc.c b/hw/char/escc.c > index 17a908c59b..463b3d2e93 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 "qemu/cutils.h" > #include "trace.h" > > /* > @@ -190,6 +192,7 @@ > #define R_MISC1I 14 > #define R_EXTINT 15 > > +static unsigned char sunkbd_layout_dip_switch(const char *sunkbd_layout); > 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 = { > .event = sunkbd_handle_event, > }; > > +static unsigned char sunkbd_layout_dip_switch(const char *kbd_layout) > +{ > + /* Return the value of the dip-switches in a SUN Type 5 keyboard */ > + static unsigned char ret = 0xff; > + > + if ((ret == 0xff) && kbd_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(kbd_layout, languages[i].lang)) { > + ret = languages[i].dip; > + return ret; > + } > + } > + /* Found no known language code */ > + > + if ((kbd_layout[0] >= '0') && (kbd_layout[0] <= '9')) { > + unsigned int tmp; > + /* As a fallback we also accept numeric dip switch value */ > + if (!qemu_strtoui(kbd_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); > @@ -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, sunkbd_layout_dip_switch(s->sunkbd_layout)); > break; > default: > break; > @@ -976,6 +1048,8 @@ static Property escc_properties[] = { > DEFINE_PROP_UINT32("chnAtype", ESCCState, chn[1].type, 0), > DEFINE_PROP_CHR("chrB", ESCCState, chn[0].chr), > DEFINE_PROP_CHR("chrA", ESCCState, chn[1].chr), > + DEFINE_PROP_STRING("chnA-sunkbd-layout", ESCCState, > + chn[1].sunkbd_layout), > DEFINE_PROP_END_OF_LIST(), > }; > > diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h > index 7e9482dee2..5669a5b811 100644 > --- a/include/hw/char/escc.h > +++ b/include/hw/char/escc.h > @@ -45,6 +45,7 @@ typedef struct ESCCChannelState { > ESCCChnType type; > uint8_t rx, tx; > QemuInputHandlerState *hs; > + char *sunkbd_layout; > } ESCCChannelState; > > struct ESCCState { I think this is about ready to merge: the only thing I'd like to change is to swap unsigned char to uint8_t in the signature of sunkbd_layout_dip_switch(), but I can fix that up myself and queue it to my qemu-sparc branch. Thanks for your patience with this patchset! ATB, Mark. ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v8] Emulate dip switch language layout settings on SUN keyboard 2023-06-27 6:33 ` Mark Cave-Ayland @ 2023-06-27 17:18 ` Henrik Carlqvist 0 siblings, 0 replies; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-27 17:18 UTC (permalink / raw) To: Mark Cave-Ayland; +Cc: berrange, qemu-devel On Tue, 27 Jun 2023 07:33:46 +0100 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > I think this is about ready to merge: the only thing I'd like to change is > to swap unsigned char to uint8_t in the signature of > sunkbd_layout_dip_switch(), but I can fix that up myself and queue it to my > qemu-sparc branch. Thanks for accepting my patch! Please let me know if you want me to do anything more! Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-06-23 18:30 ` [PATCH v8] " Henrik Carlqvist 2023-06-26 9:42 ` Daniel P. Berrangé 2023-06-27 6:33 ` Mark Cave-Ayland @ 2023-08-01 21:27 ` Henrik Carlqvist 2023-08-02 19:53 ` Samuel Thibault 2 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-08-01 21:27 UTC (permalink / raw) To: qemu-devel; +Cc: samuel.thibault, hc981 From c480f787981308067a059213a1a7ce9c70ab668e Mon Sep 17 00:00:00 2001 From: Henrik Carlqvist <hc1245@poolhem.se> Date: Tue, 1 Aug 2023 23:00:15 +0200 Subject: [PATCH] Allowing setting and overriding parameters in smb.conf Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se> --- It would be nice to be able to change settings in smb.conf from the qemu command line. A kludge to edit the qemu smb.conf of a running smbd process is described at https://wiki.archlinux.org/title/QEMU , but IMHO my patch provides a cleaner solution where parameters can be initially set to the preferred values. Best regards Henrik net/slirp.c | 44 ++++++++++++++++++++++++++++++++++++++------ qapi/net.json | 3 +++ qemu-options.hx | 15 ++++++++++++--- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index c33b3e02e7..f860ea48f6 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -106,7 +106,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp); #if defined(CONFIG_SMBD_COMMAND) static int slirp_smb(SlirpState *s, const char *exported_dir, - struct in_addr vserver_addr, Error **errp); + struct in_addr vserver_addr, const char *smbparams, + Error **errp); static void slirp_smb_cleanup(SlirpState *s); #else static inline void slirp_smb_cleanup(SlirpState *s) { } @@ -424,6 +425,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, const char *bootfile, const char *vdhcp_start, const char *vnameserver, const char *vnameserver6, const char *smb_export, const char *vsmbserver, + const char *smbparams, const char **dnssearch, const char *vdomainname, const char *tftp_server_name, Error **errp) @@ -678,7 +680,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, } #if defined(CONFIG_SMBD_COMMAND) if (smb_export) { - if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { + if (slirp_smb(s, smb_export, smbsrv, smbparams, errp) < 0) { goto error; } } @@ -891,7 +893,8 @@ static void slirp_smb_cleanup(SlirpState *s) } static int slirp_smb(SlirpState* s, const char *exported_dir, - struct in_addr vserver_addr, Error **errp) + struct in_addr vserver_addr, const char *smbparams, + Error **errp) { char *smb_conf; char *smb_cmdline; @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, "printing = bsd\n" "disable spoolss = yes\n" "usershare max shares = 0\n" - "[qemu]\n" - "path=%s\n" "read only=no\n" "guest ok=yes\n" + "%s" + "[qemu]\n" + "path=%s\n" "force user=%s\n", s->smb_dir, s->smb_dir, @@ -963,6 +967,7 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, s->smb_dir, s->smb_dir, s->smb_dir, + smbparams, exported_dir, passwd->pw_name ); @@ -1143,6 +1148,29 @@ static const char **slirp_dnssearch(const StringList *dnsname) return ret; } +static char *slirp_smbparams(const StringList *smbparam) +{ + const StringList *c = smbparam; + size_t i = 1; /* for string terminating 0 */ + char *ret; + + while (c) { + i += strlen(c->value->str); + i++; /* for \n */ + c = c->next; + } + ret = g_malloc(i * sizeof(*ret)); + ret[0]=0; /* Start with empty string */ + + c = smbparam; + while (c) { + pstrcat(ret, i * sizeof(*ret), c->value->str); + pstrcat(ret, i * sizeof(*ret), "\n"); + c = c->next; + } + return ret; +} + int net_init_slirp(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -1151,6 +1179,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, int ret; const NetdevUserOptions *user; const char **dnssearch; + char *smbparams; bool ipv4 = true, ipv6 = true; assert(netdev->type == NET_CLIENT_DRIVER_USER); @@ -1170,6 +1199,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, NULL; dnssearch = slirp_dnssearch(user->dnssearch); + smbparams = slirp_smbparams(user->smbparam); /* all optional fields are initialized to "all bits zero" */ @@ -1182,7 +1212,8 @@ int net_init_slirp(const Netdev *netdev, const char *name, user->ipv6_host, user->hostname, user->tftp, user->bootfile, user->dhcpstart, user->dns, user->ipv6_dns, user->smb, - user->smbserver, dnssearch, user->domainname, + user->smbserver, smbparams, + dnssearch, user->domainname, user->tftp_server_name, errp); while (slirp_configs) { @@ -1193,6 +1224,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, g_free(vnet); g_free(dnssearch); + g_free(smbparams); return ret; } diff --git a/qapi/net.json b/qapi/net.json index 313c8a606e..163091719c 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -156,6 +156,8 @@ # # @smbserver: IP address of the built-in SMB server # +# @smbparam: list of parameters with values for smb.conf +# # @hostfwd: redirect incoming TCP or UDP host connections to guest # endpoints # @@ -186,6 +188,7 @@ '*ipv6-dns': 'str', '*smb': 'str', '*smbserver': 'str', + '*smbparam': ['String'], '*hostfwd': ['String'], '*guestfwd': ['String'], '*tftp-server-name': 'str' } } diff --git a/qemu-options.hx b/qemu-options.hx index 29b98c3d4c..7b92d08c3e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2758,9 +2758,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " [,ipv6=on|off][,ipv6-net=addr[/int]][,ipv6-host=addr]\n" " [,restrict=on|off][,hostname=host][,dhcpstart=addr]\n" " [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,domainname=domain]\n" - " [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=rule]" + " [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=rule]\n" #ifndef _WIN32 - "[,smb=dir[,smbserver=addr]]\n" + " [,smb=dir[,smbserver=addr][,smbparam=parameter=value]]\n" #endif " configure a user mode network backend with ID 'str',\n" " its DHCP server and optional services\n" @@ -3062,7 +3062,7 @@ SRST |qemu_system| -hda linux.img -boot n -device e1000,netdev=n1 \\ -netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 - ``smb=dir[,smbserver=addr]`` + ``smb=dir[,smbserver=addr][,smbparam=parameter=value]`` When using the user mode network stack, activate a built-in SMB server so that Windows OSes can access to the host files in ``dir`` transparently. The IP address of the SMB server can be @@ -3081,6 +3081,15 @@ SRST Then ``dir`` can be accessed in ``\\smbserver\qemu``. + It is possible to set samba parameters in the generated smb.conf + with one or more ``smbparam=parameter=value``. Example: + + .. parsed-literal:: + + |qemu_system| -nic user,smb=/tmp,smbparam="read only"=yes,smbparam="server min protocol"=NT1 + + See the man page of smb.conf for a complete listing of parameters. + Note that a SAMBA server must be installed on the host OS. ``hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport`` -- 2.35.1 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-01 21:27 ` [PATCH v1] Allowing setting and overriding parameters in smb.conf Henrik Carlqvist @ 2023-08-02 19:53 ` Samuel Thibault 2023-08-02 23:09 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Samuel Thibault @ 2023-08-02 19:53 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: qemu-devel Henrik Carlqvist, le mar. 01 août 2023 23:27:25 +0200, a ecrit: > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, > "printing = bsd\n" > "disable spoolss = yes\n" > "usershare max shares = 0\n" > - "[qemu]\n" > - "path=%s\n" > "read only=no\n" > "guest ok=yes\n" > + "%s" > + "[qemu]\n" > + "path=%s\n" ?This is moving read only and guest ok to the global section? Samuel ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-02 19:53 ` Samuel Thibault @ 2023-08-02 23:09 ` Henrik Carlqvist 2023-08-02 23:13 ` Samuel Thibault 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-08-02 23:09 UTC (permalink / raw) To: Samuel Thibault; +Cc: qemu-devel On Wed, 2 Aug 2023 21:53:56 +0200 Samuel Thibault <samuel.thibault@gnu.org> wrote: > Henrik Carlqvist, le mar. 01 août 2023 23:27:25 +0200, a ecrit: > > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char > > *exported_dir, > > "printing = bsd\n" > > "disable spoolss = yes\n" > > "usershare max shares = 0\n" > > - "[qemu]\n" > > - "path=%s\n" > > "read only=no\n" > > "guest ok=yes\n" > > + "%s" > > + "[qemu]\n" > > + "path=%s\n" > > ?This is moving read only and guest ok to the global section? Thanks for your quick reply! Yes, I thought that would be OK because the [qemu] share will inherit those settings from the global section. By placing those in the global section it is possible to override them with later contradicting statements like "read only=yes\n" in the %s before the [qemu] section. If I wouldn't have moved them to the global section there could have been a need to be able to alter parameters both in the global section and the [qemu] share section as any setting in a share section overrides any global settings. By only adding custom parameter settings to the end of the global section the user interface was kept in a more simple way. regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-02 23:09 ` Henrik Carlqvist @ 2023-08-02 23:13 ` Samuel Thibault 2023-08-02 23:26 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Samuel Thibault @ 2023-08-02 23:13 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: qemu-devel Henrik Carlqvist, le jeu. 03 août 2023 01:09:09 +0200, a ecrit: > On Wed, 2 Aug 2023 21:53:56 +0200 > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > Henrik Carlqvist, le mar. 01 août 2023 23:27:25 +0200, a ecrit: > > > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char > > > *exported_dir, > > > "printing = bsd\n" > > > "disable spoolss = yes\n" > > > "usershare max shares = 0\n" > > > - "[qemu]\n" > > > - "path=%s\n" > > > "read only=no\n" > > > "guest ok=yes\n" > > > + "%s" > > > + "[qemu]\n" > > > + "path=%s\n" > > > > ?This is moving read only and guest ok to the global section? > > Thanks for your quick reply! > > Yes, I thought that would be OK because the [qemu] share will inherit those > settings from the global section. By placing those in the global section it is > possible to override them with later contradicting statements like > "read only=yes\n" in the %s before the [qemu] section. Ok, it would be useful to mention that in the changelog. Thanks, Samuel ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-02 23:13 ` Samuel Thibault @ 2023-08-02 23:26 ` Henrik Carlqvist 2023-08-02 23:34 ` Samuel Thibault 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-08-02 23:26 UTC (permalink / raw) To: Samuel Thibault; +Cc: qemu-devel On Thu, 3 Aug 2023 01:13:24 +0200 Samuel Thibault <samuel.thibault@gnu.org> wrote: > Henrik Carlqvist, le jeu. 03 août 2023 01:09:09 +0200, a ecrit: > > On Wed, 2 Aug 2023 21:53:56 +0200 > > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > > > Henrik Carlqvist, le mar. 01 août 2023 23:27:25 +0200, a ecrit: > > > > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char > > > > *exported_dir, > > > > "printing = bsd\n" > > > > "disable spoolss = yes\n" > > > > "usershare max shares = 0\n" > > > > - "[qemu]\n" > > > > - "path=%s\n" > > > > "read only=no\n" > > > > "guest ok=yes\n" > > > > + "%s" > > > > + "[qemu]\n" > > > > + "path=%s\n" > > > > > > ?This is moving read only and guest ok to the global section? > > > > Thanks for your quick reply! > > > > Yes, I thought that would be OK because the [qemu] share will inherit > > those settings from the global section. By placing those in the global > > section it is possible to override them with later contradicting > > statements like "read only=yes\n" in the %s before the [qemu] section. > > Ok, it would be useful to mention that in the changelog. Is there a changelog in the repo? Or do you mean that I should mention that in the git commit message? Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-02 23:26 ` Henrik Carlqvist @ 2023-08-02 23:34 ` Samuel Thibault 2023-08-03 0:13 ` Henrik Carlqvist 2023-08-03 15:12 ` [PATCH v2] " Henrik Carlqvist 0 siblings, 2 replies; 37+ messages in thread From: Samuel Thibault @ 2023-08-02 23:34 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: qemu-devel Henrik Carlqvist, le jeu. 03 août 2023 01:26:02 +0200, a ecrit: > On Thu, 3 Aug 2023 01:13:24 +0200 > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > Henrik Carlqvist, le jeu. 03 août 2023 01:09:09 +0200, a ecrit: > > > On Wed, 2 Aug 2023 21:53:56 +0200 > > > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > > > > > Henrik Carlqvist, le mar. 01 août 2023 23:27:25 +0200, a ecrit: > > > > > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const char > > > > > *exported_dir, > > > > > "printing = bsd\n" > > > > > "disable spoolss = yes\n" > > > > > "usershare max shares = 0\n" > > > > > - "[qemu]\n" > > > > > - "path=%s\n" > > > > > "read only=no\n" > > > > > "guest ok=yes\n" > > > > > + "%s" > > > > > + "[qemu]\n" > > > > > + "path=%s\n" > > > > > > > > ?This is moving read only and guest ok to the global section? > > > > > > Thanks for your quick reply! > > > > > > Yes, I thought that would be OK because the [qemu] share will inherit > > > those settings from the global section. By placing those in the global > > > section it is possible to override them with later contradicting > > > statements like "read only=yes\n" in the %s before the [qemu] section. > > > > Ok, it would be useful to mention that in the changelog. > > Is there a changelog in the repo? Or do you mean that I should mention that in > the git commit message? I mean the latter, yes. Samuel ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1] Allowing setting and overriding parameters in smb.conf 2023-08-02 23:34 ` Samuel Thibault @ 2023-08-03 0:13 ` Henrik Carlqvist 2023-08-03 15:12 ` [PATCH v2] " Henrik Carlqvist 1 sibling, 0 replies; 37+ messages in thread From: Henrik Carlqvist @ 2023-08-03 0:13 UTC (permalink / raw) To: Samuel Thibault; +Cc: qemu-devel On Thu, 3 Aug 2023 01:34:04 +0200 Samuel Thibault <samuel.thibault@gnu.org> wrote: > Henrik Carlqvist, le jeu. 03 août 2023 01:26:02 +0200, a ecrit: > > On Thu, 3 Aug 2023 01:13:24 +0200 > > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > > > Henrik Carlqvist, le jeu. 03 août 2023 01:09:09 +0200, a ecrit: > > > > On Wed, 2 Aug 2023 21:53:56 +0200 > > > > Samuel Thibault <samuel.thibault@gnu.org> wrote: > > > > > > > > > Henrik Carlqvist, le mar. 01 aoÃÂût 2023 23:27:25 +0200, a > > > > > ecrit: > > > > > > @@ -950,10 +953,11 @@ static int slirp_smb(SlirpState* s, const > > > > > > char*exported_dir, > > > > > > "printing = bsd\n" > > > > > > "disable spoolss = yes\n" > > > > > > "usershare max shares = 0\n" > > > > > > - "[qemu]\n" > > > > > > - "path=%s\n" > > > > > > "read only=no\n" > > > > > > "guest ok=yes\n" > > > > > > + "%s" > > > > > > + "[qemu]\n" > > > > > > + "path=%s\n" > > > > > > > > > > ?This is moving read only and guest ok to the global section? > > > > > > > > Thanks for your quick reply! > > > > > > > > Yes, I thought that would be OK because the [qemu] share will inherit > > > > those settings from the global section. By placing those in the global > > > > section it is possible to override them with later contradicting > > > > statements like "read only=yes\n" in the %s before the [qemu] section. > > > > > > Ok, it would be useful to mention that in the changelog. > > > > Is there a changelog in the repo? Or do you mean that I should mention > > that in the git commit message? > > I mean the latter, yes. Thanks for your feedback! I will provide a new patch tomorrow. Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v2] Allowing setting and overriding parameters in smb.conf 2023-08-02 23:34 ` Samuel Thibault 2023-08-03 0:13 ` Henrik Carlqvist @ 2023-08-03 15:12 ` Henrik Carlqvist 2023-09-10 11:48 ` Ping: " Henrik Carlqvist 1 sibling, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-08-03 15:12 UTC (permalink / raw) To: Samuel Thibault; +Cc: qemu-devel From a6dfb322a88965281e3bba00a92f8d5e437bfa95 Mon Sep 17 00:00:00 2001 From: Henrik Carlqvist <hc1245@poolhem.se> Date: Thu, 3 Aug 2023 16:52:25 +0200 Subject: [PATCH] Allowing setting and overriding parameters in smb.conf, moving some parameters from the [qemu] section to the [global] section to allow them to get overridden by custom user settings. Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se> --- In this second version of the patch I have moved also the "force user" parameter to the global section of smb.conf. Even though I do not self see the usefullness of altering that parameter we might just as well give the users the freedom to alter anything in smb.conf. Maybe someone else will see the need to alter that parameter. Best regards Henrik net/slirp.c | 50 ++++++++++++++++++++++++++++++++++++++++--------- qapi/net.json | 3 +++ qemu-options.hx | 15 ++++++++++++--- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index c33b3e02e7..e27d115bc4 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -106,7 +106,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp); #if defined(CONFIG_SMBD_COMMAND) static int slirp_smb(SlirpState *s, const char *exported_dir, - struct in_addr vserver_addr, Error **errp); + struct in_addr vserver_addr, const char *smbparams, + Error **errp); static void slirp_smb_cleanup(SlirpState *s); #else static inline void slirp_smb_cleanup(SlirpState *s) { } @@ -424,6 +425,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, const char *bootfile, const char *vdhcp_start, const char *vnameserver, const char *vnameserver6, const char *smb_export, const char *vsmbserver, + const char *smbparams, const char **dnssearch, const char *vdomainname, const char *tftp_server_name, Error **errp) @@ -678,7 +680,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, } #if defined(CONFIG_SMBD_COMMAND) if (smb_export) { - if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { + if (slirp_smb(s, smb_export, smbsrv, smbparams, errp) < 0) { goto error; } } @@ -891,7 +893,8 @@ static void slirp_smb_cleanup(SlirpState *s) } static int slirp_smb(SlirpState* s, const char *exported_dir, - struct in_addr vserver_addr, Error **errp) + struct in_addr vserver_addr, const char *smbparams, + Error **errp) { char *smb_conf; char *smb_cmdline; @@ -950,11 +953,12 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, "printing = bsd\n" "disable spoolss = yes\n" "usershare max shares = 0\n" - "[qemu]\n" - "path=%s\n" "read only=no\n" "guest ok=yes\n" - "force user=%s\n", + "force user=%s\n" + "%s" + "[qemu]\n" + "path=%s\n", s->smb_dir, s->smb_dir, s->smb_dir, @@ -963,8 +967,9 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, s->smb_dir, s->smb_dir, s->smb_dir, - exported_dir, - passwd->pw_name + passwd->pw_name, + smbparams, + exported_dir ); fclose(f); @@ -1143,6 +1148,29 @@ static const char **slirp_dnssearch(const StringList *dnsname) return ret; } +static char *slirp_smbparams(const StringList *smbparam) +{ + const StringList *c = smbparam; + size_t i = 1; /* for string terminating 0 */ + char *ret; + + while (c) { + i += strlen(c->value->str); + i++; /* for \n */ + c = c->next; + } + ret = g_malloc(i * sizeof(*ret)); + ret[0]=0; /* Start with empty string */ + + c = smbparam; + while (c) { + pstrcat(ret, i * sizeof(*ret), c->value->str); + pstrcat(ret, i * sizeof(*ret), "\n"); + c = c->next; + } + return ret; +} + int net_init_slirp(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -1151,6 +1179,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, int ret; const NetdevUserOptions *user; const char **dnssearch; + char *smbparams; bool ipv4 = true, ipv6 = true; assert(netdev->type == NET_CLIENT_DRIVER_USER); @@ -1170,6 +1199,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, NULL; dnssearch = slirp_dnssearch(user->dnssearch); + smbparams = slirp_smbparams(user->smbparam); /* all optional fields are initialized to "all bits zero" */ @@ -1182,7 +1212,8 @@ int net_init_slirp(const Netdev *netdev, const char *name, user->ipv6_host, user->hostname, user->tftp, user->bootfile, user->dhcpstart, user->dns, user->ipv6_dns, user->smb, - user->smbserver, dnssearch, user->domainname, + user->smbserver, smbparams, + dnssearch, user->domainname, user->tftp_server_name, errp); while (slirp_configs) { @@ -1193,6 +1224,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, g_free(vnet); g_free(dnssearch); + g_free(smbparams); return ret; } diff --git a/qapi/net.json b/qapi/net.json index 313c8a606e..163091719c 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -156,6 +156,8 @@ # # @smbserver: IP address of the built-in SMB server # +# @smbparam: list of parameters with values for smb.conf +# # @hostfwd: redirect incoming TCP or UDP host connections to guest # endpoints # @@ -186,6 +188,7 @@ '*ipv6-dns': 'str', '*smb': 'str', '*smbserver': 'str', + '*smbparam': ['String'], '*hostfwd': ['String'], '*guestfwd': ['String'], '*tftp-server-name': 'str' } } diff --git a/qemu-options.hx b/qemu-options.hx index 29b98c3d4c..7b92d08c3e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2758,9 +2758,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " [,ipv6=on|off][,ipv6-net=addr[/int]][,ipv6-host=addr]\n" " [,restrict=on|off][,hostname=host][,dhcpstart=addr]\n" " [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,domainname=domain]\n" - " [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=rule]" + " [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=rule]\n" #ifndef _WIN32 - "[,smb=dir[,smbserver=addr]]\n" + " [,smb=dir[,smbserver=addr][,smbparam=parameter=value]]\n" #endif " configure a user mode network backend with ID 'str',\n" " its DHCP server and optional services\n" @@ -3062,7 +3062,7 @@ SRST |qemu_system| -hda linux.img -boot n -device e1000,netdev=n1 \\ -netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 - ``smb=dir[,smbserver=addr]`` + ``smb=dir[,smbserver=addr][,smbparam=parameter=value]`` When using the user mode network stack, activate a built-in SMB server so that Windows OSes can access to the host files in ``dir`` transparently. The IP address of the SMB server can be @@ -3081,6 +3081,15 @@ SRST Then ``dir`` can be accessed in ``\\smbserver\qemu``. + It is possible to set samba parameters in the generated smb.conf + with one or more ``smbparam=parameter=value``. Example: + + .. parsed-literal:: + + |qemu_system| -nic user,smb=/tmp,smbparam="read only"=yes,smbparam="server min protocol"=NT1 + + See the man page of smb.conf for a complete listing of parameters. + Note that a SAMBA server must be installed on the host OS. ``hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport`` -- 2.35.1 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Ping: [PATCH v2] Allowing setting and overriding parameters in smb.conf 2023-08-03 15:12 ` [PATCH v2] " Henrik Carlqvist @ 2023-09-10 11:48 ` Henrik Carlqvist 2024-02-17 22:28 ` Ping 2: " Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-09-10 11:48 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: samuel.thibault, qemu-devel, Henrik Carlqvist I'm just wondering if there are any plans to apply my patch in this version or if you would like me to change anything more in the patch? I am aware that during this time of the year many have been away on vacation and it has also been a new release 8.1 which has blocked any submitted patches but bug fixes. However, now might be a good time to push this patch towards master? Best regards Henrik On Thu, 3 Aug 2023 17:12:56 +0200 Henrik Carlqvist <hc981@poolhem.se> wrote: > From a6dfb322a88965281e3bba00a92f8d5e437bfa95 Mon Sep 17 00:00:00 2001 > From: Henrik Carlqvist <hc1245@poolhem.se> > Date: Thu, 3 Aug 2023 16:52:25 +0200 > Subject: [PATCH] Allowing setting and overriding parameters in smb.conf, > moving some parameters from the [qemu] section to the [global] section to > allow them to get overridden by custom user settings. > > Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se> > --- > > In this second version of the patch I have moved also the "force user" > parameter to the global section of smb.conf. Even though I do not self see > the usefullness of altering that parameter we might just as well give the > users the freedom to alter anything in smb.conf. Maybe someone else will see > the need to alter that parameter. > > Best regards Henrik > > net/slirp.c | 50 ++++++++++++++++++++++++++++++++++++++++--------- > qapi/net.json | 3 +++ > qemu-options.hx | 15 ++++++++++++--- > 3 files changed, 56 insertions(+), 12 deletions(-) > > diff --git a/net/slirp.c b/net/slirp.c > index c33b3e02e7..e27d115bc4 100644 > --- a/net/slirp.c > +++ b/net/slirp.c > @@ -106,7 +106,8 @@ static int slirp_guestfwd(SlirpState *s, const char > *config_str, Error **errp); > > #if defined(CONFIG_SMBD_COMMAND) > static int slirp_smb(SlirpState *s, const char *exported_dir, > - struct in_addr vserver_addr, Error **errp); > + struct in_addr vserver_addr, const char *smbparams, > + Error **errp); > static void slirp_smb_cleanup(SlirpState *s); > #else > static inline void slirp_smb_cleanup(SlirpState *s) { } > @@ -424,6 +425,7 @@ static int net_slirp_init(NetClientState *peer, const > char *model, > const char *bootfile, const char *vdhcp_start, > const char *vnameserver, const char > *vnameserver6, const char *smb_export, const char > *vsmbserver, > + const char *smbparams, > const char **dnssearch, const char *vdomainname, > const char *tftp_server_name, > Error **errp) > @@ -678,7 +680,7 @@ static int net_slirp_init(NetClientState *peer, const > char *model, > } > #if defined(CONFIG_SMBD_COMMAND) > if (smb_export) { > - if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { > + if (slirp_smb(s, smb_export, smbsrv, smbparams, errp) < 0) { > goto error; > } > } > @@ -891,7 +893,8 @@ static void slirp_smb_cleanup(SlirpState *s) > } > > static int slirp_smb(SlirpState* s, const char *exported_dir, > - struct in_addr vserver_addr, Error **errp) > + struct in_addr vserver_addr, const char *smbparams, > + Error **errp) > { > char *smb_conf; > char *smb_cmdline; > @@ -950,11 +953,12 @@ static int slirp_smb(SlirpState* s, const char > *exported_dir, > "printing = bsd\n" > "disable spoolss = yes\n" > "usershare max shares = 0\n" > - "[qemu]\n" > - "path=%s\n" > "read only=no\n" > "guest ok=yes\n" > - "force user=%s\n", > + "force user=%s\n" > + "%s" > + "[qemu]\n" > + "path=%s\n", > s->smb_dir, > s->smb_dir, > s->smb_dir, > @@ -963,8 +967,9 @@ static int slirp_smb(SlirpState* s, const char > *exported_dir, > s->smb_dir, > s->smb_dir, > s->smb_dir, > - exported_dir, > - passwd->pw_name > + passwd->pw_name, > + smbparams, > + exported_dir > ); > fclose(f); > > @@ -1143,6 +1148,29 @@ static const char **slirp_dnssearch(const StringList > *dnsname) > return ret; > } > > +static char *slirp_smbparams(const StringList *smbparam) > +{ > + const StringList *c = smbparam; > + size_t i = 1; /* for string terminating 0 */ > + char *ret; > + > + while (c) { > + i += strlen(c->value->str); > + i++; /* for \n */ > + c = c->next; > + } > + ret = g_malloc(i * sizeof(*ret)); > + ret[0]=0; /* Start with empty string */ > + > + c = smbparam; > + while (c) { > + pstrcat(ret, i * sizeof(*ret), c->value->str); > + pstrcat(ret, i * sizeof(*ret), "\n"); > + c = c->next; > + } > + return ret; > +} > + > int net_init_slirp(const Netdev *netdev, const char *name, > NetClientState *peer, Error **errp) > { > @@ -1151,6 +1179,7 @@ int net_init_slirp(const Netdev *netdev, const char > *name, > int ret; > const NetdevUserOptions *user; > const char **dnssearch; > + char *smbparams; > bool ipv4 = true, ipv6 = true; > > assert(netdev->type == NET_CLIENT_DRIVER_USER); > @@ -1170,6 +1199,7 @@ int net_init_slirp(const Netdev *netdev, const char > *name, > NULL; > > dnssearch = slirp_dnssearch(user->dnssearch); > + smbparams = slirp_smbparams(user->smbparam); > > /* all optional fields are initialized to "all bits zero" */ > > @@ -1182,7 +1212,8 @@ int net_init_slirp(const Netdev *netdev, const char > *name, > user->ipv6_host, user->hostname, user->tftp, > user->bootfile, user->dhcpstart, > user->dns, user->ipv6_dns, user->smb, > - user->smbserver, dnssearch, user->domainname, > + user->smbserver, smbparams, > + dnssearch, user->domainname, > user->tftp_server_name, errp); > > while (slirp_configs) { > @@ -1193,6 +1224,7 @@ int net_init_slirp(const Netdev *netdev, const char > *name, > > g_free(vnet); > g_free(dnssearch); > + g_free(smbparams); > > return ret; > } > diff --git a/qapi/net.json b/qapi/net.json > index 313c8a606e..163091719c 100644 > --- a/qapi/net.json > +++ b/qapi/net.json > @@ -156,6 +156,8 @@ > # > # @smbserver: IP address of the built-in SMB server > # > +# @smbparam: list of parameters with values for smb.conf > +# > # @hostfwd: redirect incoming TCP or UDP host connections to guest > # endpoints > # > @@ -186,6 +188,7 @@ > '*ipv6-dns': 'str', > '*smb': 'str', > '*smbserver': 'str', > + '*smbparam': ['String'], > '*hostfwd': ['String'], > '*guestfwd': ['String'], > '*tftp-server-name': 'str' } } > diff --git a/qemu-options.hx b/qemu-options.hx > index 29b98c3d4c..7b92d08c3e 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -2758,9 +2758,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, > " [,ipv6=on|off][,ipv6-net=addr[/int]][,ipv6-host=addr]\n" > " [,restrict=on|off][,hostname=host][,dhcpstart=addr]\n" > " > [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,domainname=domain]\n" > - " > [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=r > ule]"+ " > [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd=r > ule]\n" > #ifndef _WIN32 > - > "[,smb=dir[,smbserver=addr]]\n"+ " > [,smb=dir[,smbserver=addr][,smbparam=parameter=value]]\n" > #endif > " configure a user mode network backend with ID > 'str',\n"" its DHCP server and optional services\n" > @@ -3062,7 +3062,7 @@ SRST > |qemu_system| -hda linux.img -boot n -device e1000,netdev=n1 \\ > -netdev > user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 > > - ``smb=dir[,smbserver=addr]`` > + ``smb=dir[,smbserver=addr][,smbparam=parameter=value]`` > When using the user mode network stack, activate a built-in SMB > server so that Windows OSes can access to the host files in > ``dir`` transparently. The IP address of the SMB server can be > @@ -3081,6 +3081,15 @@ SRST > > Then ``dir`` can be accessed in ``\\smbserver\qemu``. > > + It is possible to set samba parameters in the generated smb.conf > + with one or more ``smbparam=parameter=value``. Example: > + > + .. parsed-literal:: > + > + |qemu_system| -nic user,smb=/tmp,smbparam="read > only"=yes,smbparam="server min protocol"=NT1+ > + See the man page of smb.conf for a complete listing of parameters. > + > Note that a SAMBA server must be installed on the host OS. > > ``hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport`` > -- > 2.35.1 > ^ permalink raw reply [flat|nested] 37+ messages in thread
* Ping 2: [PATCH v2] Allowing setting and overriding parameters in smb.conf 2023-09-10 11:48 ` Ping: " Henrik Carlqvist @ 2024-02-17 22:28 ` Henrik Carlqvist 2024-02-18 9:30 ` Michael Tokarev 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2024-02-17 22:28 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: samuel.thibault, qemu-devel Still wondering if there are any plans to apply my patch or if you would like to change anything in the patch? Being able to set parameters in smb.conf would be really useful these days for people running old versions of Windows like Windows XP in a qemu guest. Today, the default settings of Samba has disabled SMBv1 making old versions of Windows unable to connect to Samba shares. regards Henrik On Sun, 10 Sep 2023 13:48:12 +0200 Henrik Carlqvist <hc94@poolhem.se> wrote: > I'm just wondering if there are any plans to apply my patch in this version > or if you would like me to change anything more in the patch? I am aware > that during this time of the year many have been away on vacation and it has > also been a new release 8.1 which has blocked any submitted patches but bug > fixes. However, now might be a good time to push this patch towards master? > > Best regards Henrik > > On Thu, 3 Aug 2023 17:12:56 +0200 > Henrik Carlqvist <hc981@poolhem.se> wrote: > > > From a6dfb322a88965281e3bba00a92f8d5e437bfa95 Mon Sep 17 00:00:00 2001 > > From: Henrik Carlqvist <hc1245@poolhem.se> > > Date: Thu, 3 Aug 2023 16:52:25 +0200 > > Subject: [PATCH] Allowing setting and overriding parameters in smb.conf, > > moving some parameters from the [qemu] section to the [global] section to > > allow them to get overridden by custom user settings. > > > > Signed-off-by: Henrik Carlqvist <hc1245@poolhem.se> > > --- > > > > In this second version of the patch I have moved also the "force user" > > parameter to the global section of smb.conf. Even though I do not self see > > the usefullness of altering that parameter we might just as well give the > > users the freedom to alter anything in smb.conf. Maybe someone else will > > see the need to alter that parameter. > > > > Best regards Henrik > > > > net/slirp.c | 50 ++++++++++++++++++++++++++++++++++++++++--------- > > qapi/net.json | 3 +++ > > qemu-options.hx | 15 ++++++++++++--- > > 3 files changed, 56 insertions(+), 12 deletions(-) > > > > diff --git a/net/slirp.c b/net/slirp.c > > index c33b3e02e7..e27d115bc4 100644 > > --- a/net/slirp.c > > +++ b/net/slirp.c > > @@ -106,7 +106,8 @@ static int slirp_guestfwd(SlirpState *s, const char > > *config_str, Error **errp); > > > > #if defined(CONFIG_SMBD_COMMAND) > > static int slirp_smb(SlirpState *s, const char *exported_dir, > > - struct in_addr vserver_addr, Error **errp); > > + struct in_addr vserver_addr, const char *smbparams, > > + Error **errp); > > static void slirp_smb_cleanup(SlirpState *s); > > #else > > static inline void slirp_smb_cleanup(SlirpState *s) { } > > @@ -424,6 +425,7 @@ static int net_slirp_init(NetClientState *peer, const > > char *model, > > const char *bootfile, const char *vdhcp_start, > > const char *vnameserver, const char > > *vnameserver6, const char *smb_export, const > > char*vsmbserver, > > + const char *smbparams, > > const char **dnssearch, const char > > *vdomainname, const char *tftp_server_name, > > Error **errp) > > @@ -678,7 +680,7 @@ static int net_slirp_init(NetClientState *peer, const > > char *model, > > } > > #if defined(CONFIG_SMBD_COMMAND) > > if (smb_export) { > > - if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { > > + if (slirp_smb(s, smb_export, smbsrv, smbparams, errp) < 0) { > > goto error; > > } > > } > > @@ -891,7 +893,8 @@ static void slirp_smb_cleanup(SlirpState *s) > > } > > > > static int slirp_smb(SlirpState* s, const char *exported_dir, > > - struct in_addr vserver_addr, Error **errp) > > + struct in_addr vserver_addr, const char *smbparams, > > + Error **errp) > > { > > char *smb_conf; > > char *smb_cmdline; > > @@ -950,11 +953,12 @@ static int slirp_smb(SlirpState* s, const char > > *exported_dir, > > "printing = bsd\n" > > "disable spoolss = yes\n" > > "usershare max shares = 0\n" > > - "[qemu]\n" > > - "path=%s\n" > > "read only=no\n" > > "guest ok=yes\n" > > - "force user=%s\n", > > + "force user=%s\n" > > + "%s" > > + "[qemu]\n" > > + "path=%s\n", > > s->smb_dir, > > s->smb_dir, > > s->smb_dir, > > @@ -963,8 +967,9 @@ static int slirp_smb(SlirpState* s, const char > > *exported_dir, > > s->smb_dir, > > s->smb_dir, > > s->smb_dir, > > - exported_dir, > > - passwd->pw_name > > + passwd->pw_name, > > + smbparams, > > + exported_dir > > ); > > fclose(f); > > > > @@ -1143,6 +1148,29 @@ static const char **slirp_dnssearch(const > > StringList*dnsname) > > return ret; > > } > > > > +static char *slirp_smbparams(const StringList *smbparam) > > +{ > > + const StringList *c = smbparam; > > + size_t i = 1; /* for string terminating 0 */ > > + char *ret; > > + > > + while (c) { > > + i += strlen(c->value->str); > > + i++; /* for \n */ > > + c = c->next; > > + } > > + ret = g_malloc(i * sizeof(*ret)); > > + ret[0]=0; /* Start with empty string */ > > + > > + c = smbparam; > > + while (c) { > > + pstrcat(ret, i * sizeof(*ret), c->value->str); > > + pstrcat(ret, i * sizeof(*ret), "\n"); > > + c = c->next; > > + } > > + return ret; > > +} > > + > > int net_init_slirp(const Netdev *netdev, const char *name, > > NetClientState *peer, Error **errp) > > { > > @@ -1151,6 +1179,7 @@ int net_init_slirp(const Netdev *netdev, const char > > *name, > > int ret; > > const NetdevUserOptions *user; > > const char **dnssearch; > > + char *smbparams; > > bool ipv4 = true, ipv6 = true; > > > > assert(netdev->type == NET_CLIENT_DRIVER_USER); > > @@ -1170,6 +1199,7 @@ int net_init_slirp(const Netdev *netdev, const char > > *name, > > NULL; > > > > dnssearch = slirp_dnssearch(user->dnssearch); > > + smbparams = slirp_smbparams(user->smbparam); > > > > /* all optional fields are initialized to "all bits zero" */ > > > > @@ -1182,7 +1212,8 @@ int net_init_slirp(const Netdev *netdev, const char > > *name, > > user->ipv6_host, user->hostname, user->tftp, > > user->bootfile, user->dhcpstart, > > user->dns, user->ipv6_dns, user->smb, > > - user->smbserver, dnssearch, user->domainname, > > + user->smbserver, smbparams, > > + dnssearch, user->domainname, > > user->tftp_server_name, errp); > > > > while (slirp_configs) { > > @@ -1193,6 +1224,7 @@ int net_init_slirp(const Netdev *netdev, const char > > *name, > > > > g_free(vnet); > > g_free(dnssearch); > > + g_free(smbparams); > > > > return ret; > > } > > diff --git a/qapi/net.json b/qapi/net.json > > index 313c8a606e..163091719c 100644 > > --- a/qapi/net.json > > +++ b/qapi/net.json > > @@ -156,6 +156,8 @@ > > # > > # @smbserver: IP address of the built-in SMB server > > # > > +# @smbparam: list of parameters with values for smb.conf > > +# > > # @hostfwd: redirect incoming TCP or UDP host connections to guest > > # endpoints > > # > > @@ -186,6 +188,7 @@ > > '*ipv6-dns': 'str', > > '*smb': 'str', > > '*smbserver': 'str', > > + '*smbparam': ['String'], > > '*hostfwd': ['String'], > > '*guestfwd': ['String'], > > '*tftp-server-name': 'str' } } > > diff --git a/qemu-options.hx b/qemu-options.hx > > index 29b98c3d4c..7b92d08c3e 100644 > > --- a/qemu-options.hx > > +++ b/qemu-options.hx > > @@ -2758,9 +2758,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, > > " [,ipv6=on|off][,ipv6-net=addr[/int]][,ipv6-host=addr]\n" > > " [,restrict=on|off][,hostname=host][,dhcpstart=addr]\n" > > " > > [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,domainname=domain]\n" > > - " > > [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd > > =r ule]"+ " > > [,tftp=dir][,tftp-server-name=name][,bootfile=f][,hostfwd=rule][,guestfwd > > =r ule]\n" > > #ifndef _WIN32 > > - > > "[,smb=dir[,smbserver=addr]]\n"+ " > > [,smb=dir[,smbserver=addr][,smbparam=parameter=value]]\n" > > #endif > > " configure a user mode network backend with ID > > 'str',\n"" its DHCP server and optional services\n" > > @@ -3062,7 +3062,7 @@ SRST > > |qemu_system| -hda linux.img -boot n -device e1000,netdev=n1 > > |\\ > > -netdev > > user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0 > > > > - ``smb=dir[,smbserver=addr]`` > > + ``smb=dir[,smbserver=addr][,smbparam=parameter=value]`` > > When using the user mode network stack, activate a built-in SMB > > server so that Windows OSes can access to the host files in > > ``dir`` transparently. The IP address of the SMB server can be > > @@ -3081,6 +3081,15 @@ SRST > > > > Then ``dir`` can be accessed in ``\\smbserver\qemu``. > > > > + It is possible to set samba parameters in the generated smb.conf > > + with one or more ``smbparam=parameter=value``. Example: > > + > > + .. parsed-literal:: > > + > > + |qemu_system| -nic user,smb=/tmp,smbparam="read > > only"=yes,smbparam="server min protocol"=NT1+ > > + See the man page of smb.conf for a complete listing of > > parameters.+ > > Note that a SAMBA server must be installed on the host OS. > > > > ``hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport`` > > -- > > 2.35.1 > > ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: Ping 2: [PATCH v2] Allowing setting and overriding parameters in smb.conf 2024-02-17 22:28 ` Ping 2: " Henrik Carlqvist @ 2024-02-18 9:30 ` Michael Tokarev 2024-02-18 14:55 ` Henrik Carlqvist 0 siblings, 1 reply; 37+ messages in thread From: Michael Tokarev @ 2024-02-18 9:30 UTC (permalink / raw) To: Henrik Carlqvist, Henrik Carlqvist; +Cc: samuel.thibault, qemu-devel 18.02.2024 01:28, Henrik Carlqvist : > Still wondering if there are any plans to apply my patch or if you would like > to change anything in the patch? > > Being able to set parameters in smb.conf would be really useful these days for > people running old versions of Windows like Windows XP in a qemu guest. Today, > the default settings of Samba has disabled SMBv1 making old versions of > Windows unable to connect to Samba shares. I don't maintain this code, so my email is just a random comment. But I did have an issue with smbd not working right due to one missing/wrong parameter or another, more than once. Also, samba is evolving too, so it might need more parameters or less. My suggestion is still the same as 10+ years ago: to ship a shell script which run smbd, instead of running smbd directly. This script will set up smb.conf (whole thing, exactly as it is done now in the C code), and exec /usr/sbin/smbd with the necessary args. This way, it's a) trivial to modify parameters on the qemu side (easy to edit just this script), b) possible to see which samba version is in use and adopt some parameters, c) use alternative smbd, and especially d) allow the end-user to override smbd or config in use. The best, I'd say, is to allow to specify the script on qemu command line (like samba=/etc/qemu/run-smbd.sh), and have default value for that, like /usr/share/qemu/run-smbd.sh, which is the default script shipped with qemu. Or maybe let qemu choose to use either the one specified on the command line, /etc/qemu/run-smbd.sh if it exists, or /usr/share/qemu/run-smbd.sh. /mjt ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: Ping 2: [PATCH v2] Allowing setting and overriding parameters in smb.conf 2024-02-18 9:30 ` Michael Tokarev @ 2024-02-18 14:55 ` Henrik Carlqvist 0 siblings, 0 replies; 37+ messages in thread From: Henrik Carlqvist @ 2024-02-18 14:55 UTC (permalink / raw) To: Michael Tokarev; +Cc: hc981, samuel.thibault, qemu-devel On Sun, 18 Feb 2024 12:30:01 +0300 Michael Tokarev <mjt@tls.msk.ru> wrote: > I don't maintain this code, so my email is just a random comment. Thanks for your comment anyway! > But I did have an issue with smbd not working right due to one > missing/wrong parameter or another, more than once. Also, samba > is evolving too, so it might need more parameters or less. During the years, my brute force approach to solve issues like this has been to locally patch qemu source code to build custom qemu binaries with the smb.conf parameters that I want. > My suggestion is still the same as 10+ years ago: to ship a shell script > which run smbd, instead of running smbd directly. This script will set > up smb.conf (whole thing, exactly as it is done now in the C code), and > exec /usr/sbin/smbd with the necessary args. Such a script would be easier to modify than changing the C sources. > This way, it's a) trivial to modify parameters on the qemu side (easy to > edit just this script), b) possible to see which samba version is in use > and adopt some parameters, c) use alternative smbd, and especially d) > allow the end-user to override smbd or config in use. During the years, I have also seen the need to use alternative smbd. I have then solved it by having the old smbd that I prefered for qemu in /usr/sbin and moved the "original" smbd provided by the Linux distribution to /usr/local/sbin where it has been started by any real Samba servers in the network. > The best, I'd say, is to allow to specify the script on qemu command line > (like samba=/etc/qemu/run-smbd.sh), and have default value for that, like > /usr/share/qemu/run-smbd.sh, which is the default script shipped with > qemu. Or maybe let qemu choose to use either the one specified on the > command line, /etc/qemu/run-smbd.sh if it exists, or > /usr/share/qemu/run-smbd.sh. Yes, by specifying such a script on the command line it would be possible to have different parameters for different qemu sessions. However, I think that also my solution allowing settings of samba parameters fixes most of the problems in a way which most of the times will be easier to use. Usually, there is no need to modify more than a handfull of parameters so those extra arguments to the qemu command line will be less to write than a separate script starting samba. In my experience qemu is mostly started from a script with a rather long qemu command line anyway. The remaining problem is when Samba comes with a new version which requires new settings of parameters. Regardless of solution some script will need to be modified to solve that problem. Again, thanks for your comment! I hope that someone will consider my patch or your suggestion. The next thing to look into would be the possibility to start some userspace NFS daemon as an alternative to Samba as Unix-guests works better with NFS than CIFS. However, that would be a much bigger project and I won't dig into such a thing until I have gotten any response on this small patch. regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-04-30 20:55 ` [PATCH v6] " Henrik Carlqvist 2023-06-08 16:14 ` Ping: " Henrik Carlqvist @ 2023-06-08 16:22 ` Daniel P. Berrangé 2023-06-08 18:12 ` Henrik Carlqvist 1 sibling, 1 reply; 37+ messages in thread From: Daniel P. Berrangé @ 2023-06-08 16:22 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel On Sun, Apr 30, 2023 at 10:55:33PM +0200, Henrik Carlqvist wrote: > I have now changed the patch to instead of using the -k switch use > > -global escc.sunkbd_layout= > > to select keyboard layout. It would be nice to somehow document this. Yes, in > the monitor, you can type "info qtree" and see something like: > > dev: escc, id "" > gpio-out "sysbus-irq" 2 > frequency = 4915200 (0x4b0000) > it_shift = 1 (0x1) > bit_swap = false > disabled = 0 (0x0) > chnBtype = 2 (0x2) > chnAtype = 1 (0x1) > chrB = "" > chrA = "" > sunkbd_layout = "43" > mmio 0000000071000000/0000000000000008 > > but that information is not easy to find and it does not say anything about > possible values. What is the best way to document this kind of global > parameters? You can put it in docs/system/sparc.rst (or sparc64.rst whichever is best?) Alternatively create a docs/system/devices/escc.rst and link it from device-emulation.rst > > Please cc me any reply as I am no longer subscribed to the mailing list. > > best regards Henrik > > 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 a command line switch like "-global escc.sunkbd_layout=de" to > select dip switch value. A table is used to lookup values from arguments like: > > -global escc.sunkbd_layout=fr > -global escc.sunkbd_layout=es > > But the patch also accepts numeric dip switch values directly to the -k > switch: > > -global escc.sunkbd_layout=0x2b > -global escc.sunkbd_layout=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 -global escc.sunkbd_layout=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 <hc1245@poolhem.se> > --- > hw/char/escc.c | 81 +++++++++++++++++++++++++++++++++++++++--- > include/hw/char/escc.h | 1 + > 2 files changed, 78 insertions(+), 4 deletions(-) > > diff --git a/hw/char/escc.c b/hw/char/escc.c > index 17a908c59b..0aac4f0f92 100644 > --- a/hw/char/escc.c > +++ b/hw/char/escc.c > @@ -31,6 +31,8 @@ > -static void handle_kbd_command(ESCCChannelState *s, int val) > +static unsigned char sun_keyboard_layout_dip_switch(const char *keyboard_layout) > +{ > + /* 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); Simpify to i < ARRAY_SIZE(languages); at which point you can fit the for(;;) on one line. > + 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; > +} With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-06-08 16:22 ` [PATCH v6] Emulate dip switch language layout settings on SUN keyboard Daniel P. Berrangé @ 2023-06-08 18:12 ` Henrik Carlqvist 2023-06-09 7:50 ` Daniel P. Berrangé 0 siblings, 1 reply; 37+ messages in thread From: Henrik Carlqvist @ 2023-06-08 18:12 UTC (permalink / raw) To: Daniel P. Berrangé; +Cc: mark.cave-ayland, hc1245, qemu-devel On Thu, 8 Jun 2023 17:22:23 +0100 Daniel P. Berrangé <berrange@redhat.com> wrote: > On Sun, Apr 30, 2023 at 10:55:33PM +0200, Henrik Carlqvist wrote: > > What is the best way to document this kind of global parameters? > > You can put it in docs/system/sparc.rst (or sparc64.rst whichever is best?) Thanks for your reply! As far as I know those dip switches are only in the keyboards of the old 32 bit sparc machines, ultrasparc used USB keyboards instead without any dip switches. I will add the text to docs/system/target-sparc.rst. Would you like the documentation as a separate patch or added to the patch which adds the functionality to hw/char/escc.c? I hope to be able to create the patch in the upcoming weekend. Best regards Henrik ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v6] Emulate dip switch language layout settings on SUN keyboard 2023-06-08 18:12 ` Henrik Carlqvist @ 2023-06-09 7:50 ` Daniel P. Berrangé 0 siblings, 0 replies; 37+ messages in thread From: Daniel P. Berrangé @ 2023-06-09 7:50 UTC (permalink / raw) To: Henrik Carlqvist; +Cc: mark.cave-ayland, hc1245, qemu-devel On Thu, Jun 08, 2023 at 08:12:21PM +0200, Henrik Carlqvist wrote: > On Thu, 8 Jun 2023 17:22:23 +0100 > Daniel P. Berrangé <berrange@redhat.com> wrote: > > > On Sun, Apr 30, 2023 at 10:55:33PM +0200, Henrik Carlqvist wrote: > > > What is the best way to document this kind of global parameters? > > > > You can put it in docs/system/sparc.rst (or sparc64.rst whichever is best?) > > Thanks for your reply! As far as I know those dip switches are only in the > keyboards of the old 32 bit sparc machines, ultrasparc used USB keyboards > instead without any dip switches. I will add the text to > docs/system/target-sparc.rst. > > Would you like the documentation as a separate patch or added to the patch > which adds the functionality to hw/char/escc.c? Either way is fine imho, mild perference to have it in the same patch if the docs are reasonably short. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2024-02-18 14:58 UTC | newest] Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-01-07 2:37 [PATCH qemu v3 0/1] [PATCH v3] Emulate dip switch language layout settings on SUN keyboard ~henca 2023-01-06 21:33 ` [PATCH qemu v3 1/1] Emulating sun keyboard language layout dip switches, taking the value for the dip switches from the "-k" option to qemu ~henca 2023-01-10 23:08 ` Mark Cave-Ayland 2023-01-23 19:09 ` [PATCH v5] Emulate dip switch language layout settings on SUN keyboard Henrik Carlqvist 2023-03-04 21:07 ` Henrik Carlqvist 2023-03-28 14:01 ` Daniel P. Berrangé 2023-03-28 17:19 ` Henrik Carlqvist 2023-03-28 17:59 ` Daniel P. Berrangé 2023-03-28 20:16 ` Henrik Carlqvist 2023-04-30 20:55 ` [PATCH v6] " Henrik Carlqvist 2023-06-08 16:14 ` Ping: " Henrik Carlqvist 2023-06-10 7:06 ` Mark Cave-Ayland 2023-06-10 10:29 ` Henrik Carlqvist 2023-06-10 23:47 ` [PATCH v7] " Henrik Carlqvist 2023-06-20 9:22 ` Daniel P. Berrangé 2023-06-20 19:50 ` Henrik Carlqvist 2023-06-21 7:09 ` Daniel P. Berrangé 2023-06-21 18:14 ` Henrik Carlqvist 2023-06-23 18:30 ` [PATCH v8] " Henrik Carlqvist 2023-06-26 9:42 ` Daniel P. Berrangé 2023-06-27 6:33 ` Mark Cave-Ayland 2023-06-27 17:18 ` Henrik Carlqvist 2023-08-01 21:27 ` [PATCH v1] Allowing setting and overriding parameters in smb.conf Henrik Carlqvist 2023-08-02 19:53 ` Samuel Thibault 2023-08-02 23:09 ` Henrik Carlqvist 2023-08-02 23:13 ` Samuel Thibault 2023-08-02 23:26 ` Henrik Carlqvist 2023-08-02 23:34 ` Samuel Thibault 2023-08-03 0:13 ` Henrik Carlqvist 2023-08-03 15:12 ` [PATCH v2] " Henrik Carlqvist 2023-09-10 11:48 ` Ping: " Henrik Carlqvist 2024-02-17 22:28 ` Ping 2: " Henrik Carlqvist 2024-02-18 9:30 ` Michael Tokarev 2024-02-18 14:55 ` Henrik Carlqvist 2023-06-08 16:22 ` [PATCH v6] Emulate dip switch language layout settings on SUN keyboard Daniel P. Berrangé 2023-06-08 18:12 ` Henrik Carlqvist 2023-06-09 7:50 ` Daniel P. Berrangé
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.