diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c.orig xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c.orig Sat Feb 26 05:43:53 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c Thu Mar 16 23:28:15 2000 @@ -66,9 +66,8 @@ # define isJensen (!_bus_base()) # endif -# define needSparse (_bus_base_sparse() != 0) - -# define BUS_BASE _bus_base() +static unsigned long xf86_axp_IOBase; +# define BUS_BASE xf86_axp_IOBase #else @@ -83,6 +82,7 @@ static pointer mapVidMem(int, unsigned long, unsigned long); static void unmapVidMem(int, pointer, unsigned long); #if defined (__alpha__) +static int checkSparseVidMemBase( void ); static pointer mapVidMemSparse(int, unsigned long, unsigned long); static void unmapVidMemSparse(int, pointer, unsigned long); # if defined(JENSEN_SUPPORT) @@ -298,15 +298,15 @@ if (isJensen) { # ifndef JENSEN_SUPPORT FatalError("Jensen is not supported any more\n" - "If you are interesetd in fixing Jensen support\n" + "If you are interested in fixing Jensen support\n" "please contact xfree86@xfree86.org\n"); # else xf86Msg(X_INFO,"Machine type is Jensen\n"); pVidMem->mapMem = mapVidMemJensen; pVidMem->unmapMem = unmapVidMemJensen; # endif /* JENSEN_SUPPORT */ - } else if (needSparse) { - xf86Msg(X_INFO,"Machine needs sparse mapping\n"); + } else if (checkSparseVidMemBase()) { + xf86Msg(X_INFO,"Machine needs sparse mapping\n"); pVidMem->mapMem = mapVidMemSparse; pVidMem->unmapMem = unmapVidMemSparse; } else { @@ -508,6 +508,82 @@ writeSparse16(int Value, pointer Base, register unsigned long Offset); static void writeSparse32(int Value, pointer Base, register unsigned long Offset); + +static int checkSparseVidMemBase( void ) +{ + char buf[256]; + char cpu_model[64]; + char sys_type[64]; + char sys_var[64]; + FILE *info_fptr; + int has_bwx = 1; + int can_bwa = 1; + + if (_bus_base_sparse()) { + /* Open /proc/cpuinfo to find out about where we are running on */ + info_fptr = fopen("/proc/cpuinfo","r"); + if (!info_fptr) { + xf86Msg(X_WARNING, + "Could not open /proc/cpuinfo, falling back to default\n"); + xf86_axp_IOBase = _bus_base_sparse(); + return 1; + } + + *cpu_model = '\0'; + *sys_type = '\0'; + *sys_var = '\0'; + + while (!feof(info_fptr)) { + fgets(buf,255,info_fptr); + if (sscanf(buf,"cpu model : %s ",cpu_model) == 1) { + if (!strcmp(cpu_model,"EV3") || + !strcmp(cpu_model,"EV4") || + !strcmp(cpu_model,"Simulate") || + !strcmp(cpu_model,"LCA4") || + !strcmp(cpu_model,"EV5") || + !strcmp(cpu_model,"EV45") ) { + has_bwx = 0; + } + } + if (sscanf(buf,"system type : %s ",sys_type) == 1) { + if (strcmp(sys_type, "EB164")) { + can_bwa = 0; + } else { + can_bwa = 1; + } + } + if (sscanf(buf,"system variation : %s ",sys_var) == 1) { + if (!strcmp(sys_var,"EB164") || + !strcmp(sys_var,"PC164") ) { + can_bwa = 0; + } + } + } + fclose(info_fptr); + + xf86Msg(X_INFO,"Alpha %s cpu on a %s (variation %s)\n", + cpu_model, sys_type, + *sys_var?sys_var:"default"); + + if (!has_bwx) { + xf86Msg(X_INFO,"CPU does not support BWX extension\n"); + xf86_axp_IOBase = _bus_base_sparse(); + return 1; + } + + if (!can_bwa) { + xf86Msg(X_INFO, + "System does not support 21164 Byte/Word addressing\n"); + xf86_axp_IOBase = _bus_base_sparse(); + return 1; + } + xf86_axp_IOBase = _bus_base() + 0x200000000; + return 0; + } else { + xf86_axp_IOBase = _bus_base(); + return 0; + } +} static pointer mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size)