diff mbox series

[v2,4/5] bios_emulator: support 16-bit reads on VGA port

Message ID 20261003-aspeed_vbios_fixes-v2-4-f8e593f024ab@oss.tenstorrent.com
State New
Delegated to: Tom Rini
Headers show
Series [v2,1/5] bios_emulator: select X86EMU_RAW_IO only on x86 | expand

Commit Message

Anirudh Srinivasan Oct. 3, 2026, 8:07 p.m. UTC
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 two 8-bit reads
(similar to how BE_outw implements 16-bit writes).

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 <asrinivasan@oss.tenstorrent.com>
---
 drivers/bios_emulator/besys.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/bios_emulator/besys.c b/drivers/bios_emulator/besys.c
index e02c9fc636c..76a05e74f55 100644
--- 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 = BE_inb(port) | ((u16)BE_inb(port + 1) << 8);
+	else if (IS_PCI_PORT(port))
 		val = PCI_inp(port, REG_READ_WORD);
 	else if (port < 0x100) {
 		DB(printf("WARN: Maybe INVALID inw.%04X -> %04X\n", (u16) port, val);)