summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/geode_msr.c54
2 files changed, 50 insertions, 14 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6817ea4..4077d72 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,7 @@ AM_CPPFLAGS = \
# -DPNL_SUP is now provided by AMD_CFLAGS
#
AM_CFLAGS = @XORG_CFLAGS@ \
- -DHAVE_GX -DHAVE_LX -DAMD_V4L2_VIDEO -DOPT_ACCEL \
+ -DHAVE_GX -DHAVE_LX -DOPT_ACCEL \
-DLINUX_2_6 @AMD_CFLAGS@
AM_CCASFLAGS = @XORG_CFLAGS@
@@ -144,11 +144,3 @@ EXTRA_DIST = \
\
gx_vga.c \
lx_vga.c
-
-ztv_drv_la_LTLIBRARIES = ztv_drv.la
-ztv_drv_la_LDFLAGS = -module -avoid-version
-ztv_drv_ladir = @moduledir@/drivers
-
-ztv_drv_la_SOURCES = \
- z4l.c
-
diff --git a/src/geode_msr.c b/src/geode_msr.c
index 6de693f..463c979 100644
--- a/src/geode_msr.c
+++ b/src/geode_msr.c
@@ -1,21 +1,39 @@
#define _LARGEFILE64_SOURCE
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#ifdef __OpenBSD__
+#include <machine/amdmsr.h>
+#endif
+
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
-#include <sys/types.h>
#include <errno.h>
+
#include "os.h"
#include "geode.h"
+#ifdef __OpenBSD__
+#define _PATH_MSRDEV "/dev/amdmsr"
+#define X_PRIVSEP
+#else
+#define _PATH_MSRDEV "/dev/cpu/0/msr"
+#endif
+
static int
_msr_open(void)
{
static int msrfd = 0;
if (msrfd == 0) {
- msrfd = open("/dev/cpu/0/msr", O_RDWR);
+#ifdef X_PRIVSEP
+ msrfd = priv_open_device(_PATH_MSRDEV);
+#else
+ msrfd = open(_PATH_MSRDEV, O_RDWR);
+#endif
if (msrfd == -1)
- ErrorF("Unable to open /dev/cpu/0/msr: %d\n", errno);
+ ErrorF("Unable to open %s: %s\n", _PATH_MSRDEV, strerror(errno));
}
return msrfd;
@@ -24,6 +42,20 @@ _msr_open(void)
int
GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
{
+#ifdef __OpenBSD__
+ struct amdmsr_req req;
+#endif
+ int fd = _msr_open();
+
+#ifdef __OpenBSD__
+ req.addr = addr;
+
+ if (ioctl(fd, RDMSR, &req) == -1)
+ ErrorF("Unable to RDMSR %d\n", errno);
+
+ *hi = req.val >> 32;
+ *lo = req.val & 0xffffffff;
+#else
unsigned int data[2];
int fd = _msr_open();
int ret;
@@ -43,13 +75,25 @@ GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
*hi = data[1];
*lo = data[0];
-
+#endif
return 0;
}
int
GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
{
+#ifdef __OpenBSD__
+ struct amdmsr_req req;
+#endif
+ int fd = _msr_open();
+
+#ifdef __OpenBSD__
+ req.addr = addr;
+ req.val = (u_int64_t)hi << 32 | (u_int64_t)lo;
+
+ if (ioctl(fd, WRMSR, &req) == -1)
+ ErrorF("Unable to WRMSR %d\n", errno);
+#else
unsigned int data[2];
int fd = _msr_open();
@@ -64,6 +108,6 @@ GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
if (write(fd, (void *)data, 8) != 8)
return -1;
-
+#endif
return 0;
}