View Javadoc
1   /*
2    * Copyright 2016-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.jna.platform.mac;
6   
7   import com.sun.jna.Native;
8   import com.sun.jna.NativeLong;
9   import com.sun.jna.Structure;
10  import com.sun.jna.Structure.FieldOrder;
11  import com.sun.jna.ptr.NativeLongByReference;
12  
13  import oshi.util.Util;
14  
15  /**
16   * The I/O Kit framework implements non-kernel access to I/O Kit objects (drivers and nubs) through the device-interface
17   * mechanism.
18   */
19  public interface IOKit extends com.sun.jna.platform.mac.IOKit {
20  
21      IOKit INSTANCE = Native.load("IOKit", IOKit.class);
22  
23      /*
24       * Do not commit SMC structures to JNA
25       */
26      /**
27       * Holds the return value of SMC version query.
28       */
29      @FieldOrder({ "major", "minor", "build", "reserved", "release" })
30      class SMCKeyDataVers extends Structure {
31          public byte major;
32          public byte minor;
33          public byte build;
34          public byte reserved;
35          public short release;
36      }
37  
38      /**
39       * Holds the return value of SMC pLimit query.
40       */
41      @FieldOrder({ "version", "length", "cpuPLimit", "gpuPLimit", "memPLimit" })
42      class SMCKeyDataPLimitData extends Structure {
43          public short version;
44          public short length;
45          public int cpuPLimit;
46          public int gpuPLimit;
47          public int memPLimit;
48      }
49  
50      /**
51       * Holds the return value of SMC KeyInfo query.
52       */
53      @FieldOrder({ "dataSize", "dataType", "dataAttributes" })
54      class SMCKeyDataKeyInfo extends Structure {
55          public int dataSize;
56          public int dataType;
57          public byte dataAttributes;
58      }
59  
60      /**
61       * Holds the return value of SMC query.
62       */
63      @FieldOrder({ "key", "vers", "pLimitData", "keyInfo", "result", "status", "data8", "data32", "bytes" })
64      class SMCKeyData extends Structure implements AutoCloseable {
65          public int key;
66          public SMCKeyDataVers vers;
67          public SMCKeyDataPLimitData pLimitData;
68          public SMCKeyDataKeyInfo keyInfo;
69          public byte result;
70          public byte status;
71          public byte data8;
72          public int data32;
73          public byte[] bytes = new byte[32];
74  
75          @Override
76          public void close() {
77              Util.freeMemory(getPointer());
78          }
79      }
80  
81      /**
82       * Holds an SMC value
83       */
84      @FieldOrder({ "key", "dataSize", "dataType", "bytes" })
85      class SMCVal extends Structure implements AutoCloseable {
86          public byte[] key = new byte[5];
87          public int dataSize;
88          public byte[] dataType = new byte[5];
89          public byte[] bytes = new byte[32];
90  
91          @Override
92          public void close() {
93              Util.freeMemory(getPointer());
94          }
95      }
96  
97      /*
98       * Beta/Non-API do not commit to JNA
99       */
100     int IOConnectCallStructMethod(IOConnect connection, int selector, Structure inputStructure,
101             NativeLong structureInputSize, Structure outputStructure, NativeLongByReference structureOutputSize);
102 }