CPU Info

BlitzMax Forums/BlitzMax Programming/CPU Info

Here is a CPU information dll I made. If its not accurate let me know.

dll and example -> http://www.stuartmorgan.5gigs.com/Files/CPU_Info.zip

Strict

' Function declarations

Global CPU_RetrieveInfo()
Global CPU_GetCPUString$z()
Global CPU_GetSteppingID()
Global CPU_GetModel()
Global CPU_GetFamily()
Global CPU_GetProcessorType()
Global CPU_GetExtendedModel()
Global CPU_GetExtendedFamily()
Global CPU_GetBrandIndex()
Global CPU_GetCPUBrand$z()
Global CPU_GetCacheLineSize()
Global CPU_GetL2Associativity()
Global CPU_GetCacheSize()
Global CPU_GetFeature(index)

' CPU Features
' Unknowns are reserved features

Const X87_FPU_ON_CHIP = 0
Const VIRTUAL_8086_MODE_ENHANCEMENT = 1
Const DEBUGGING_EXTENSIONS = 2
Const PAGE_FILE_EXTENSIONS = 3
Const TIME_STAMP_COUNTER = 4
Const RDMSR_AND_WRMSR_SUPPORT = 5
Const PHYSICAL_ADDRESS_EXTENSIONS = 6
Const MACHINE_CHECK_EXCEPTION = 7
Const CMPXCHG8B_INSTRUCTION = 8
Const APIC_ON_CHIP = 9
Const UNKNOWN1 = 10
Const SYSENTER_AND_SYSEXIT = 11
Const MEMORY_TYPE_RANGE_REGISTERS = 12
Const PTE_GLOBAL_BIT = 13
Const MACHINE_CHECK_ARCHITECTURE = 14
Const CONDITIONAL_MOVE_COMPARE_INSTRUCTION = 15
Const PAGE_ATTRIBUTE_TABLE = 16
Const PAGE_SIZE_EXTENSION = 17
Const PROCESSOR_SERIAL_NUMBER = 18
Const CFLUSH_EXTENSION = 19
Const UNKNOWN2 = 20
Const DEBUG_STORE = 21
Const THERMAL_MONITOR_AND_CLOCK_CTRL = 22
Const MMX_TECHNOLOGY = 23
Const FXSAVE_FXRSTOR = 24
Const SSE_EXTENSIONS = 25
Const SSE2_EXTENSIONS = 26
Const SELF_SNOOP = 27
Const HYPER_THREADING_TECHNOLOGY = 28
Const THERMAL_MONITOR = 29
Const UNKNOWN4 = 30
Const PEND_BRK_EN = 31

' Load Dll

Local lib = LoadLibraryA("CPUInfo.dll")

If lib
    CPU_RetrieveInfo = GetProcAddress(lib,"CPU_RetrieveInfo")
	CPU_GetCPUString = GetProcAddress(lib,"CPU_GetCPUString")
	CPU_GetSteppingID = GetProcAddress(lib,"CPU_GetSteppingID")
	CPU_GetModel = GetProcAddress(lib,"CPU_GetModel")
	CPU_GetFamily = GetProcAddress(lib,"CPU_GetFamily")
	CPU_GetProcessorType = GetProcAddress(lib,"CPU_GetProcessorType")
	CPU_GetExtendedModel = GetProcAddress(lib,"CPU_GetExtendedModel")
	CPU_GetExtendedFamily = GetProcAddress(lib,"CPU_GetExtendedFamily")
	CPU_GetBrandIndex = GetProcAddress(lib,"CPU_GetBrandIndex")
	CPU_GetCPUBrand = GetProcAddress(lib,"CPU_GetCPUBrand")
	CPU_GetCacheLineSize = GetProcAddress(lib,"CPU_GetCacheLineSize")
	CPU_GetL2Associativity = GetProcAddress(lib,"CPU_GetL2Associativity")
	CPU_GetCacheSize = GetProcAddress(lib,"CPU_GetCacheSize")
	CPU_GetFeature = GetProcAddress(lib,"CPU_GetFeature")
Else
    Print "Library not found"
	End
EndIf

' CPU_RetrieveInfo must be called first to get all the info

CPU_RetrieveInfo()

Local cpu_string:String = CPU_GetCPUString()
Local cpu_brand:String = CPU_GetCPUBrand()

Print ""
Print "CPU String: "+cpu_string
Print "CPU Brand: "+cpu_brand
Print "Stepping ID: "+CPU_GetSteppingID()
Print "Model: "+CPU_GetModel()
Print "Family: "+CPU_GetFamily()
Print ""
Print "Processor type: " + CPU_GetProcessorType()
Print "Extended model: " + CPU_GetExtendedModel()
Print "Extended family: " + CPU_GetExtendedFamily()
Print "Brand index: " + CPU_GetBrandIndex()
Print ""
Print "Cache line size: " + CPU_GetCacheLineSize() + "Kb"
Print "L2 Associativity: " + CPU_GetL2Associativity()
Print "Cache size: " + CPU_GetCacheSize() + "Kb"
Print ""
Print "The folllowing features are supported:"
Print ""
Print "~tx87 FPU On Chip - " + YesNo(CPU_GetFeature(0))
Print "~tVirtual-8086 Mode Enhancement - " + YesNo(CPU_GetFeature(1))
Print "~tDebugging Extensions - " + YesNo(CPU_GetFeature(2))
Print "~tPage Size Extensions - " + YesNo(CPU_GetFeature(3))
Print "~tTime Stamp Counter - " + YesNo(CPU_GetFeature(4))
Print "~tRDMSR and WRMSR Support - " + YesNo(CPU_GetFeature(5))
Print "~tPhysical Address Extensions - " + YesNo(CPU_GetFeature(6))
Print "~tMachine Check Exception - " + YesNo(CPU_GetFeature(7))
Print "~tCMPXCHG8B Instruction - " + YesNo(CPU_GetFeature(8))
Print "~tAPIC On Chip - " + YesNo(CPU_GetFeature(9))
Print "~tUnknown1 - " + YesNo(CPU_GetFeature(10))
Print "~tSYSENTER and SYSEXIT - " + YesNo(CPU_GetFeature(11))
Print "~tMemory Type Range Registers - " + YesNo(CPU_GetFeature(12))
Print "~tPTE Global Bit - " + YesNo(CPU_GetFeature(13))
Print "~tMachine Check Architecture - " + YesNo(CPU_GetFeature(14))
Print "~tConditional Move/Compare Instruction - " + YesNo(CPU_GetFeature(15))
Print "~tPage Attribute Table - " + YesNo(CPU_GetFeature(16))
Print "~tPage Size Extension - " + YesNo(CPU_GetFeature(17))
Print "~tProcessor Serial Number - " + YesNo(CPU_GetFeature(18))
Print "~tCFLUSH Extension - " + YesNo(CPU_GetFeature(19))
Print "~tUnknown2 - " + YesNo(CPU_GetFeature(20))
Print "~tDebug Store - " + YesNo(CPU_GetFeature(21))
Print "~tThermal Monitor and Clock Ctrl - " + YesNo(CPU_GetFeature(22))
Print "~tMMX Technology - " + YesNo(CPU_GetFeature(23))
Print "~tFXSAVE/FXRSTOR - " + YesNo(CPU_GetFeature(24))
Print "~tSSE Extensions - " + YesNo(CPU_GetFeature(25))
Print "~tSSE2 Extensions - " + YesNo(CPU_GetFeature(26))
Print "~tSelf Snoop - " + YesNo(CPU_GetFeature(27))
Print "~tHyper-threading Technology - " + YesNo(CPU_GetFeature(28))
Print "~tThermal Monitor - " + YesNo(CPU_GetFeature(29))
Print "~tUnknown4 - " + YesNo(CPU_GetFeature(30))
Print "~tPend. Brk. EN. - " + YesNo(CPU_GetFeature(31))

Function YesNo:String(value)
	If value = 1
		Return "Yes"
	Else
		Return "No"
	EndIf
End Function


Sounds good, but weirdly enough it can't find the DLL here, when it's right there in the directory with the source! What compiler was the DLL created with? Any chance you could post an executable so I can see if that works?


CPU_RetreiveInfo


I before E, except after C, etc... "retrieve" :P

hmmm was made with Visual C++ 2005

try this (C exe) -> http://www.stuartmorgan.5gigs.com/Files/CPUInfo.exe

I before E, except after C, etc... "retrieve" :P

Thx, Ill remember that. ;)

Built without .NET dependency?

Ok, sorry it does require .NET, I'll see if i can adapt it to work without it.

Hmm, I do have .net installed, but no idea if such a DLL should work if called 'normally' (I'd have thought so). No joy with the executable here, but (apparently) for other reasons:


"This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."



perhaps .NET installation error? (or not the .NET 2.0 beta as he uses beta software ... would be quite "anormal" to have MS beta installed ;))

Same problem for me, I have .net installed.

If it's built with C++ 2005 (Whidbey) it needs the .NET 2.0 framework to run.

The .NET Framework 2.0 redistributable can be found here (public BETA, release in November):

.NET Framework Version 2.0 Redistributable Package Beta 2 (x86)

.NET Framework 2.0 runs fine together with 1.0/1.1. (At least on XP). I've been running them in parallell since March. No problems.

Yeah or the creator has to change the used .NET back to 1.1 if no newer vesion is needed. As he only uses C++, there shouldn't be much of a problem

It should now work without .NET but I cant gaurantee that it will.

Check updated link at top.

That worked... not sure how much is true!


CPU String: AuthenticAMD
CPU Brand: AMD Athlon(tm)
Stepping ID: 1
Model: 8
Family: 6

Processor type: 0
Extended model: 0
Extended family: 0
Brand index: 0

Cache line size: 64Kb
L2 Associativity: 8
Cache size: 256Kb

The folllowing features are supported:

x87 FPU On Chip - Yes
Virtual-8086 Mode Enhancement - Yes
Debugging Extensions - Yes
Page Size Extensions - Yes
Time Stamp Counter - Yes
RDMSR and WRMSR Support - Yes
Physical Address Extensions - Yes
Machine Check Exception - Yes
CMPXCHG8B Instruction - Yes
APIC On Chip - Yes
Unknown1 - No
SYSENTER and SYSEXIT - Yes
Memory Type Range Registers - Yes
PTE Global Bit - Yes
Machine Check Architecture - Yes
Conditional Move/Compare Instruction - Yes
Page Attribute Table - Yes
Page Size Extension - Yes
Processor Serial Number - No
CFLUSH Extension - No
Unknown2 - No
Debug Store - No
Thermal Monitor and Clock Ctrl - No
MMX Technology - Yes
FXSAVE/FXRSTOR - Yes
SSE Extensions - Yes
SSE2 Extensions - No
Self Snoop - No
Hyper-threading Technology - No
Thermal Monitor - No
Unknown4 - No
Pend. Brk. EN. - No