Use a block cursor on VGA console :-)
[coreboot.git] / payloads / libpayload / i386 / timer.c
index a7876460735fb70683ae8012f57562eb0eeb3d81..e1a886e3022435b04e0b10bd7eb7c8bd86e2bea0 100644 (file)
  * SUCH DAMAGE.
  */
 
+/**
+ * @file i386/timer.c
+ * i386 specific timer routines
+ */
+
 #include <libpayload.h>
 #include <arch/rdtsc.h>
 
-static unsigned int cpu_khz;
+/**
+ * @ingroup arch
+ * Global variable containing the speed of the processor in KHz.
+ */
+u32 cpu_khz;
 
 /**
  * Calculate the speed of the processor for use in delays.
@@ -57,11 +66,13 @@ unsigned int get_cpu_speed(void)
        end = rdtsc();
 
        /*
-        * The clock rate is 1193180 Hz, the number of miliseconds for a
+        * The clock rate is 1193180 Hz, the number of milliseconds for a
         * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
         * Multiply that by the number of measured clocks to get the kHz value.
         */
        cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
+
+       return cpu_khz;
 }
 
 static inline void _delay(unsigned int delta)
@@ -70,16 +81,41 @@ static inline void _delay(unsigned int delta)
        while (rdtsc() < timeout) ;
 }
 
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param n Number of nanoseconds to delay for.
+ */
 void ndelay(unsigned int n)
 {
        _delay(n * cpu_khz / 1000000);
 }
 
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param n Number of microseconds to delay for.
+ */
+void udelay(unsigned int n)
+{
+       _delay(n * cpu_khz / 1000);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param m Number of milliseconds to delay for.
+ */
 void mdelay(unsigned int m)
 {
        _delay(m * cpu_khz);
 }
 
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
 void delay(unsigned int s)
 {
        _delay(s * cpu_khz * 1000);