* rework tsc based timer code to use inb instead of outb for calibration
[coreboot.git] / src / cpu / x86 / tsc / delay_tsc.c
index c7c431baacc4dc3d9dfcac3e1653306a005b73dd..72b1f7196c0638e5e8edaeafeca1f6b7e9d1b6d4 100644 (file)
@@ -102,14 +102,14 @@ bad_ctc:
 static unsigned long long calibrate_tsc(void)
 {
        unsigned long long start, end, delta;
-       unsigned long allones = (unsigned long) -1, result;
-       unsigned long count;
+       unsigned long result, count;
        
+       printk_spew("Calibrating delay loop...\n");
        start = rdtscll();
-       // no udivdi3, dammit.
+       // no udivdi3 because we don't like libgcc. (only in x86emu)
        // so we count to 1<< 20 and then right shift 20
        for(count = 0; count < (1<<20); count ++)
-               outb(0x80, 0x80);
+               inb(0x80);
        end = rdtscll();
 
 #if 0
@@ -128,11 +128,12 @@ static unsigned long long calibrate_tsc(void)
        delta >>= 20;
        // save this for microsecond timing.
        result = delta;
-       printk_spew("end %x:%x, start %x:%x\n",
-               endhigh, endlow, starthigh, startlow);
-       printk_spew("32-bit delta %d\n", (unsigned long) delta);
+       printk_spew("end %llx, start %llx\n", end, start);
+       printk_spew("32-bit delta %ld\n", (unsigned long) delta);
        
-       printk_spew(__FUNCTION__ " 32-bit result is %d\n", result);
+       printk_spew("%s 32-bit result is %ld\n",
+                       __func__,
+                       result);
        return delta;
 }
 
@@ -143,7 +144,7 @@ void init_timer(void)
 {
        if (!clocks_per_usec) {
                clocks_per_usec = calibrate_tsc();
-               printk_info("clocks_per_usec: %u\n", clocks_per_usec);
+               printk_info("clocks_per_usec: %lu\n", clocks_per_usec);
        }
 }