File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# !/usr/bin/make -f
22
3- CFLAGS ?= -O2 -Wall -Wextra
3+ # -mno-red-zone: the inline SMM asm pushes to the stack, which would
4+ # otherwise land in the 128-byte red zone the ABI lets gcc use
5+ CFLAGS ?= -O2 -Wall -Wextra -mno-red-zone
46
57all : dell-bios-fan-control
68
Original file line number Diff line number Diff line change 11/*
22 * dell-bios-fan-control
3- * user space utility to set control of fans by bios on Dell 9560 Laptops .
3+ * user space utility to enable or disable BIOS fan control on Dell machines .
44 *
55 * SMM Management code from i8k. See file drivers/char/i8k.c at Linux kernel.
66 *
2828#include <unistd.h>
2929#include <sys/io.h>
3030
31+ #if !defined(__x86_64__ )
32+ #error "x86-64 only: the SMM call goes out through ports 0xb2 and 0x84"
33+ #endif
34+
3135/*
3236 *
3337 * Most of the code was taken from https://github.com/clopez/dellfan
@@ -131,18 +135,16 @@ int main(int argc, char **argv) {
131135
132136 init_ioperm ();
133137
134- if (enable ) {
138+ if (enable )
135139 rc = send (ENABLE_BIOS_METHOD2 , 0 );
136- printf ("BIOS CONTROL ENABLED\n" );
137- }
138- else {
140+ else
139141 rc = send (DISABLE_BIOS_METHOD2 , 0 );
140- printf ("BIOS CONTROL DISABLED\n" );
141- }
142142
143143 /* The error heuristic can misfire on some BIOSes, so warn only */
144144 if (rc != 0 )
145145 fprintf (stderr , "warning: SMM call may have failed\n" );
146146
147+ printf ("BIOS CONTROL %s\n" , enable ? "ENABLED" : "DISABLED" );
148+
147149 return 0 ;
148150}
You can’t perform that action at this time.
0 commit comments