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>
struct rtc_device {
u8 cmos_idx;
+ u8 cmos_data[128];
};
static struct rtc_device rtc;
case RTC_YEAR:
ioport__write8(data, bin2bcd(tm->tm_year));
break;
+ default:
+ ioport__write8(data, rtc.cmos_data[rtc.cmos_idx]);
+ break;
}
return true;
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;
}