Hardware/IOControlCode.cs
author moel.mich
Sun, 26 Jun 2011 17:00:32 +0000
changeset 306 e9127c00ada1
child 344 3145aadca3d2
permissions -rw-r--r--
Added support for package level temperature sensors on new Intel Sandy Bridge CPUs.
moel@236
     1
/*
moel@236
     2
  
moel@236
     3
  Version: MPL 1.1/GPL 2.0/LGPL 2.1
moel@236
     4
moel@236
     5
  The contents of this file are subject to the Mozilla Public License Version
moel@236
     6
  1.1 (the "License"); you may not use this file except in compliance with
moel@236
     7
  the License. You may obtain a copy of the License at
moel@236
     8
 
moel@236
     9
  http://www.mozilla.org/MPL/
moel@236
    10
moel@236
    11
  Software distributed under the License is distributed on an "AS IS" basis,
moel@236
    12
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
moel@236
    13
  for the specific language governing rights and limitations under the License.
moel@236
    14
moel@236
    15
  The Original Code is the Open Hardware Monitor code.
moel@236
    16
moel@236
    17
  The Initial Developer of the Original Code is 
moel@236
    18
  Michael Möller <m.moeller@gmx.ch>.
moel@236
    19
  Portions created by the Initial Developer are Copyright (C) 2010
moel@236
    20
  the Initial Developer. All Rights Reserved.
moel@236
    21
moel@236
    22
  Contributor(s):
moel@236
    23
moel@236
    24
  Alternatively, the contents of this file may be used under the terms of
moel@236
    25
  either the GNU General Public License Version 2 or later (the "GPL"), or
moel@236
    26
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
moel@236
    27
  in which case the provisions of the GPL or the LGPL are applicable instead
moel@236
    28
  of those above. If you wish to allow use of your version of this file only
moel@236
    29
  under the terms of either the GPL or the LGPL, and not to allow others to
moel@236
    30
  use your version of this file under the terms of the MPL, indicate your
moel@236
    31
  decision by deleting the provisions above and replace them with the notice
moel@236
    32
  and other provisions required by the GPL or the LGPL. If you do not delete
moel@236
    33
  the provisions above, a recipient may use your version of this file under
moel@236
    34
  the terms of any one of the MPL, the GPL or the LGPL.
moel@236
    35
 
moel@236
    36
*/
moel@236
    37
moel@236
    38
using System;
moel@236
    39
using System.Runtime.InteropServices;
moel@236
    40
moel@236
    41
namespace OpenHardwareMonitor.Hardware {
moel@236
    42
moel@236
    43
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
moel@236
    44
  internal struct IOControlCode {
moel@236
    45
    private uint code;
moel@236
    46
moel@236
    47
    public IOControlCode(uint deviceType, uint function, Access access) :
moel@236
    48
      this(deviceType, function, Method.Buffered, access) { }
moel@236
    49
moel@236
    50
    public IOControlCode(uint deviceType, uint function, Method method, 
moel@236
    51
      Access access) 
moel@236
    52
    {
moel@236
    53
      code = (deviceType << 16) | 
moel@236
    54
        ((uint)access << 14) | (function << 2) | (uint)method;
moel@236
    55
    }
moel@236
    56
moel@236
    57
    public enum Method : uint {
moel@236
    58
      Buffered = 0,
moel@236
    59
      InDirect = 1,
moel@236
    60
      OutDirect = 2,
moel@236
    61
      Neither = 3
moel@236
    62
    }
moel@236
    63
moel@236
    64
    public enum Access : uint {
moel@236
    65
      Any = 0,
moel@236
    66
      Read = 1,
moel@236
    67
      Write = 2
moel@236
    68
    }
moel@236
    69
  }    
moel@236
    70
}