basic-cpuid-0.1.0.0: A small package to access the cpuid instruction directly.

Copyright(c) 2017 Anselm Jonas Scholl
LicenseBSD3
Maintaineranselm.scholl@tu-harburg.de
Stabilityexperimental
Portabilityx86
Safe HaskellSafe
LanguageHaskell2010

System.Cpuid.Basic

Contents

Description

This module gives access to the CPUID instruction on x86 based systems. The module will still build on other systems but will not provide any useful functionality instead.

Synopsis

CPUID support

data CpuidArg Source #

Argument for the CPUID instruction.

Constructors

CpuidArg 

Fields

  • caEAX :: !Word32

    Value to query for.

  • caECX :: !Word32

    Additional value for queries. You can leave this at 0 most of the time.

data CpuidResult Source #

Result of a call to the CPUID instruction.

Constructors

CpuidResult 

Fields

  • crEAX :: !Word32

    Value of EAX after the CPUID instruction.

  • crEBX :: !Word32

    Value of EBX after the CPUID instruction.

  • crECX :: !Word32

    Value of ECX after the CPUID instruction.

  • crEDX :: !Word32

    Value of EDX after the CPUID instruction.

cpuidSupported :: Bool Source #

True if the platform supports the CPUID instruction (that is, if this code runs on x86 or AMD64).

cpuid :: CpuidArg -> IO CpuidResult Source #

Call the CPUID instruction. If the instruction is not supported, throw an error.

cpuidMaybe :: Maybe (CpuidArg -> IO CpuidResult) Source #

A safe version of cpuid which never throws exceptions if a Just is returned.

cpuidHighestFunctionParameter :: IO Word32 Source #

Get the highest supported function parameter (EAX) for the CPUID instruction. Returns 0 if CPUID is unsupported.

XGETBV support

type XGetBVArg = Word32 Source #

Argument for the XGETBV instruction.

data XGetBVResult Source #

Result of a call to the XGETBV instruction.

Constructors

XGetBVResult 

Fields

xgetbvSupport :: IO Bool Source #

Returns true if the platform supports the XGETBV instruction (that is, if the code runs on x86 or AMD64) AND the processor (or operating system) support it (that is, the OSXSAVE bit is set)

xgetbv :: XGetBVArg -> IO XGetBVResult Source #

Call the XGETBV instruction. If the instruction is not supported, throw an error. You also have to check for support of the instruction by the operating system and the processor first (use xgetbvSupport).

xgetbvMaybe :: IO (Maybe (XGetBVArg -> IO XGetBVResult)) Source #

A safe version of xgetbv which never throws exceptions if a Just is returned.

Utilities

supportsSSE2 :: IO Bool Source #

Check whether the processor indicated support for SSE2. Note that this does not mean the OS will save the XMM upon context switches.

supportsAVX2 :: IO Bool Source #

Check whether OS and CPU support the AVX2 instruction set.

supportsAVX512f :: IO Bool Source #

Check whether OS and CPU support the AVX512f instruction set.