Apple SMCs contain numerous undocumented voltage, current, power,
and ambient light sensors. This change adds automatic detection
and registration of these sensors as sysctls.
New sysctl trees:
dev.asmc.0.voltage.* - Voltage sensors (millivolts) dev.asmc.0.current.* - Current sensors (milliamps) dev.asmc.0.power.* - Power sensors (milliwatts) dev.asmc.0.ambient.* - Ambient light sensors
Implementation:
- Scans all SMC keys at attach time via asmc_key_dump_by_index()
- Identifies sensors by key prefix patterns:
- Voltage: VC*, VD*, VG*, VP*, VI*
- Current: I{C,D,G,M,N,O,H,P,B,A,L}*
- Power: P{C,D,N,S,T,H,F,Z,z}*
- Light: ALV*, ALS*
- Dynamically creates sysctls for detected sensors
- Supports 8 fixed-point SMC data types:
- sp78, sp87, sp4b, sp5a, sp69, sp96, sp2d, ui16
- Auto-converts all values to milli-units (mV, mA, mW)
On Mac Mini 5,1, detects:
- 7 voltage sensors
- 18 current sensors
- 27 power sensors
- 2 ambient light sensors
Enables power consumption monitoring, voltage rail debugging,
and ambient light detection without hardcoding model-specific
sensor lists.
Tested on:
- Mac Mini 5,1 (2011) running FreeBSD 15.0-RELEASE
- 54 sensors auto-detected and exposed via sysctl
- All sensor types verified with multimeter readings
- Fixed-point conversions validated against known values
- Memory management tested (malloc/free on detach)