Hi Anirudh,

On 2026-07-19T18:03:31, Anirudh Srinivasan
<[email protected]> wrote:
> bios_emulator: support 16-bit reads on VGA port
>
> BE_inw currently doesn't handle 16 bit reads on VGA ports and falls back
> to LOG_inpw, which doesn't do anything on non x86 architectures that
> don't support I/O ports. Implement this 16 bit read as 2 8 bit reads
> (similar to how BE_outw implements 16 bit writes).

Nit: '16-bit', '8-bit', 'non-x86', and 'two 8-bit reads' reads better
than '2 8 bit reads'.

>
> The Aspeed AST2600's VBIOS has these 16 bit read instructions in it, so
> this is needed to emulate that.
>
> Signed-off-by: Anirudh Srinivasan <[email protected]>
>
> drivers/bios_emulator/besys.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

> diff --git a/drivers/bios_emulator/besys.c b/drivers/bios_emulator/besys.c
> @@ -612,7 +612,9 @@ u16 X86API BE_inw(X86EMU_pioAddr port)
>       u16 val = 0;
>
>  #if !defined(CONFIG_X86EMU_RAW_IO)
> -     if (IS_PCI_PORT(port))
> +     if (IS_VGA_PORT(port))
> +             val = VGA_inpb(port) | ((u16)VGA_inpb(port + 1) << 8);
> +     else if (IS_PCI_PORT(port))

BE_inb() has a special case for port 0x3c3 that falls back to
LOG_inpb() rather than VGA_inpb(). Calling VGA_inpb() directly here
skips that quirk when a 16-bit read straddles 0x3c2/0x3c3. Cleaner as:

    val = BE_inb(port) | ((u16)BE_inb(port + 1) << 8);

so the 0x3c3 handling stays in one place. That also mirrors the fact
that BE_outw()/VGA_outpb() have no such special case, whereas BE_inb()
does.

Regards,
Simon

Reply via email to