热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

一个全面获取IntelCPUID的代码

主函数:CStringGetCPUIDString()Copyright(C)shangweixiao2011
// 主函数:CString GetCPUIDString()
// Copyright (C) shangweixiao 2011

////////////////////////////////////////////////////////
class CSortStringArray:public CStringArray
{
public:
	void Sort();
private:
	BOOL CompareAndSwap(int pos);
};

void CSortStringArray::Sort()
{
	BOOL bNotDOne= TRUE;

	while (bNotDone)
	{
		bNotDOne= FALSE;
		for(int pos = 0;pos  0)
	{
		temp = GetAt(posFirst);
		SetAt(posFirst, GetAt(posNext));
		SetAt(posNext, temp);
		return TRUE;

	}
	return FALSE;
}
////////////////////////////////////////////////////////////

void GetCPUID(UINT32 Operand, UINT32 Value[8])
{
	UINT32 ulS1,ulS2,ulS3,ulS4;

	__asm
	{
			mov eax,Operand
			xor ebx,ebx
			xor ecx,ecx
			xor edx,edx
			cpuid
			mov ulS1,eax
			mov ulS2,ebx
			mov ulS3,ecx
			mov ulS4,edx
	}

	Value[0] = ulS1;
	Value[1] = ulS2;
	Value[2] = ulS3;
	Value[3] = ulS4;
}

void GetCPUID2(UINT32 Operand,UINT32 Operand2,UINT32 Value[8])
{
	UINT32 ulS1,ulS2,ulS3,ulS4;

	__asm
	{
			mov eax,Operand
			mov ecx,Operand2
			xor ebx,ebx
			xor edx,edx
			cpuid
			mov ulS1,eax
			mov ulS2,ebx
			mov ulS3,ecx
			mov ulS4,edx
	}

	Value[0] = ulS1;
	Value[1] = ulS2;
	Value[2] = ulS3;
	Value[3] = ulS4;
}

#define SWAP_VALUE(x,y) {x=x^y;y=x^y;x=x^y;}
#define SET_BIT(v,i) ((v) |= (0x1 <<(i)))
#define TEST_BIT(v,i) (!!((v) & (0x1 <<(i))))
int GetBitsValue(UINT32 org,UINT32 start,UINT32 end)
{
	UINT32 i,mask=0;

	for(i=start;i<=end;i++)
	{
		SET_BIT(mask,i);
	}
	return (org & mask)>>start;
}

char *BrandString[]={
	"None",
	"Intel(R) Celeron(R) processor",
	"Intel(R) Pentium(R) III processor",
	"Intel(R) Pentium(R) III Xeon(R) processor",
	"Intel(R) Pentium(R) III processor",
	"Mobile Intel(R) Pentium(R) III processor-M",
	"Mobile Intel(R) Celeron(R) processor",
	"Intel(R) Pentium(R) 4 processor",
	"Intel(R) Pentium(R) 4 processor",
	"Intel(R) Celeron(R) processor",
	"Intel(R) Xeon(R) processor",
	"Intel(R) Xeon(R) processor MP",
	"Mobile Intel(R) Pentium(R) 4 processor-M",
	"Mobile Intel(R) Celeron(R) processor",
	"Mobile Genuine Intel(R) processor",
	"Intel(R) Celeron(R) M processor",
	"Mobile Intel(R) Celeron(R) processor",
	"Intel(R) Celeron(R) processor",
	"Mobile Genuine Intel(R) processor",
	"Intel(R) Pentium(R) M processor",
	"Mobile Intel(R) Celeron(R) processor"
};
char *Leaf_2_Descriptors[]={""
/*00*/ "", //"Null descriptor, this byte contains no information",
/*01*/ "Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries",
/*02*/ "Instruction TLB: 4 MByte pages, fully associative, 2 entries",
/*03*/ "Data TLB: 4 KByte pages, 4-way set associative, 64 entries",
/*04*/ "Data TLB: 4 MByte pages, 4-way set associative, 8 entries",
/*05*/ "Data TLB1: 4 MByte pages, 4-way set associative, 32 entries",
/*06*/ "1st-level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size",
/*07*/ "",
/*08*/ "1st-level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size",
/*09*/ "1st-level instruction cache: 32KBytes, 4-way set associative, 64 byte line size",
/*0A*/ "1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size",
/*0B*/ "Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries",
/*0C*/ "1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size",
/*0D*/ "1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size",
/*0E*/ "1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size",
/*0F*/ "",
/*10*/ "",
/*11*/ "",
/*12*/ "",
/*13*/ "",
/*14*/ "",
/*15*/ "",
/*16*/ "",
/*17*/ "",
/*18*/ "",
/*19*/ "",
/*1A*/ "",
/*1B*/ "",
/*1C*/ "",
/*1D*/ "",
/*1E*/ "",
/*1F*/ "",
/*20*/ "",
/*21*/ "2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size",
/*22*/ "3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector",
/*23*/ "3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector",
/*24*/ "",
/*25*/ "3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector",
/*26*/ "",
/*27*/ "",
/*28*/ "",
/*29*/ "3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector",
/*2A*/ "",
/*2B*/ "",
/*2C*/ "1st-level data cache: 32 KBytes, 8-way set associative, 64 byte line size",
/*2D*/ "",
/*2E*/ "",
/*2F*/ "",
/*30*/ "1st-level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size",
/*31*/ "",
/*32*/ "",
/*33*/ "",
/*34*/ "",
/*35*/ "",
/*36*/ "",
/*37*/ "",
/*38*/ "",
/*39*/ "",
/*3A*/ "",
/*3B*/ "",
/*3C*/ "",
/*3D*/ "",
/*3E*/ "",
/*3F*/ "",
/*40*/ "No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rdlevel cache",
/*41*/ "2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size",
/*42*/ "2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size",
/*43*/ "2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size",
/*44*/ "2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size",
/*45*/ "2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size",
/*46*/ "3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size",
/*47*/ "3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size",
/*48*/ "2nd-level cache: 3MByte, 12-way set associative, 64 byte line size",
/*49*/ "3rd-level cache: 4MB, 16-way set associative, 64-byte line size (Intel Xeon processor MP, Family 0FH, Model 06H);",
/*4A*/ "3rd-level cache: 6MByte, 12-way set associative, 64 byte line size",
/*4B*/ "3rd-level cache: 8MByte, 16-way set associative, 64 byte line size",
/*4C*/ "3rd-level cache: 12MByte, 12-way set associative, 64 byte line size",
/*4D*/ "3rd-level cache: 16MByte, 16-way set associative, 64 byte line size",
/*4E*/ "2nd-level cache: 6MByte, 24-way set associative, 64 byte line size",
/*4F*/ "Instruction TLB: 4 KByte pages, 32 entries",
/*50*/ "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries",
/*51*/ "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries",
/*52*/ "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries",
/*53*/ "",
/*54*/ "",
/*55*/ "Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries",
/*56*/ "Data TLB0: 4 MByte pages, 4-way set associative, 16 entries",
/*57*/ "Data TLB0: 4 KByte pages, 4-way associative, 16 entries",
/*58*/ "",
/*59*/ "Data TLB0: 4 KByte pages, fully associative, 16 entries",
/*5A*/ "Data TLB0: 2-MByte or 4 MByte pages, 4-way set associative, 32 entries",
/*5B*/ "Data TLB: 4 KByte and 4 MByte pages, 64 entries",
/*5C*/ "Data TLB: 4 KByte and 4 MByte pages,128 entries",
/*5D*/ "Data TLB: 4 KByte and 4 MByte pages,256 entries",
/*5E*/ "",
/*5F*/ "",
/*60*/ "1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size",
/*61*/ "",
/*62*/ "",
/*63*/ "",
/*64*/ "",
/*65*/ "",
/*66*/ "1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size",
/*67*/ "1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size",
/*68*/ "1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size",
/*69*/ "",
/*6A*/ "",
/*6B*/ "",
/*6C*/ "",
/*6D*/ "",
/*6E*/ "",
/*6F*/ "",
/*70*/ "Trace cache: 12 K-uop, 8-way set associative",
/*71*/ "Trace cache: 16 K-uop, 8-way set associative",
/*72*/ "Trace cache: 32 K-uop, 8-way set associative",
/*73*/ "",
/*74*/ "",
/*75*/ "",
/*76*/ "",
/*77*/ "",
/*78*/ "2nd-level cache: 1 MByte, 4-way set associative, 64byte line size",
/*79*/ "2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, 2 lines per sector",
/*7A*/ "2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, 2 lines per sector",
/*7B*/ "2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, 2 lines per sector",
/*7C*/ "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, 2 lines per sector",
/*7D*/ "2nd-level cache: 2 MByte, 8-way set associative, 64byte line size",
/*7E*/ "",
/*7F*/ "2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size",
/*80*/ "2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size",
/*81*/ "",
/*82*/ "2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size",
/*83*/ "2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size",
/*84*/ "2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size",
/*85*/ "2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size",
/*86*/ "2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size",
/*87*/ "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size",
/*88*/ "",
/*89*/ "",
/*8A*/ "",
/*8B*/ "",
/*8C*/ "",
/*8D*/ "",
/*8E*/ "",
/*8F*/ "",
/*90*/ "",
/*91*/ "",
/*92*/ "",
/*93*/ "",
/*94*/ "",
/*95*/ "",
/*96*/ "",
/*97*/ "",
/*98*/ "",
/*99*/ "",
/*9A*/ "",
/*9B*/ "",
/*9C*/ "",
/*9D*/ "",
/*9E*/ "",
/*9F*/ "",
/*A0*/ "",
/*A1*/ "",
/*A2*/ "",
/*A3*/ "",
/*A4*/ "",
/*A5*/ "",
/*A6*/ "",
/*A7*/ "",
/*A8*/ "",
/*A9*/ "",
/*AA*/ "",
/*AB*/ "",
/*AC*/ "",
/*AD*/ "",
/*AE*/ "",
/*AF*/ "",
/*B0*/ "Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries",
/*B1*/ "Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries",
/*B2*/ "Instruction TLB: 4KByte pages, 4-way set associative, 64 entries",
/*B3*/ "Data TLB: 4 KByte pages, 4-way set associative, 128 entries",
/*B4*/ "Data TLB1: 4 KByte pages, 4-way associative, 256 entries",
/*B5*/ "",
/*B6*/ "",
/*B7*/ "",
/*B8*/ "",
/*B9*/ "",
/*BA*/ "Data TLB1: 4 KByte pages, 4-way associative, 64 entries",
/*BB*/ "",
/*BC*/ "",
/*BD*/ "",
/*BE*/ "",
/*BF*/ "",
/*C0*/ "Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries",
/*C1*/ "",
/*C2*/ "",
/*C3*/ "",
/*C4*/ "",
/*C5*/ "",
/*C6*/ "",
/*C7*/ "",
/*C8*/ "",
/*C9*/ "",
/*CA*/ "Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries",
/*CB*/ "",
/*CC*/ "",
/*CD*/ "",
/*CE*/ "",
/*CF*/ "",
/*D0*/ "",
/*D1*/ "",
/*D2*/ "",
/*D3*/ "",
/*D4*/ "",
/*D5*/ "",
/*D6*/ "",
/*D7*/ "",
/*D8*/ "",
/*D9*/ "",
/*DA*/ "",
/*DB*/ "",
/*DC*/ "",
/*DD*/ "",
/*DE*/ "",
/*DF*/ "",
/*E0*/ "",
/*E1*/ "",
/*E2*/ "",
/*E3*/ "",
/*E4*/ "3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size",
/*E5*/ "",
/*E6*/ "",
/*E7*/ "",
/*E8*/ "",
/*E9*/ "",
/*EA*/ "3rd-level cache: 12MByte, 24-way set associative, 64 byte line size",
/*EB*/ "3rd-level cache: 18MByte, 24-way set associative, 64 byte line size",
/*EC*/ "3rd-level cache: 24MByte, 24-way set associative, 64 byte line size",
/*ED*/ "",
/*EE*/ "",
/*EF*/ "",
/*F0*/ "64-Byte prefetching",
/*F1*/ "128-Byte prefetching",
/*F2*/ "",
/*F3*/ "",
/*F4*/ "",
/*F5*/ "",
/*F6*/ "",
/*F7*/ "",
/*F8*/ "",
/*F9*/ "",
/*FA*/ "",
/*FB*/ "",
/*FC*/ "",
/*FD*/ "",
/*FE*/ "",
/*FF*/ "CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters",
};

char *Feature_Information1[]={
	"SSE3","PCLMULQDQ",
	"DTES64 64-bit DS Area",
	"MONITOR MONITOR/MWAIT",
	"DS-CPL CPL Qualified Debug Store",
	"VMX Virtual Machine Extensions",
	"SMX Safer Mode Extensions",
	"EST Enhanced Intel SpeedStep technology",
	"TM2 Thermal Monitor 2",
	"SSSE3",
	"CNXT-ID L1 Context ID",
	"",
	"FMA",
	"CMPXCHG16B CMPXCHG16B Available",
	"xTPR Update Control",
	"PDCM Perfmon and Debug Capability",
	"",
	"PCID Process-context identifiers",
	"DCA",
	"SSE4.1",
	"SSE4.2",
	"x2APIC",
	"MOVBE",
	"MOVBE",
	"TSC-Deadline",
	"AESNI",
	"XSAVE",
	"OSXSAVE",
	"AVX",
	"",
	"",
	"",
};
char *Feature_Information2[]={
	"FPU",
	"VME Virtual 8086 Mode Enhancements",
	"DE Debugging Extensions",
	"PSE Page Size Extension",
	"TSC Time Stamp Counter",
	"MSR Model Specific Registers RDMSR and WRMSR Instructions",
	"PAE",
	"MCE Machine Check Exception",
	"CX8 CMPXCHG8B Instruction",
	"APIC",
	"",
	"SEP SYSENTER and SYSEXIT Instructions",
	"MTRR Memory Type Range Registers",
	"PGE Page Global Bit",
	"MCA Machine Check Architecture",
	"CMOV Conditional Move Instructions",
	"PAT Page Attribute Table",
	"PSE-36 36-Bit Page Size Extension",
	"PSN Processor Serial Number",
	"CLFSH CLFLUSH Instruction",
	"",
	"DS Debug Store",
	"ACPI Thermal Monitor and Software Controlled Clock Facilities",
	"MMX",
	"FXSR FXSAVE and FXRSTOR Instructions",
	"SSE",
	"SSE2",
	"SS",
	"HTT Multi-Threading",
	"TM Thermal Monitor",
	"",
	"PBE Pending Break Enable",
};

char *Cache_Type[]={
	"Null - No more caches",
	"Data Cache",
	"Instruction Cache",
	"Unified Cache",
	"","","","","","","","","","","","","","","","","","","","","","","","","","","","",
};

char *Power_Management[]={
	"Digital temperature sensor is supported",
	"Intel Turbo Boost Technology Available",
	"ARAT APIC-Timer-always-running",
	"",
	"PLN Power limit notification controls",
	"ECMD Clock modulation duty cycle extension",
	"PTM Package thermal management"
};

CString GetCPUIDString()
{
	CString OutputStr,OrgStr;
	UINT32 i,j,Value[8],MaxOperand;
	CSortStringArray sortArray;

	MaxOperand = 0;
	OutputStr.Empty();
	for(i=0;i<=MaxOperand;i++)
	{
		if(i==7 || i==8 || i==0x0c)
		{
			continue;
		}
		memset(Value,0,sizeof(Value));
		GetCPUID(i,Value);
		OrgStr.Format("EAX Operand 0x%X,0x%08X-0x%08X-0x%08X-0x%08X\r\n",i,Value[0],Value[1],Value[2],Value[3]);
		OutputStr.Append(OrgStr);
		switch(i)
		{
			case 0:
				MaxOperand = Value[0];
				SWAP_VALUE(Value[2],Value[3]);
				OrgStr.Format("Vendor:%s\r\n",(char*)(&Value[1]));
				OutputStr.Append(OrgStr);
				OutputStr.Append("\r\n");
				break;
			case 1:
				OrgStr.Format("Extended Family ID:0x%X, Extended Model ID:0x%X, Family ID:0x%X, Model:0x%X, Stepping ID:0x%X\r\n",
					GetBitsValue(Value[0],20,27),GetBitsValue(Value[0],16,19),GetBitsValue(Value[0],8,11),
					GetBitsValue(Value[0],4,7),GetBitsValue(Value[0],0,3));
				OutputStr.Append(OrgStr);
				
				OrgStr.Format("Brand:%s, CLFLUSH line size:0x%X, Maximum number of addressable IDs:0x%X, Initial APIC ID: 0x%X\r\n",
					BrandString[GetBitsValue(Value[1],0,7)],GetBitsValue(Value[1],8,15),GetBitsValue(Value[1],24,31));
				OutputStr.Append(OrgStr);
				
				sortArray.RemoveAll();
				OrgStr.Empty();
				OutputStr.Append("Feature Information:");
				for(j=0;j<32;j++)
				{
					if(j==11 || j==16 || j==29 || j==30)
					{
						continue;
					}
					if(TEST_BIT(Value[2],j))
					{
						OrgStr.Format("%s,",Feature_Information1[j]);
						if(OrgStr.GetLength()<1)
						{
							continue;
						}
						sortArray.Add(OrgStr);
					}
				}

				for(j=0;j<32;j++)
				{
					if(j==10 || j==20 || j==30)
					{
						continue;
					}
					if(TEST_BIT(Value[3],j))
					{
						OrgStr.Format("%s,",Feature_Information2[j]);
						if(OrgStr.GetLength()<1)
						{
							continue;
						}
						sortArray.Add(OrgStr);
					}
				}

				sortArray.Sort();
				for(j=0;j<=sortArray.GetUpperBound();j++)
				{
					if(sortArray[j].GetLength()<1)
					{
						continue;
					}
					OutputStr.Append(sortArray[j]);
					if(j && 0==j%10)
					{
						OutputStr.Append("\r\n");
					}
				}
				OutputStr.Append("\r\n");
				OutputStr.Append("\r\n");
				break;
			case 2:
				sortArray.RemoveAll();
				if(!TEST_BIT(Value[0],31))
				{
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[0],24,31)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[0],16,23)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[0],8,15)]);
					sortArray.Add(OrgStr);
				}


				if(!TEST_BIT(Value[1],31))
				{
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[1],24,31)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[1],16,23)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[1],8,15)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[1],0,7)]);
					sortArray.Add(OrgStr);
				}

				if(!TEST_BIT(Value[2],31))
				{
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[2],24,31)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[2],16,23)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[2],8,15)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[2],0,7)]);
					sortArray.Add(OrgStr);
				}


				if(!TEST_BIT(Value[3],31))
				{
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[3],24,31)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[3],16,23)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[3],8,15)]);
					sortArray.Add(OrgStr);
					OrgStr.Format("%s",Leaf_2_Descriptors[GetBitsValue(Value[3],0,7)]);
					sortArray.Add(OrgStr);
				}

				sortArray.Sort();
				for(j=0;j<=sortArray.GetUpperBound();j++)
				{
					if(sortArray[j].GetLength()<1)
					{
						continue;
					}
					OutputStr.Append(sortArray[j]);
					OutputStr.Append("\r\n");
				}
				OutputStr.Append("\r\n");
				break;
			case 3:
				OrgStr.Format("processor serial number:0x%08X-0x%08X-0x%08X-0x%08X\r\n",Value[0],Value[1],Value[2],Value[3]);
				OutputStr.Append(OrgStr);
				OutputStr.Append("\r\n");
				break;
			case 4:
				GetCPUID2(4,0,Value);
				OrgStr.Format("Cache Type:%s,Cache Level:%d,Ways of associativity:%d,Cache Size:%dKB\r\n",
					Cache_Type[GetBitsValue(Value[0],0,4)],GetBitsValue(Value[0],5,7),GetBitsValue(Value[1],22,31),
					((GetBitsValue(Value[1],22,31)+1)*(GetBitsValue(Value[1],12,21)+1)*(GetBitsValue(Value[1],0,11)+1)*(Value[2]+1))>>10);
				OutputStr.Append(OrgStr);
				GetCPUID2(4,1,Value);
				OrgStr.Format("Cache Type:%s,Cache Level:%d,Ways of associativity:%d,Cache Size:%dKB\r\n",
					Cache_Type[GetBitsValue(Value[0],0,4)],GetBitsValue(Value[0],5,7),GetBitsValue(Value[1],22,31),
					((GetBitsValue(Value[1],22,31)+1)*(GetBitsValue(Value[1],12,21)+1)*(GetBitsValue(Value[1],0,11)+1)*(Value[2]+1))>>10);
				OutputStr.Append(OrgStr);
				GetCPUID2(4,2,Value);
				OrgStr.Format("Cache Type:%s,Cache Level:%d,Ways of associativity:%d,Cache Size:%dKB\r\n",
					Cache_Type[GetBitsValue(Value[0],0,4)],GetBitsValue(Value[0],5,7),GetBitsValue(Value[1],22,31),
					((GetBitsValue(Value[1],22,31)+1)*(GetBitsValue(Value[1],12,21)+1)*(GetBitsValue(Value[1],0,11)+1)*(Value[2]+1))>>10);
				OutputStr.Append(OrgStr);				
				OutputStr.Append("\r\n");
				break;
			case 5:
				break;
			case 6:
				for(j=0;j<=6;j++)
				{
					if(j==3)
					{
						continue;
					}
					if(TEST_BIT(Value[0],j))
					{
						OrgStr.Format("%s\r\n",Power_Management[j]);
						OutputStr.Append(OrgStr);
					}
				}
				OutputStr.Append("\r\n");
				break;
			case 0x0B:
				break;
			default:
				break;
		}
	}

	//m_Output.SetWindowText(OutputStr);

	OutputStr.Append("\r\n");
	MaxOperand = 0x80000000;
	for(i=0x80000000;i<=MaxOperand;i++)
	{
		memset(Value,0,sizeof(Value));
		GetCPUID(i,Value);
		OrgStr.Format("EAX Operand 0x%X,0x%08X-0x%08X-0x%08X-0x%08X\r\n",i,Value[0],Value[1],Value[2],Value[3]);
		OutputStr.Append(OrgStr);
		switch(i)
		{
			case 0x80000000:
				MaxOperand = Value[0];
				break;
			case 0x80000002:
			case 0x80000003:
			case 0x80000004:
				OrgStr.Format("%s\r\n",(char*)Value);
				OutputStr.Append(OrgStr);
				if (0x80000004 == i)
				{
					OutputStr.Append("\r\n");
				}
				break;
			default:
				//OrgStr.Format("0x%08X-0x%08X-0x%08X-0x%08X\r\n",Value[0],Value[1],Value[2],Value[3]);
				//OutputStr.Append(OrgStr);
				//OutputStr.Append("\r\n");
				break;
		}
	}

	return OutputStr;
}


推荐阅读
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
  • SpringMVC接收请求参数的方式总结
    本文总结了在SpringMVC开发中处理控制器参数的各种方式,包括处理使用@RequestParam注解的参数、MultipartFile类型参数和Simple类型参数的RequestParamMethodArgumentResolver,处理@RequestBody注解的参数的RequestResponseBodyMethodProcessor,以及PathVariableMapMethodArgumentResol等子类。 ... [详细]
  • 本文由编程笔记#小编整理,主要介绍了关于数论相关的知识,包括数论的算法和百度百科的链接。文章还介绍了欧几里得算法、辗转相除法、gcd、lcm和扩展欧几里得算法的使用方法。此外,文章还提到了数论在求解不定方程、模线性方程和乘法逆元方面的应用。摘要长度:184字。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 1引言在多线程并发编程中Synchronized一直是元老级角色,很多人都会称呼它为重量级锁,但是随着JavaSE1.6对Synchronized进行 ... [详细]
  • 本文目录一览:1、\mysybase.dump对数据库正常使用有影响吗 ... [详细]
author-avatar
小白牛
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有