From cfb8234face2dbd1edfa300ddb531db9c1bdeb3d Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 24 Feb 2012 20:20:16 +0200 Subject: [PATCH] kvm tools: Fast A20 gate emulation Add simple "fast A20 gate" PS/2 system control port emulation for SeaBIOS that probes the port. As A20 gate is always enabled under KVM, ignore writes to the port and report back that the gate is enabled. Signed-off-by: Pekka Enberg --- tools/kvm/x86/ioport.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/kvm/x86/ioport.c b/tools/kvm/x86/ioport.c index e35d0ee93186..824ef257cdb5 100644 --- a/tools/kvm/x86/ioport.c +++ b/tools/kvm/x86/ioport.c @@ -46,6 +46,25 @@ static struct ioport_operations dummy_write_only_ioport_ops = { .io_out = dummy_io_out, }; +/* + * The "fast A20 gate" + */ + +static bool ps2_control_a_io_in(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size) +{ + /* + * A20 is always enabled. + */ + ioport__write8(data, 0x02); + + return true; +} + +static struct ioport_operations ps2_control_a_ops = { + .io_in = ps2_control_a_io_in, + .io_out = dummy_io_out, +}; + void ioport__setup_arch(struct kvm *kvm) { /* Legacy ioport setup */ @@ -56,6 +75,9 @@ void ioport__setup_arch(struct kvm *kvm) /* PORT 0040-005F - PIT - PROGRAMMABLE INTERVAL TIMER (8253, 8254) */ ioport__register(kvm, 0x0040, &dummy_read_write_ioport_ops, 4, NULL); + /* 0092 - PS/2 system control port A */ + ioport__register(kvm, 0x0092, &ps2_control_a_ops, 1, NULL); + /* 0x00A0 - 0x00AF - 8259A PIC 2 */ ioport__register(kvm, 0x00A0, &dummy_read_write_ioport_ops, 2, NULL); -- 2.39.5