Skip to content

Commit

Permalink
Merge pull request #434 from nealsid/client-build-and-topology-struct…
Browse files Browse the repository at this point in the history
…ure-mismatch

Add IOUserClient class to CMake builds, and add fields in kernel
  • Loading branch information
opcm authored Sep 7, 2022
2 parents 3aa0827 + eee1719 commit c022f7a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/MacMSRDriver/PcmMsr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_executable(
PcmMsrDriver
MACOSX_BUNDLE
PcmMsr.cpp
PcmMSrClient.cpp
PcmMsrDriver_info.c
PcmMsr-Info.plist
)
Expand Down
10 changes: 6 additions & 4 deletions src/MacMSRDriver/PcmMsr/PcmMsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void cpuWriteMSR(void* pIDatas){
}

void cpuGetTopoData(void* pTopos){
kTopologyEntry* entries = (kTopologyEntry*)pTopos;
topologyEntry* entries = (topologyEntry*)pTopos;
volatile uint cpu = cpu_number();
int info[4];
entries[cpu].os_id = cpu;
Expand Down Expand Up @@ -119,15 +119,17 @@ bool PcmMsrDriverClassName::init(OSDictionary *dict)
topologies = 0;
if(result && num_cores != 0)
{
topologies = (kTopologyEntry*)IOMallocAligned(sizeof(kTopologyEntry)*num_cores, 128);
topologies = (topologyEntry*)IOMallocAligned(sizeof(topologyEntry)*num_cores, 32);
}
return (result && topologies && num_cores != 0);
}

void PcmMsrDriverClassName::free()
{
if(topologies)
IOFreeAligned(topologies, sizeof(kTopologyEntry)*num_cores);
if (topologies)
{
IOFreeAligned(topologies, sizeof(topologyEntry)*num_cores);
}
super::free();
}

Expand Down
2 changes: 1 addition & 1 deletion src/MacMSRDriver/PcmMsr/PcmMsr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PcmMsrDriverClassName : public IOService
// number of providers currently using the driver
uint32_t num_clients = 0;
uint32_t num_cores;
kTopologyEntry *topologies;
topologyEntry *topologies;
};

#ifdef DEBUG
Expand Down
18 changes: 5 additions & 13 deletions src/MacMSRDriver/PcmMsr/UserKernelShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,18 @@ typedef struct {
} k_pcm_msr_data_t;

// The topologyEntry struct that is used by PCM
typedef struct{
typedef struct
{
uint32_t os_id;
uint32_t thread_id;
uint32_t core_id;
uint32_t tile_id;
uint32_t socket;
uint32_t native_cpu_model;
uint32_t core_type; // This is an enum in the userland structure.
uint32_t padding;
} topologyEntry;

// A kernel version of the topology entry structure. It has
// an extra unused int to explicitly align the struct on a 64bit
// boundary, preventing the compiler from adding extra padding.
typedef struct{
uint32_t os_id;
uint32_t thread_id;
uint32_t core_id;
uint32_t tile_id;
uint32_t socket;
char padding[108];
} kTopologyEntry;

enum {
kOpenDriver,
kCloseDriver,
Expand Down

0 comments on commit c022f7a

Please sign in to comment.