Pyrogenesis  trunk
Classes | Enumerations | Functions | Variables
x86_x64 Namespace Reference

Classes

struct  CpuidRegs
 registers used/returned by cpuid More...
 
class  ScopedSetPriority
 
class  StringStripper
 functor to remove substrings from the CPU identifier string More...
 

Enumerations

enum  Vendors { VENDOR_UNKNOWN, VENDOR_INTEL, VENDOR_AMD }
 CPU vendor. More...
 
enum  Models {
  MODEL_NEHALEM_EP = 0x1A, MODEL_NEHALEM_EP_2 = 0x1E, MODEL_I7_I5 = 0x1F, MODEL_CLARKDALE = 0x25,
  MODEL_WESTMERE_EP = 0x2C, MODEL_NEHALEM_EX = 0x2E, MODEL_WESTMERE_EX = 0x2F, MODEL_SANDY_BRIDGE = 0x2A,
  MODEL_SANDY_BRIDGE_2 = 0x2D
}
 
enum  Caps {
  CAP_SSE3 = 0+0, CAP_EST = 0+7, CAP_SSSE3 = 0+9, CAP_SSE41 = 0+19,
  CAP_SSE42 = 0+20, CAP_FPU = 32+0, CAP_TSC = 32+4, CAP_MSR = 32+5,
  CAP_CMOV = 32+15, CAP_TM_SCC = 32+22, CAP_MMX = 32+23, CAP_SSE = 32+25,
  CAP_SSE2 = 32+26, CAP_HT = 32+28, CAP_AMD_CMP_LEGACY = 64+1, CAP_AMD_MP = 96+19,
  CAP_AMD_MMX_EXT = 96+22, CAP_AMD_3DNOW_PRO = 96+30, CAP_AMD_3DNOW = 96+31
}
 bit indices of CPU capability flags (128 bits). More...
 

Functions

static void Invoke_cpuid (CpuidRegs *regs)
 
static Status InitCpuid ()
 
bool cpuid (CpuidRegs *regs)
 invoke CPUID instruction. More...
 
static Status InitCaps ()
 
bool Cap (Caps cap)
 
void GetCapBits (u32 *d0, u32 *d1, u32 *d2, u32 *d3)
 
static Status InitVendor ()
 
Vendors Vendor ()
 
static Status InitSignature ()
 
size_t Model ()
 
size_t Family ()
 
static Status InitIdentifierString ()
 
static const char * IdentifierString ()
 
u64 rdtsc ()
 
void DebugBreak ()
 trigger a breakpoint inside this function when it is called. More...
 
double ClockFrequency ()
 measure the CPU clock frequency via rdtsc and timer_Time. More...
 
size_t Generation ()
 

Variables

static u32 cpuid_maxFunction
 
static u32 cpuid_maxExtendedFunction
 
static u32 caps [4]
 
static ModuleInitState capsInitState
 
static Vendors vendor
 
static size_t m_Model
 
static size_t m_Family
 
static ModuleInitState signatureInitState
 
static char identifierString [48+1]
 

Enumeration Type Documentation

◆ Caps

bit indices of CPU capability flags (128 bits).

values are defined by IA-32 CPUID feature flags - do not change!

Enumerator
CAP_SSE3 
CAP_EST 
CAP_SSSE3 
CAP_SSE41 
CAP_SSE42 
CAP_FPU 
CAP_TSC 
CAP_MSR 
CAP_CMOV 
CAP_TM_SCC 
CAP_MMX 
CAP_SSE 
CAP_SSE2 
CAP_HT 
CAP_AMD_CMP_LEGACY 
CAP_AMD_MP 
CAP_AMD_MMX_EXT 
CAP_AMD_3DNOW_PRO 
CAP_AMD_3DNOW 

◆ Models

Enumerator
MODEL_NEHALEM_EP 
MODEL_NEHALEM_EP_2 
MODEL_I7_I5 
MODEL_CLARKDALE 
MODEL_WESTMERE_EP 
MODEL_NEHALEM_EX 
MODEL_WESTMERE_EX 
MODEL_SANDY_BRIDGE 
MODEL_SANDY_BRIDGE_2 

◆ Vendors

CPU vendor.

(this is exposed because some CPUID functions are vendor-specific.) (an enum is easier to compare than the original string values.)

Enumerator
VENDOR_UNKNOWN 
VENDOR_INTEL 
VENDOR_AMD 

Function Documentation

◆ Cap()

bool x86_x64::Cap ( Caps  cap)
Returns
whether the CPU supports the indicated Cap / feature flag.

◆ ClockFrequency()

double x86_x64::ClockFrequency ( )

measure the CPU clock frequency via rdtsc and timer_Time.

(it follows that this must not be called from WHRT init.) this takes several milliseconds (i.e. much longer than os_cpu_ClockFrequency) but delivers accurate measurements.

◆ cpuid()

bool x86_x64::cpuid ( CpuidRegs regs)

invoke CPUID instruction.

Parameters
regsinput/output registers. regs->eax must be set to the desired function. some functions (e.g. 4) require regs->ecx to be set as well. rationale: this interface (input/output structure vs. function parameters) avoids unnecessary copying/initialization if some inputs aren't needed and allows graceful expansion to functions that require further inputs.
Returns
true on success or false if the sub-function isn't supported.

◆ DebugBreak()

void x86_x64::DebugBreak ( )

trigger a breakpoint inside this function when it is called.

◆ Family()

size_t x86_x64::Family ( )

◆ Generation()

size_t x86_x64::Generation ( )
Returns
the colloquial processor generation (5 = Pentium, 6 = Pentium Pro/II/III / K6, 7 = Pentium4 / Athlon, 8 = Core / Opteron)

◆ GetCapBits()

void x86_x64::GetCapBits ( u32 d0,
u32 d1,
u32 d2,
u32 d3 
)

◆ IdentifierString()

static const char* x86_x64::IdentifierString ( )
static

◆ InitCaps()

static Status x86_x64::InitCaps ( )
static

◆ InitCpuid()

static Status x86_x64::InitCpuid ( )
static

◆ InitIdentifierString()

static Status x86_x64::InitIdentifierString ( )
static

◆ InitSignature()

static Status x86_x64::InitSignature ( )
static

◆ InitVendor()

static Status x86_x64::InitVendor ( )
static

◆ Invoke_cpuid()

static void x86_x64::Invoke_cpuid ( CpuidRegs regs)
static

◆ Model()

size_t x86_x64::Model ( )

◆ rdtsc()

u64 x86_x64::rdtsc ( )
Returns
the current value of the TimeStampCounter (a counter of CPU cycles since power-on, which is useful for high-resolution timing but potentially differs between multiple CPUs)

notes:

  • a macro avoids call overhead, which is important for TIMER_ACCRUE.
  • x64 RDTSC writes to edx:eax and clears the upper halves of rdx and rax.

◆ Vendor()

Vendors x86_x64::Vendor ( )

Variable Documentation

◆ caps

u32 x86_x64::caps[4]
static

◆ capsInitState

ModuleInitState x86_x64::capsInitState
static

◆ cpuid_maxExtendedFunction

u32 x86_x64::cpuid_maxExtendedFunction
static

◆ cpuid_maxFunction

u32 x86_x64::cpuid_maxFunction
static

◆ identifierString

char x86_x64::identifierString[48+1]
static

◆ m_Family

size_t x86_x64::m_Family
static

◆ m_Model

size_t x86_x64::m_Model
static

◆ signatureInitState

ModuleInitState x86_x64::signatureInitState
static

◆ vendor

Vendors x86_x64::vendor
static