Subject: xsrc/20560: alpha_video.c from XF4.3.0 doesn't compile on Alpha
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dhop@nwlink.com>
List: netbsd-bugs
Date: 03/03/2003 09:20:43
>Number:         20560
>Category:       xsrc
>Synopsis:       alpha_video.c doesn't compile on alpha
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 03 09:22:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     David Hopper
>Release:        NetBSD 1.6O
>Organization:
	
>Environment:
	
	
System: NetBSD scarab 1.6O NetBSD 1.6O (ALPHA-$Revision: 1.127.2.4 $) #0: Wed 
Feb 26 16:12:06 UTC 2003 bard@scarab:/usr/src/sys/arch/alpha/compile/SCARAB 
alpha
Architecture: alpha
Machine: alpha
>Description:
	

The import of XFree86 4.3.0 breaks on alpha; the new 
xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c 
does not compile.

alpha_video.c: In function `checkDevMem':
alpha_video.c:269: parse error before `void'
alpha_video.c:273: `pVidMem' undeclared (first use in this function)
alpha_video.c:273: (Each undeclared identifier is reported only once
alpha_video.c:273: for each function it appears in.)
alpha_video.c:283: `axpSystem' undeclared (first use in this function)
alpha_video.c:285: `hae_thresh' undeclared (first use in this function)
alpha_video.c:286: `hae_mask' undeclared (first use in this function)
alpha_video.c:287: `sparse_size' undeclared (first use in this function)
alpha_video.c: In function `readSparse8':
alpha_video.c:549: `hae_thresh' undeclared (first use in this function)
alpha_video.c:550: `hae_mask' undeclared (first use in this function)
alpha_video.c: In function `readSparse16':
alpha_video.c:572: `hae_thresh' undeclared (first use in this function)
alpha_video.c:573: `hae_mask' undeclared (first use in this function)
alpha_video.c: In function `writeSparse8':
alpha_video.c:600: `hae_thresh' undeclared (first use in this function)
alpha_video.c:601: `hae_mask' undeclared (first use in this function)
alpha_video.c: In function `writeSparse16':
alpha_video.c:619: `hae_thresh' undeclared (first use in this function)
alpha_video.c:620: `hae_mask' undeclared (first use in this function)
alpha_video.c: In function `writeSparseNB8':
alpha_video.c:647: `hae_thresh' undeclared (first use in this function)
alpha_video.c:648: `hae_mask' undeclared (first use in this function)
alpha_video.c: In function `writeSparseNB16':
alpha_video.c:665: `hae_thresh' undeclared (first use in this function)
alpha_video.c:666: `hae_mask' undeclared (first use in this function)
*** Error code 1

The problem is due to two errors:  the first is that the hae_* variables defined 
in the sparse subroutines are defined in a segment of code #ifndef'd out from 
NetBSD's consideration.  Those variables are never defined for us, so we have to 
hard code them (these particular patches were brought forward from bsd_video.c 
in the 4.2.1 codebase).

The second problem is a parse error that I just couldn't work out on my own.  I 
had to remove the APERTURE_DRV #ifdefs from the code to clear it-- a minor
problem for now, as we are probably some time from an aperture driver on alpha.

However, these diffs very much need to be made more diplomatic.

>How-To-Repeat:
	
>Fix:
	

--- xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c	2003-03-01 21:12:14.000000000 +0000
+++ xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c	2003-03-02 16:47:37.000000000 +0000
@@ -205,28 +205,6 @@
 	    return;
 	devMemChecked = TRUE;

-#ifdef HAS_APERTURE_DRV
-       /* Try the aperture driver first */
-       if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
-           /* Try to map a page at the VGA address */
-           base = mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
-                            MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-       
-           if (base != MAP_FAILED) {
-               munmap((caddr_t)base, 4096);
-               devMemFd = fd;
-               useDevMem = TRUE;
-               xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
-                       DEV_APERTURE);
-               return;
-           } else {
-               if (warn) {
-                   xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
-                           DEV_APERTURE, strerror(errno));
-               }
-           }
-       }
-#endif
        if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
 	    /* Try to map a page at the VGA address */
 	    base = mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
@@ -245,25 +223,12 @@
 	    }
 	}
 	if (warn) {
-#ifndef HAS_APERTURE_DRV
            xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
                    DEV_MEM, strerror(errno));
            xf86ErrorF("\tlinear framebuffer access unavailable\n");
-#else
-#ifndef __OpenBSD__
-           xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
-               "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
-#else /* __OpenBSD__ */
-           xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
-                   "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
-                   SYSCTL_MSG);
-#endif /* __OpenBSD__ */
-	   
-           xf86ErrorF("\tlinear framebuffer access unavailable\n");
 	}
 	useDevMem = FALSE;
 	return;
-#endif
 }

 void
@@ -280,11 +245,6 @@
 	    xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
 	    pVidMem->mapMem = mapVidMemSparse;
 	    pVidMem->unmapMem = unmapVidMemSparse;
-	    if (axpSystem == -1)
-                axpSystem = bsdGetAXP(); 
-	    hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
-            hae_mask = xf86AXPParams[axpSystem].hae_mask;
-            sparse_size = xf86AXPParams[axpSystem].size;
 	}
 	pVidMem->initialised = TRUE;
 }
@@ -546,8 +506,8 @@
     mem_barrier();
     Offset += (unsigned long)Base - (unsigned long)memBase;
     shift = (Offset & 0x3) << 3;
-      if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
+      if (Offset >= (1UL << 24)) {
+        msb = Offset & 0xf8000000UL;
         Offset -= msb;
 	if (msb_set != msb) {
 	sethae(msb);
@@ -569,8 +529,8 @@
     mem_barrier();
     Offset += (unsigned long)Base - (unsigned long)memBase;
     shift = (Offset & 0x2) << 3;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
+    if (Offset >= (1UL << 24)) {
+        msb = Offset & 0xf8000000UL;
         Offset -= msb;
       if (msb_set != msb) {
 	sethae(msb);
@@ -597,8 +557,8 @@

     write_mem_barrier();
     Offset += (unsigned long)Base - (unsigned long)memBase;
-    if (Offset >= (hae_thresh)) {
-      msb = Offset & hae_mask;
+    if (Offset >= (1UL << 24)) {
+      msb = Offset & 0xf8000000;
       Offset -= msb;
       if (msb_set != msb) {
 	sethae(msb);
@@ -616,8 +576,8 @@

     write_mem_barrier();
     Offset += (unsigned long)Base - (unsigned long)memBase;
-    if (Offset >= (hae_thresh)) {
-      msb = Offset & hae_mask;
+    if (Offset >= (1UL << 24)) {
+      msb = Offset & 0xf8000000;
       Offset -= msb;
       if (msb_set != msb) {
 	sethae(msb);
@@ -644,8 +604,8 @@
     register unsigned int b = Value & 0xffU;

     Offset += (unsigned long)Base - (unsigned long)memBase;
-    if (Offset >= (hae_thresh)) {
-      msb = Offset & hae_mask;
+    if (Offset >= (1UL << 24)) {
+      msb = Offset & 0xf8000000;
       Offset -= msb;
       if (msb_set != msb) {
 	sethae(msb);
@@ -662,8 +622,8 @@
     register unsigned int w = Value & 0xffffU;
 
     Offset += (unsigned long)Base - (unsigned long)memBase;
-    if (Offset >= (hae_thresh)) {
-      msb = Offset & hae_mask ;
+    if (Offset >= (1UL << 24)) {
+      msb = Offset & 0xf8000000;
       Offset -= msb;
       if (msb_set != msb) {
 	sethae(msb);
>Release-Note:
>Audit-Trail:
>Unformatted: