summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Gaiarin2017-07-06 11:24:42 +0200
committerSimone Gaiarin2017-07-06 11:31:35 +0200
commitd4eeb5aba29e5f6b504444a0d900b0d3eb8dd1f5 (patch)
treed3693033c7a3ba1396a2a97a43aacb5d4cb7f364
downloadaur-d4eeb5aba29e5f6b504444a0d900b0d3eb8dd1f5.tar.gz
Initial release
-rw-r--r--.SRCINFO18
-rw-r--r--PKGBUILD42
-rw-r--r--dell-smm-hwmon-i8kutils.install12
-rw-r--r--dell-smm-hwmon.patch67
-rw-r--r--smm.c74
5 files changed, 213 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..0eec3934c4db
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,18 @@
+pkgbase = dell-smm-hwmon-i8kutils
+ pkgdesc = Redshift plasmoid provides a configuration interface and allows to start/stop Redshift daemon either manually or automatically based on the current activity. Plasma5 development version.
+ pkgver = 4.9.34
+ pkgrel = 1
+ install = dell-smm-hwmon-i8kutils.install
+ arch = any
+ license = GPL
+ makedepends = linux49-headers
+ depends = linux49
+ source = https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.34.tar.xz
+ source = dell-smm-hwmon.patch
+ source = smm.c
+ md5sums = 92aaa07c90e1c7de60fcdd8a9726dd59
+ md5sums = ccfe8a74d9cbf587d5a9cb395cae2834
+ md5sums = a5e33f4c632c3055bd51853edeef51fc
+
+pkgname = dell-smm-hwmon-i8kutils
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..7d5c94dffccb
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Simone Gaiarin <simgunz@gmail.com>
+
+pkgname=dell-smm-hwmon-i8kutils
+pkgver=4.9.34
+pkgrel=1
+pkgdesc='Redshift plasmoid provides a configuration interface and allows to start/stop Redshift daemon either manually or automatically based on the current activity. Plasma5 development version.'
+arch=('any')
+license=('GPL')
+depends=('linux49')
+makedepends=('linux49-headers')
+install='dell-smm-hwmon-i8kutils.install'
+source=("https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$pkgver.tar.xz"
+ 'dell-smm-hwmon.patch'
+ 'smm.c')
+md5sums=('92aaa07c90e1c7de60fcdd8a9726dd59'
+ 'ccfe8a74d9cbf587d5a9cb395cae2834'
+ 'a5e33f4c632c3055bd51853edeef51fc')
+
+prepare() {
+ cd "$srcdir/linux-$pkgver"
+ patch -p0 < ../dell-smm-hwmon.patch
+ make mrproper
+ cp "/usr/lib/modules/$(uname -r)/build/.config" ./
+ cp "/usr/lib/modules/$(uname -r)/build/Module.symvers" ./
+}
+
+build() {
+ cd "$srcdir"
+ gcc -o smm smm.c
+ cd "$srcdir/linux-$pkgver"
+ make prepare
+ make scripts
+ make M=drivers/hwmon
+ gzip ./drivers/hwmon/dell-smm-hwmon.ko
+}
+
+package() {
+ mkdir -p "${pkgdir}/usr/lib/modules/$(uname -r)/updates/"
+ cp "${srcdir}/linux-$pkgver/drivers/hwmon/dell-smm-hwmon.ko.gz" "${pkgdir}/usr/lib/modules/$(uname -r)/updates/"
+ mkdir -p "${pkgdir}/usr/bin/"
+ cp "${srcdir}/smm" "${pkgdir}/usr/bin/"
+}
diff --git a/dell-smm-hwmon-i8kutils.install b/dell-smm-hwmon-i8kutils.install
new file mode 100644
index 000000000000..3bd4071030d9
--- /dev/null
+++ b/dell-smm-hwmon-i8kutils.install
@@ -0,0 +1,12 @@
+post_install() {
+ echo "Running depmod.."
+ depmod
+ echo --------------------------------------------------------
+ echo After install, reboot the system in order to be able
+ echo to use the command smm.
+ echo --------------------------------------------------------
+}
+
+post_upgrade () {
+ post_install
+}
diff --git a/dell-smm-hwmon.patch b/dell-smm-hwmon.patch
new file mode 100644
index 000000000000..84a2d5901780
--- /dev/null
+++ b/dell-smm-hwmon.patch
@@ -0,0 +1,67 @@
+--- drivers/hwmon/dell-smm-hwmon.c 2017-06-17 06:43:47.000000000 +0200
++++ drivers/hwmon/dell-smm-hwmon.c.modded 2017-06-22 17:56:45.768725404 +0200
+@@ -41,6 +41,8 @@
+
+ #include <linux/i8k.h>
+
++#define I8K_SMM _IOWR('i', 0x88, size_t)
++
+ #define I8K_SMM_FN_STATUS 0x0025
+ #define I8K_SMM_POWER_STATUS 0x0069
+ #define I8K_SMM_SET_FAN 0x01a3
+@@ -409,6 +411,18 @@
+ return (regs.eax & 0xff) == I8K_POWER_AC ? I8K_AC : I8K_BATTERY;
+ }
+
++static int i8k_smm_raw(int eax,int ebx,int ecx,int edx,int esi,int edi)
++{
++ struct smm_regs regs = { .eax=eax, .ebx=ebx, .ecx=ecx, .edx=edx, .esi=esi, .edi=edi};
++ int rc;
++
++ rc = i8k_smm(&regs);
++ if (rc < 0)
++ return rc;
++
++ return 0;
++}
++
+ /*
+ * Procfs interface
+ */
+@@ -420,6 +434,7 @@
+ int speed;
+ unsigned char buff[16];
+ int __user *argp = (int __user *)arg;
++ int eax; int ebx; int ecx; int edx; int esi; int edi;
+
+ if (!argp)
+ return -EINVAL;
+@@ -481,6 +496,28 @@
+ val = i8k_set_fan(val, speed);
+ break;
+
++ case I8K_SMM:
++ if (copy_from_user(&eax, argp, sizeof(int)))
++ return -EFAULT;
++
++ if (copy_from_user(&ebx, argp+1, sizeof(int)))
++ return -EFAULT;
++
++ if (copy_from_user(&ecx, argp+2, sizeof(int)))
++ return -EFAULT;
++
++ if (copy_from_user(&edx, argp+3, sizeof(int)))
++ return -EFAULT;
++
++ if (copy_from_user(&esi, argp+4, sizeof(int)))
++ return -EFAULT;
++
++ if (copy_from_user(&edi, argp+5, sizeof(int)))
++ return -EFAULT;
++
++ val = i8k_smm_raw(eax,ebx,ecx,edx,esi,edi);
++ break;
++
+ default:
+ return -EINVAL;
+ }
diff --git a/smm.c b/smm.c
new file mode 100644
index 000000000000..4d16f32fe95e
--- /dev/null
+++ b/smm.c
@@ -0,0 +1,74 @@
+/*
+ * smm.c -- Utility to test SMM BIOS calls on Inspiron 8000 laptops
+ *
+ * Copyright (C) 2017 Vitor Augusto <vitorafsr@gmail.com>
+ * Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * WARNING!!! READ CAREFULLY BEFORE USING THIS PROGRAM!!!
+ *
+ * THIS PROGRAM IS VERY DANGEROUS. IT CAN CRASH YOUR COMPUTER, DESTROY DATA
+ * ON THE HARDISK, CORRUPT THE BIOS, PHYSICALLY DAMAGE YOUR HARDWARE AND
+ * MAKE YOUR COMPUTER TOTALLY UNUSABLE.
+ *
+ * DON'T USE THIS PROGRAM UNLESS YOU REALLY KNOW WHAT YOU ARE DOING. I WILL
+ * NOT BE RESPONSIBLE FOR ANY DIRECT OR INDIRECT DAMAGE CAUSED BY USING THIS
+ * PROGRAM.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/io.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#define I8K_SMM _IOWR('i', 0x88, size_t)
+
+int
+main(int argc, char **argv)
+{
+ int registers[6];
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s eax ebx ecx edx esi edi\n", argv[0]);
+ exit(1);
+ }
+
+ if (argc > 1) registers[0] = strtol(argv[1],NULL,16);
+ if (argc > 2) registers[1] = strtol(argv[2],NULL,16);
+ if (argc > 3) registers[2] = strtol(argv[3],NULL,16);
+ if (argc > 4) registers[3] = strtol(argv[4],NULL,16);
+ if (argc > 5) registers[4] = strtol(argv[5],NULL,16);
+ if (argc > 6) registers[5] = strtol(argv[6],NULL,16);
+
+ int fp = open("/proc/i8k", O_WRONLY);
+ if (fp == -1) {
+ perror("Error opening file /proc/i8k\n");
+ return -1;
+ }
+
+ fp = ioctl(fp, I8K_SMM, &registers);
+ if (fp == -1) {
+ perror("Error on ioctl\n");
+ fprintf(stderr, "Err no. %d\n", fp);
+ close(fp);
+ return -1;
+ }
+
+ close(fp);
+
+ return 0;
+}
+
+/* end of file */