All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Kevin O'Connor <kevin@koconnor.net>
Cc: seabios@seabios.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [SeaBIOS] [RFC PATCH 2/2] serial console, input
Date: Mon, 04 Jul 2016 11:16:45 +0200	[thread overview]
Message-ID: <1467623805.15123.166.camel@redhat.com> (raw)
In-Reply-To: <20160701170739.GB11200@morn.lan>

  Hi,

> > +#define FLAG_CTRL  (1<<0)
> > +#define FLAG_SHIFT (1<<1)
> > +
> > +VARLOW struct {
> > +    u8 flags;
> > +    u8 scancode;
> > +} termchr[256] = {
> > +    [ '1'        ] = { .scancode = 0x02,                      },
> 
> I think this table should be generated at runtime from
> kbd.c:scan_to_keycode[].  Since it doesn't change at runtime,
> malloc_fseg() / GET_GLOBAL() could be used instead of VARLOW.

Ah, ok.  Didn't notice this one can be used for ascii -> scancode
lookups.

I'm wondering whenever it makes sense to build a reverse table.  We
could simply search scan_to_keycode[] instead.  Sure it is slower than a
table lookup, but still _way_ faster than any human can type, and we
would save some real-mode memory.

> Is it necessary to use process_key() here instead of injecting the
> keycode directly with enqueue_key()?

From a brief look at the code I think I can use enqueue_key directly
without anything breaking.  I'll give it a try.

> > +void VISIBLE16
> > +sercon_check_event(void)
> 
> Does this need VISIBLE16?

Don't think so, I'll drop it.

> If I understand correctly, most keys are sent on the serial port as
> single bytes, but there are a few keys that are sent as multi-byte
> sequences.

Yes.  Single-byte us-ascii for letters and numbers.  multibyte sequences
starting with ESC (0x1b) for almost everything else (function keys,
cursor keys, home, end, pageup, pagedown, ...)

The list in the patch isn't complete, I've only added the most important
keys for initial testing.

You may also see input with the 8th bit set, which has a high chance to
be a multibyte sequence (utf8) too these days.  But I think we can
safely ignore any input with the 8th bit set, we can't map that to us
keyboard layout anyway even if we manage to correctly identify the
character typed.

> There's a lot of complexity to implement buffering for
> that unusual case.  I wonder if the buffer could be avoided - I played
> with it a little and came up with the below (totally untested).  I'm
> not sure if it's an improvement.

Hmm, so you avoid the buffer by maintaining an index into termseq and
matched byte count instead.  Hmm.  Yes, avoids the buffer and also a few
cpu cycles because you can continue searching where you left off.  I
find the code flow harder to follow though.

cheers,
  Gerd

  parent reply	other threads:[~2016-07-04  9:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-01 10:54 [Qemu-devel] [RFC PATCH 0/2] seabios: add serial console support Gerd Hoffmann
2016-07-01 10:54 ` [Qemu-devel] [RFC PATCH 1/2] serial console, output Gerd Hoffmann
2016-07-01 15:47   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2016-07-04  8:16     ` Gerd Hoffmann
2016-07-04  9:11       ` [Qemu-devel] " Paolo Bonzini
2016-07-04 12:46         ` Gerd Hoffmann
2016-07-04 12:48           ` Paolo Bonzini
2016-07-04 15:26           ` Kevin O'Connor
2016-07-04 15:45             ` Paolo Bonzini
2016-07-04 20:10               ` Gerd Hoffmann
2016-07-04 16:00             ` Kevin O'Connor
2016-07-04 16:03               ` Paolo Bonzini
2016-07-04 17:28                 ` Kevin O'Connor
2016-07-04 20:18                   ` Gerd Hoffmann
2016-07-04 20:23             ` Gerd Hoffmann
2016-07-01 10:54 ` [Qemu-devel] [RFC PATCH 2/2] serial console, input Gerd Hoffmann
2016-07-01 17:07   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2016-07-01 18:07     ` Kevin O'Connor
2016-07-04  9:16     ` Gerd Hoffmann [this message]
2016-07-04 15:34       ` Kevin O'Connor
2016-07-04 20:03         ` Gerd Hoffmann
2016-07-01 15:47 ` [Qemu-devel] [RFC PATCH 0/2] seabios: add serial console support Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467623805.15123.166.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.