Hi Anirudh, On 2026-07-19T18:03:31, Anirudh Srinivasan <[email protected]> wrote: > bios_emulator: extend VGA I/O ports to include ports 0x3B4-0x3DA > > The IS_VGA_PORT macro currently doesn't cover the 0x3B4, 0x3B5 and 0x3BA > I/O ports. Reads/writes to this currently fall through to LOG_inpb/outb > which are unimplemented on non x86 architectures (which don't support > I/O ports). > > Add these ports to the IS_VGA_PORT macro, and implement reads/writes to > these ports. 0x3B4 and 0x3B5 are mirrors of 0x3D4 and 0x3D5 that are > used in monochrome mode (bit 0 of 0x3C2 is not set). Implement these > with the same logic and env state as 0x3D4/0x3D5, but with the bit check > condition for 0x3C2 flipped. 0x3BA is a mirror of 0x3DA, so the > implementation for this falls back to the same logic as 0x3DA. > > The Aspeed AST2600's VBIOS uses these I/O ports, and these changes are > needed for it's VBIOS to run. > > Signed-off-by: Anirudh Srinivasan <[email protected]> > > drivers/bios_emulator/besys.c | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-)
> diff --git a/drivers/bios_emulator/besys.c b/drivers/bios_emulator/besys.c > @@ -249,7 +249,7 @@ void X86API BE_wrl(u32 addr, u32 val) > #define IS_TIMER_PORT(port) (0x40 <= port && port <= 0x43) > #define IS_CMOS_PORT(port) (0x70 <= port && port <= 0x71) > /*#define IS_VGA_PORT(port) (_BE_env.emulateVGA && 0x3C0 <= port && port > <= 0x3DA)*/ > -#define IS_VGA_PORT(port) (0x3C0 <= port && port <= 0x3DA) > +#define IS_VGA_PORT(port) (0x3B4 <= port && port <= 0x3DA) This also swallows 0x3b6..0x3b9 and 0x3bb..0x3bf, which are not VGA ports (0x3bc-0x3bf is the LPT1 range on legacy PCs). Any access to those from the VBIOS will silently return 0xff from VGA_inpb() rather than falling through to the real inpb/outb path. Probably harmless here, but please mention it in the commit message. Also update or remove the stale commented-out line just above. > diff --git a/drivers/bios_emulator/besys.c b/drivers/bios_emulator/besys.c > @@ -270,6 +270,18 @@ static u8 VGA_inpb (const int port) > + /* > + * 3B4 and 3B5 are mirrors of 3D4 and 3D5 that are used in > + * monochrome mode (i.e bit 0 of 3C2 is not set) > + */ > + case 0x3B4: > + if (!(_BE_env.emu3C2 & 0x1)) > + return _BE_env.emu3D4; > + break; > + case 0x3B5: > + if (!(_BE_env.emu3C2 & 0x1) && (_BE_env.emu3D4 < CRT_C)) > + return _BE_env.emu3D5[_BE_env.emu3D4]; > + break; Please use 'i.e.' with a trailing period and a comma after it. Also, the outpb() side adds 0x3b4/0x3b5 but not 0x3ba - consistent with the existing code (no 0x3da write handler), so no change needed, but please call this out in the commit message. Regards, Simon
