Changeset 8889
- Timestamp:
- 05/16/08 14:36:58 (4 months ago)
- Files:
-
- trunk/include/iprt/asm.h (modified) (2 diffs)
- trunk/src/VBox/Runtime/testcase/tstInlineAsm.cpp (modified) (3 diffs)
- trunk/src/VBox/VMM/CPUM.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/iprt/asm.h
r8882 r8889 944 944 945 945 /** 946 * Tests if it an genuin Intel CPU based on the ASMCpuId(0) output. 947 * 948 * @returns true/false. 949 * @param uEBX EBX return from ASMCpuId(0) 950 * @param uECX ECX return from ASMCpuId(0) 951 * @param uEDX EDX return from ASMCpuId(0) 952 */ 953 DECLINLINE(bool) ASMIsIntelCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX) 954 { 955 return uEBX == 0x756e6547 956 || uECX == 0x6c65746e 957 || uEDX == 0x49656e69; 958 } 959 960 961 /** 962 * Tests if this is an genuin Intel CPU. 963 * 964 * @returns true/false. 965 */ 966 DECLINLINE(bool) ASMIsIntelCpu(void) 967 { 968 uint32_t uEAX, uEBX, uECX, uEDX; 969 ASMCpuId(1, &uEAX, &uEBX, &uECX, &uEDX); 970 return ASMIsIntelCpuEx(uEBX, uECX, uEDX); 971 } 972 973 974 /** 946 975 * Extracts the CPU family from ASMCpuId(1) or ASMCpuId(0x80000001) 947 976 * … … 958 987 959 988 /** 960 * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001) 989 * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001), Intel variant. 961 990 * 962 991 * @returns Model. 963 992 * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001). 964 */ 965 DECLINLINE(uint32_t) ASMGetCpuModel(uint32_t uEAX) 966 { 967 return ((uEAX >> 8) & 0xf) == 0xf /* family! */ 993 * @param fIntel Whether it's an intel CPU. 994 */ 995 DECLINLINE(uint32_t) ASMGetCpuModelIntel(uint32_t uEAX) 996 { 997 return ((uEAX >> 8) & 0xf) == 0xf || (((uEAX >> 8) & 0xf) == 0x6) /* family! */ 998 ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0) 999 : ((uEAX >> 4) & 0xf); 1000 } 1001 1002 1003 /** 1004 * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001), AMD variant. 1005 * 1006 * @returns Model. 1007 * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001). 1008 * @param fIntel Whether it's an intel CPU. 1009 */ 1010 DECLINLINE(uint32_t) ASMGetCpuModelAMD(uint32_t uEAX) 1011 { 1012 return ((uEAX >> 8) & 0xf) == 0xf 1013 ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0) 1014 : ((uEAX >> 4) & 0xf); 1015 } 1016 1017 1018 /** 1019 * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001) 1020 * 1021 * @returns Model. 1022 * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001). 1023 * @param fIntel Whether it's an intel CPU. Use ASMIsIntelCpuEx() or ASMIsIntelCpu(). 1024 */ 1025 DECLINLINE(uint32_t) ASMGetCpuModel(uint32_t uEAX, bool fIntel) 1026 { 1027 return ((uEAX >> 8) & 0xf) == 0xf || (((uEAX >> 8) & 0xf) == 0x6 && fIntel) /* family! */ 968 1028 ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0) 969 1029 : ((uEAX >> 4) & 0xf); trunk/src/VBox/Runtime/testcase/tstInlineAsm.cpp
r8882 r8889 175 175 "Support: 0-%u\n", 176 176 &s.uEBX, &s.uEDX, &s.uECX, s.uEAX); 177 bool const fIntel = ASMIsIntelCpuEx(s.uEBX, s.uECX, s.uEDX); 177 178 178 179 /* … … 190 191 "Brand ID: %#04x\n", 191 192 (s.uEAX >> 8) & 0xf, (s.uEAX >> 20) & 0x7f, ASMGetCpuFamily(s.uEAX), 192 (s.uEAX >> 4) & 0xf, (s.uEAX >> 16) & 0x0f, ASMGetCpuModel(s.uEAX ),193 (s.uEAX >> 4) & 0xf, (s.uEAX >> 16) & 0x0f, ASMGetCpuModel(s.uEAX, fIntel), 193 194 ASMGetCpuStepping(s.uEAX), 194 195 (s.uEBX >> 24) & 0xff, … … 285 286 "Brand ID: %#05x\n", 286 287 (s.uEAX >> 8) & 0xf, (s.uEAX >> 20) & 0x7f, ASMGetCpuFamily(s.uEAX), 287 (s.uEAX >> 4) & 0xf, (s.uEAX >> 16) & 0x0f, ASMGetCpuModel(s.uEAX ),288 (s.uEAX >> 4) & 0xf, (s.uEAX >> 16) & 0x0f, ASMGetCpuModel(s.uEAX, fIntel), 288 289 ASMGetCpuStepping(s.uEAX), 289 290 s.uEBX & 0xfff); trunk/src/VBox/VMM/CPUM.cpp
r8885 r8889 1045 1045 case 4: return "4 way "; 1046 1046 case 5: return "res5 "; 1047 case 6: return "8 way "; 1048 case 7: return "res7 "; 1047 case 6: return "8 way "; case 7: return "res7 "; 1049 1048 case 8: return "16 way"; 1050 1049 case 9: return "res9 "; … … 1093 1092 " RAW Standard CPUIDs\n" 1094 1093 " Function eax ebx ecx edx\n"); 1095 for (unsigned i = 0; i < ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); i++)1094 for (unsigned i = 0; i < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd); i++) 1096 1095 { 1097 1096 Guest = pVM->cpum.s.aGuestCpuIdStd[i]; … … 1121 1120 * Get Features. 1122 1121 */ 1122 bool const fIntel = ASMIsIntelCpuEx(pVM->cpum.s.aGuestCpuIdStd[0].ebx, 1123 pVM->cpum.s.aGuestCpuIdStd[0].ecx, 1124 pVM->cpum.s.aGuestCpuIdStd[0].edx); 1123 1125 if (cStdMax >= 1 && iVerbosity) 1124 1126 { … … 1135 1137 "Brand ID: %#04x\n", 1136 1138 (uEAX >> 8) & 0xf, (uEAX >> 20) & 0x7f, ASMGetCpuFamily(uEAX), 1137 (uEAX >> 4) & 0xf, (uEAX >> 16) & 0x0f, ASMGetCpuModel(uEAX ),1139 (uEAX >> 4) & 0xf, (uEAX >> 16) & 0x0f, ASMGetCpuModel(uEAX, fIntel), 1138 1140 ASMGetCpuStepping(uEAX), 1139 1141 (Guest.ebx >> 24) & 0xff, … … 1309 1311 "Brand ID: %#05x\n", 1310 1312 (uEAX >> 8) & 0xf, (uEAX >> 20) & 0x7f, ASMGetCpuFamily(uEAX), 1311 (uEAX >> 4) & 0xf, (uEAX >> 16) & 0x0f, ASMGetCpuModel(uEAX ),1313 (uEAX >> 4) & 0xf, (uEAX >> 16) & 0x0f, ASMGetCpuModel(uEAX, fIntel), 1312 1314 ASMGetCpuStepping(uEAX), 1313 1315 Guest.ebx & 0xfff);

