diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2008-03-20 19:54:59 +0000 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2008-03-20 19:54:59 +0000 |
commit | 6a441bfb46337ed6b59abed56dad35d94802282c (patch) | |
tree | 44eb1d67fcbc450907472186bbc0036afe9e380c /payloads/libpayload/i386/timer.c | |
parent | 5f4c8abb6537fa7377969e837dab987abefcf922 (diff) | |
download | coreboot-6a441bfb46337ed6b59abed56dad35d94802282c.tar.xz |
Cosmetics, coding style fixes (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3180 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/i386/timer.c')
-rw-r--r-- | payloads/libpayload/i386/timer.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/payloads/libpayload/i386/timer.c b/payloads/libpayload/i386/timer.c index 852cbe6c03..a787646073 100644 --- a/payloads/libpayload/i386/timer.c +++ b/payloads/libpayload/i386/timer.c @@ -32,53 +32,47 @@ static unsigned int cpu_khz; -/* Calculate the speed of the processor for use in delays */ - +/** + * Calculate the speed of the processor for use in delays. + * + * @return The CPU speed in kHz. + */ unsigned int get_cpu_speed(void) { unsigned long long start, end; - /* Set up the PPC port - disable the speaker, - * enable the T2 gate */ - + /* Set up the PPC port - disable the speaker, enable the T2 gate. */ outb((inb(0x61) & ~0x02) | 0x01, 0x61); - /* Set the PIT to Mode 0, counter 2, word access */ + /* Set the PIT to Mode 0, counter 2, word access. */ outb(0xB0, 0x43); - /* Load the counter with 0xFFFF */ - - outb(0xFF, 0x42); - outb(0xFF, 0x42); - - /* Read the number of ticks during the period */ + /* Load the counter with 0xffff. */ + outb(0xff, 0x42); + outb(0xff, 0x42); + /* Read the number of ticks during the period. */ start = rdtsc(); - while(!(inb(0x61) & 0x20)); + while (!(inb(0x61) & 0x20)) ; end = rdtsc(); - /* The clock rate is 1193180 Hz - * the number of miliseconds 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)); + /* + * The clock rate is 1193180 Hz, the number of miliseconds 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)); } -/* Global delay functions */ - static inline void _delay(unsigned int delta) { unsigned long long timeout = rdtsc() + delta; - while (rdtsc() < timeout); + while (rdtsc() < timeout) ; } void ndelay(unsigned int n) { - _delay(n * cpu_khz / 1000000); + _delay(n * cpu_khz / 1000000); } void mdelay(unsigned int m) |