cpu Reference

File
core/xeos/include/xeos/hal/cpu.h
Date
Wednesday, June 25, 2014
Includes
  • <stdbool.h>
  • <stdint.h>

Tasks

XEOS_HAL_CPU_CPUID

CPU identification (cpuid instruction)

void XEOS_HAL_CPU_CPUID( uint32_t info, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx );

Parameters
  • info
    The info to request
  • eax
    On return, the content of the EAX register
  • ebx
    On return, the content of the EBX register
  • ecx
    On return, the content of the ECX register
  • edx
    On return, the content of the EDX register

XEOS_HAL_CPU_DisableInterrupts

Disables all interrupts

void XEOS_HAL_CPU_DisableInterrupts( void );

XEOS_HAL_CPU_DisablePAE

Disables PAE (Physical Address Extension)

void XEOS_HAL_CPU_DisablePAE( void );

XEOS_HAL_CPU_DisablePaging

Disables paging

void XEOS_HAL_CPU_DisablePaging( void );

XEOS_HAL_CPU_EnableInterrupts

Enables all interrupts

void XEOS_HAL_CPU_EnableInterrupts( void );

XEOS_HAL_CPU_EnablePAE

Enables PAE (Physical Address Extension)

void XEOS_HAL_CPU_EnablePAE( void );

XEOS_HAL_CPU_EnablePaging

Enables paging

void XEOS_HAL_CPU_EnablePaging( void );

XEOS_HAL_CPU_GetBrandName

Gets the CPU brand name string

const char * XEOS_HAL_CPU_GetBrandName( void );

Return value

The CPU brand name string

XEOS_HAL_CPU_GetCR0

Gets the content of the Control Register 0 (CR0)

uint32_t XEOS_HAL_CPU_GetCR0( void );

Return value

The content of CR0

XEOS_HAL_CPU_GetCR1

Gets the content of the Control Register 1 (CR1)

uint32_t XEOS_HAL_CPU_GetCR1( void );

Return value

The content of CR1

XEOS_HAL_CPU_GetCR2

Gets the content of the Control Register 2 (CR2)

uint32_t XEOS_HAL_CPU_GetCR2( void );

Return value

The content of CR2

XEOS_HAL_CPU_GetCR3

Gets the content of the Control Register 3 (CR3)

uint32_t XEOS_HAL_CPU_GetCR3( void );

Return value

The content of CR3

XEOS_HAL_CPU_GetCR4

Gets the content of the Control Register 4 (CR4)

uint32_t XEOS_HAL_CPU_GetCR4( void );

Return value

The content of CR4

XEOS_HAL_CPU_GetVendorID

Gets the CPU vendor ID string

const char * XEOS_HAL_CPU_GetVendorID( void );

Return value

The CPU vendor ID string

XEOS_HAL_CPU_Halt

Halts the CPU

void XEOS_HAL_CPU_Halt( void );

XEOS_HAL_CPU_HasFeature

Checks if the CPU supports a feature

bool XEOS_HAL_CPU_HasFeature( XEOS_HAL_CPUInfos_Feature feature );

Parameters
  • feature
    The CPU feature to check
Return value

True if the feature is supported, otherwise false

XEOS_HAL_CPU_InterruptsEnabled

Checks if the interrupts are enabled

bool XEOS_HAL_CPU_InterruptsEnabled( void );

Return value

True if the interrupts are enabled, otherwise false

XEOS_HAL_CPU_LoadGDT

Loads the Global Descriptor Table (GDT) pointer

void XEOS_HAL_CPU_LoadGDT( void *p );

Parameters
  • p
    The GDT pointer

XEOS_HAL_CPU_LoadIDT

Loads the Interrupt Descriptor Table (IDT) pointer

void XEOS_HAL_CPU_LoadIDT( void *p );

Parameters
  • p
    The IDT pointer

XEOS_HAL_CPU_PAEEnabled

Checks if PAE (Physical Address Extension)

bool XEOS_HAL_CPU_PAEEnabled( void );

Return value

True if PAE is enabled, otherwise false

XEOS_HAL_CPU_PagingEnabled

Checks if paging is enabled

bool XEOS_HAL_CPU_PagingEnabled( void );

Return value

True if paging is enabled, otherwise false

XEOS_HAL_CPU_RDMSR

Gets the content of a Model Specific Register (MSR)

uint64_t XEOS_HAL_CPU_RDMSR( uint32_t id );

Parameters
  • id
    The MSR ID
Return value

The MSR value

XEOS_HAL_CPU_SetCR0

Sets the content of the Control Register 0 (CR0)

void XEOS_HAL_CPU_SetCR0( uint32_t value );

Parameters
  • value
    The content of CR0

XEOS_HAL_CPU_SetCR1

Sets the content of the Control Register 1 (CR1)

void XEOS_HAL_CPU_SetCR1( uint32_t value );

Parameters
  • value
    The content of CR1

XEOS_HAL_CPU_SetCR2

Sets the content of the Control Register 2 (CR2)

void XEOS_HAL_CPU_SetCR2( uint32_t value );

Parameters
  • value
    The content of CR2

XEOS_HAL_CPU_SetCR3

Sets the content of the Control Register 3 (CR3)

void XEOS_HAL_CPU_SetCR3( uint32_t value );

Parameters
  • value
    The content of CR3

XEOS_HAL_CPU_SetCR4

Sets the content of the Control Register 4 (CR4)

void XEOS_HAL_CPU_SetCR4( uint32_t value );

Parameters
  • value
    The content of CR4

XEOS_HAL_CPU_SoftwareInterrupt

Generates a software interrupt

void XEOS_HAL_CPU_SoftwareInterrupt( uint8_t n );

Parameters
  • n
    The interrupt number

XEOS_HAL_CPU_WRMSR

Writes a value into a Model Specifi Register (MSR)

void XEOS_HAL_CPU_WRMSR( uint32_t id, uint64_t value );

Parameters
  • id
    The MSR ID
  • value
    The value to write

Types

XEOS_HAL_CPU_Registers

x86-64 registers

typedef struct { uint64_t rax; uint64_t rbx; uint64_t rcx; uint64_t rdx; uint64_t rsi; uint64_t rdi; uint64_t r8; uint64_t r9; uint64_t r10; uint64_t r11; uint64_t r12; uint64_t r13; uint64_t r14; uint64_t r15; uint64_t rsp; uint64_t rbp; } XEOS_HAL_CPU_Registers;

Discussion

Structure representing the x86-64 registers. For i386, the same typedef is available, but with a different layout.

XEOS_HAL_CPU_Registers

i386 registers

typedef struct { uint32_t eax; uint32_t ebx; uint32_t ecx; uint32_t edx; uint32_t esi; uint32_t edi; uint32_t esp; uint32_t ebp; } XEOS_HAL_CPU_Registers;

Discussion

Structure representing the i386 registers. For x86-64, the same typedef is available, but with a different layout.

XEOS_HAL_CPUInfos_Feature

CPU features

typedef enum { XEOS_HAL_CPUInfos_FeatureFPU = 0x000, XEOS_HAL_CPUInfos_FeatureVME = 0x001, XEOS_HAL_CPUInfos_FeatureDE = 0x002, XEOS_HAL_CPUInfos_FeaturePSE = 0x003, XEOS_HAL_CPUInfos_FeatureTSC = 0x004, XEOS_HAL_CPUInfos_FeatureMSR = 0x005, XEOS_HAL_CPUInfos_FeaturePAE = 0x006, XEOS_HAL_CPUInfos_FeatureMCE = 0x007, XEOS_HAL_CPUInfos_FeatureCX8 = 0x008, XEOS_HAL_CPUInfos_FeatureAPIC = 0x009, XEOS_HAL_CPUInfos_FeatureSEP = 0x00B, XEOS_HAL_CPUInfos_FeatureMTRR = 0x00C, XEOS_HAL_CPUInfos_FeaturePGE = 0x00D, XEOS_HAL_CPUInfos_FeatureMCA = 0x00E, XEOS_HAL_CPUInfos_FeatureCMOV = 0x00F, XEOS_HAL_CPUInfos_FeaturePAT = 0x010, XEOS_HAL_CPUInfos_FeaturePSE36 = 0x011, XEOS_HAL_CPUInfos_FeaturePN = 0x012, XEOS_HAL_CPUInfos_FeatureCLFlush = 0x013, XEOS_HAL_CPUInfos_FeatureDTS = 0x015, XEOS_HAL_CPUInfos_FeatureACPI = 0x016, XEOS_HAL_CPUInfos_FeatureMMX = 0x017, XEOS_HAL_CPUInfos_FeatureFXSR = 0x018, XEOS_HAL_CPUInfos_FeatureSSE = 0x019, XEOS_HAL_CPUInfos_FeatureSSE2 = 0x01A, XEOS_HAL_CPUInfos_FeatureSS = 0x01B, XEOS_HAL_CPUInfos_FeatureHT = 0x01C, XEOS_HAL_CPUInfos_FeatureTM = 0x01D, XEOS_HAL_CPUInfos_FeatureIA64 = 0x01E, XEOS_HAL_CPUInfos_FeaturePBE = 0x01F, XEOS_HAL_CPUInfos_FeaturePNI = 0x100, XEOS_HAL_CPUInfos_FeaturePCLMulQDQ = 0x101, XEOS_HAL_CPUInfos_FeatureDTES64 = 0x102, XEOS_HAL_CPUInfos_FeatureMonitor = 0x103, XEOS_HAL_CPUInfos_FeatureDSCPL = 0x104, XEOS_HAL_CPUInfos_FeatureVMX = 0x105, XEOS_HAL_CPUInfos_FeatureSMX = 0x106, XEOS_HAL_CPUInfos_FeatureEST = 0x107, XEOS_HAL_CPUInfos_FeatureTM2 = 0x108, XEOS_HAL_CPUInfos_FeatureSSSE3 = 0x109, XEOS_HAL_CPUInfos_FeatureCID = 0x10A, XEOS_HAL_CPUInfos_FeatureFMA = 0x10C, XEOS_HAL_CPUInfos_FeatureCX16 = 0x10D, XEOS_HAL_CPUInfos_FeatureXTPT = 0x10E, XEOS_HAL_CPUInfos_FeaturePDCM = 0x10F, XEOS_HAL_CPUInfos_FeaturePCID = 0x111, XEOS_HAL_CPUInfos_FeatureDCA = 0x112, XEOS_HAL_CPUInfos_FeatureSSE41 = 0x113, XEOS_HAL_CPUInfos_FeatureSSE42 = 0x114, XEOS_HAL_CPUInfos_FeatureX2APIC = 0x115, XEOS_HAL_CPUInfos_FeatureMOVBE = 0x116, XEOS_HAL_CPUInfos_FeaturePOPCNT = 0x117, XEOS_HAL_CPUInfos_FeatureTSCDeadLine = 0x118, XEOS_HAL_CPUInfos_FeatureAES = 0x119, XEOS_HAL_CPUInfos_FeatureXSave = 0x11A, XEOS_HAL_CPUInfos_FeatureOSXSave = 0x11B, XEOS_HAL_CPUInfos_FeatureAVX = 0x11C, XEOS_HAL_CPUInfos_FeatureF16C = 0x11D, XEOS_HAL_CPUInfos_FeatureRDRND = 0x11E, XEOS_HAL_CPUInfos_FeatureHypervisor = 0x11F } XEOS_HAL_CPUInfos_Feature;

Constants
  • XEOS_HAL_CPUInfos_FeatureFPU
    Onboard x87 FPU
  • XEOS_HAL_CPUInfos_FeatureVME
    Virtual mode extensions (VIF)
  • XEOS_HAL_CPUInfos_FeatureDE
    Debugging extensions (CR4 bit 3)
  • XEOS_HAL_CPUInfos_FeaturePSE
    Page size extensions
  • XEOS_HAL_CPUInfos_FeatureTSC
    Time Stamp Counter
  • XEOS_HAL_CPUInfos_FeatureMSR
    Model-specific registers
  • XEOS_HAL_CPUInfos_FeaturePAE
    Physical Address Extension
  • XEOS_HAL_CPUInfos_FeatureMCE
    Machine Check Exception
  • XEOS_HAL_CPUInfos_FeatureCX8
    CMPXCHG8 (compare-and-swap) instruction
  • XEOS_HAL_CPUInfos_FeatureAPIC
    Onboard Advanced Programmable Interrupt Controller
  • XEOS_HAL_CPUInfos_FeatureSEP
    SYSENTER and SYSEXIT instructions
  • XEOS_HAL_CPUInfos_FeatureMTRR
    Memory Type Range Registers
  • XEOS_HAL_CPUInfos_FeaturePGE
    Page Global Enable bit in CR4
  • XEOS_HAL_CPUInfos_FeatureMCA
    Machine check architecture
  • XEOS_HAL_CPUInfos_FeatureCMOV
    Conditional move and FCMOV instructions
  • XEOS_HAL_CPUInfos_FeaturePAT
    Page Attribute Table
  • XEOS_HAL_CPUInfos_FeaturePSE36
    36-bit page huge pages
  • XEOS_HAL_CPUInfos_FeaturePN
    Processor Serial Number
  • XEOS_HAL_CPUInfos_FeatureCLFlush
    CLFLUSH instruction (SSE2)
  • XEOS_HAL_CPUInfos_FeatureDTS
    Debug store: save trace of executed jumps
  • XEOS_HAL_CPUInfos_FeatureACPI
    Onboard thermal control MSRs for ACPI
  • XEOS_HAL_CPUInfos_FeatureMMX
    MMX instructions
  • XEOS_HAL_CPUInfos_FeatureFXSR
    FXSAVE, FXRESTOR instructions, CR4 bit 9
  • XEOS_HAL_CPUInfos_FeatureSSE
    SSE instructions (a.k.a. Katmai New Instructions)
  • XEOS_HAL_CPUInfos_FeatureSSE2
    SSE2 instructions
  • XEOS_HAL_CPUInfos_FeatureSS
    CPU cache supports self-snoop
  • XEOS_HAL_CPUInfos_FeatureHT
    Hyper-threading
  • XEOS_HAL_CPUInfos_FeatureTM
    Thermal monitor automatically limits temperature
  • XEOS_HAL_CPUInfos_FeatureIA64
    IA64 processor emulating x86
  • XEOS_HAL_CPUInfos_FeaturePBE
    Pending Break Enable (PBE# pin) wakeup support
  • XEOS_HAL_CPUInfos_FeaturePNI
    Prescott New Instructions (SSE3)
  • XEOS_HAL_CPUInfos_FeaturePCLMulQDQ
    PCLMULQDQ support
  • XEOS_HAL_CPUInfos_FeatureDTES64
    64-bit debug store (edx bit 21)
  • XEOS_HAL_CPUInfos_FeatureMonitor
    MONITOR and MWAIT instructions (SSE3)
  • XEOS_HAL_CPUInfos_FeatureDSCPL
    CPL qualified debug store
  • XEOS_HAL_CPUInfos_FeatureVMX
    Virtual Machine eXtensions
  • XEOS_HAL_CPUInfos_FeatureSMX
    Safer Mode Extensions (LaGrande)
  • XEOS_HAL_CPUInfos_FeatureEST
    Enhanced SpeedStep
  • XEOS_HAL_CPUInfos_FeatureTM2
    Thermal Monitor 2
  • XEOS_HAL_CPUInfos_FeatureSSSE3
    Supplemental SSE3 instructions
  • XEOS_HAL_CPUInfos_FeatureCID
    Context ID
  • XEOS_HAL_CPUInfos_FeatureFMA
    Fused multiply-add (FMA3)
  • XEOS_HAL_CPUInfos_FeatureCX16
    CMPXCHG16B instruction
  • XEOS_HAL_CPUInfos_FeatureXTPT
    Can disable sending task priority messages
  • XEOS_HAL_CPUInfos_FeaturePDCM
    Perfmon & debug capability
  • XEOS_HAL_CPUInfos_FeaturePCID
    Process context identifiers (CR4 bit 17)
  • XEOS_HAL_CPUInfos_FeatureDCA
    Direct cache access for DMA writes
  • XEOS_HAL_CPUInfos_FeatureSSE41
    SSE4.1 instructions
  • XEOS_HAL_CPUInfos_FeatureSSE42
    SSE4.2 instructions
  • XEOS_HAL_CPUInfos_FeatureX2APIC
    x2APIC support
  • XEOS_HAL_CPUInfos_FeatureMOVBE
    MOVBE instruction (big-endian, Intel Atom only)
  • XEOS_HAL_CPUInfos_FeaturePOPCNT
    POPCNT instruction
  • XEOS_HAL_CPUInfos_FeatureTSCDeadLine
    APIC supports one-shot operation using a TSC deadline value
  • XEOS_HAL_CPUInfos_FeatureAES
    AES instruction set
  • XEOS_HAL_CPUInfos_FeatureXSave
    XSAVE, XRESTOR, XSETBV, XGETBV
  • XEOS_HAL_CPUInfos_FeatureOSXSave
    XSAVE enabled by OS
  • XEOS_HAL_CPUInfos_FeatureAVX
    Advanced Vector Extensions
  • XEOS_HAL_CPUInfos_FeatureF16C
    CVT16 instruction set (half-precision) FP support
  • XEOS_HAL_CPUInfos_FeatureRDRND
    RDRAND (on-chip random number generator) support
  • XEOS_HAL_CPUInfos_FeatureHypervisor
    Running on a hypervisor (always 0 on a real CPU)

Macros

__XEOS_HAL_CPU_H__

#define __XEOS_HAL_CPU_H__