|
1 | 1 | // SPDX-License-Identifier: BSD-3-Clause
|
2 | 2 | // Copyright (c) 2012, Intel Corporation
|
3 | 3 | // written by Austen Ott
|
4 |
| -// |
| 4 | +// |
5 | 5 |
|
6 | 6 | #include "DriverInterface.h"
|
7 | 7 |
|
8 | 8 | kern_return_t openMSRClient(io_connect_t connect)
|
9 | 9 | {
|
10 |
| - kern_return_t kernResult; |
11 |
| - |
12 |
| -#if !defined(__LP64__) |
13 |
| - if (IOConnectCallScalarMethod != NULL) { |
14 |
| -#endif |
15 |
| - kernResult = IOConnectCallScalarMethod(connect, kOpenDriver, NULL, 0, NULL, NULL); |
16 |
| -#if !defined(__LP64__) |
17 |
| - } |
18 |
| - else { |
19 |
| - kernResult = IOConnectMethodScalarIScalarO(connect, kOpenDriver, 0, 0); |
20 |
| - } |
21 |
| -#endif |
22 |
| - |
23 |
| - return kernResult; |
| 10 | + return IOConnectCallScalarMethod(connect, kOpenDriver, NULL, 0, NULL, NULL); |
24 | 11 | }
|
25 | 12 |
|
26 | 13 | kern_return_t closeMSRClient(io_connect_t connect)
|
27 | 14 | {
|
28 |
| - |
29 |
| - kern_return_t kernResult; |
30 |
| - |
31 |
| -#if !defined(__LP64__) |
32 |
| - if (IOConnectCallScalarMethod != NULL) { |
33 |
| -#endif |
34 |
| - kernResult = IOConnectCallScalarMethod(connect, kCloseDriver, NULL, 0, NULL, NULL); |
35 |
| -#if !defined(__LP64__) |
36 |
| - } |
37 |
| - else { |
38 |
| - kernResult = IOConnectMethodScalarIScalarO(connect, kCloseDriver, 0, 0); |
39 |
| - } |
40 |
| -#endif |
41 |
| - |
42 |
| - return kernResult; |
| 15 | + return IOConnectCallScalarMethod(connect, kCloseDriver, NULL, 0, NULL, NULL); |
43 | 16 | }
|
44 | 17 |
|
45 | 18 | kern_return_t readMSR(io_connect_t connect, pcm_msr_data_t* idata, size_t* idata_size,pcm_msr_data_t* odata, size_t* odata_size)
|
46 | 19 | {
|
47 |
| - |
48 |
| - kern_return_t kernResult; |
49 |
| -#if !defined(__LP64__) |
50 |
| - if (IOConnectCallStructMethod != NULL) { |
51 |
| -#endif |
52 |
| - kernResult = IOConnectCallStructMethod(connect, kReadMSR, idata, *idata_size, odata, odata_size); |
53 |
| -#if !defined(__LP64__) |
54 |
| - } |
55 |
| - else { |
56 |
| - kernResult = IOConnectMethodStructIStructO(connect, kReadMSR, *idata_size, odata_size, idata, odata); |
57 |
| - } |
58 |
| -#endif |
59 |
| - return kernResult; |
| 20 | + return IOConnectCallStructMethod(connect, kReadMSR, idata, *idata_size, odata, odata_size); |
60 | 21 | }
|
61 | 22 |
|
62 | 23 | kern_return_t writeMSR(io_connect_t connect, pcm_msr_data_t* data, size_t* idata_size)
|
63 | 24 | {
|
64 |
| - kern_return_t kernResult; |
65 |
| -#if !defined(__LP64__) |
66 |
| - if (IOConnectCallStructMethod != NULL) { |
67 |
| -#endif |
68 |
| - kernResult = IOConnectCallStructMethod(connect, kWriteMSR, (void*)data, *idata_size, NULL, NULL); |
69 |
| -#if !defined(__LP64__) |
70 |
| - } |
71 |
| - else { |
72 |
| - kernResult = IOConnectMethodStructIStructO(connect, kWriteMSR, *idata_size, NULL, data, NULL); |
73 |
| - } |
74 |
| -#endif |
75 |
| - |
76 |
| - return kernResult; |
| 25 | + return IOConnectCallStructMethod(connect, kWriteMSR, (void*)data, *idata_size, NULL, NULL); |
77 | 26 | }
|
78 | 27 |
|
79 | 28 | kern_return_t getTopologyInfo(io_connect_t connect, topologyEntry* data, size_t* data_size)
|
80 | 29 | {
|
81 |
| - kern_return_t kernResult; |
82 |
| -#if !defined(__LP64__) |
83 |
| - if (IOConnectCallStructMethod != NULL) { |
84 |
| -#endif |
85 |
| - kernResult = IOConnectCallStructMethod(connect, kBuildTopology, NULL, 0, data, data_size); |
86 |
| -#if !defined(__LP64__) |
87 |
| - } |
88 |
| - else { |
89 |
| - kernResult = IOConnectMethodStructIStructO(connect, kBuildTopology, 0, data_size, NULL, data); |
90 |
| - } |
91 |
| -#endif |
92 |
| - |
93 |
| - return kernResult; |
| 30 | + return IOConnectCallStructMethod(connect, kBuildTopology, NULL, 0, data, data_size); |
94 | 31 | }
|
95 | 32 |
|
96 | 33 | kern_return_t getNumClients(io_connect_t connect, uint32_t* num_insts)
|
97 | 34 | {
|
98 | 35 | kern_return_t kernResult;
|
99 |
| -#if !defined(__LP64__) |
100 |
| - if (IOConnectCallStructMethod != NULL) { |
101 |
| -#endif |
102 |
| - size_t num_outputs = 1; |
103 |
| - uint64_t knum_insts; |
104 |
| - kernResult = IOConnectCallStructMethod(connect, kGetNumInstances, NULL, 0, &knum_insts, &num_outputs); |
| 36 | + size_t num_outputs = 1; |
| 37 | + uint64_t knum_insts; |
| 38 | + |
| 39 | + kernResult = IOConnectCallStructMethod(connect, kGetNumInstances, NULL, 0, &knum_insts, &num_outputs); |
105 | 40 | *num_insts = (uint32_t)knum_insts;
|
106 |
| -#if !defined(__LP64__) |
107 |
| - } |
108 |
| - else { |
109 |
| - kernResult = IOConnectMethodScalarIScalarO(connect, kGetNumInstances, 0, 1, NULL, num_insts); |
110 |
| - } |
111 |
| -#endif |
112 |
| - |
113 |
| - return kernResult; |
| 41 | + return kernResult; |
114 | 42 | }
|
| 43 | + |
115 | 44 | kern_return_t incrementNumClients(io_connect_t connect, uint32_t* num_insts)
|
116 | 45 | {
|
117 | 46 | kern_return_t kernResult;
|
118 |
| -#if !defined(__LP64__) |
119 |
| - if (IOConnectCallStructMethod != NULL) { |
120 |
| -#endif |
121 |
| - size_t num_outputs = 1; |
122 |
| - uint64_t knum_insts; |
123 |
| - kernResult = IOConnectCallStructMethod(connect, kIncrementNumInstances, NULL, 0, &knum_insts, &num_outputs); |
| 47 | + size_t num_outputs = 1; |
| 48 | + uint64_t knum_insts; |
| 49 | + |
| 50 | + kernResult = IOConnectCallStructMethod(connect, kIncrementNumInstances, NULL, 0, &knum_insts, &num_outputs); |
124 | 51 | *num_insts = (uint32_t)knum_insts;
|
125 |
| -#if !defined(__LP64__) |
126 |
| - } |
127 |
| - else { |
128 |
| - kernResult = IOConnectMethodScalarIScalarO(connect, kIncrementNumInstances, 0, 1, NULL, num_insts); |
129 |
| - } |
130 |
| -#endif |
131 |
| - |
132 |
| - return kernResult; |
| 52 | + return kernResult; |
133 | 53 | }
|
134 | 54 |
|
135 | 55 | kern_return_t decrementNumClients(io_connect_t connect, uint32_t* num_insts)
|
136 | 56 | {
|
137 | 57 | kern_return_t kernResult;
|
138 |
| -#if !defined(__LP64__) |
139 |
| - if (IOConnectCallStructMethod != NULL) { |
140 |
| -#endif |
141 |
| - size_t num_outputs = 1; |
142 |
| - uint64_t knum_insts; |
143 |
| - kernResult = IOConnectCallStructMethod(connect, kDecrementNumInstances, NULL, 0, &knum_insts, &num_outputs); |
| 58 | + size_t num_outputs = 1; |
| 59 | + uint64_t knum_insts; |
| 60 | + |
| 61 | + kernResult = IOConnectCallStructMethod(connect, kDecrementNumInstances, NULL, 0, &knum_insts, &num_outputs); |
144 | 62 | *num_insts = (uint32_t)knum_insts;
|
145 |
| -#if !defined(__LP64__) |
146 |
| - } |
147 |
| - else { |
148 |
| - kernResult = IOConnectMethodScalarIScalarO(connect, kDecrementNumInstances, 0, 1, NULL, num_insts); |
149 |
| - } |
150 |
| -#endif |
151 |
| - |
152 |
| - return kernResult; |
| 63 | + return kernResult; |
153 | 64 | }
|
0 commit comments