wok-tiny view memtest/stuff/memtest86+-5.01-386.patch @ rev 168

memtest: 386 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 30 16:35:54 2021 +0000 (2021-04-30)
parents
children
line source
1 --- memtest86+-5.01/cpuid.c
2 +++ memtest86+-5.01/cpuid.c
3 @@ -14,6 +14,15 @@
4 unsigned int *v, dummy[3];
5 char *p, *q;
7 + switch (has_cpuid(AC_BIT|CPUID_BIT)) {
8 + case 0:
9 + cpu_id.vers.bits.family = 3;
10 + return;
11 + case AC_BIT:
12 + cpu_id.vers.bits.family = 4;
13 + return;
14 + }
15 +
16 /* Get max std cpuid & vendor ID */
17 cpuid(0x0, &cpu_id.max_cpuid, &cpu_id.vend_id.uint32_array[0],
18 &cpu_id.vend_id.uint32_array[2], &cpu_id.vend_id.uint32_array[1]);
19 --- memtest86+-5.01/cpuid.h
20 +++ memtest86+-5.01/cpuid.h
21 @@ -11,6 +11,26 @@
23 extern struct cpu_ident cpu_id;
25 +#define AC_BIT (1<<18)
26 +#define CPUID_BIT (1<<21)
27 +static inline int has_cpuid(int bits)
28 +{
29 + int eax, edx;
30 + asm __volatile__(
31 + "pushfl\n\t"
32 + "popl %0\n\t"
33 + "movl %0,%1\n\t"
34 + "xorl %2,%0\n\t"
35 + "pushl %0\n\t"
36 + "popfl\n\t"
37 + "pushfl\n\t"
38 + "popl %0\n\t"
39 + "pushl %1\n\t"
40 + "popfl\n\t"
41 + "xorl %1,%0":"=a" (eax),"=d" (edx):"c" (bits));
42 + return eax;
43 +}
44 +
45 static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
46 unsigned int *ecx, unsigned int *edx)
47 {
48 --- memtest86+-5.01/init.c
49 +++ memtest86+-5.01/init.c
50 @@ -77,6 +77,7 @@
51 cprint(19, 15, "==> Press F2 to force Multi-Threading (SMP) <==");
52 }
54 + if (cpu_id.fid.bits.rdtsc) {
55 /* save the starting time */
56 asm __volatile__(
57 "rdtsc":"=a" (sl),"=d" (sh));
58 @@ -122,6 +123,7 @@
59 }
61 }
62 + }
64 cprint(18, 18, " ");
65 cprint(19, 15, " ");
66 @@ -321,7 +323,9 @@
67 beep(1000);
69 /* Record the start time */
70 + if (cpu_id.fid.bits.rdtsc) {
71 asm __volatile__ ("rdtsc":"=a" (v->startl),"=d" (v->starth));
72 + }
73 v->snapl = v->startl;
74 v->snaph = v->starth;
75 if (l1_cache == 0) { l1_cache = 64; }
76 @@ -998,10 +1002,18 @@
77 default:
78 /* Make a guess at the family */
79 switch(cpu_id.vers.bits.family) {
80 + case 3:
81 + cprint(0, COL_MID, "386");
82 + break;
83 + case 4:
84 + cprint(0, COL_MID, "486");
85 + break;
86 case 5:
87 cprint(0, COL_MID, "586");
88 + break;
89 case 6:
90 cprint(0, COL_MID, "686");
91 + break;
92 default:
93 cprint(0, COL_MID, "Unidentified Processor");
94 }
95 --- memtest86+-5.01/test.c
96 +++ memtest86+-5.01/test.c
97 @@ -1501,6 +1501,8 @@
98 {
99 ulong sh, sl, l, h, t, ip=0;
101 + if (cpu_id.fid.bits.rdtsc == 0) return;
102 +
103 /* save the starting time */
104 asm __volatile__(
105 "rdtsc":"=a" (sl),"=d" (sh));