comparison loader/win32.c @ 3404:1261ff74abd9

updated cpudetection
author alex
date Sun, 09 Dec 2001 17:04:55 +0000
parents 181db9e5a887
children ce4df7bff5e1
comparison
equal deleted inserted replaced
3403:c4ca766a2d05 3404:1261ff74abd9
862 cachedsi.dwProcessorType = PROCESSOR_INTEL_386; 862 cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
863 cachedsi.dwAllocationGranularity = 0x10000; 863 cachedsi.dwAllocationGranularity = 0x10000;
864 cachedsi.wProcessorLevel = 5; /* pentium */ 864 cachedsi.wProcessorLevel = 5; /* pentium */
865 cachedsi.wProcessorRevision = 0x0101; 865 cachedsi.wProcessorRevision = 0x0101;
866 866
867 #if 1
868 /* mplayer's way to detect PF's */ 867 /* mplayer's way to detect PF's */
869 { 868 {
870 #include "../cpudetect.h" 869 #include "../cpudetect.h"
871 extern CpuCaps gCpuCaps; 870 extern CpuCaps gCpuCaps;
872 871
874 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; 873 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
875 if (gCpuCaps.hasSSE) 874 if (gCpuCaps.hasSSE)
876 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE; 875 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
877 if (gCpuCaps.has3DNow) 876 if (gCpuCaps.has3DNow)
878 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; 877 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
878
879 switch(gCpuCaps.cpuType)
880 {
881 case CPUTYPE_I686:
882 case CPUTYPE_I586:
883 cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
884 cachedsi.wProcessorLevel = 5;
885 break;
886 case CPUTYPE_I486:
887 cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
888 cachedsi.wProcessorLevel = 4;
889 break;
890 case CPUTYPE_I386:
891 default:
892 cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
893 cachedsi.wProcessorLevel = 3;
894 break;
895 }
896 cachedsi.wProcessorRevision = gCpuCaps.cpuStepping;
897 cachedsi.dwNumberOfProcessors = 1; /* hardcoded */
879 } 898 }
880 #endif 899
881 900 /* disable cpuid based detection (mplayer's cpudetect.c does this - see above) */
901 #if 0
882 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__) 902 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__)
883 do_cpuid(1, regs); 903 do_cpuid(1, regs);
884 switch ((regs[0] >> 8) & 0xf) { // cpu family 904 switch ((regs[0] >> 8) & 0xf) { // cpu family
885 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386; 905 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
886 cachedsi.wProcessorLevel= 3; 906 cachedsi.wProcessorLevel= 3;
906 if (regs[3] & (1 << 25)) 926 if (regs[3] & (1 << 25))
907 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE; 927 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
908 if (regs[3] & (1 << 31)) 928 if (regs[3] & (1 << 31))
909 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; 929 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
910 cachedsi.dwNumberOfProcessors=1; 930 cachedsi.dwNumberOfProcessors=1;
911 #else 931 #endif
932 #endif /* if 0 */
933
934 /* linux detection enabled (based on proc/cpuinfo) for checking
935 fdiv_bug and fpu emulation flags -- alex */
936 #ifdef __linux__
912 { 937 {
913 char buf[20]; 938 char buf[20];
914 char line[200]; 939 char line[200];
915 FILE *f = fopen ("/proc/cpuinfo", "r"); 940 FILE *f = fopen ("/proc/cpuinfo", "r");
916 941
1035 * CreateThread ...etc.. 1060 * CreateThread ...etc..
1036 * 1061 *
1037 */ 1062 */
1038 cachedsi.dwNumberOfProcessors=1; 1063 cachedsi.dwNumberOfProcessors=1;
1039 } 1064 }
1040 #endif /* __FreeBSD__ */ 1065 #endif /* __linux__ */
1066
1041 cache = 1; 1067 cache = 1;
1042 memcpy(si,&cachedsi,sizeof(*si)); 1068 memcpy(si,&cachedsi,sizeof(*si));
1043 DumpSystemInfo(si); 1069 DumpSystemInfo(si);
1044 } 1070 }
1045 1071