21

I want to access the embedded controller of my (windows) laptop to control the fan speed. Currently I am doing this manually using RW Everything - how can I access the embedded controller e.g. using C? Thanks for any hint!

Please note: I am aware that RW Everything can be used from the commandline, but calling it every second to read some register isn't that nice...

bmargulies
  • 91,317
  • 38
  • 166
  • 290
stefan.at.wpf
  • 13,061
  • 31
  • 116
  • 199
  • 5
    Check out http://stackoverflow.com/q/485448/1098754 - seems like a good starting point. – David Pointer Feb 21 '12 at 21:17
  • 5
    thanks david. sad it's so complicated on windows. on linux it's really easy, guess i should install linux on my laptop :D – stefan.at.wpf Feb 21 '12 at 21:34
  • 1
    possible duplicate of [How can I control my PC's fan speed using C++ in Vista?](http://stackoverflow.com/questions/786984/how-can-i-control-my-pcs-fan-speed-using-c-in-vista) – Clifford Mar 26 '12 at 08:59
  • May I ask why you need to control the fan? – LastStar007 Jul 25 '12 at 18:35
  • Maybe Speedfan would fit what you want to do, did you check it out? [speedfan](http://www.almico.com/speedfan.php) – genetix Jul 26 '12 at 02:25
  • @stefan.at.wpf, could you please supply some specific data (tutorial or docs) about the exact method to control the fan speed by using ' RW Everything'? I would like to test it too. Thanks you. – Sopalajo de Arrierez Jun 10 '14 at 10:39
  • @SopalajodeArrierez Google for Acer fan control, there is a tool named like that and somewhere there's also some documentation. I don't have it anymore unfortunately, but it should still be online somewhere. – stefan.at.wpf Jun 10 '14 at 14:27

2 Answers2

1

If you're using RWEverything to simply change bits at physical memory addresses, you can always map physical memory to process local memory space using MmMapIoSpace or any of the other windows api functions that give you RW access to physical memory. After mapping the section of space that you need access to, you can directly address and alter it.

I've only ever used this method for writing to the parallel port on windows, but I've used similar solutions for other projects in linux.

Sniggerfardimungus
  • 10,708
  • 10
  • 46
  • 91
1

Programmatically, you'd need to create a kernel mode driver that uses MmMapIoSpace and handles IOCTLs off the IRP_MJ_CONTROL major function and then call StartServiceManager, CreateService and StartService on it and then send IOCTLs using DeviceIoControl to perform tasks which manipulate underlying physical memory / IO space / MSRs. See: https://stackoverflow.com/a/40449498/7194773. You can no longer program the fan. Note Margaret's answer:

It's worth noting that 9y later the SuperIOs are gone in laptop systems, replaced by the ECs. ECs have their firmware and use the PECI interface to read the DTS of the CPU. The EC's PWM HW is accessible only from the EC, the OS has no longer control over the CPU FAN if not by setting the CPU throttling policy.

You used to be able to select a SuperIO logical device by writing 07h to I/O port 2Eh (Index register) which cause the southbridge to generate LPC cycles which cause the SIO to select the LDN register (at offset 07h in the generic space: offsets 00h–30h) and then write the LDN to port 2Fh (data register) to generate LPC cycles that cause the SIO to select that LDN. This would cause the configuration space of the LDN at offset 30h–FFh to be mapped in at the ports, which can then be accessed using the index and then read/writing to the data register. A bit in the LPC bridge on the PCH is used to select whether to expose ports 2F/2E or 4F/4E.

With the ECs, the registers have been separated into host view and an EC view. All of the PWM and PECI registers are no longer logical devices and their registers are only mapped into the MMIO space of the on board EC CPU, leaving only a few generic registers in the regular IO space visible to the host. Some LDNs expose IO base address registers in their own space (offset 30h–FFh) which allow extra registers to be mapped in. The EC's firmware uses the PECI bus to read the DTSs of the CPU and adjust fan speeds accordingly at known register offsets in its MMIO space.

Lewis Kelsey
  • 2,465
  • 1
  • 13
  • 21