Skip to content

Commit c6c46df

Browse files
authored
Merge pull request #428 from nealsid/macos-remove-32bit
Remove 32 bit code from DriverInterface & update project build
2 parents 19b7e61 + c3f1b11 commit c6c46df

File tree

3 files changed

+26
-118
lines changed

3 files changed

+26
-118
lines changed

src/MacMSRDriver/DriverInterface.c

Lines changed: 22 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,64 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
// Copyright (c) 2012, Intel Corporation
33
// written by Austen Ott
4-
//
4+
//
55

66
#include "DriverInterface.h"
77

88
kern_return_t openMSRClient(io_connect_t connect)
99
{
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);
2411
}
2512

2613
kern_return_t closeMSRClient(io_connect_t connect)
2714
{
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);
4316
}
4417

4518
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)
4619
{
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);
6021
}
6122

6223
kern_return_t writeMSR(io_connect_t connect, pcm_msr_data_t* data, size_t* idata_size)
6324
{
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);
7726
}
7827

7928
kern_return_t getTopologyInfo(io_connect_t connect, topologyEntry* data, size_t* data_size)
8029
{
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);
9431
}
9532

9633
kern_return_t getNumClients(io_connect_t connect, uint32_t* num_insts)
9734
{
9835
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);
10540
*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;
11442
}
43+
11544
kern_return_t incrementNumClients(io_connect_t connect, uint32_t* num_insts)
11645
{
11746
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);
12451
*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;
13353
}
13454

13555
kern_return_t decrementNumClients(io_connect_t connect, uint32_t* num_insts)
13656
{
13757
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);
14462
*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;
15364
}

src/MacMSRDriver/PcmMsr.xcodeproj/project.pbxproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
developmentRegion = English;
219219
hasScannedForEncodings = 0;
220220
knownRegions = (
221+
English,
221222
en,
222223
);
223224
mainGroup = 81F91BAF156D9BF8007DD788;
@@ -296,7 +297,6 @@
296297
EXECUTABLE_PREFIX = lib;
297298
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
298299
INSTALL_PATH = /usr/lib;
299-
MACOSX_DEPLOYMENT_TARGET = 10.9;
300300
PRODUCT_NAME = PcmMsr;
301301
};
302302
name = Debug;
@@ -311,7 +311,6 @@
311311
EXECUTABLE_PREFIX = lib;
312312
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
313313
INSTALL_PATH = /usr/lib;
314-
MACOSX_DEPLOYMENT_TARGET = 10.9;
315314
PRODUCT_NAME = PcmMsr;
316315
};
317316
name = Release;
@@ -348,7 +347,7 @@
348347
GCC_WARN_UNINITIALIZED_AUTOS = YES;
349348
GCC_WARN_UNUSED_FUNCTION = YES;
350349
GCC_WARN_UNUSED_VARIABLE = YES;
351-
MACOSX_DEPLOYMENT_TARGET = "";
350+
MACOSX_DEPLOYMENT_TARGET = 13.0;
352351
ONLY_ACTIVE_ARCH = YES;
353352
SDKROOT = macosx;
354353
};
@@ -378,7 +377,7 @@
378377
GCC_WARN_UNINITIALIZED_AUTOS = YES;
379378
GCC_WARN_UNUSED_FUNCTION = YES;
380379
GCC_WARN_UNUSED_VARIABLE = YES;
381-
MACOSX_DEPLOYMENT_TARGET = "";
380+
MACOSX_DEPLOYMENT_TARGET = 13.0;
382381
SDKROOT = macosx;
383382
};
384383
name = Release;
@@ -392,7 +391,6 @@
392391
GCC_PREFIX_HEADER = "PcmMsr/PcmMsr-Prefix.pch";
393392
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
394393
INFOPLIST_FILE = "PcmMsr/PcmMsr-Info.plist";
395-
MACOSX_DEPLOYMENT_TARGET = 10.9;
396394
MODULE_NAME = com.intel.driver.PcmMsrDriver;
397395
MODULE_VERSION = 1.0.0d1;
398396
ONLY_ACTIVE_ARCH = YES;
@@ -413,7 +411,6 @@
413411
GCC_PREFIX_HEADER = "PcmMsr/PcmMsr-Prefix.pch";
414412
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
415413
INFOPLIST_FILE = "PcmMsr/PcmMsr-Info.plist";
416-
MACOSX_DEPLOYMENT_TARGET = 10.9;
417414
MODULE_NAME = com.intel.driver.PcmMsrDriver;
418415
MODULE_VERSION = 1.0.0d1;
419416
ONLY_ACTIVE_ARCH = YES;

src/MacMSRDriver/PcmMsr/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ target_link_libraries(PcmMsrDriver PRIVATE ${IOKIT_LIBRARY}
4141
# PcmMsrDriver.kext is built here and located in 'build/bin'
4242
set(LIB_EXT_PATH "/Library/Extensions")
4343
install(TARGETS PcmMsrDriver DESTINATION "${LIB_EXT_PATH}/")
44-
install(CODE "execute_process(COMMAND kmutil load ${LIB_EXT_PATH}/PcmMsrDriver.kext)")
44+
install(CODE "execute_process(COMMAND kmutil load -b com.intel.driver.PcmMsr)")

0 commit comments

Comments
 (0)