From d741ef36c83f9fcee2670a773f94e955f2d64b1b Mon Sep 17 00:00:00 2001 From: stefan Date: Wed, 24 Nov 2010 18:58:42 +0000 Subject: [PATCH] - now, get_cpu_frequency returns MHz instead of Hz - more suitable for future architecture git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@266 315a16e6-25f9-4109-90ae-ca3045a26c18 --- kernel/main.c | 2 +- kernel/processor.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 02ab5ab3..880899e7 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -162,7 +162,7 @@ int main(void) system_calibration(); - kprintf("Processor frequency: %u MHz\n", get_cpu_frequency()/1000000); + kprintf("Processor frequency: %u MHz\n", get_cpu_frequency()); kprintf("Total memory: %u MBytes\n", atomic_int32_read(&total_pages)/((1024*1024)/PAGE_SIZE)); kprintf("Current allocated memory: %u KBytes\n", atomic_int32_read(&total_allocated_pages)*(PAGE_SIZE/1024)); kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE)); diff --git a/kernel/processor.c b/kernel/processor.c index 98d2a001..d97f9e86 100644 --- a/kernel/processor.c +++ b/kernel/processor.c @@ -36,12 +36,12 @@ uint32_t detect_cpu_frequency(void) ; start = rdtsc(); - /* wait 5 time slices to determine the frequency */ + /* wait a second to determine the frequency */ while(get_clock_tick() - ticks < TIMER_FREQ) ; end = rdtsc(); - cpu_freq = (uint32_t) (end - start); + cpu_freq = (uint32_t) ((end - start) / (uint64_t) 1000000); return cpu_freq; } @@ -57,7 +57,7 @@ uint32_t get_cpu_frequency(void) void udelay(unsigned int usecs) { uint64_t start = rdtsc(); - uint64_t deadline = (get_cpu_frequency()*usecs)/1000000; + uint64_t deadline = get_cpu_frequency() * usecs; while(rdtsc() - start < deadline) ;