summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArrigo Marchiori <ardovm@yahoo.it>2015-09-28 13:52:34 +0300
committerMartin-Éric Racine <martin-eric.racine@iki.fi>2015-09-28 13:52:34 +0300
commit44c508916af7a6e59d898829faaec599dbd51f4a (patch)
treef17225082178229c877aa7fb9f512104722b0921
parentaecb0803d318e8100d6024f34a96df225ff738aa (diff)
Geode MSR support for FreeBSD
The file src/geode_msr.c does not compile under FreeBSD. The attached patch allows to compile the driver. Closes: Free Desktop Bug #92158 Signed-off-by: Arrigo Marchiori <ardovm@yahoo.it>
-rw-r--r--src/geode_msr.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/geode_msr.c b/src/geode_msr.c
index 8f57939..8cecb30 100644
--- a/src/geode_msr.c
+++ b/src/geode_msr.c
@@ -39,12 +39,19 @@
#include <machine/amdmsr.h>
#endif
+#ifdef __FreeBSD__
+#include <sys/ioctl.h>
+#include <sys/cpuctl.h>
+#endif
+
#include "os.h"
#include "geode.h"
#ifdef __OpenBSD__
#define _PATH_MSRDEV "/dev/amdmsr"
#define X_PRIVSEP
+#elif defined __FreeBSD__
+#define _PATH_MSRDEV "/dev/cpuctl0"
#else
#define _PATH_MSRDEV "/dev/cpu/0/msr"
#endif
@@ -83,6 +90,18 @@ GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
*hi = req.val >> 32;
*lo = req.val & 0xffffffff;
+#elif defined __FreeBSD__
+ cpuctl_msr_args_t args;
+ int fd = _msr_open();
+
+ args.msr = addr;
+
+ if (ioctl(fd, CPUCTL_RDMSR, &args) == -1)
+ FatalError("Unable to read MSR at address %0x06x: %s\n", addr,
+ strerror(errno));
+
+ *hi = args.data >> 32;
+ *lo = args.data & 0xffffffff;
#else
unsigned int data[2];
int fd = _msr_open();
@@ -120,6 +139,16 @@ GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
if (ioctl(fd, WRMSR, &req) == -1)
FatalError("Unable to write MSR at address 0x%06x: %s\n", addr,
strerror(errno));
+#elif defined __FreeBSD__
+ cpuctl_msr_args_t args;
+ int fd = _msr_open();
+
+ args.msr = addr;
+ args.data = (u_int64_t) hi << 32 | (u_int64_t)lo;
+
+ if (ioctl(fd, CPUCTL_WRMSR, &args) == -1)
+ FatalError("Unable to write MSR at address 0x%06x: %s\n", addr,
+ strerror(errno));
#else
unsigned int data[2];
int fd = _msr_open();