Subject: Re: warning: src/x11 broken
To: Matthias Scheler <tron@zhadum.de>
From: Nicolas Joly <njoly@pasteur.fr>
List: port-amd64
Date: 04/13/2004 18:58:32
--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Apr 11, 2004 at 11:28:46AM +0200, Matthias Scheler wrote:
> On Sun, Apr 11, 2004 at 11:29:08AM +0200, Frank van der Linden wrote:
> > That's not a bad idea..
> 
> Thank you.
[...]
> > I think this might work.. I have no time to try it for a few days, though.
> 
> And I don't have a NetBSD-amd64 system unfortunately.
> 
> Any volunteer?

I just got a working X server with loadable modules with the following
patches (for xsrc and src/x11).

I checked it on our amd64 machines (workstation with 1GB of memory,
and server with 4GB).

NB: I had some problems with Frank suggestions, which are not included
here.

NB2: src/x11 Makefiles patches include xdm vt switching fixes (PCVT
support, like i386).

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="netbsd-x11loader.diff"

Index: src/share/mk/bsd.x11.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.x11.mk,v
retrieving revision 1.38
diff -u -r1.38 bsd.x11.mk
--- src/share/mk/bsd.x11.mk	27 Mar 2004 20:16:16 -0000	1.38
+++ src/share/mk/bsd.x11.mk	13 Apr 2004 16:52:54 -0000
@@ -97,6 +97,10 @@
 CPPFLAGS+=		-DCSRG_BASED -DFUNCPROTO=15 -DNARROWPROTO
 CPPFLAGS+=		-I${DESTDIR}${X11INCDIR}
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=		-D__AMD64__
+.endif
+
 LDFLAGS+=		-Wl,-rpath-link,${DESTDIR}${X11USRLIBDIR} \
 			-R${X11USRLIBDIR} \
 			-L${DESTDIR}${X11USRLIBDIR}
Index: src/x11/Xserver/hw/xfree86/bin/kbd_mode/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/bin/kbd_mode/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- src/x11/Xserver/hw/xfree86/bin/kbd_mode/Makefile	26 Dec 2003 05:23:15 -0000	1.1
+++ src/x11/Xserver/hw/xfree86/bin/kbd_mode/Makefile	13 Apr 2004 16:53:13 -0000
@@ -20,6 +20,9 @@
 
 CPPFLAGS+=	-DWSCONS_SUPPORT
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=	-DPCVT_SUPPORT
+.endif
 .if ${MACHINE} == "i386"
 CPPFLAGS+=	-DPCCONS_SUPPORT -DPCVT_SUPPORT
 .endif
Index: src/x11/Xserver/hw/xfree86/bin/xf86cfg/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/bin/xf86cfg/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- src/x11/Xserver/hw/xfree86/bin/xf86cfg/Makefile	28 Mar 2004 15:19:30 -0000	1.4
+++ src/x11/Xserver/hw/xfree86/bin/xf86cfg/Makefile	13 Apr 2004 16:53:13 -0000
@@ -37,6 +37,9 @@
 		-DPROJECT_ROOT=\"/usr/X11R6\" \
 		-DXF86CONFIGDIR=\"/etc/X11\" -DWSCONS_SUPPORT
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=	-DPCVT_SUPPORT
+.endif
 .if ${MACHINE} == "i386"
 CPPFLAGS+=	-DPCCONS_SUPPORT -DPCVT_SUPPORT
 .endif
Index: src/x11/Xserver/hw/xfree86/bin/xf86config/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/bin/xf86config/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- src/x11/Xserver/hw/xfree86/bin/xf86config/Makefile	17 Mar 2004 23:19:48 -0000	1.4
+++ src/x11/Xserver/hw/xfree86/bin/xf86config/Makefile	13 Apr 2004 16:53:13 -0000
@@ -17,6 +17,9 @@
 		-DXVERSION="${XVERSION}" \
 		-DWSCONS_SUPPORT
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=	-DPCVT_SUPPORT
+.endif
 .if ${MACHINE} == "i386"
 CPPFLAGS+=	-DPCCONS_SUPPORT -DPCVT_SUPPORT
 .endif
Index: src/x11/Xserver/hw/xfree86/loader/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/loader/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- src/x11/Xserver/hw/xfree86/loader/Makefile	6 Mar 2004 03:31:08 -0000	1.3
+++ src/x11/Xserver/hw/xfree86/loader/Makefile	13 Apr 2004 16:53:14 -0000
@@ -34,6 +34,10 @@
 CPPFLAGS+=	${X11FLAGS.OS_DEFINES} -DDLOPEN_SUPPORT -DHAS_SHM \
 		-DFONTENC_COMPATIBILITY -DXFree86LOADER -DFONTCACHE
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=	-DUseMMAP
+.endif
+
 CPPFLAGS.loadmod.c=	${X11FLAGS.EXTENSION} -DDEFAULT_MODULE_PATH=\"${X11USRLIBDIR}/modules\"
 CPPFLAGS.xf86sym.c=	${X11FLAGS.EXTENSION}
 CPPFLAGS.dixsym.c=	${X11FLAGS.EXTENSION}
Index: src/x11/Xserver/hw/xfree86/xf86/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/xf86/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- src/x11/Xserver/hw/xfree86/xf86/Makefile	6 Mar 2004 03:31:08 -0000	1.5
+++ src/x11/Xserver/hw/xfree86/xf86/Makefile	13 Apr 2004 16:53:14 -0000
@@ -60,6 +60,9 @@
 CPPFLAGS+=	${X11FLAGS.EXTENSION} ${X11FLAGS.OS_DEFINES} \
 		-DXFree86LOADER -DWSCONS_SUPPORT
 
+.if ${MACHINE} == "amd64"
+CPPFLAGS+=	-DPCVT_SUPPORT
+.endif
 .if ${MACHINE} == "i386"
 CPPFLAGS+=	-DPCCONS_SUPPORT -DPCVT_SUPPORT
 .endif
Index: src/x11/Xserver/hw/xfree86/xf86_os/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/xfree86/xf86_os/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- src/x11/Xserver/hw/xfree86/xf86_os/Makefile	6 Mar 2004 03:31:08 -0000	1.7
+++ src/x11/Xserver/hw/xfree86/xf86_os/Makefile	13 Apr 2004 16:53:14 -0000
@@ -22,9 +22,10 @@
 SRCS.bsd+=	i386_video.c stdResource.c lnx_agp.c ioperm_noop.c
 .for _FN in ${SRCS.bsd}
 .if ${MACHINE} == "i386"
-CPPFLAGS.${_FN}+=	-DPCCONS_SUPPORT -DPCVT_SUPPORT -DHAS_APERTURE_DRV
+CPPFLAGS.${_FN}+=	-DPCCONS_SUPPORT -DHAS_APERTURE_DRV
 .endif
-CPPFLAGS.${_FN}+=	-DWSCONS_SUPPORT -DUSESTDRES -DHAVE_SYSV_IPC \
+CPPFLAGS.${_FN}+=	-DWSCONS_SUPPORT -DPCVT_SUPPORT \
+			-DUSESTDRES -DHAVE_SYSV_IPC \
 			-DHAS_MTRR_BUILTIN -DUSE_I386_IOPL 
 .endfor
 .endif
Index: xsrc/xfree/xc/config/cf/NetBSD.cf
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/config/cf/NetBSD.cf,v
retrieving revision 1.67
diff -u -r1.67 NetBSD.cf
--- xsrc/xfree/xc/config/cf/NetBSD.cf	11 Apr 2004 09:09:30 -0000	1.67
+++ xsrc/xfree/xc/config/cf/NetBSD.cf	13 Apr 2004 16:53:27 -0000
@@ -204,7 +204,7 @@
  * Disabled for NetBSD/vax until I figure out the scheme. --CS 
  */
 #if ((OSMajorVersion > 0) && defined(i386Architecture)) || \
-    defined(PpcArchitecture)
+    defined(PpcArchitecture) || defined(AMD64Architecture)
 #  ifndef DoLoadableServer
 #  define DoLoadableServer	YES
 #  endif
Index: xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 Imakefile
--- xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile	5 Mar 2004 14:29:15 -0000	1.1.1.7
+++ xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile	13 Apr 2004 16:53:36 -0000
@@ -36,6 +36,8 @@
 
 #if defined (AMD64Architecture) && defined(linux)
 ARCHDEFINES = -DDoMMAPedMerge -DMmapPageAlign
+#elif defined (AMD64Architecture) && defined(NetBSDArchitecture)
+ARCHDEFINES = -DUseMMAP
 #endif
 
 DEFINES = $(DBMALLOCDEFINE) $(DLOPENDEFINES) $(OS_DEFINES) $(COMPAT_DEFINES) \
Index: xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c,v
retrieving revision 1.5
diff -u -r1.5 loader.c
--- xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c	28 Mar 2004 15:24:25 -0000	1.5
+++ xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c	13 Apr 2004 16:53:36 -0000
@@ -485,6 +485,12 @@
 #ifdef UseMMAP
     unsigned long ret;
 
+# if defined(__NetBSD__) && (__AMD64__)
+    static char *mm_addr = (char *)(1L << 30);
+# else
+    char *mm_addr = NULL;
+# endif
+
 # ifdef MmapPageAlign
     unsigned long pagesize;
     unsigned long new_size;
@@ -506,22 +512,28 @@
     new_off_bias = (offset + offsetbias) - new_off;
     if ((new_off_bias + size) > new_size)
 	new_size += pagesize;
-    ret = (unsigned long)mmap(0, new_size, MMAP_PROT, MAP_PRIVATE
-#  ifdef __AMD64__
+    ret = (unsigned long)mmap(mm_addr, new_size, MMAP_PROT, MAP_PRIVATE
+#  if !defined(__NetBSD__) && defined(__AMD64__)
 			      | MAP_32BIT
 #  endif
 			      , fd, new_off);
     if (ret == -1)
 	FatalError("mmap() failed: %s\n", strerror(errno));
+#if defined(__NetBSD__) && (__AMD64__)
+    mm_addr += new_size;
+#endif
     return (void *)(ret + new_off_bias);
 # else
-    ret = (unsigned long)mmap(0, size, MMAP_PROT, MAP_PRIVATE
-#  ifdef __AMD64__
+    ret = (unsigned long)mmap(mm_addr, size, MMAP_PROT, MAP_PRIVATE
+#  if !defined(__NetBSD__) && defined(__AMD64__)
 			      | MAP_32BIT
 #  endif
 			      , fd, offset + offsetbias);
     if (ret == -1)
 	FatalError("mmap() failed: %s\n", strerror(errno));
+#if defined(__NetBSD__) && (__AMD64__)
+    mm_addr += size;
+#endif
     return (void *)ret;
 # endif
 #else

--IJpNTDwzlM2Ie8A6--