News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

SYSTEM_PROCESSOR_INFORMATION documented

Started by guga, July 13, 2014, 06:34:15 PM

Previous topic - Next topic

guga

SYSTEM_PROCESSOR_INFORMATION structure documented by me
Quote
SYSTEM_PROCESSOR_INFORMATION

structure

Retrieves information about the processor architecture.

RosAsm syntax:

[SYSTEM_PROCESSOR_INFORMATION:
ProcessorArchitecture: W$ 0
ProcessorLevel: W$ 0
ProcessorRevision: W$ 0
MaximumProcessors: W$ 0
ProcessorFeatureBits: D$ 0]

C Syntax:

typedef struct _SYSTEM_PROCESSOR_INFORMATION {
    USHORT ProcessorArchitecture;
    USHORT ProcessorLevel;
    USHORT ProcessorRevision;
    USHORT MaximumProcessors;
    ULONG ProcessorFeatureBits;
} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;


Members
ProcessorArchitecture
   The system's processor architecture. Some of the possible values are defined in winnt.h and SYSTEM_INFO structure with identifiers of the form PROCESSOR_ARCHITECTURE_* (where '*' is a wildcard).
   This member can be one of the following values.


PROCESSOR_ARCHITECTURE_ALPHA   02   Alpha 32 bits developed by Digital Equipment Corp.      
PROCESSOR_ARCHITECTURE_ALPHA64   07   Alpha 64 bits developed by Digital Equipment Corp.      
PROCESSOR_ARCHITECTURE_AMD64   09   x64 (AMD or Intel)      
PROCESSOR_ARCHITECTURE_ARM   05   ARM      
PROCESSOR_ARCHITECTURE_IA32_ON_WIN64   0A         
PROCESSOR_ARCHITECTURE_IA64   06   Intel Itanium-based      
PROCESSOR_ARCHITECTURE_INTEL   0   x86      
PROCESSOR_ARCHITECTURE_MIPS   01   MIPS (Microprocessor without interlocked pipeline stages)      
PROCESSOR_ARCHITECTURE_MSIL   08   MSIL (Microsoft Intermediate Language)      
PROCESSOR_ARCHITECTURE_PPC   03   PowerPC      
PROCESSOR_ARCHITECTURE_SHX   04   ShX microprocessor architecture type.      
PROCESSOR_ARCHITECTURE_UNKNOWN   0FFFF   Unknown microprocessor architecture type.   

ProcessorLevel
   The system's architecture-dependent processor level. Some of the possible values are defined in the Win32 documentation for the SYSTEM_INFO structure.
   It should be used only for display purposes. To determine the feature set of a processor, use the IsProcessorFeaturePresent function.
   If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, wProcessorLevel is defined by the CPU vendor.
   If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, wProcessorLevel is set to 1.

   This is the least common denominator for an MP system:
      For PROCESSOR_ARCHITECTURE_IA64:
                        1 - Intel 64 bits

      For PROCESSOR_ARCHITECTURE_INTEL:
                        3 - Intel 80386
                        4 - Intel 80486
                        5 - Intel 586 or Pentium
                        6 - Intel Pentium Pro or Pentium II, I7 (I presume if you are using XP, the maximum value is 6, since my processor is an I7 and it returns also 6)

      For PROCESSOR_ARCHITECTURE_MIPS:
                        00xx - where xx is 8-bit implementation number (bits 8-15 of PRId register)
                        0004 - Mips R4000. The best way to retrieve the level is perform an "And 0FF" operation with ProcessorLevel value
             If the resultant value is 4, then it is a Mips R4000

      For PROCESSOR_ARCHITECTURE_ALPHA:
                        xxxx - where xxxx is 16-bit processor version number (low order 16 bits of processor version number from firmware)
                        21064 - Alpha 21064
                        21066 - Alpha 21066
                        21164 - Alpha 21164

      For PROCESSOR_ARCHITECTURE_PPC:
                        xxxx - where xxxx is 16-bit processor version number (high order 16 bits of Processor Version Register).
                        1 - PPC 601
                        3 - PPC 603
                        4 - PPC 604
                        6 - PPC 603+
                        9 - PPC 604+
                        20 - PPC 620

ProcessorRevision
   The system's architecture-dependent processor revision. Some of the possible values are defined in the Win32 documentation for the SYSTEM_INFO structure.
   The following table shows how the revision value is assembled for each type of processor architecture.
      Processor            Value
      Intel Pentium, Cyrix, or NextGen 586   The high byte is the model and the low byte is the stepping. For example, if the value is xxyy, the model number and stepping can be displayed as follows:
                     Model xx, Stepping yy
      Intel 80386 or 80486         A value of the form xxyz.
                     If xx is equal to 0xFF, y - 0xA is the model number, and z is the stepping identifier.
                     If xx is not equal to 0xFF, xx + 'A' is the stepping letter and yz is the minor stepping.
      ARM               Reserved.

   Other examples. This is the least common denominator for an MP system:

                    For PROCESSOR_ARCHITECTURE_INTEL:
                        For Old Intel 386 or 486:
                            FFxx - where xx is displayed as a hexadecimal CPU stepping (e.g. FFD0 is D0 stepping)
                        For Intel Pentium or Cyrix/NexGen 486
                            xxyy - where xx is model number and yy is stepping, so 0201 is Model 2, Stepping 1

                    For PROCESSOR_ARCHITECTURE_MIPS:
                        00xx is 8-bit revision number of processor (low order 8 bits of PRId Register)

                    For PROCESSOR_ARCHITECTURE_ALPHA:
                        xxyy - where xxyy is 16-bit processor revision number (low order 16 bits of processor revision number from firmware). Displayed as Model 'A'+xx, Pass yy

                    For PROCESSOR_ARCHITECTURE_PPC:
                        xxyy - where xxyy is 16-bit processor revision number (low order 16 bits of Processor Version Register).  Displayed as a fixed point number xx.yy

MaximumProcessors
   On Windows8 and above it contains the maximum amount of processors allowed to be inserted on the hardware.
   On older Windows versions, this value is always contains zero.

ProcessorFeatureBits
   A bit mask representing any special features of the system's processor (for example, whether the Intel MMX instruction set is available).The flags for the Intel platform include:
      For i386 Feature bit definitions can be represented as

Equate Name   Value   Description      
KF_V86_VIS   01   VME: Virtual-8086 Mode Enhancements      
KF_RDTSC   02   TCS: Time Stamp Counter      
KF_CR4   04   CR4 Register      
KF_CMOV   08   Conditional Mov/Cmp Instruction      
KF_GLOBAL_PAGE   010   PTE Global Bit      
KF_LARGE_PAGE   020   PSE: Page Size Extensions      
KF_MTRR   040   Memory Type Range Registers      
KF_CMPXCHG8B   080   CMPXCHGB8 Instruction      
KF_MMX   0100   MMX Technology      
KF_WORKING_PTE   0200   PTE: Page Table Extensions      
KF_PAT   0400   Page Attribute Table      
KF_FXSR   0800   Fast Floating Point Save and Restore      
KF_FAST_SYSCALL   01000   Syscall      
KF_XMMI   02000   Streaming SIMD Extension      
KF_3DNOW   04000   3D Now      
KF_AMDK6MTRR   08000         
KF_XMMI64   010000         
KF_DTS   020000         
KF_NOEXECUTE   020000000         
KF_GLOBAL_32BIT_EXECUTE   040000000         
KF_GLOBAL_32BIT_NOEXECUTE   080000000      

Remarks
   Much of the data in this information class can be obtained by calling the Win32 function GetSystemInfo.

See also:
i386.h
amd64.h
kernlini.c
sysinfo.c
GetSystemInfo
GetNativeSystemInfo
IsProcessorFeaturePresent


Example:

Use Windows.Pkg
Use Dferror.Pkg

Type SYSTEM_INFO
   Field SYSTEM_INFO.wProcessorArchitecture As Word
   Field SYSTEM_INFO.wReserved As Word
   Field SYSTEM_INFO.dwPageSize As Dword
   Field SYSTEM_INFO.lpMinimumApplicationAddress As Pointer
   Field SYSTEM_INFO.lpMaximumApplicationAddress As Pointer
   Field SYSTEM_INFO.dwActiveProcessorMask As Dword
   Field SYSTEM_INFO.dwNumberOfProcessors As Dword
   Field SYSTEM_INFO.dwProcessorType As Dword
   Field SYSTEM_INFO.dwAllocationGranularity As Dword
   Field SYSTEM_INFO.wProcessorLevel As Word
   Field SYSTEM_INFO.wProcessorRevision As Word
End_Type // SYSTEM_INFO

External_Function WinAPI_GetSystemInfo "GetSystemInfo" Kernel32.Dll Pointer lpSystemInfo Returns Integer

Define PROCESSOR_INTEL_386     For 386
Define PROCESSOR_INTEL_486     For 486
Define PROCESSOR_INTEL_PENTIUM For 586
Define PROCESSOR_MIPS_R4000    For 4000    // incl R4101 & R3910 for Windows CE
Define PROCESSOR_ALPHA_21064   For 21064
Define PROCESSOR_PPC_601       For 601
Define PROCESSOR_PPC_603       For 603
Define PROCESSOR_PPC_604       For 604
Define PROCESSOR_PPC_620       For 620
Define PROCESSOR_HITACHI_SH3   For 10003   // Windows CE
Define PROCESSOR_HITACHI_SH3E  For 10004   // Windows CE
Define PROCESSOR_HITACHI_SH4   For 10005   // Windows CE
Define PROCESSOR_MOTOROLA_821  For 821     // Windows CE
Define PROCESSOR_SHx_SH3       For 103     // Windows CE
Define PROCESSOR_SHx_SH4       For 104     // Windows CE
Define PROCESSOR_STRONGARM     For 2577    // Windows CE - 0xA11
Define PROCESSOR_ARM720        For 1824    // Windows CE - 0x720
Define PROCESSOR_ARM820        For 2080    // Windows CE - 0x820
Define PROCESSOR_ARM920        For 2336    // Windows CE - 0x920
Define PROCESSOR_ARM_7TDMI     For 70001   // Windows CE

Define PROCESSOR_ARCHITECTURE_INTEL   For 0
Define PROCESSOR_ARCHITECTURE_MIPS    For 1
Define PROCESSOR_ARCHITECTURE_ALPHA   For 2
Define PROCESSOR_ARCHITECTURE_PPC     For 3
Define PROCESSOR_ARCHITECTURE_SHX     For 4
Define PROCESSOR_ARCHITECTURE_ARM     For 5
Define PROCESSOR_ARCHITECTURE_IA64    For 6
Define PROCESSOR_ARCHITECTURE_ALPHA64 For 7
Define PROCESSOR_ARCHITECTURE_UNKNOWN For |CI$FFFF

Procedure DoTest
   String sSystemInfo
   Integer iVoid iProcessorArchitecture iProcessorType iProcessorLevel iProcessorRevision iProcessorCount

   ZeroType SYSTEM_INFO To sSystemInfo

   Move (WinAPI_GetSystemInfo (AddressOf (sSystemInfo))) To iVoid

   GetBuff From sSystemInfo At SYSTEM_INFO.wProcessorArchitecture To iProcessorArchitecture
   Showln "ProcessorArchitecture: " iProcessorArchitecture

   GetBuff From sSystemInfo At SYSTEM_INFO.dwNumberOfProcessors To iProcessorCount
   Showln "ProcessorCount: " iProcessorCount

   GetBuff From sSystemInfo At SYSTEM_INFO.dwProcessorType To iProcessorType
   Showln "ProcessorType: " iProcessorType

   GetBuff From sSystemInfo At SYSTEM_INFO.wProcessorLevel To iProcessorLevel
   Show "ProcessorLevel; "
   Case Begin
      Case (iProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL)
         Case Begin
            Case (iProcessorLevel = 3)
               Showln "Intel 80386"
               Case Break
            Case (iProcessorLevel = 4)
               Showln "Intel 80486"
               Case Break
            Case (iProcessorLevel = 5)
               Showln "Intel Pentium"
               Case Break
            Case (iProcessorLevel = 6)
               Showln "Intel Pentium Pro or Pentium II"
               Case Break
            Case Else
               Showln "Intel MSDN unspecified " iProcessorLevel
               Case Break
         Case End
         Case Break
      Case (iProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64)
         Showln "Intel 64 bits"
         Case Break
      Case (iProcessorArchitecture = PROCESSOR_ARCHITECTURE_MIPS)
         If ((iProcessorLevel iAnd $FF) = 4) Begin
            Showln "MIPS R4000"
         End
         Else Begin
            Showln "MIPS MSDN unspecified " iProcessorLevel
         End
         Case Break
      Case (iProcessorArchitecture = PROCESSOR_ARCHITECTURE_ALPHA)
         Case Begin
            Case (iProcessorLevel = 21064)
               Showln "Alpha 21064"
               Case Break
            Case (iProcessorLevel = 21066)
               Showln "Alpha 21066"
               Case Break
            Case (iProcessorLevel = 21164)
               Showln "Alpha 21164"
               Case Break
            Case Else
               Showln "Alpha MSDN unspecified"
               Case Break
         Case End
         Case Break
      Case (iProcessorArchitecture = PROCESSOR_ARCHITECTURE_PPC)
         Case Begin
            Case (iProcessorLevel = 1)
               Showln "PPC 601"
               Case Break
            Case (iProcessorLevel = 3)
               Showln "PPC 603"
               Case Break
            Case (iProcessorLevel = 4)
               Showln "PPC 604"
               Case Break
            Case (iProcessorLevel = 6)
               Showln "PPC 603+"
               Case Break
            Case (iProcessorLevel = 9)
               Showln "PPC 604+"
               Case Break
            Case (iProcessorLevel = 20)
               Showln "PPC 620"
               Case Break
            Case Else
               Showln "PPC MSDN unspecified"
               Case Break
         Case End
         Case Break
      Case Else
         Showln "Architecture MSDN unspecified, processor level " iProcessorLevel
         Case Break
   Case End

   GetBuff From sSystemInfo At SYSTEM_INFO.wProcessorRevision To iProcessorRevision
   Show "ProcessorRevision; "
   Case Begin
      Case (iProcessorType = PROCESSOR_INTEL_386)
      Case (iProcessorType = PROCESSOR_INTEL_486)
         If ((iProcessorRevision / $000000FF) = $FF) Begin
            Showln "Model " ((iProcessorRevision iAnd $000000FF) - $0A) ", stepping " (iProcessorRevision iAnd $0000000F)
         End
         Else Begin
            Showln "Model " (iProcessorRevision / $000000FF) "A, minor stepping " (iProcessorRevision iAnd $000000FF)
         End
         Case Break
      Case (iProcessorType = PROCESSOR_INTEL_PENTIUM)
         Showln "Model " (iProcessorRevision / $000000FF) ", stepping " (iProcessorRevision iAnd $000000FF)
         Case Break
      Case (iProcessorType = PROCESSOR_MIPS_R4000)
         Showln "Processor revision " (iProcessorRevision iAnd $000000FF)
         Case Break
      Case (iProcessorType = PROCESSOR_ALPHA_21064)
         Showln "Model A+" (iProcessorRevision / $000000FF) ", Pass " (iProcessorRevision iAnd $000000FF)
         Case Break
      Case (iProcessorType = PROCESSOR_PPC_601)
      Case (iProcessorType = PROCESSOR_PPC_603)
      Case (iProcessorType = PROCESSOR_PPC_604)
      Case (iProcessorType = PROCESSOR_PPC_620)
         Showln (iProcessorRevision / $000000FF) "." (iProcessorRevision iAnd $000000FF)
         Case Break
      Case Else
         Showln "Unkown type: " iProcessorRevision
         Case Break
   Case End
End_Procedure // DoTest

Send DoTest
Send Info_Box "Ready"

NOTE:
The above code is NOT tested on any platform else than a INTEL PENTIUM III 450 Mhz running Windows 2000.


This structure is to be used with SYS_NFO_SYSTEM_PROCESSOR_INFORMATION equate (Aka: SystemProcessorInformation. Value = 01) in NtQuerySystemInformation function.

Example of usage:
[SYSTEM_PROCESSOR_INFORMATION:
SYSTEM_PROCESSOR_INFORMATION.ProcessorArchitecture: W$ 0
SYSTEM_PROCESSOR_INFORMATION.ProcessorLevel: W$ 0
SYSTEM_PROCESSOR_INFORMATION.ProcessorRevision: W$ 0
SYSTEM_PROCESSOR_INFORMATION.MaximumProcessors: W$ 0
SYSTEM_PROCESSOR_INFORMATION.ProcessorFeatureBits: D$ 0]

[Size_of_SYSTEM_PROCESSOR_INFORMATION 12]

call 'ntdll.NtQuerySystemInformation' &SYS_NFO_SYSTEM_PROCESSOR_INFORMATION, SYSTEM_PROCESSOR_INFORMATION, Size_of_SYSTEM_PROCESSOR_INFORMATION, 0


Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Gunther

You have to know the facts before you can distort them.

guga

Tks Gunther  :t

The worst thing is, this whole set of enumerations and structures are already documented since 1999 from the book WindowsNT-2000 Native API Reference, and also on all sources i have of windows (NT, 2000 and the Windows Research Kernel) all of this is somewhat documented.

There is absolutely no reason why M$ didn´t do that.

The worst is, i´m having to gatter information from a pdb dumper as well, to check for the information for the different OSes, like in here for example.

I took a look in some pdb dumpers available, but i strongly believe that we really need our own tool for that task. It shouldn´t be hard to code one that can export header files. Maybe eventually i´ll be forced to do such app, but if others could do that, it will be way better :)

I always believed that the information inside a pdb and a lib file so important as the source code itself.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Gunther

Gustavo,

Quote from: guga on July 13, 2014, 08:31:42 PM
I always believed that the information inside a pdb and a lib file so important as the source code itself.

No doubt about that. Thank you again for your work.

Gunther
You have to know the facts before you can distort them.

Zen

GUGA (GUSTAVO),
This is great intel, thanks. Do you mind if I highjack some of the defines for my MASM project ???
Zen

guga

Hi Zen

of course i don´t mind. Feel free to use it as you wish  :t
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com