Struggling with VirtualBox

Michael Neumann mneumann at ntecs.de
Wed Dec 3 09:57:14 PST 2008


Hi,

I'm still trying to get DragonFly reliably working on VirtualBox (just because Qemu on my Ubuntu doesn't like to run with the
accelerator kqemu).
So I modified DELAY to break out if delta <= 0. Together with acpi_load=YES I can boot, but:

  - When I boot for the first time ("turn power on"), pressing a key in the boot menu (the "1. Boot DragonFly [default]" ... "7. Reboot" menu)
    will freeze the system.
  - Or if I let the countdown timer pass, it will just execute for a very show while to then begin to spin in DELAY with delta=0
    and ticks_left=2 [1].
  - If I now reset the system, the boot menu works (pressing a key doesn't freeze the system anymore). And I can also boot into DragonFly.

The patch I am using is appended. I am thankful for any hints or further suggestions what the reason for this strange behaviour could be!
Also note that the clock calibration returns a difference of more than 1%.
Matt, you suggested a while ago, to use the APIC timer and get completely rid of the 8254 timer. If you could give me a starting point
I'd like to try that out. At least I can now boot and successuflly compile a kernel in VirtualBox, which is a big help in testing things
out.
Regards,

  Michael

[1]: Notice that I only break the loop while in startrtclock(). At the end of this function, I reset cold_delay_timer to 0.


diff --git a/sys/platform/pc32/isa/clock.c b/sys/platform/pc32/isa/clock.c
index f02333d..170a240 100644
--- a/sys/platform/pc32/isa/clock.c
+++ b/sys/platform/pc32/isa/clock.c
@@ -152,6 +152,8 @@ static struct cputimer	i8254_cputimer = {
     0, 0, 0
 };
 
+static int cold_delay_timer = 1;
+
 /*
  * timer0 clock interrupt.  Timer0 is in one-shot mode and has stopped
  * counting as of this interrupt.  We use timer1 in free-running mode (not
@@ -415,8 +417,18 @@ DODELAY(int n, int doswitch)
 #endif
 		delta = tick - prev_tick;
 		prev_tick = tick;
-		if (delta < 0)
+
+		if (delta <= 0) {
+			/* break delay loop during early boot as
+			   the timer might not be correctly working */
+			if (cold_delay_timer) {
+				break;
+			} else {
+				kprintf("delta: %d, ticks_left: %d\n",
+					delta, ticks_left);
+			}
 			delta = 0;
+		}
 		ticks_left -= delta;
 		if (doswitch && ticks_left > 0)
 			lwkt_switch();
@@ -600,6 +612,7 @@ fail:
 static void
 i8254_restore(void)
 {
+	kprintf("i8254_restore\n");
 	timer0_state = ACQUIRED;
 
 	clock_lock();
@@ -794,6 +807,11 @@ startrtclock(void)
 #endif
 	}
 
+	/* Timer should now work correctly! */
+	cold_delay_timer = 0;
+	//if (bootverbose)
+		kprintf("cold_delay_timer -> 0\n");
+
 	EVENTHANDLER_REGISTER(shutdown_post_sync, resettodr_on_shutdown, NULL, SHUTDOWN_PRI_LAST);
 
 #if !defined(SMP)




More information about the Kernel mailing list