Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Sep 2013 04:29:04 +0000 (UTC)
From:      Peter Grehan <grehan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255689 - head/usr.sbin/bhyve
Message-ID:  <201309190429.r8J4T4nZ092865@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: grehan
Date: Thu Sep 19 04:29:03 2013
New Revision: 255689
URL: http://svnweb.freebsd.org/changeset/base/255689

Log:
  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)

Modified:
  head/usr.sbin/bhyve/rtc.c

Modified: head/usr.sbin/bhyve/rtc.c
==============================================================================
--- head/usr.sbin/bhyve/rtc.c	Thu Sep 19 04:20:18 2013	(r255688)
+++ head/usr.sbin/bhyve/rtc.c	Thu Sep 19 04:29:03 2013	(r255689)
@@ -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 
 
 	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 
 
 	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 
 	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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309190429.r8J4T4nZ092865>