CPU Info

BlitzMax Forums/BlitzMax Programming/CPU Info

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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