Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Feb 2006 06:57:12 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 90915 for review
Message-ID:  <200602020657.k126vC1R048633@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=90915

Change 90915 by kmacy@kmacy:freebsd7_xen3 on 2006/02/02 06:56:43

	enable INITDOMAIN and PHYSDEV_ACCESS by default
	fix compile-time errors
	fix errors caused by running as domU with this set

Affected files ...

.. //depot/projects/xen3/src/sys/i386-xen/conf/XENCONF#5 edit
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#10 edit
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#9 edit
.. //depot/projects/xen3/src/sys/i386/i386/bios.c#3 edit

Differences ...

==== //depot/projects/xen3/src/sys/i386-xen/conf/XENCONF#5 (text+ko) ====

@@ -144,6 +144,8 @@
 
 #options		BOOTP
 options		XEN
+options		XEN_PHYSDEV_ACCESS
+options		XEN_PRIVILEGED_GUEST 
 options		MCLSHIFT=12	# this has to be enabled for Xen as we can only have one cluster per page
 options		MSIZE=256 
 options 	DIAGNOSTIC

==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#10 (text+ko) ====

@@ -109,6 +109,8 @@
 #define	RTC_UNLOCK	mtx_unlock_spin(&clock_lock)
 
 static	const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
+static  u_char  rtc_statusb = RTCSB_24HR;
+
 
 /* Values for timerX_state: */
 #define	RELEASED	0
@@ -517,6 +519,111 @@
 	rdtscll(alarm);
 }
 
+/*
+ * RTC support routines
+ */
+
+int
+rtcin(reg)
+	int reg;
+{
+	u_char val;
+
+	RTC_LOCK;
+	outb(IO_RTC, reg);
+	inb(0x84);
+	val = inb(IO_RTC + 1);
+	inb(0x84);
+	RTC_UNLOCK;
+	return (val);
+}
+
+static __inline void
+writertc(u_char reg, u_char val)
+{
+
+	RTC_LOCK;
+	inb(0x84);
+	outb(IO_RTC, reg);
+	inb(0x84);
+	outb(IO_RTC + 1, val);
+	inb(0x84);		/* XXX work around wrong order in rtcin() */
+	RTC_UNLOCK;
+}
+
+static __inline int
+readrtc(int port)
+{
+	return(bcd2bin(rtcin(port)));
+}
+
+
+/*
+ * Initialize the time of day register, based on the time base which is, e.g.
+ * from a filesystem.
+ */
+static void
+domu_inittodr(time_t base)
+{
+	unsigned long   sec;
+	int		s, y;
+	struct timespec ts;
+
+	update_wallclock();
+	
+	s = splclock();
+	if (base) {
+		ts.tv_sec = base;
+		ts.tv_nsec = 0;
+		tc_setclock(&ts);
+	}
+
+	sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
+
+	y = time_second - shadow_tv.tv_sec;
+	if (y <= -2 || y >= 2) {
+		/* badly off, adjust it */
+		tc_setclock(&shadow_tv);
+	}
+	splx(s);
+}
+
+/*
+ * Write system time back to RTC.  
+ */
+static void
+domu_resettodr(void)
+{
+	unsigned long tm;
+	int s;
+	dom0_op_t op;
+	struct shadow_time_info *shadow;
+
+	shadow = &per_cpu(shadow_time, smp_processor_id());
+	if (disable_rtc_set)
+		return;
+	
+	s = splclock();
+	tm = time_second;
+	splx(s);
+	
+	tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
+	
+	if ((xen_start_info->flags & SIF_INITDOMAIN) &&
+	    !independent_wallclock)
+	{
+		op.cmd = DOM0_SETTIME;
+		op.u.settime.secs        = tm;
+		op.u.settime.nsecs       = 0;
+		op.u.settime.system_time = shadow->system_timestamp;
+		HYPERVISOR_dom0_op(&op);
+		update_wallclock();
+	} else if (independent_wallclock) {
+		/* notyet */
+		;
+	}		
+}
+
 #ifdef XEN_PRIVILEGED_GUEST
 /*
  * Initialize the time of day register, based on the time base which is, e.g.
@@ -530,6 +637,11 @@
 	int		y, m, s;
 	struct timespec ts;
 
+	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
+	        domu_inittodr(base);
+		return;
+	}
+
 	if (base) {
 		s = splclock();
 		ts.tv_sec = base;
@@ -605,6 +717,11 @@
 	unsigned long	tm;
 	int		y, m, s;
 
+	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
+	        domu_resettodr();
+		return;
+	}
+	       
 	if (disable_rtc_set)
 		return;
 
@@ -654,113 +771,9 @@
 	rtcin(RTC_INTR);
 }
 
-#else
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
-	unsigned long   sec;
-	int		s, y;
-	struct timespec ts;
-
-	update_wallclock();
-	
-	s = splclock();
-	if (base) {
-		ts.tv_sec = base;
-		ts.tv_nsec = 0;
-		tc_setclock(&ts);
-	}
-
-	sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
-	y = time_second - shadow_tv.tv_sec;
-	if (y <= -2 || y >= 2) {
-		/* badly off, adjust it */
-		tc_setclock(&shadow_tv);
-	}
-	splx(s);
-}
-
-/*
- * Write system time back to RTC.  
- */
-void
-resettodr()
-{
-	unsigned long tm;
-	int s;
-	dom0_op_t op;
-	struct shadow_time_info *shadow;
-
-	shadow = &per_cpu(shadow_time, smp_processor_id());
-	if (disable_rtc_set)
-		return;
-	
-	s = splclock();
-	tm = time_second;
-	splx(s);
-	
-	tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-	
-	if ((xen_start_info->flags & SIF_INITDOMAIN) &&
-	    !independent_wallclock)
-	{
-		op.cmd = DOM0_SETTIME;
-		op.u.settime.secs        = tm;
-		op.u.settime.nsecs       = 0;
-		op.u.settime.system_time = shadow->system_timestamp;
-		HYPERVISOR_dom0_op(&op);
-		update_wallclock();
-	} else if (independent_wallclock) {
-		/* notyet */
-		;
-	}		
-}
 #endif
 
 
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
-	int reg;
-{
-	u_char val;
-
-	RTC_LOCK;
-	outb(IO_RTC, reg);
-	inb(0x84);
-	val = inb(IO_RTC + 1);
-	inb(0x84);
-	RTC_UNLOCK;
-	return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
-
-	RTC_LOCK;
-	inb(0x84);
-	outb(IO_RTC, reg);
-	inb(0x84);
-	outb(IO_RTC + 1, val);
-	inb(0x84);		/* XXX work around wrong order in rtcin() */
-	RTC_UNLOCK;
-}
-
-static __inline int
-readrtc(int port)
-{
-	return(bcd2bin(rtcin(port)));
-}
-
 int
 acquire_timer2(int mode)
 {

==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#9 (text+ko) ====

@@ -1695,20 +1695,22 @@
 	 * this will panic with the current bootmem allocator - still need to
 	 * figure out how little I can get away with there
 	 */
+	if (xen_start_info->flags & SIF_INITDOMAIN) {
 	map = bootmem_alloc(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_may = map;
+	op.u.physical_memory_map.memory_map = map;
 	op.u.physical_memory_map.max_map_entries = 
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
-	PANIC_IF(HYPERVISOR_dom0_op(&ap));
+	PANIC_IF(HYPERVISOR_dom0_op(&op));
 	
 	last = 0x100000000ULL;
 	gapstart = 0x10000000;
 	gapsize = 0x400000;
 
 	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
+#if 0
 		struct resource *res;
-
+#endif
 		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
 			gapsize = last - map[i].end;
 			gapstart = map[i].end;
@@ -1749,8 +1751,9 @@
 	printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
 		pci_mem_start, gapstart, gapsize);
 #endif
+	}
 
-#elif defined(XEN)
+#if defined(XEN)
 	Maxmem = xen_start_info->nr_pages - init_first;
 	pmap_bootstrap((init_first << PAGE_SHIFT), 0);
 	for (i = 0; i < 10; i++)
@@ -1762,7 +1765,7 @@
 	phys_avail[1] = avail_end;
 	return;
 #endif
-
+#endif
 	hasbrokenint12 = 0;
 	TUNABLE_INT_FETCH("hw.hasbrokenint12", &hasbrokenint12);
 	bzero(&vmf, sizeof(vmf));

==== //depot/projects/xen3/src/sys/i386/i386/bios.c#3 (text+ko) ====

@@ -83,8 +83,9 @@
     int				i;
     char			*p;
     
-#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
-    return;
+#if defined(XEN)
+    if (!(xen_start_info->flags & SIF_INITDOMAIN))
+        return;
 #endif
     /*
      * BIOS32 Service Directory, PCI BIOS



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