NetBSD Problem Report #43487

From www@NetBSD.org  Thu Jun 17 14:22:40 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id BB15363B916
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 17 Jun 2010 14:22:40 +0000 (UTC)
Message-Id: <20100617142240.4A23563B100@www.NetBSD.org>
Date: Thu, 17 Jun 2010 14:22:40 +0000 (UTC)
From: polachok@gmail.com
Reply-To: polachok@gmail.com
To: gnats-bugs@NetBSD.org
Subject: sysutils/915resolution fix for DragonFly
X-Send-Pr-Version: www-1.0

>Number:         43487
>Category:       pkg
>Synopsis:       sysutils/915resolution fix for DragonFly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 17 14:25:00 +0000 2010
>Closed-Date:    Sun Jun 20 11:07:09 +0000 2010
>Last-Modified:  Sun Jun 20 11:10:03 +0000 2010
>Originator:     Alexander Polakov
>Release:        n/a
>Organization:
>Environment:
>Description:
915resolution is disabled for DragonFly and FreeBSD due to missing iopl(). 
This can be worked around with a patch attached (not tested on FreeBSD, but inspired by this: http://www.freebsd.org/cgi/cvsweb.cgi/ports/sysutils/915resolution/files/patch-915resolution.c?rev=1.2;content-type=text/plain)

Build and works fine, tested on DragonFly with my ASUS Eee netbook.
>How-To-Repeat:

>Fix:
--- 915resolution.c.orig        2007-04-15 14:46:56 +0400
+++ 915resolution.c     2010-06-17 18:04:11 +0400
@@ -22,11 +22,57 @@
 #include <string.h>
 #include <sys/mman.h>
 #include <fcntl.h>
+#ifdef __linux__
 #include <sys/io.h>
+#endif
+#ifdef __NetBSD__
+#include <machine/pio.h>
+#include <machine/sysarch.h>
+# if defined(__i386__)
+#define iopl(a) i386_iopl(a)
+# elif defined(__x86_64__)
+#define iopl(a) x86_64_iopl(a)
+# endif
+#endif
 #include <unistd.h>
 #include <assert.h>

+static uint8_t
+asm_inb(unsigned port)
+{
+       uint8_t data;
+       __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+       return data;
+}
+
+static __inline void
+asm_outb(uint8_t data, unsigned port)
+{
+       __asm volatile("outb %0,%w1" : : "a" (data), "d" (port));
+}
+
+static uint32_t
+asm_inl(unsigned port)
+{
+       uint32_t data;
+       __asm volatile("inl %w1,%0" : "=a" (data) : "d" (port));
+       return data;
+}

+static __inline void
+asm_outl(uint32_t data, unsigned port)
+{
+       __asm volatile("outl %0,%w1" : : "a" (data), "d" (port));
+}
+
+#undef inb
+#undef outb
+#define        inb asm_inb
+#define        outb asm_outb
+#undef inl
+#undef outl
+#define        inl asm_inl
+#define        outl asm_outl

 #define NEW(a) ((a *)(calloc(1, sizeof(a))))
 #define FREE(a) (free(a))
@@ -165,7 +211,12 @@
 void initialize_system(char * filename) {

     if (!filename) {
+#if !defined(__FreeBSD__) & !defined(__DragonFly__)
         if (iopl(3) < 0) {
+#else
+       FILE *iof = fopen("/dev/io", "r");
+       if(iof == NULL) {
+#endif
             perror("Unable to obtain the proper IO permissions");
             exit(2);
         }

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sun, 20 Jun 2010 11:07:09 +0000
State-Changed-Why:
Committed, thanks. The patch had whitespace problems.
I've enabled the package on FreeBSD and DragonFly, please
let me know if there are problems with the patterns.


From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43487 CVS commit: pkgsrc/sysutils/915resolution
Date: Sun, 20 Jun 2010 11:06:04 +0000

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Sun Jun 20 11:06:04 UTC 2010

 Modified Files:
 	pkgsrc/sysutils/915resolution: Makefile distinfo
 	pkgsrc/sysutils/915resolution/patches: patch-aa

 Log Message:
 Fix build on DragonFly and FreeBSD, by Alexander Polakov in PR 43487.
 Enable on FreeBSD-*-i386 FreeBSD-*-x86_64 DragonFly-*-i386.


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 pkgsrc/sysutils/915resolution/Makefile \
     pkgsrc/sysutils/915resolution/distinfo
 cvs rdiff -u -r1.3 -r1.4 pkgsrc/sysutils/915resolution/patches/patch-aa

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.