SMC Interface Engine (AppleSMC IOKit Client) #2
Notifications
Due Date
No due date set.
Blocks
Depends on
#3 CPU Core Temperatures & Thermal Zone Monitoring
gronod/MacMonitor
#4 Fan Speed & Multi-Fan Telemetry
gronod/MacMonitor
#18 Motherboard, PCH, Heatsink & Component Temperatures
gronod/MacMonitor
#19 Power Consumption, Voltage & Current Sensor Telemetry
gronod/MacMonitor
Reference: gronod/MacMonitor#2
Reference in New Issue
Block a user
Purpose
Provide a robust low-level interface to the Apple System Management Controller (AppleSMC) on Intel Macs via IOKit. The AppleSMC driver governs critical Intel hardware telemetry including core temperatures, fan RPMs, voltage/current levels, and power consumption.
Priority
Critical (Prerequisite for all temperature, fan, voltage, and thermal monitoring)
Dependencies
Scope
AppleSMCservice in the IOKit registry via an Objective-C wrapper.kSMCGetKeyInfo), and data reading (kSMCReadKey).sp78(Signed 8.8 fixed-point integer for temperatures)fpe2(Unsigned 14.2 fixed-point integer for fan speeds)ui8,ui16,ui32(Unsigned integers for counters and state flags)flt(32-bit floating point numbers)Implementation Suggestions
MMAppleSMCClient) interfacing withIOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleSMC"))andIOServiceOpen().IOConnectCallStructMethodtargeting SMC selector indices to communicate with the SMC driver.Technical Implementation Plan & Code Solution
1. Low-Level Architecture & IOKit Mach Structures
The Apple System Management Controller (AppleSMC) communicates via the
AppleSMCClientuser client class in IOKit. Calls are made using Mach struct method calls viaIOConnectCallStructMethod.Core C Definitions & Structures (
SMCInterface.h)2. Client Class Implementation (
MMAppleSMCClient.m)3. Edge Cases & Resilience
os_unfair_lockprovides zero-overhead thread synchronization._connectionviaIOServiceCloseto prevent stale Mach port handles upon waking. Re-open dynamically on first read.Implementation Completed (Milestone 1)
The SMC Interface Engine (AppleSMC IOKit Client) has been implemented in commit
dba5af3on branchfeat/2-smc-clientand merged intomilestone/m1-foundation(commita274927).Delivered Components:
MMSMCDefines.h): Low-level Mach/IOKit structure definitions (SMCKeyData_t,SMCVal_t,SMCKeyInfoData) and command selectors (kSMCHandleYPCEvent,kSMCReadKey,kSMCGetKeyInfo).MMSMCParser.m): High-performance decoders for fixed-pointsp78(temperature),fpe2(fan RPM),flt(IEEE 754),ui8,ui16,ui32, and boolean flags.MMAppleSMCClient.m): Thread-safe driver interface usingos_unfair_lock, connecting toAppleSMCClientviaIOServiceOpen, automatic key info caching, sensor key enumeration (#KEY), and fallback handling for non-Mac/virtualized environments.MacMonitor-Bridging-Header.h.MMSMCTests.swift): 6 comprehensive unit tests verifying numeric decoding precision against synthetic byte buffers and driver availability probing. 100% passing.