From bc1d6700f21955a8477239bfa33a11db0f8917c8 Mon Sep 17 00:00:00 2001 From: grehan Date: Thu, 19 Sep 2013 04:29:03 +0000 Subject: Allow the alarm hours/mins/seconds registers to be read/written, though without any action. This avoids a hypervisor exit when o/s's access these regs (Linux). Reviewed by: neel Approved by: re@ (blanket) --- usr.sbin/bhyve/rtc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'usr.sbin/bhyve') diff --git a/usr.sbin/bhyve/rtc.c b/usr.sbin/bhyve/rtc.c index 05542e7..e2b9f30 100644 --- a/usr.sbin/bhyve/rtc.c +++ b/usr.sbin/bhyve/rtc.c @@ -46,8 +46,11 @@ __FBSDID("$FreeBSD$"); #define IO_RTC 0x70 #define RTC_SEC 0x00 /* seconds */ +#define RTC_SEC_ALARM 0x01 #define RTC_MIN 0x02 +#define RTC_MIN_ALARM 0x03 #define RTC_HRS 0x04 +#define RTC_HRS_ALARM 0x05 #define RTC_WDAY 0x06 #define RTC_DAY 0x07 #define RTC_MONTH 0x08 @@ -94,6 +97,12 @@ static uint8_t rtc_nvram[RTC_NVRAM_SZ]; /* XXX initialize these to default values as they would be from BIOS */ static uint8_t status_a, status_b; +static struct { + uint8_t hours; + uint8_t mins; + uint8_t secs; +} rtc_alarm; + static u_char const bin2bcd_data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, @@ -148,8 +157,11 @@ rtc_addr_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, switch (*eax & 0x7f) { case RTC_SEC: + case RTC_SEC_ALARM: case RTC_MIN: + case RTC_MIN_ALARM: case RTC_HRS: + case RTC_HRS_ALARM: case RTC_WDAY: case RTC_DAY: case RTC_MONTH: @@ -199,6 +211,15 @@ rtc_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, if (in) { switch (addr) { + case RTC_SEC_ALARM: + *eax = rtc_alarm.secs; + break; + case RTC_MIN_ALARM: + *eax = rtc_alarm.mins; + break; + case RTC_HRS_ALARM: + *eax = rtc_alarm.hours; + break; case RTC_SEC: *eax = rtcout(tm.tm_sec); return (0); @@ -266,6 +287,15 @@ rtc_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, case RTC_STATUSD: /* ignore write */ break; + case RTC_SEC_ALARM: + rtc_alarm.secs = *eax; + break; + case RTC_MIN_ALARM: + rtc_alarm.mins = *eax; + break; + case RTC_HRS_ALARM: + rtc_alarm.hours = *eax; + break; case RTC_SEC: case RTC_MIN: case RTC_HRS: -- cgit v1.1