wok rev 25513
memtest: update sleep()
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 14 15:41:57 2023 +0000 (22 months ago) |
parents | e92394c9bae5 |
children | a7a39e042b62 |
files | memtest/receipt memtest/stuff/memtest86+-6-386.patch |
line diff
1.1 --- a/memtest/receipt Tue Feb 14 07:20:48 2023 +0000 1.2 +++ b/memtest/receipt Tue Feb 14 15:41:57 2023 +0000 1.3 @@ -75,7 +75,7 @@ 1.4 objdump -t boot/startup.o | \ 1.5 awk '/patch/ { print "sed -i \"s|" $5 "|0x" $1 "|\" ../boot/setup.S" }' | sh 1.6 make memtest.bin 1.7 - tune_lzma memtest.bin 208,mf=bt2 LC 3 PB 2 1.8 + tune_lzma memtest.bin 161,mf=bt2 LC 3 PB 2 1.9 } 1.10 1.11
2.1 --- a/memtest/stuff/memtest86+-6-386.patch Tue Feb 14 07:20:48 2023 +0000 2.2 +++ b/memtest/stuff/memtest86+-6-386.patch Tue Feb 14 15:41:57 2023 +0000 2.3 @@ -1,6 +1,17 @@ 2.4 --- system/cpuinfo.c 2.5 +++ system/cpuinfo.c 2.6 -@@ -848,6 +848,12 @@ 2.7 +@@ -490,6 +490,10 @@ 2.8 + 2.9 + static void determine_cpu_model(void) 2.10 + { 2.11 ++ if (cpuid_info.version.family <= 4) { 2.12 ++ pause_at_start = false; 2.13 ++ } 2.14 ++ 2.15 + // If we can get a brand string use it, and we are done. 2.16 + if (cpuid_info.max_xcpuid >= 0x80000004) { 2.17 + cpu_model = cpuid_info.brand_id.str; 2.18 +@@ -848,6 +852,12 @@ 2.19 default: 2.20 // Unknown processor - make a guess at the family. 2.21 switch (cpuid_info.version.family) { 2.22 @@ -43,18 +54,16 @@ 2.23 2.24 //------------------------------------------------------------------------------ 2.25 // Public Variables 2.26 -@@ -24,6 +45,17 @@ 2.27 +@@ -24,6 +45,15 @@ 2.28 uint32_t reg[4]; 2.29 char *p, *q; 2.30 2.31 + switch (has_cpuid(AC_BIT|CPUID_BIT)) { 2.32 + case 0: 2.33 + cpuid_info.version.family = 3; 2.34 -+ pause_at_start = false; 2.35 + return; 2.36 + case AC_BIT: 2.37 + cpuid_info.version.family = 4; 2.38 -+ pause_at_start = false; 2.39 + return; 2.40 + } 2.41 + 2.42 @@ -200,3 +209,40 @@ 2.43 window_end = VM_WINDOW_SIZE; 2.44 break; 2.45 default: 2.46 +--- lib/unistd.c 2.47 ++++ lib/unistd.c 2.48 +@@ -5,10 +5,17 @@ 2.49 + 2.50 + #include "cpuinfo.h" 2.51 + #include "tsc.h" 2.52 ++#include "io.h" 2.53 + 2.54 + #include "unistd.h" 2.55 + 2.56 + //------------------------------------------------------------------------------ 2.57 ++// Constants 2.58 ++//------------------------------------------------------------------------------ 2.59 ++ 2.60 ++#define PIT_TICKS_50mS 59659 // PIT clock is 1.193182MHz 2.61 ++ 2.62 ++//------------------------------------------------------------------------------ 2.63 + // Public Functions 2.64 + //------------------------------------------------------------------------------ 2.65 + 2.66 +@@ -22,9 +29,14 @@ 2.67 + __builtin_ia32_pause(); 2.68 + } while ((get_tsc() - t0) < cycles); 2.69 + } else { 2.70 +- // This will be highly inaccurate, but should give at least the requested delay. 2.71 +- volatile uint64_t count = (uint64_t)usec * 1000; 2.72 ++ volatile uint64_t count = (uint64_t)usec / 50000; 2.73 + while (count > 0) { 2.74 ++ // Use PIT Timer 2.75 ++ outb((inb(0x61) & ~0x02) | 0x01, 0x61); 2.76 ++ outb(0xb0, 0x43); 2.77 ++ outb(PIT_TICKS_50mS & 0xff, 0x42); 2.78 ++ outb(PIT_TICKS_50mS >> 8, 0x42); 2.79 ++ while ((inb(0x61) & 0x20) == 0); 2.80 + count--; 2.81 + } 2.82 + }