# HG changeset patch # User Pascal Bellard # Date 1676389317 0 # Node ID 2956e54cc56ad84937a1d18be9051129c5949612 # Parent e92394c9bae5bf102937fa4e097cea8cb709d137 memtest: update sleep() diff -r e92394c9bae5 -r 2956e54cc56a memtest/receipt --- a/memtest/receipt Tue Feb 14 07:20:48 2023 +0000 +++ b/memtest/receipt Tue Feb 14 15:41:57 2023 +0000 @@ -75,7 +75,7 @@ objdump -t boot/startup.o | \ awk '/patch/ { print "sed -i \"s|" $5 "|0x" $1 "|\" ../boot/setup.S" }' | sh make memtest.bin - tune_lzma memtest.bin 208,mf=bt2 LC 3 PB 2 + tune_lzma memtest.bin 161,mf=bt2 LC 3 PB 2 } diff -r e92394c9bae5 -r 2956e54cc56a memtest/stuff/memtest86+-6-386.patch --- a/memtest/stuff/memtest86+-6-386.patch Tue Feb 14 07:20:48 2023 +0000 +++ b/memtest/stuff/memtest86+-6-386.patch Tue Feb 14 15:41:57 2023 +0000 @@ -1,6 +1,17 @@ --- system/cpuinfo.c +++ system/cpuinfo.c -@@ -848,6 +848,12 @@ +@@ -490,6 +490,10 @@ + + static void determine_cpu_model(void) + { ++ if (cpuid_info.version.family <= 4) { ++ pause_at_start = false; ++ } ++ + // If we can get a brand string use it, and we are done. + if (cpuid_info.max_xcpuid >= 0x80000004) { + cpu_model = cpuid_info.brand_id.str; +@@ -848,6 +852,12 @@ default: // Unknown processor - make a guess at the family. switch (cpuid_info.version.family) { @@ -43,18 +54,16 @@ //------------------------------------------------------------------------------ // Public Variables -@@ -24,6 +45,17 @@ +@@ -24,6 +45,15 @@ uint32_t reg[4]; char *p, *q; + switch (has_cpuid(AC_BIT|CPUID_BIT)) { + case 0: + cpuid_info.version.family = 3; -+ pause_at_start = false; + return; + case AC_BIT: + cpuid_info.version.family = 4; -+ pause_at_start = false; + return; + } + @@ -200,3 +209,40 @@ window_end = VM_WINDOW_SIZE; break; default: +--- lib/unistd.c ++++ lib/unistd.c +@@ -5,10 +5,17 @@ + + #include "cpuinfo.h" + #include "tsc.h" ++#include "io.h" + + #include "unistd.h" + + //------------------------------------------------------------------------------ ++// Constants ++//------------------------------------------------------------------------------ ++ ++#define PIT_TICKS_50mS 59659 // PIT clock is 1.193182MHz ++ ++//------------------------------------------------------------------------------ + // Public Functions + //------------------------------------------------------------------------------ + +@@ -22,9 +29,14 @@ + __builtin_ia32_pause(); + } while ((get_tsc() - t0) < cycles); + } else { +- // This will be highly inaccurate, but should give at least the requested delay. +- volatile uint64_t count = (uint64_t)usec * 1000; ++ volatile uint64_t count = (uint64_t)usec / 50000; + while (count > 0) { ++ // Use PIT Timer ++ outb((inb(0x61) & ~0x02) | 0x01, 0x61); ++ outb(0xb0, 0x43); ++ outb(PIT_TICKS_50mS & 0xff, 0x42); ++ outb(PIT_TICKS_50mS >> 8, 0x42); ++ while ((inb(0x61) & 0x20) == 0); + count--; + } + }