]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools, rtc: Nonvolatile BIOS memory support
authorPekka Enberg <penberg@kernel.org>
Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)
committerPekka Enberg <penberg@kernel.org>
Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)
This adds a ->cmos_data array to 'struct rtc_device' that is used to emulate
nonvolatile BIOS memory and the RTC registers.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/hw/rtc.c

index 0dc6223832e091bbc2b93e22e3c3b27d3f7a3ce5..6d4a05af7029838c4889d3afce2dde92920b3c15 100644 (file)
@@ -26,6 +26,7 @@
 
 struct rtc_device {
        u8                      cmos_idx;
+       u8                      cmos_data[128];
 };
 
 static struct rtc_device       rtc;
@@ -66,6 +67,9 @@ static bool cmos_ram_data_in(struct ioport *ioport, struct kvm *kvm, u16 port, v
        case RTC_YEAR:
                ioport__write8(data, bin2bcd(tm->tm_year));
                break;
+       default:
+               ioport__write8(data, rtc.cmos_data[rtc.cmos_idx]);
+               break;
        }
 
        return true;
@@ -73,6 +77,16 @@ static bool cmos_ram_data_in(struct ioport *ioport, struct kvm *kvm, u16 port, v
 
 static bool cmos_ram_data_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size)
 {
+       switch (rtc.cmos_idx) {
+       case RTC_REG_C:
+       case RTC_REG_D:
+               /* Read-only */
+               break;
+       default:
+               rtc.cmos_data[rtc.cmos_idx] = ioport__read8(data);
+               break;
+       }
+
        return true;
 }