diff options
author | Marc Balmer <mbalmer@cvs.openbsd.org> | 2008-06-14 22:26:14 +0000 |
---|---|---|
committer | Marc Balmer <mbalmer@cvs.openbsd.org> | 2008-06-14 22:26:14 +0000 |
commit | 87e94aee3efc5e5261d2c2f63036b1d84bed3eb7 (patch) | |
tree | ab6d5a3c1d78ea31cc2632f91ea51623be11beeb | |
parent | 712cd360edb69a4337f3e8fd83297afd7057d224 (diff) |
Changes needed to run on OpenBSD using the new amdmsr(4) driver.
-rw-r--r-- | driver/xf86-video-geode/src/Makefile.am | 10 | ||||
-rw-r--r-- | driver/xf86-video-geode/src/geode_msr.c | 58 |
2 files changed, 52 insertions, 16 deletions
diff --git a/driver/xf86-video-geode/src/Makefile.am b/driver/xf86-video-geode/src/Makefile.am index 15c9f6609..e7babe5ed 100644 --- a/driver/xf86-video-geode/src/Makefile.am +++ b/driver/xf86-video-geode/src/Makefile.am @@ -30,7 +30,7 @@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) \ # -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@ @@ -140,11 +140,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/driver/xf86-video-geode/src/geode_msr.c b/driver/xf86-video-geode/src/geode_msr.c index 167ccd623..b58ca155f 100644 --- a/driver/xf86-video-geode/src/geode_msr.c +++ b/driver/xf86-video-geode/src/geode_msr.c @@ -1,21 +1,39 @@ #define _LARGEFILE64_SOURCE + +#include <sys/types.h> +#include <sys/ioctl.h> +#ifdef __OpenBSD__ +#include <sys/amdmsr.h> +#endif + +#include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/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; } |