From nobody@FreeBSD.org  Sat Mar  6 18:18:40 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3F4BA106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  6 Mar 2010 18:18:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 303A98FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  6 Mar 2010 18:18:40 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o26IIdkF085271
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 6 Mar 2010 18:18:39 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o26IIdDj085270;
	Sat, 6 Mar 2010 18:18:39 GMT
	(envelope-from nobody)
Message-Id: <201003061818.o26IIdDj085270@www.freebsd.org>
Date: Sat, 6 Mar 2010 18:18:39 GMT
From: nrgmilk <nrgmilk@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PORTS PATCH] sysutils/jfbterm 
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: bsdports@gmail.com

>Number:         144510
>Category:       ports
>Synopsis:       [PORTS PATCH] sysutils/jfbterm
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 06 18:20:01 UTC 2010
>Closed-Date:    Sat Jun 05 21:04:51 UTC 2010
>Last-Modified:  Sat Jun 05 21:04:51 UTC 2010
>Originator:     nrgmilk
>Release:        FreeBSD 9-CURRENT
>Organization:
>Environment:
>Description:
Hello.

This patch was offered from jkim at freebsd.org.

This patch fixes three things, 
a) enable 16-color mode on amd64
b) make write-combining range power of two (for -CURRENT)
c) remove write-combining memory range before exiting

thanks
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- sysutils/jfbterm/Makefile	1 Mar 2009 19:38:06 -0000	1.8
+++ sysutils/jfbterm/Makefile	23 Feb 2010 01:15:15 -0000
@@ -6,6 +6,7 @@
 
 PORTNAME=	jfbterm
 PORTVERSION=	0.6.0
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	http://www.ac.auone-net.jp/~baba/jfbterm/ \
 		http://chirashi-no-ura.net/files/
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysutils/jfbterm/files/patch-configure	23 Feb 2010 01:15:15 -0000
@@ -0,0 +1,11 @@
+--- configure.in.orig	2009-02-10 19:40:45.000000000 -0500
++++ configure.in	2010-02-22 16:37:33.000000000 -0500
+@@ -111,7 +111,7 @@
+   case $system in
+   Linux|FreeBSD)
+     case $machine in
+-    i?86|x86_64)
++    amd64|i?86|x86_64)
+       AC_DEFINE(ENABLE_VGA16FB)
+       ;;
+     *)
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysutils/jfbterm/files/patch-mtrr	23 Feb 2010 01:15:15 -0000
@@ -0,0 +1,90 @@
+--- framebuffer.c.orig	2009-02-23 18:23:54.000000000 -0500
++++ framebuffer.c	2010-02-22 19:26:38.000000000 -0500
+@@ -442,6 +442,11 @@
+ 	assert(initialized);
+ 
+ 	if (self->memory != MAP_FAILED) {
++		if (writecombine.enable) {
++			memctl_clearWriteCombine(writecombine.base,
++			    writecombine.size);
++			writecombine.enable = false;
++		}
+ 		if (munmap(self->memory, self->length) == -1)
+ 			warn("munmap()");
+ 		self->memory = MAP_FAILED;
+@@ -1162,18 +1167,21 @@
+ 			warnx("Invalid write-combining base detected. "
+ 			      "Start of framebuffer memory is %#x.",
+ 			      video_adapter_info.va_window);
+-		writecombine.base = video_adapter_info.va_window;
++		writecombine.base = (u_long)video_adapter_info.va_window;
+ 		if (writecombine.size != 0 &&
+ 		    video_adapter_info.va_window_size != writecombine.size)
+ 			warnx("Invalid write-combining size detected. "
+ 			      "Framebuffer size is %#x.",
+ 			      video_adapter_info.va_window_size);
+ 		writecombine.size = video_adapter_info.va_window_size;
++		writecombine.size = powerof2(writecombine.size) ?
++		    writecombine.size : 1UL << flsl(writecombine.size);
+ #endif
+-		if (writecombine.base != 0 && writecombine.size != 0)
+-			memctl_setWriteCombine(writecombine.base,
+-					       writecombine.size);
++		if (writecombine.base == 0 || writecombine.size == 0)
++			writecombine.enable = false;
+ 	}
++	if (writecombine.enable)
++		memctl_setWriteCombine(writecombine.base, writecombine.size);
+ 
+ 	/* VGA */
+ #ifdef ENABLE_VGA16FB
+--- memctl.c.orig	2009-01-23 10:53:36.000000000 -0500
++++ memctl.c	2010-02-22 19:26:38.000000000 -0500
+@@ -92,7 +92,7 @@
+ 		mem_range_desc.mr_owner[sizeof(mem_range_desc.mr_owner) - 1] =
+ 			'\0';
+ 		mem_range_op.mo_desc   = &mem_range_desc;
+-		mem_range_op.mo_arg[0] = 0;
++		mem_range_op.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ 		if (ioctl(fd, MEMRANGE_SET, &mem_range_op) != -1)
+ 			result = true;
+ 		close(fd);
+@@ -130,3 +130,28 @@
+ #endif
+ }
+ 
++void memctl_clearWriteCombine(unsigned long base, unsigned long size)
++{
++#if defined (__FreeBSD__) && (defined (__amd64__) || defined (__i386__))
++	struct mem_range_desc mem_range_desc;
++	struct mem_range_op mem_range_op;
++	int fd;
++
++	assert(base != 0);
++	assert(size != 0);
++
++	privilege_on();
++	fd = open(_PATH_MEM, O_RDONLY);
++	privilege_off();
++	if (fd != -1) {
++		mem_range_desc.mr_base = base;
++		mem_range_desc.mr_len  = size;
++		mem_range_op.mo_desc   = &mem_range_desc;
++		mem_range_op.mo_arg[0] = MEMRANGE_SET_REMOVE;
++		if (ioctl(fd, MEMRANGE_SET, &mem_range_op) == -1)
++			warn("failed to clear mtrr (0x%lx/0x%lx)\n",
++			    base, size);
++		close(fd);
++	}
++#endif
++}
+--- memctl.h.orig	2009-01-23 10:53:36.000000000 -0500
++++ memctl.h	2010-02-22 19:26:38.000000000 -0500
+@@ -31,6 +31,7 @@
+ #include <stdbool.h>
+ 
+ bool memctl_setWriteCombine(unsigned long base, unsigned long size);
++void memctl_clearWriteCombine(unsigned long base, unsigned long size);
+ 
+ #endif /* INCLUDE_MEMCTL_H */
+ 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sat Mar 6 18:20:11 UTC 2010 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144510 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: bsdports@gmail.com
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/144510: [PORTS PATCH] sysutils/jfbterm
Date: Sat, 6 Mar 2010 18:20:09 UT

 Maintainer of sysutils/jfbterm,
 
 Please note that PR ports/144510 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/144510
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org
State-Changed-From-To: feedback->closed 
State-Changed-By: miwi 
State-Changed-When: Sat Jun 5 21:04:50 UTC 2010 
State-Changed-Why:  
fixed with 146238 commit. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144510 
>Unformatted:
