diff options
author | Regina König | 2021-04-21 14:42:48 +0200 |
---|---|---|
committer | Regina König | 2021-04-21 14:42:48 +0200 |
commit | 7f4c689d34cdb08c528f1fea64d38e88d8aad283 (patch) | |
tree | 6f4d58967f3b6b9cc6ba04383a505840cd775897 | |
parent | Fix assembly code. Now the correct CLK value is computed (diff) | |
download | memtest86-7f4c689d34cdb08c528f1fea64d38e88d8aad283.tar.gz memtest86-7f4c689d34cdb08c528f1fea64d38e88d8aad283.tar.xz memtest86-7f4c689d34cdb08c528f1fea64d38e88d8aad283.zip |
Complete refactoring of cpuspeed()
-rw-r--r-- | efi_memtest/MemtestEfi.c | 1 | ||||
-rw-r--r-- | efi_memtest/memtest86+/efi/init.c | 59 |
2 files changed, 10 insertions, 50 deletions
diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c index 0399b30..dcde760 100644 --- a/efi_memtest/MemtestEfi.c +++ b/efi_memtest/MemtestEfi.c @@ -12,6 +12,7 @@ extern EFI_SYSTEM_TABLE *gST; short logflag = 1; short log_fine = 0; +short log_cpuspeed = 0; short log_memspeed = 0; short log_mem_tbl = 1; short log_comp_seg = 0; diff --git a/efi_memtest/memtest86+/efi/init.c b/efi_memtest/memtest86+/efi/init.c index cc7f57d..0231af8 100644 --- a/efi_memtest/memtest86+/efi/init.c +++ b/efi_memtest/memtest86+/efi/init.c @@ -35,6 +35,7 @@ extern char cpu_mask[]; extern void initialise_cpus(); extern short logflag; +extern short log_cpuspeed; extern short log_memspeed; /* Here we store all of the cpuid data */ @@ -373,7 +374,7 @@ void init(void) vv->printmode=PRINTMODE_ADDRESSES; vv->numpatn=0; - //while(1); + while(1); /* * WARNING: do not print anything before this statement. Otherwise it will be overwritten @@ -644,7 +645,7 @@ void detect_imc(void) case 0x7: imc_type = 0x0105; // Kabini & related (Family 16h) break; - } + } return; } @@ -1205,14 +1206,14 @@ void get_mem_speed(int me, int ncpus) /* Returns CPU clock in khz */ static int cpuspeed(void) { - if (logflag) { + if (logflag && log_cpuspeed) { char log[] = "cpuspeed() started."; print_log(log, sizeof(log) - 1); } int loops; - int stlow, sthigh; // TODO ulong or int? - int end_low, end_high; // TODO ulong or int? + int stlow, sthigh; + int end_low, end_high; if (cpu_id.fid.bits.rdtsc == 0 ) { return(-1); @@ -1224,6 +1225,7 @@ static int cpuspeed(void) outb(TICKS & 0xff, 0x42); outb(TICKS >> 8, 0x42); + /* Get start time */ asm __volatile__ ("rdtsc":"=a" (stlow),"=d" (sthigh)); loops = 0; @@ -1231,15 +1233,7 @@ static int cpuspeed(void) loops++; } while ((inb(0x61) & 0x20) == 0); - /* - ORIGINAL: - asm __volatile__ ( - "rdtsc\n\t" \ - "subl stlow,%%eax\n\t" \ - "sbbl sthigh,%%edx\n\t" \ - :"=a" (end_low), "=d" (end_high) - );*/ - + /* Get difference to end time */ asm __volatile__ ( "rdtsc\n\t" \ "subl %2, %%eax\n\t" \ @@ -1248,41 +1242,6 @@ static int cpuspeed(void) :"r" (stlow), "r" (sthigh) ); - /*asm __volatile__ ( - "rdtsc" - :"=a" (end_low), "=d" (end_high) - );*/ - - if (logflag) { - char log[28] = "stlow = "; - int length = 8; - int_to_charr(stlow, log, &length); - print_log(log, length); - } - - if (logflag) { - char log[29] = "sthigh = "; - int length = 9; - int_to_charr(sthigh, log, &length); - print_log(log, length); - } - - if (logflag) { - char log[30] = "end_low = "; - int length = 10; - int_to_charr(end_low, log, &length); - print_log(log, length); - } - - if (logflag) { - char log[31] = "end_high = "; - int length = 11; - int_to_charr(end_high, log, &length); - print_log(log, length); - } - - //end_low -= stlow; // TODO remember the carry flag - /* Make sure we have a credible result */ if (loops < 4 || end_low < 50000) { return(-1); @@ -1291,7 +1250,7 @@ static int cpuspeed(void) if (tsc_invariable) end_low = correct_tsc(end_low); - if (logflag) { + if (logflag && log_cpuspeed) { char log[35] = "cpuspeed(): clks_msec = "; int length = 24; int_to_charr(vv->clks_msec, log, &length); |