///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//          Copyright (c) NVIDIA Corporation.  All rights reserved.          //
//                                                                           //
// All information contained herein is proprietary and confidential to       //
// NVIDIA Corporation.  Any use, reproduction, or disclosure without the     //
// written permission of NVIDIA Corporation is prohibited.                   //
//                                                                           //
// Project : NVWMI v2.0                                                      //
// File Name : nvwmi.mof                                                     //
// Date : 8/23/2010                                                          //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

// This is trimmed down 2.0 version of MOF

#pragma autorecover
#pragma namespace("\\\\.\\root\\cimv2")

Instance of __Namespace
{
    Name = "NV";
};

#pragma namespace("\\\\.\\root\\cimv2\\NV")

instance of __Win32Provider as $NVPROV
{
    ClientLoadableCLSID    = NULL;
    CLSID                  = "{96CDE098-DB47-4040-97CF-C522384F5554}";  // unchanged from 1.1
    DefaultMachineName     = NULL;
    HostingModel           = "Decoupled:Com";
    InitializeAsAdminFirst = FALSE;
    Name                   = "NVIDIA|NVWMI|2.0";
    UnloadTimeout          = NULL;
    SecurityDescriptor     = "O:BAG:SYD:(A;;0x10000001;;;BA)(A;;0x10000001;;;SY)";
    Version                = 0x02000000;         // 2.0.0 (major in MSB byte, then byte with minor, then 16-bit word with build) 
                                                 // Note that Version here is a property inherited from __Win32Provider
};


instance of __InstanceProviderRegistration
{
    Provider            = $NVPROV;
    InteractionType     = 0;                     // 0- Pull, 1 - Push, 2 - PushVerify
    SupportsPut         = TRUE;
    SupportsGet         = TRUE;
    SupportsDelete      = TRUE;
    SupportsEnumeration = TRUE;
    QuerySupportLevels  = {"WQL:UnarySelect", "WQL:References"};
};


instance of __PropertyProviderRegistration
{
    Provider           = $NVPROV;
    SupportsPut        = TRUE;
    SupportsGet        = TRUE;
};


instance of __MethodProviderRegistration
{
    Provider = $NVPROV;
};


[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), Description("Internal version of NV objects")]
class Version
{
    [Key,Read: ToInstance ToSubClass, Description("Ordered version value, guaranteed to grow monotonically")] 
    uint32                  orderedValue;       //!< Ordered version value, guaranteed to grow monotonically

    [Read: ToInstance ToSubClass, Description("Raw version value")] 
    uint32                  value;              //!< Raw version value
    
    [Read: ToInstance ToSubClass, Description("Human-readable string with version value")] 
    string                  strValue;           //!< Human-readable string with version value
};


[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE), 
Description("Base class for all named NV objects")]
class NamedObject
{
    [Read: ToInstance ToSubClass, Description("Version of named object")]
    Version                 ver;                //!< Version of named object

    [Read: ToInstance ToSubClass, Description("LUID of named object")]
    string                  luid;               //!< LUID of named object

    [Key, Read: ToInstance ToSubClass, Description("Unique id of named object, used as a key")]
    uint32                  id;                 //!< Unique id of named object, used as a key

    [Read: ToInstance ToSubClass, Description("Name of an object")]
    string                  name;               //!< Name of an object

    [Key, Read: ToInstance ToSubClass, Description("Unique name of an object")]
    string                  uname;              //!< Unique name of an object

    [Read: ToInstance ToSubClass, Description("Ordinal number of named object among objects with same names")]
    sint32                  ordinal;            //!< Ordinal number of named object among objects with same names

    [Read: ToInstance ToSubClass, Description("Total number of named objects with same name")]
    sint32                  total;              //!< Total number of named objects with same name
};

[Version("2.0.1"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE),
Description("Represents an NVIDIA GPU")]
class Gpu : NamedObject
{
    [Read: ToInstance ToSubClass, Description("Unique identification of the NVIDIA GPU")]
    uint32                  handle;             //!< Unique identification of the NVIDIA GPU"

    [Read: ToInstance ToSubClass, Values {"GeForce","NVS","Quadro","Tesla"},
    Description("Gpu type - GeForce, NVS, Quadro, Tesla")]
    uint32                  type;               //!< Gpu type - GeForce, NVS, Quadro, Tesla
    
    [Read: ToInstance ToSubClass, Values {"SDRAM", "DDR1", "DDR2", "GDDR2", "GDDR3", "GDDR4", "DDR3", "GDDR5"},
    Description("The type of VRAM associated with this GPU - SDRAM, DDR1, DDR2, GDDR2, GDDR3, GDDR4, DDR3, GDDR5 ")]
    uint32                  vramType;           //!< The type of VRAM associated with this GPU - SDRAM, DDR1, DDR2, GDDR2, GDDR3, GDDR4, DDR3, GDDR5
    
    [Read: ToInstance ToSubClass, Description("The virtual size of framebuffer in KB. (Physical RAM + System RAM)")]
    uint32                  virtualFrameBufferSize;          //!< The virtual size of framebuffer in KB. (Physical RAM + System RAM)
    
    [Read: ToInstance ToSubClass, Description("The physical size of framebuffer in KB. (No system RAM)")]
    uint32                  physicalFrameBufferSize;         //!< The physical size of framebuffer in KB. (No system RAM)
    
    [Read: ToInstance ToSubClass, Description("The width of the GPU's RAM memory bus")]
    uint32                  frameBufferWidth;                //!< The width of the GPU's RAM memory bus
    
    [Read: ToInstance ToSubClass, Description("The total number of Cores defined for a GPU")]
    uint32                  coreCount;                       //!< The total number of Cores defined for a GPU
    
    [Read: ToInstance ToSubClass, Description("The memory clock frequency in kHz")]
    uint32                  memClockFrequency;               //!< The memory clock frequency in kHz
    
    [Read: ToInstance ToSubClass, Description("The GPU clock frequency in kHz")]
    uint32                  gpuClockFrequency;               //!< The GPU clock frequency in kHz
    
    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of thermal probes of this GPU")]
    ThermalProbe ref        thermalProbes[];    //!< Array of thermal probes of this GPU

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of references to coolers of this GPU")]
    Cooler ref              coolers[];          //!< Array of references to coolers of this GPU
    
    [Read: ToInstance ToSubClass, Description("The name of the graphics card to which this GPU belongs")]
    string                  boardName;          //!< The name of the graphics card to which this GPU belongs

    [Implemented, Description("Formats basic info about this GPU into a human-readable string")]
    string                  info();             //!< Formats basic info about this display into a human-readable string
    
    [Implemented, Description("Updates all objects and data")]
    boolean                 update();           //!< Updates all objects and data
};

[Version("2.0.0"), Singleton, Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE), 
Description("Represents root object for NV-related HW and SW in the system")]
class NV
{
    [Read: ToInstance ToSubClass, Description("NV root class version")]
    Version                 ver;                    //!< NV root class version

    [Read: ToInstance ToSubClass, Description("Version of the NV WMI driver")]
    Version                 verWMI;                 //!< Version of the NV WMI driver

    [Read: ToInstance ToSubClass, Description("Version of the NV display driver")]
    Version                 verDisplayDriver;       //!< Version of the NV display driver

    [Read: ToInstance ToSubClass, Description("Firmware version of the SDI input board")]
    Version                 verSdiInputFirmware;    //!< Firmware version of the SDI input board

    [Read: ToInstance ToSubClass, Description("Firmware version of the SDI output board")]
    Version                 verSdiOutputFirmware;   //!< Firmware version of the SDI output board

    [Read: ToInstance ToSubClass, Description("Driver version for the SDI output")]
    Version                 verSdiOutputDriver;     //!< Driver version for the SDI output

    [Read: ToInstance ToSubClass, Description("Version of the G-Sync board firmware")]
    Version                 verGsyncFirmware;       //!< Version of the G-Sync board firmware

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of GPUs installed on this system")]
    Gpu                     gpus[];                 //!< Array of GPUs installed on this system

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of displays on this system")]
    Display                 displays[];             //!< Array of displays on this system

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of boards on this system")]
    Board                   boards[];               //!< Array of boards on this system

    [Read: ToInstance ToSubClass, Description("Current Global 3D profile (D3D, OGL)")]
    string                  currentProfile3D;       //!< Current Global 3D profile (D3D, OGL)

    [Read: ToInstance ToSubClass, Description("Current Desktop Profile (nView)")]
    string                  currentProfileDesktop;  //!< Current Desktop Profile (nView)

    [Read: ToInstance ToSubClass, Description("Default Global 3D profile (D3D, OGL)")]
    string                  defaultProfile3D;       //!< Default Global 3D profile (D3D, OGL)

    [Read: ToInstance ToSubClass, Description("Default Desktop Profile (nView)")]
    string                  defaultProfileDesktop;  //!< Default Desktop Profile (nView)

    [Implemented, Static, Description("Restore all profiles to default")]
    boolean                 restoreDefaults();      //!< Restore all profiles to default
    
    [Implemented, Static, Description("Set current profile")]
    boolean                 setCurrentProfile       //!< Set current profile
    (
        [in]string name                             //!< Name of existing profile to set as current
    );
    
    [Implemented, Static, Description("Formats basic info about NV objects in a system into a human-readable string")]
    string                  info();                 //!< Formats basic info about NV objects in a system into a human-readable string
    
    [Implemented, Static, Description("Updates all objects and data")]
    boolean                 update();               //!< Updates all objects and data
};


[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE),
Description("Represents a board with NVIDIA GPU(s)")]
class Board : NamedObject
{
    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of references to GPUs installed on this board")]
    Gpu ref                 gpus[];             //!< Array of references to GPUs installed on this board

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of references to thermal probes of this board")]
    ThermalProbe ref        thermalProbes[];    //!< Array of thermal probes of this board

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of references to coolers of this board")]
    Cooler ref              coolers[];          //!< Array of references to coolers of this board
};


[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE), Description("Represents display")]
class Display : NamedObject
{
    [Read: ToInstance ToSubClass, Description("Firmware version of this display")]
    Version                 verFirmware;        //!< Firmware version of this display

    [Read: ToInstance ToSubClass, Description("Manufacturer of this display")]
    string                  make;               //!< Manufacturer of this display

    [Read: ToInstance ToSubClass, Description("Model of this display")]
    string                  model;              //!< Model of this display
    
    [Read: ToInstance ToSubClass, Description("Horizontal position of this display on the desktop")]
    sint32                  positionX;          //!< Horizontal position of this display on the desktop

    [Read: ToInstance ToSubClass, Description("Vertical position of this display on the desktop")]
    sint32                  positionY;          //!< Vertical position of this display on the desktop

    [Read: ToInstance ToSubClass, Values {"Invalid", "Monitor", "Center", "FixedAspect", "Fill"},
    Description("Display scaling mode - Invalid, Monitor, Center, FixedAspect, Fill")]
    uint32                  scaling;            //!< Display scaling mode - Invalid, Monitor, Center, FixedAspect, Fill

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Array of references to GPUs connected to this display")]
    Gpu ref                 gpus[];             //!< Array of references to GPUs connected to this display

    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Current display mode")]
    Mode                    currentMode;        //!< Current display mode
    
    [Read: ToInstance ToSubClass, ArrayType("Ordered"), Description("Native display mode")]
    Mode                    nativeMode;         //!< Native display mode

    [Implemented, Description("Formats basic info about this display into a human-readable string")]
    string                  info();             //!< Formats basic info about this display into a human-readable string
    
    [Implemented, Description("Updates all objects and data")]
    boolean                 update();           //!< Updates all objects and data
};

[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE),
Description("Represents display mode")]
class Mode
{
    [Key, Read: ToInstance ToSubClass, Description("Unique identification of the display mode")]
    uint32                  modeKey;            //!< Unique identification of the display mode

    [Read, Write: ToInstance ToSubClass, Description("Display mode width")]
    sint32                  width;              //!< Display mode width

    [Read, Write: ToInstance ToSubClass, Description("Display mode height")]
    sint32                  height;             //!< Display mode height

    [Read, Write: ToInstance ToSubClass, Description("Display mode refresh rate")]
    float                   refreshRate;        //!< Display mode refresh rate

    [Read, Write: ToInstance ToSubClass, Description("Display mode depth")]
    sint32                  depth;              //!< Display mode depth
};


[Version("1.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE),
Description("Represents a cooler (fan, liquid system etc.)")]
class Cooler
{
//! \publicsection
    [Read: ToInstance ToSubClass, Description("Cooler class version")]
    Version                 ver;
    
    [key, Read: ToInstance ToSubClass, Description("Unique identification of the NVIDIA GPU")]
    uint32                  handle;

    [Read: ToInstance ToSubClass, Description("Cooler Rate in percents")]
    uint32                  percentCoolerRate;    //!< current percentage speed of a cooler fan (or liquid flow rate %)
    
    [Read: ToInstance ToSubClass, Description("The tachometer reading for fan speed in rpm")]
    uint32                  fanSpeed;    //!< current tachometer reading of fan speed in rpm
    
    [Read: ToInstance ToSubClass, Values{"unknown","normal","warning","critical"}, Description("Cooler fan speed level")]
    uint32                  coolerLevel;          //!< current Level (Normal, Warning or Critical) of the cooler
    
    [implemented]string     info();               //!< formats basic info about the Cooler object in a system into a human-readable string
    [implemented]boolean    update();             //!< updates all objects and data
};

[Version("1.0.0"), Dynamic, Provider("NVIDIA|NVWMI|2.0"), SupportsUpdate(TRUE),
Description("Represents a thermal probe")]
class ThermalProbe
{
//! \publicsection
    [Read: ToInstance ToSubClass, Description("Thermal probe class version")]
    Version                 ver;
    
    [key, Read: ToInstance ToSubClass, Description("Unique identification of the NVIDIA GPU")]
    uint32                  handle;
    
    [Read: ToInstance ToSubClass, Description("current temperature value of a thermal sensor in Celsius")]
    sint32                  temperature;         //!< the current temperature value of the thermal sensor in degrees centigrade
   
    [Read: ToInstance ToSubClass, Values{"unknown","normal","warning","critical"}, Description("current temperature level")]
    uint32                  thermalLevel;        //!< current thermal level
    
    [implemented]string info();                  //!< formats basic info about the Thermal object in a system into a human-readable string
    [implemented]boolean update();               //!< updates all objects and data
};


Instance of __Namespace
{
    Name = "Events";
};


#pragma namespace("\\\\.\\root\\cimv2\\NV\\Events")

instance of __Win32Provider as $EVENTPROVIDER
{
    ClientLoadableCLSID    = NULL;
    CLSID                  = "{0CB84A35-AB4F-4B6B-B4F6-493624B6C132}"; 
    DefaultMachineName     = NULL;
    HostingModel           = "Decoupled:Com";
    InitializeAsAdminFirst = FALSE;
    Name                   = "NVIDIA|NVWMI|EVENTS|2.0";
    UnloadTimeout          = NULL;
    SecurityDescriptor     = "O:BAG:SYD:(A;;0x10000001;;;BA)(A;;0x10000001;;;SY)";
    Version                = 0x02000000;         // 2.0.0 (major in MSB byte, then byte with minor, then 16-bit word with build) 
                                                 // Note that Version here is a property inherited from __Win32Provider
};

instance of __EventProviderRegistration
{
    Provider            = $EVENTPROVIDER;
    EventQueryList = {"select * from CoolerEvent", "select * from ThermalEvent"};
};

[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|EVENTS|2.0"), Description("Class to represent GPU thermal events")]
class ThermalEvent : __ExtrinsicEvent
{
    [Key, Read: ToInstance ToSubClass, Description("Unique handle of the NVIDIA GPU")]
    uint32                  handleGpu;          //!< Unique handle of the NVIDIA GPU

    [Read: ToInstance ToSubClass, Description("Thermal probe index in array of probes on a given GPU")]
    uint32                  probeIndex;         //!< Thermal probe index in array of probes on a given GPU

    [Read: ToInstance ToSubClass, Description("Thermal level to identify the temperature zone")]
    uint32                  thermalLevel;       //!< Thermal level to identify the temperature zone

    object ref              source;             //!< provides a reference to the host object which contains important context data (like GPU handle etc.)

};

[Version("2.0.0"), Dynamic, Provider("NVIDIA|NVWMI|EVENTS|2.0"), Description("Class to represent GPU cooler events")]
class CoolerEvent : __ExtrinsicEvent
{
    [Key, Read: ToInstance ToSubClass, Description("Unique handle of the NVIDIA GPU")]
    uint32                  handleGpu;          //!< Unique handle of the NVIDIA GPU

    [Read: ToInstance ToSubClass, Description("Cooler index in array of coolers on a given GPU")]
    uint32                  coolerIndex;        //!< Cooler index in array of coolers on a given GPU

    [Read: ToInstance ToSubClass, Description("Cooler level to identify the cooler zone")]
    uint32                  coolerLevel;        //!< Cooler level to identify the cooler zone

    object ref              source;             //!< provides a reference to the host object which contains important context data (like GPU handle etc.)
};