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
#include < IOKit/IOLib.h>
6
6
#include < libkern/sysctl.h>
7
7
#include " PcmMsr.h"
@@ -63,7 +63,7 @@ void cpuGetTopoData(void* pTopos){
63
63
entries[cpu].os_id = cpu;
64
64
cpuid (0xB , 1 , info[0 ], info[1 ], info[2 ], info[3 ]);
65
65
entries[cpu].socket = info[3 ] >> info[0 ] & 0xF ;
66
-
66
+
67
67
cpuid (0xB , 0 , info[0 ], info[1 ], info[2 ], info[3 ]);
68
68
entries[cpu].core_id = info[3 ] >> info[0 ] & 0xF ;
69
69
}
@@ -75,15 +75,15 @@ OSDefineMetaClassAndStructors(com_intel_driver_PcmMsr, IOService)
75
75
bool PcmMsrDriverClassName::start (IOService* provider){
76
76
bool success;
77
77
success = super::start (provider);
78
-
78
+
79
79
if (!g_pci_driver) {
80
80
g_pci_driver = this ;
81
81
}
82
-
82
+
83
83
if (success) {
84
- registerService ();
84
+ registerService ();
85
85
}
86
-
86
+
87
87
return success;
88
88
}
89
89
uint32_t PcmMsrDriverClassName::getNumCores ()
@@ -149,9 +149,9 @@ IOReturn PcmMsrDriverClassName::readMSR(pcm_msr_data_t* idatas,pcm_msr_data_t* o
149
149
// All the msr_nums should be the same, so we just use the first one to pass to all cores
150
150
IOReturn ret = kIOReturnBadArgument ;
151
151
if (idatas->cpu_num < num_cores)
152
- {
152
+ {
153
153
mp_rendezvous_no_intrs (cpuReadMSR, (void *)idatas);
154
-
154
+
155
155
odatas->cpu_num = idatas->cpu_num ;
156
156
odatas->msr_num = idatas->msr_num ;
157
157
odatas->value = idatas->value ;
@@ -169,14 +169,14 @@ IOReturn PcmMsrDriverClassName::writeMSR(pcm_msr_data_t* idata){
169
169
if (idata->cpu_num < num_cores)
170
170
{
171
171
mp_rendezvous_no_intrs (cpuWriteMSR, (void *)idata);
172
-
172
+
173
173
ret = kIOReturnSuccess ;
174
174
}
175
175
else
176
176
{
177
177
IOLog (" Tried to write to a core with id higher than max core id.\n " );
178
178
}
179
-
179
+
180
180
return ret;
181
181
}
182
182
@@ -210,7 +210,7 @@ IOReturn PcmMsrDriverClassName::decrementNumInstances(uint32_t* num_insts){
210
210
uint32_t PcmMsrDriverClassName::read (uint32_t pci_address)
211
211
{
212
212
uint32_t value = 0 ;
213
-
213
+
214
214
__asm__ (" \t "
215
215
" movw $0xCF8,%%dx\n\t "
216
216
" andb $0xFC,%%al\n\t "
@@ -220,15 +220,15 @@ uint32_t PcmMsrDriverClassName::read(uint32_t pci_address)
220
220
: " =a" (value)
221
221
: " a" (pci_address)
222
222
: " %edx" );
223
-
223
+
224
224
return value;
225
225
}
226
226
227
227
228
228
// write
229
229
void PcmMsrDriverClassName::write (uint32_t pci_address, uint32_t value)
230
230
{
231
-
231
+
232
232
__asm__ (" \t "
233
233
" movw $0xCF8,%%dx\n\t "
234
234
" andb $0xFC,%%al\n\t "
@@ -246,7 +246,7 @@ void PcmMsrDriverClassName::write(uint32_t pci_address, uint32_t value)
246
246
void * PcmMsrDriverClassName::mapMemory (uint32_t address, UInt8 **virtual_address)
247
247
{
248
248
PRINT_DEBUG (" %s[%p]::%s()\n " , getName (), this , __FUNCTION__);
249
-
249
+
250
250
IOMemoryMap *memory_map = NULL ;
251
251
IOMemoryDescriptor *memory_descriptor = NULL ;
252
252
#ifndef __clang_analyzer__ // address a false-positive
@@ -278,7 +278,7 @@ void* PcmMsrDriverClassName::mapMemory (uint32_t address, UInt8 **virtual_addres
278
278
} else {
279
279
IOLog (" %s[%p]::%s() -- IOMemoryDescriptor::withPhysicalAddress() failure\n " , getName (), this , __FUNCTION__);
280
280
}
281
-
281
+
282
282
return (void *)memory_map;
283
283
}
284
284
@@ -287,9 +287,9 @@ void* PcmMsrDriverClassName::mapMemory (uint32_t address, UInt8 **virtual_addres
287
287
void PcmMsrDriverClassName::unmapMemory (void *memory_map)
288
288
{
289
289
PRINT_DEBUG (" %s[%p]::%s()\n " , getName (), this , __FUNCTION__);
290
-
290
+
291
291
IOMemoryMap *m_map = (IOMemoryMap*)memory_map;
292
-
292
+
293
293
if (m_map) {
294
294
m_map->getMemoryDescriptor ()->complete ();
295
295
#ifndef __clang_analyzer__ // address a false-positive
@@ -298,6 +298,6 @@ void PcmMsrDriverClassName::unmapMemory (void *memory_map)
298
298
m_map->unmap ();
299
299
m_map->release ();
300
300
}
301
-
301
+
302
302
return ;
303
303
}
0 commit comments