wok-current rev 25511
memtest: 386 support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Feb 13 17:17:56 2023 +0000 (22 months ago) |
parents | 69e1e705f038 |
children | e92394c9bae5 |
files | memtest/receipt memtest/stuff/memtest86+-6-386.patch |
line diff
1.1 --- a/memtest/receipt Sun Feb 12 20:36:56 2023 +0000 1.2 +++ b/memtest/receipt Mon Feb 13 17:17:56 2023 +0000 1.3 @@ -67,11 +67,15 @@ 1.4 compile_rules() 1.5 { 1.6 # Need CPUID instruction (586+ cpu) 1.7 - sed -i 's|64, MT_VERSION "." GIT_HASH|65, MT_VERSION ".SliTaz"|;s|"\.x32"|".586"|' app/display.c 1.8 - sed 's|gcc|gcc-83|' -i build32/Makefile 1.9 + sed -i 's|64, MT_VERSION "." GIT_HASH|65, MT_VERSION ".SliTaz"|;s|"\.x32"|".386"|' app/display.c 1.10 + sed 's|gcc|gcc-83|;s|march=i586|march=i486|' -i build32/Makefile 1.11 + patch -p0 < $stuff/memtest86\+-6-386.patch 1.12 cd build32 1.13 + make boot/startup.o 1.14 + objdump -t boot/startup.o | \ 1.15 + awk '/patch/ { print "sed -i \"s|" $5 "|0x" $1 "|\" ../boot/setup.S" }' | sh 1.16 make memtest.bin 1.17 - tune_lzma memtest.bin 122,mf=bt4 LC 3 PB 2 1.18 + tune_lzma memtest.bin 161,mf=bt2 LC 3 PB 2 1.19 } 1.20 1.21
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/memtest/stuff/memtest86+-6-386.patch Mon Feb 13 17:17:56 2023 +0000 2.3 @@ -0,0 +1,149 @@ 2.4 +--- system/cpuinfo.c 2.5 ++++ system/cpuinfo.c 2.6 +@@ -848,6 +848,12 @@ 2.7 + default: 2.8 + // Unknown processor - make a guess at the family. 2.9 + switch (cpuid_info.version.family) { 2.10 ++ case 3: 2.11 ++ cpu_model = "386"; 2.12 ++ break; 2.13 ++ case 4: 2.14 ++ cpu_model = "486"; 2.15 ++ break; 2.16 + case 5: 2.17 + cpu_model = "586"; 2.18 + break; 2.19 +--- system/cpuid.c 2.20 ++++ system/cpuid.c 2.21 +@@ -8,6 +8,27 @@ 2.22 + #include <stdint.h> 2.23 + 2.24 + #include "cpuid.h" 2.25 ++#include "config.h" 2.26 ++ 2.27 ++#define AC_BIT (1<<18) 2.28 ++#define CPUID_BIT (1<<21) 2.29 ++static inline int has_cpuid(int bits) 2.30 ++{ 2.31 ++ int eax, edx; 2.32 ++ __asm__ __volatile__( 2.33 ++ "pushfl\n\t" 2.34 ++ "popl %0\n\t" 2.35 ++ "movl %0,%1\n\t" 2.36 ++ "xorl %2,%0\n\t" 2.37 ++ "pushl %0\n\t" 2.38 ++ "popfl\n\t" 2.39 ++ "pushfl\n\t" 2.40 ++ "popl %0\n\t" 2.41 ++ "pushl %1\n\t" 2.42 ++ "popfl\n\t" 2.43 ++ "xorl %1,%0":"=a" (eax),"=d" (edx):"c" (bits)); 2.44 ++ return eax; 2.45 ++} 2.46 + 2.47 + //------------------------------------------------------------------------------ 2.48 + // Public Variables 2.49 +@@ -24,6 +45,17 @@ 2.50 + uint32_t reg[4]; 2.51 + char *p, *q; 2.52 + 2.53 ++ switch (has_cpuid(AC_BIT|CPUID_BIT)) { 2.54 ++ case 0: 2.55 ++ cpuid_info.version.family = 3; 2.56 ++ pause_at_start = false; 2.57 ++ return; 2.58 ++ case AC_BIT: 2.59 ++ cpuid_info.version.family = 4; 2.60 ++ pause_at_start = false; 2.61 ++ return; 2.62 ++ } 2.63 ++ 2.64 + // Get the max standard cpuid & vendor ID. 2.65 + cpuid(0x0, 0, 2.66 + &cpuid_info.max_cpuid, 2.67 +--- boot/setup.S 2.68 ++++ boot/setup.S 2.69 +@@ -100,6 +100,29 @@ 2.70 + .long 0x10 2.71 + 2.72 + do_setup: 2.73 ++ 2.74 ++ # Check cpuid support 2.75 ++ 2.76 ++ pushfl 2.77 ++ popw %dx 2.78 ++ popw %ax 2.79 ++ xorb $0x20, %al # toggle CPUID feature bit (21) 2.80 ++ pushw %ax 2.81 ++ pushw %dx 2.82 ++ popfl 2.83 ++ pushfl 2.84 ++ popw %dx 2.85 ++ popw %ax 2.86 ++ xorb %dl, %al 2.87 ++ and $0x20, %al 2.88 ++ jz 1f 2.89 ++ movw $0x1000, %ax 2.90 ++ movw %ax, %ds 2.91 ++ movb $0xa8, %al # testb $imm %al opcode 2.92 ++ movw %ax, patch1 2.93 ++ movw %ax, patch2 2.94 ++1: 2.95 ++ 2.96 + # Reload the segment registers, except for the stack. 2.97 + 2.98 + movw %cs, %ax 2.99 +--- boot/startup32.S 2.100 ++++ boot/startup32.S 2.101 +@@ -105,6 +105,8 @@ 2.102 + 2.103 + # ...and check if the processor supports long mode. 2.104 + 2.105 ++patch1: 2.106 ++ jmp 1f 2.107 + movl $0x80000000, %eax # check if function 0x80000001 is available 2.108 + pushl %ebx # ebx is overwritten by cpuid 2.109 + cpuid 2.110 +@@ -198,6 +200,8 @@ 2.111 + 2.112 + # Enable PAE if supported. 2.113 + 2.114 ++patch2: 2.115 ++ jmp 1f 2.116 + pushl %ebx # ebx is overwritten by cpuid 2.117 + movl $0x00000001, %eax # test the PAE flag 2.118 + cpuid 2.119 +--- system/cache.h 2.120 ++++ system/cache.h 2.121 +@@ -1,6 +1,7 @@ 2.122 + // SPDX-License-Identifier: GPL-2.0 2.123 + #ifndef CACHE_H 2.124 + #define CACHE_H 2.125 ++#include "cpuid.h" 2.126 + /** 2.127 + * \file 2.128 + * 2.129 +@@ -26,6 +27,7 @@ 2.130 + : "rax", "memory" 2.131 + ); 2.132 + #else 2.133 ++ if (cpuid_info.version.family >= 4) 2.134 + __asm__ __volatile__ ("\t" 2.135 + "movl %%cr0, %%eax \n\t" 2.136 + "orl $0x40000000, %%eax \n\t" /* Set CD */ 2.137 +@@ -53,6 +55,7 @@ 2.138 + : "rax", "memory" 2.139 + ); 2.140 + #else 2.141 ++ // if (cpuid_info.version.family >= 4) 2.142 + __asm__ __volatile__ ("\t" 2.143 + "movl %%cr0, %%eax \n\t" 2.144 + "andl $0x9fffffff, %%eax \n\t" /* Clear CD and NW */ 2.145 +@@ -69,6 +72,7 @@ 2.146 + */ 2.147 + static inline void cache_flush(void) 2.148 + { 2.149 ++ if (cpuid_info.version.family >= 4) 2.150 + __asm__ __volatile__ ("\t" 2.151 + "wbinvd\n" 2.152 + : /* no outputs */