Subject: Re: porting XF3 servers to XF4
To: None <mrg@eterna.com.au>
From: TAKEMURA Shin Takemura <takemura@ca2.so-net.ne.jp>
List: tech-x11
Date: 01/02/2004 20:34:20
----Next_Part(Fri_Jan__2_20:34:20_2004_434)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I've also succeeded in cross compiling Xhpc server for hpcmips and the
server runs some degree. At least, Xhpc, xterm, oclock, xload and twm
seems to be OK. Thank you, matthew!

I, however, found that system froze entirely when I tried ico. And I 
haven't even started native compile stuff.

Because Tyler seems to be working for Xhpc cross compiling, I'm sending
my patch instead of commiting into the repository. Please find the patch
and new files in the attachment.

modified files (Xhpc-src.diff and Xhpc-xsrc.diff):
---------------------------------------------------
M src/x11/Xserver/Makefile
M src/x11/Xserver/Xserver/Makefile
M src/x11/Xserver/Xserver/Makefile.Xserver
M src/x11/Xserver/hw/Makefile
M xsrc/xfree/xc/programs/Xserver/cfb/cfb8line.c
M xsrc/xfree/xc/programs/Xserver/cfb/cfbmskbits.h

new files (Xhpc-src-new.tgz):
---------------------------------------------------
A src/x11/Xserver/Xserver/Xhpc/Makefile
A src/x11/Xserver/Xserver/Xhpc/Xhpc.c
A src/x11/Xserver/hw/netbsd/hpc/Makefile
(And the patch for xc/programs/Xserver/hw/netbsd/hpc is Xhpc.diff)

For the change of cfb8line.c, please refer my change in XF3 tree,
http://cvsweb.netbsd.org/cgi-bin/cvsweb.cgi/xsrc/xc/programs/Xserver/cfb/cfb8line.c.diff?r1=1.5&r2=1.6

The change of cfbmskbits.h suppress the warning about type conversion
between "unsigned long *" and "unsigned int *" like,
xsrc/xfree/xc/programs/Xserver/cfb/cfbtegblt.c: In function `cfbTEGlyphBlt':
xsrc/xfree/xc/programs/Xserver/cfb/cfbtegblt.c:197: warning: passing arg 1 of `ldl_u' from incompatible pointer type

TAKEMURA

From: matthew green <mrg@eterna.com.au>
Subject: porting XF3 servers to XF4
Date: Sun, 28 Dec 2003 17:09:32 +1100

> hi folks.
> 
> 
> it seems pretty easy to port XF3 servers to XF4.  i ported Xmacppc
> and the biggest problem was dealing with the fact that in XF4 much
> of the Xserver is built with more options.. this won't be the case
> for most platforms remaining.  i've also got Xmacppc building in
> src/x11/Xserver (cross)...

----Next_Part(Fri_Jan__2_20:34:20_2004_434)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Xhpc.diff"

diff -crN xc/programs/Xserver/hw/netbsd/hpc/GetTime.c xfree/xc/programs/Xserver/hw/netbsd/hpc/GetTime.c
*** xc/programs/Xserver/hw/netbsd/hpc/GetTime.c	Thu Jan  1 09:00:00 1970
--- xfree/xc/programs/Xserver/hw/netbsd/hpc/GetTime.c	Tue Dec 30 19:04:10 2003
***************
*** 0 ****
--- 1,43 ----
+ /* $Xorg: GetTime.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+ /*
+ 
+ Copyright (c) 1993  X Consortium
+ 
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ 
+ Except as contained in this notice, the name of the X Consortium shall
+ not be used in advertising or otherwise to promote the sale, use or
+ other dealings in this Software without prior written authorization
+ from the X Consortium.
+ 
+ */
+ 
+ 
+ #include "Xos.h"
+ #include <time.h>
+ 
+ long
+ GetTimeInMillis()
+ {
+     struct timeval  tp;
+ 
+     X_GETTIMEOFDAY(&tp);
+     return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ }
diff -crN xc/programs/Xserver/hw/netbsd/hpc/hpcFB.c xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcFB.c
*** xc/programs/Xserver/hw/netbsd/hpc/hpcFB.c	Tue Jun 26 23:20:40 2001
--- xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcFB.c	Fri Jan  2 17:38:41 2004
***************
*** 35,41 ****
  
  #include <stdio.h>
  
! extern miBSFuncRec cfbBSFuncRec;
  extern int cfb16ScreenPrivateIndex;
  extern Bool cfbCreateScreenResources(ScreenPtr pScreen);
  extern Bool cfb16CreateScreenResources(ScreenPtr pScreen);
--- 35,47 ----
  
  #include <stdio.h>
  
! /* Adapt cfb logic */
! #undef CFB_NEED_SCREEN_PRIVATE
! #if !defined(SINGLEDEPTH) || defined(FORDE_SEPARATE_PRIVATE)
! #define CFB_NEED_SCREEN_PRIVATE
! #endif
! 
! extern BSFuncRec cfbBSFuncRec, cfb16BSFuncRec;
  extern int cfb16ScreenPrivateIndex;
  extern Bool cfbCreateScreenResources(ScreenPtr pScreen);
  extern Bool cfb16CreateScreenResources(ScreenPtr pScreen);
***************
*** 96,103 ****
  
      if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  			rootdepth, ndepths, depths,
! 			defaultVisual, nvisuals, visuals,
! 			(miBSFuncPtr) 0))
  	return FALSE;
  
      /* overwrite miCloseScreen with our own */
--- 102,108 ----
  
      if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  			rootdepth, ndepths, depths,
! 			defaultVisual, nvisuals, visuals))
  	return FALSE;
  
      /* overwrite miCloseScreen with our own */
***************
*** 105,111 ****
  
      /* init backing store here so we can overwrite CloseScreen without stepping
       * on the backing store wrapped version */
!     miInitializeBackingStore (pScreen, &cfbBSFuncRec);
  
      return TRUE;
  }
--- 110,116 ----
  
      /* init backing store here so we can overwrite CloseScreen without stepping
       * on the backing store wrapped version */
!     pScreen->BackingStoreFuncs = cfbBSFuncRec;
  
      return TRUE;
  }
***************
*** 176,183 ****
  #endif
      if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  			rootdepth, ndepths, depths,
! 			defaultVisual, nvisuals, visuals,
! 			(miBSFuncPtr) 0))
  	return FALSE;
  
      /* overwrite miCloseScreen with our own */
--- 181,187 ----
  #endif
      if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  			rootdepth, ndepths, depths,
! 			defaultVisual, nvisuals, visuals))
  	return FALSE;
  
      /* overwrite miCloseScreen with our own */
***************
*** 185,191 ****
  
      /* init backing store here so we can overwrite CloseScreen without stepping
       * on the backing store wrapped version */
!     miInitializeBackingStore (pScreen, &cfbBSFuncRec);
  
  #ifdef CFB_NEED_SCREEN_PRIVATE
      pScreen->CreateScreenResources = cfb16CreateScreenResources;
--- 189,195 ----
  
      /* init backing store here so we can overwrite CloseScreen without stepping
       * on the backing store wrapped version */
!     pScreen->BackingStoreFuncs = cfb16BSFuncRec;
  
  #ifdef CFB_NEED_SCREEN_PRIVATE
      pScreen->CreateScreenResources = cfb16CreateScreenResources;
***************
*** 203,216 ****
  {
      if (prevmode != NULL) {
  	if (ioctl(fd, WSDISPLAYIO_GMODE, prevmode) < 0) {
! 	    hpcError("ioctl(WSDISPLAYIO_GMODE)");
  	    return (-1);
  	}
      }
  
      if (prevmode == NULL || *prevmode != mode) {
  	    if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
! 		hpcError("ioctl(WSDISPLAYIO_SMODE)");
  		return (-1);
  	    }
      }
--- 207,220 ----
  {
      if (prevmode != NULL) {
  	if (ioctl(fd, WSDISPLAYIO_GMODE, prevmode) < 0) {
! 	    Error("ioctl(WSDISPLAYIO_GMODE)");
  	    return (-1);
  	}
      }
  
      if (prevmode == NULL || *prevmode != mode) {
  	    if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
! 		Error("ioctl(WSDISPLAYIO_SMODE)");
  		return (-1);
  	    }
      }
diff -crN xc/programs/Xserver/hw/netbsd/hpc/hpcInit.c xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcInit.c
*** xc/programs/Xserver/hw/netbsd/hpc/hpcInit.c	Sun Jun 24 23:46:54 2001
--- xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcInit.c	Fri Jan  2 17:39:38 2004
***************
*** 403,405 ****
--- 403,436 ----
  	}
      }
  }
+ 
+ /*#ifdef DDXOSFATALERROR*/
+ void OsVendorFatalError(void)
+ {
+ }
+ /*#endif*/
+ 
+ #ifdef DPMSExtension
+ /**************************************************************
+  * DPMSSet(), DPMSGet(), DPMSSupported()
+  *
+  * stubs
+  *
+  ***************************************************************/
+ 
+ void DPMSSet (level)
+     int level;
+ {
+ }
+ 
+ int DPMSGet (level)
+     int* level;
+ {
+     return -1;
+ }
+ 
+ Bool DPMSSupported ()
+ {
+     return FALSE;
+ }
+ #endif
diff -crN xc/programs/Xserver/hw/netbsd/hpc/hpcKbd.c xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKbd.c
*** xc/programs/Xserver/hw/netbsd/hpc/hpcKbd.c	Sat Jan  4 11:45:47 2003
--- xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKbd.c	Tue Dec 30 09:50:25 2003
***************
*** 222,227 ****
--- 222,228 ----
  	    break;
  	case HPC_KBDDEV_WSKBD:
  	case HPC_KBDDEV_WSMUX:
+ 	    break;
  	}
  	hpcCleanupFd(pPriv->fd);
  	AddEnabledDevice(pPriv->fd);
***************
*** 242,247 ****
--- 243,249 ----
  	    break;
  	case HPC_KBDDEV_WSKBD:
  	case HPC_KBDDEV_WSMUX:
+ 	    break;
  	}
  	break;
      default:

----Next_Part(Fri_Jan__2_20:34:20_2004_434)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Xhpc-xsrc.diff"

Index: programs/Xserver/cfb/cfb8line.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/cfb/cfb8line.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 cfb8line.c
*** programs/Xserver/cfb/cfb8line.c	28 Feb 2003 13:19:58 -0000	1.1.1.5
--- programs/Xserver/cfb/cfb8line.c	2 Jan 2004 08:25:40 -0000
***************
*** 687,699 ****
  # if PSZ == 24
  	    y1_or_e1 = xOffset & 3;
  # else
! #  if PGSZ == 64 /* PIM value from <cfbmskbits.h> is not it! (for 16/32 PSZ)*/
! 	    y1_or_e1 = ((long) addrp) & 0x7;
  	    addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
- #  else
- 	    y1_or_e1 = ((long) addrp) & PIM;
- 	    addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
- #  endif
  #if PGSZ == 32
  #  if PWSH != 2
  	    y1_or_e1 >>= (2 - PWSH);
--- 687,694 ----
  # if PSZ == 24
  	    y1_or_e1 = xOffset & 3;
  # else
! 	    y1_or_e1 = ((long) addrp) & (PGSZB - 1);
  	    addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
  #if PGSZ == 32
  #  if PWSH != 2
  	    y1_or_e1 >>= (2 - PWSH);
Index: programs/Xserver/cfb/cfbmskbits.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/cfb/cfbmskbits.h,v
retrieving revision 1.2
diff -c -r1.2 cfbmskbits.h
*** programs/Xserver/cfb/cfbmskbits.h	23 Dec 2003 04:33:27 -0000	1.2
--- programs/Xserver/cfb/cfbmskbits.h	2 Jan 2004 08:25:41 -0000
***************
*** 890,896 ****
  #else /* BITMAP_BIT_ORDER == LSB */
  
  /* this must load 32 bits worth; for most machines, thats an int */
! #define CfbFetchUnaligned(x)	ldl_u(x)
  
  #define getstipplepixels( psrcstip, xt, w, ones, psrcpix, destpix ) \
  { \
--- 890,896 ----
  #else /* BITMAP_BIT_ORDER == LSB */
  
  /* this must load 32 bits worth; for most machines, thats an int */
! #define CfbFetchUnaligned(x)	ldl_u((unsigned int *)x)
  
  #define getstipplepixels( psrcstip, xt, w, ones, psrcpix, destpix ) \
  { \

----Next_Part(Fri_Jan__2_20:34:20_2004_434)--
Content-Type: Application/Octet-Stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Xhpc-src-new.tgz"

H4sIAGQz9T8AA+1Y35OiRhD2Vf6Kyd7WPVyyIAi6tRVTpcIasupa6l64VF4Qx11q+VWAt1xS/u/p
YUZA73S5rPElfKXSzXTP9Ex/w9BGoSUkoigYEQ4/4zC/PgWWUDsNkNxoKwqqISQpkkSugAa7MgW1
2225KSntZgshUWlKcg0pJxr/KNZRbIYI1WLzGbvr0Dxk9/KEsXOOgM6L6Fj+R7AmK9vBbxxDbDRa
snww/1KrxfIvtZWGQvLfBocaapxkhq/gf57/d/XLMY57M/UGbbP902ck8iKSGo2mIEqC1Ib9eCO2
bhQZueEj0pIAXXIcb3uWs15i9PMiWvL+i8e7z79w3GR6P+jUCXu4nj4e3ataR26LIseN7kbdcafu
+eA66c5/valf/m2I4mzaV/Upn1gbIQj9x9B0o4yDTy+Ch2PoXiDd5SNe8HxGTZ4ZX3DcUO2q6o8d
6DeV+KWdbNBWce1c9qMNunIMc01+l64VZC07I27Qn1zWmbVa5B2AIrYKfZO2gq2Bk1iAb5SbJM8F
98T2gnWc684iSf2vHJDWse1kLaHpLcPcMMTeEhd0mKGQBFG8XkQ7ARQnWzaYgnsaT+lgCo57y7cf
QiHwBS52ZPnhcqejwVB4dArZA30wBKuCVxKHZpCqeq//+7Q7mWhTtorGyvdimMAqxDj+EuCD6wWm
EBZhgSjC71/wdTlOnWx5lEpbHlGFLi2V/YiNb3QftpI66k9yi2/xibYwPmUK5RMbI+MT1XdSSG+x
FDIl4xPVt3xKIxr2jIe5PsxbszQyNeNUNts9Tn098bIBFdzTmL4roILzV7zaDaMQPOXVtqMCr+it
nFeZnvOKxX6IVzS/t/fjOWu9nWra/NNEO7Z2xEUzth5AMyb9wa6jzf6TFA7j9Em6e5c8G9Pbp37+
Hz3/yQ9vvXmMV85/OPuV9PxvKrKkyOT8b8nNRnX+nwPCh/wFwHBNKyAZL/MGUP8gnJyMFc6O/f2/
86g9UQFYtv5TpKYoN0VS/8lSo6r/zoHj+T9NAfha/SeK0l7+26IiVs//c+Dt9R+pxugnq8kolxx7
cXGwToR3n06dlnX/qhoEy1naAf+EktV16w5/cc0AFDMG0TNdHIEC72BgctvjLQRX3adXZpvKMwuK
BA9kaqp7dsyMFksqjPx1hKnY9x0/zFx1T0tAGuB4brtgwXHGTJt+1Kb6mMzihw6ylvCWN9bmsLx0
ZpudvbZdmffvwWwCbvP73m/EiuPeoTi0XUQKmQgJCF5ysRfbvkeUnVGQvUKBH0X2wsFcfzK5HXYH
MyhervTvW1Ay/xJOJc0E1y5tuVqUNbXKm26XtqS5H2WWqjabkxykPnSNNwKpD7/dFRtIoJk6bpNm
MUqzmBkWcwl5L2bwwbgFbl63hvddVZsiol+3Puoq+VMFsVZDHXRZy0if9Wm/qapOddbQ0wekauG4
3oM+VGefRkN9fAebJ9u3rg0fG5gPARapXa40gW3+n1QmFSpUqFChQoUKFSpUqFChQoUKFU6BfwBP
f9p+ACgAAA==

----Next_Part(Fri_Jan__2_20:34:20_2004_434)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Xhpc-src.diff"

Index: Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/Makefile,v
retrieving revision 1.7
diff -c -r1.7 Makefile
*** Makefile	23 Dec 2003 14:44:07 -0000	1.7
--- Makefile	2 Jan 2004 08:23:46 -0000
***************
*** 2,8 ****
  
  .include <bsd.own.mk>
  
! .if ${MACHINE} != "sparc" && ${MACHINE} != "sparc64"
  SUBDIR.md=fontbase Xfont
  .endif
  
--- 2,8 ----
  
  .include <bsd.own.mk>
  
! .if ${MACHINE} != "sparc" && ${MACHINE} != "sparc64" && ${MACHINE} != "hpcmips"
  SUBDIR.md=fontbase Xfont
  .endif
  
Index: Xserver/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/Xserver/Makefile,v
retrieving revision 1.5
diff -c -r1.5 Makefile
*** Xserver/Makefile	23 Dec 2003 10:20:57 -0000	1.5
--- Xserver/Makefile	2 Jan 2004 08:23:46 -0000
***************
*** 6,11 ****
--- 6,13 ----
  
  .if ${MACHINE} == "sparc" || ${MACHINE} == "sparc64"
  SUBDIR+=	Xsun Xsun24 XsunMono
+ .elif ${MACHINE} == "hpcmips" 
+ SUBDIR+=	Xhpc
  .else
  SUBDIR+=	XFree86
  .endif
Index: Xserver/Makefile.Xserver
===================================================================
RCS file: /cvsroot/src/x11/Xserver/Xserver/Makefile.Xserver,v
retrieving revision 1.8
diff -c -r1.8 Makefile.Xserver
*** Xserver/Makefile.Xserver	27 Dec 2003 15:14:40 -0000	1.8
--- Xserver/Makefile.Xserver	2 Jan 2004 08:23:46 -0000
***************
*** 10,16 ****
  		dix/xpstubs hw/sun hw/xfree86/xf86 hw/xfree86/xf86_os \
  		hw/xfree86/xf86config hw/xfree86/loader \
  		\
! 		hw/netbsd/macppc
  
  .if !defined(LIBDIR.${_SL})
  LIBDIR.${_SL}!=	cd ${NETBSDSRCDIR}/x11/Xserver/${_SL} && ${PRINTOBJDIR}
--- 10,16 ----
  		dix/xpstubs hw/sun hw/xfree86/xf86 hw/xfree86/xf86_os \
  		hw/xfree86/xf86config hw/xfree86/loader \
  		\
! 		hw/netbsd/macppc hw/netbsd/hpc
  
  .if !defined(LIBDIR.${_SL})
  LIBDIR.${_SL}!=	cd ${NETBSDSRCDIR}/x11/Xserver/${_SL} && ${PRINTOBJDIR}
Index: hw/Makefile
===================================================================
RCS file: /cvsroot/src/x11/Xserver/hw/Makefile,v
retrieving revision 1.5
diff -c -r1.5 Makefile
*** hw/Makefile	27 Dec 2003 15:16:09 -0000	1.5
--- hw/Makefile	2 Jan 2004 08:23:46 -0000
***************
*** 15,19 ****
--- 15,23 ----
  SUBDIR+=netbsd/macppc
  .endif
  
+ .if ${MACHINE} == "hpcmips"
+ SUBDIR+=netbsd/hpc
+ .endif
+ 
  
  .include <bsd.subdir.mk>

----Next_Part(Fri_Jan__2_20:34:20_2004_434)----