diff mbox series

[4/4] serial: Allow unaligned i/o access

Message ID 20220906194755.98090-5-arwed.meyer@gmx.de
State New
Headers show
Series Make serial msmouse work | expand

Commit Message

Arwed Meyer Sept. 6, 2022, 7:47 p.m. UTC
Unaligned i/o access on serial UART works on real PCs.
This is used for example by FreeDOS CTMouse driver. Without this it
can't reset and detect serial mice.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/77
Signed-off-by: Arwed Meyer <arwed.meyer@gmx.de>
---
 hw/char/serial.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.34.1

Comments

Marc-André Lureau Sept. 8, 2022, 10:11 a.m. UTC | #1
Hi

On Wed, Sep 7, 2022 at 2:03 AM Arwed Meyer <arwed.meyer@gmx.de> wrote:

> Unaligned i/o access on serial UART works on real PCs.
> This is used for example by FreeDOS CTMouse driver. Without this it
> can't reset and detect serial mice.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/77
> Signed-off-by: Arwed Meyer <arwed.meyer@gmx.de>
> ---
>  hw/char/serial.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index 7061aacbce..41b5e61977 100644
> --- a/hw/char/serial.c
> +++ b/hw/char/serial.c
> @@ -961,6 +961,9 @@ void serial_set_frequency(SerialState *s, uint32_t
> frequency)
>  const MemoryRegionOps serial_io_ops = {
>      .read = serial_ioport_read,
>      .write = serial_ioport_write,
> +    .valid = {
> +        .unaligned = 1,
> +    },
>

I don't get how this can help if both min_access_size & max_access_size are
1.


>      .impl = {
>          .min_access_size = 1,
>          .max_access_size = 1,
> --
> 2.34.1
>
>
>
Michael S. Tsirkin Sept. 8, 2022, 11:15 a.m. UTC | #2
On Thu, Sep 08, 2022 at 02:11:28PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Sep 7, 2022 at 2:03 AM Arwed Meyer <arwed.meyer@gmx.de> wrote:
> 
>     Unaligned i/o access on serial UART works on real PCs.
>     This is used for example by FreeDOS CTMouse driver. Without this it
>     can't reset and detect serial mice.
> 
>     Resolves: https://gitlab.com/qemu-project/qemu/-/issues/77
>     Signed-off-by: Arwed Meyer <arwed.meyer@gmx.de>
>     ---
>      hw/char/serial.c | 3 +++
>      1 file changed, 3 insertions(+)
> 
>     diff --git a/hw/char/serial.c b/hw/char/serial.c
>     index 7061aacbce..41b5e61977 100644
>     --- a/hw/char/serial.c
>     +++ b/hw/char/serial.c
>     @@ -961,6 +961,9 @@ void serial_set_frequency(SerialState *s, uint32_t
>     frequency)
>      const MemoryRegionOps serial_io_ops = {
>          .read = serial_ioport_read,
>          .write = serial_ioport_write,
>     +    .valid = {
>     +        .unaligned = 1,
>     +    },
> 
> 
> I don't get how this can help if both min_access_size & max_access_size are 1.
>  
> 
>          .impl = {
>              .min_access_size = 1,
>              .max_access_size = 1,
>     --
>     2.34.1


Because that's .impl. If access is invalid we don't get as far
as breaking it up to chunks.

> 
> 
> 
> 
> --
> Marc-André Lureau
Arwed Meyer Sept. 8, 2022, 5:19 p.m. UTC | #3
Am 08.09.22 um 13:15 schrieb Michael S. Tsirkin:
> On Thu, Sep 08, 2022 at 02:11:28PM +0400, Marc-André Lureau wrote:
>> Hi
>>
>> On Wed, Sep 7, 2022 at 2:03 AM Arwed Meyer <arwed.meyer@gmx.de> wrote:
>>
>>      Unaligned i/o access on serial UART works on real PCs.
>>      This is used for example by FreeDOS CTMouse driver. Without this it
>>      can't reset and detect serial mice.
>>
>>      Resolves: https://gitlab.com/qemu-project/qemu/-/issues/77
>>      Signed-off-by: Arwed Meyer <arwed.meyer@gmx.de>
>>      ---
>>       hw/char/serial.c | 3 +++
>>       1 file changed, 3 insertions(+)
>>
>>      diff --git a/hw/char/serial.c b/hw/char/serial.c
>>      index 7061aacbce..41b5e61977 100644
>>      --- a/hw/char/serial.c
>>      +++ b/hw/char/serial.c
>>      @@ -961,6 +961,9 @@ void serial_set_frequency(SerialState *s, uint32_t
>>      frequency)
>>       const MemoryRegionOps serial_io_ops = {
>>           .read = serial_ioport_read,
>>           .write = serial_ioport_write,
>>      +    .valid = {
>>      +        .unaligned = 1,
>>      +    },
>>
>>
>> I don't get how this can help if both min_access_size & max_access_size are 1.
>>
>>
>>           .impl = {
>>               .min_access_size = 1,
>>               .max_access_size = 1,
>>      --
>>      2.34.1
>
>
> Because that's .impl. If access is invalid we don't get as far
> as breaking it up to chunks.
>
>>
>>
>>
>>
>> --
>> Marc-André Lureau
>
Exactly. Not really knowing the serial/chardev code much it took me a
while to figure out why calling FreeDOS CTMouse/protocol.com would never
execute the ioctl mouse reset code in msmouse.c.
diff mbox series

Patch

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 7061aacbce..41b5e61977 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -961,6 +961,9 @@  void serial_set_frequency(SerialState *s, uint32_t frequency)
 const MemoryRegionOps serial_io_ops = {
     .read = serial_ioport_read,
     .write = serial_ioport_write,
+    .valid = {
+        .unaligned = 1,
+    },
     .impl = {
         .min_access_size = 1,
         .max_access_size = 1,