diff -u XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile --- XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile Sun Dec 19 01:15:44 2004 +++ sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile Tue Apr 19 16:59:06 2005 @@ -25,6 +25,7 @@ SNPRINTFOBJS = snprintf.o #endif +#if HasDlopen SRCS =\ accessx.c\ card-cfg.c\ @@ -46,8 +47,34 @@ stubs.c\ $(TEXTSRC)\ vidmode.c\ + xf86config.c\ + dummy.c +#else +SRCS =\ + accessx.c\ + card-cfg.c\ + cards.c\ + config.c\ + expert.c\ + help.c\ + interface.c\ + keyboard-cfg.c\ + $(LDSRCS) \ + monitor-cfg.c\ + mouse-cfg.c\ + options.c\ + screen-cfg.c\ + screen.c\ + $(SNPRINTFSRCS)\ + startx.c\ + $(STRLSRCS)\ + stubs.c\ + $(TEXTSRC)\ + vidmode.c\ xf86config.c +#endif +#if HasDlopen OBJS =\ accessx.o\ cards.o\ @@ -69,10 +96,40 @@ stubs.o\ $(TEXTOBJ)\ vidmode.o\ + xf86config.o\ + dummy.o +#else +OBJS =\ + accessx.o\ + cards.o\ + config.o\ + card-cfg.o\ + expert.o\ + help.o\ + interface.o\ + keyboard-cfg.o\ + $(LDOBJS) \ + monitor-cfg.o\ + mouse-cfg.o\ + options.o\ + screen-cfg.o\ + screen.o\ + $(SNPRINTFOBJS)\ + startx.o\ + $(STRLOBJS)\ + stubs.o\ + $(TEXTOBJ)\ + vidmode.o\ xf86config.o +#endif PROG = xorgcfg +#if HasDlopen +DUMMYGENSRC = dummygen.c +DUMMYGENTOOL = dummygen +#endif + XBMPICS =\ card.xbm\ keyboard.xbm\ @@ -94,6 +151,14 @@ monitor.xpm\ mouse.xpm +#if HasDlopen +dummy.c :: $(DUMMYGENTOOL) $(DUMMYGENSRC) + ./$(DUMMYGENTOOL) + +clean:: + RemoveFiles($(DUMMYGENTOOL) dummy.c) +#endif + AllTarget(ProgramTargetName($(PROG))) #if DoLoadableServer diff -u XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c --- XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c Sun Dec 19 01:15:44 2004 +++ sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c Fri May 6 18:13:20 2005 @@ -275,7 +276,7 @@ nfont_modules = numFontModules; error_level = 0; ErrorF("CHECK MODULE %s\n", *ploaderList); - if ((ok = xf86cfgCheckModule()) == 0) { + if ((ok = xf86cfgCheckModule(module_types[i])) == 0) { CheckMsg(CHECKER_LOAD_FAILED, "ERROR Failed to load module.\n"); error_level += 50; @@ -373,7 +374,7 @@ ErrorF(" SUMMARY error_level set to %d.\n\n", error_level); } else - (void)xf86cfgCheckModule(); + (void)xf86cfgCheckModule(module_types[i]); } signal(SIGTRAP, SIG_DFL); signal(SIGBUS, SIG_DFL); diff -u XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h --- XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h Mon Dec 20 19:54:07 2004 +++ sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h Fri May 6 18:13:20 2005 @@ -62,7 +62,6 @@ void xf86cfgLoaderInit(void); void xf86cfgLoaderInitList(int); void xf86cfgLoaderFreeList(void); -int xf86cfgCheckModule(void); #ifndef LOADER_PRIVATE /* common/xf86Opt.h */ @@ -128,6 +127,8 @@ FontRendererModule } ModuleType; +int xf86cfgCheckModule(ModuleType); + typedef struct _xf86cfgModuleOptions { char *name; ModuleType type; diff -u XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c --- XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c Sun Dec 19 01:15:44 2004 +++ sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/loadmod.c Fri May 6 18:13:20 2005 @@ -42,6 +42,7 @@ #define LOADER_PRIVATE #include "loader.h" +#include "xf86PciInfo.h" #define True 1 #define False 0 @@ -323,6 +324,51 @@ {0,0} }; +static SymTabRec ATIChipsets[] = { + { PCI_CHIP_MACH64CT, "Mach 64 CT" }, + { PCI_CHIP_MACH64CX, "Mach 64 CX" }, + { PCI_CHIP_MACH64ET, "Mach 64 ET" }, + { PCI_CHIP_MACH64GB, "Mach 64 GB" }, + { PCI_CHIP_MACH64GD, "Mach 64 GD" }, + { PCI_CHIP_MACH64GI, "Mach 64 GI" }, + { PCI_CHIP_MACH64GL, "Mach 64 GL" }, + { PCI_CHIP_MACH64GM, "Mach 64 GM" }, + { PCI_CHIP_MACH64GN, "Mach 64 GN" }, + { PCI_CHIP_MACH64GO, "Mach 64 GO" }, + { PCI_CHIP_MACH64GP, "Mach 64 GP" }, + { PCI_CHIP_MACH64GQ, "Mach 64 GQ" }, + { PCI_CHIP_MACH64GR, "Mach 64 GR" }, + { PCI_CHIP_MACH64GS, "Mach 64 GS" }, + { PCI_CHIP_MACH64GT, "Mach 64 GT" }, + { PCI_CHIP_MACH64GU, "Mach 64 GU" }, + { PCI_CHIP_MACH64GV, "Mach 64 GV" }, + { PCI_CHIP_MACH64GW, "Mach 64 GW" }, + { PCI_CHIP_MACH64GX, "Mach 64 GX" }, + { PCI_CHIP_MACH64GY, "Mach 64 GY" }, + { PCI_CHIP_MACH64GZ, "Mach 64 GZ" }, + { PCI_CHIP_MACH64LB, "Mach 64 LB" }, + { PCI_CHIP_MACH64LD, "Mach 64 LD" }, + { PCI_CHIP_MACH64LG, "Mach 64 LG" }, + { PCI_CHIP_MACH64LI, "Mach 64 LI" }, + { PCI_CHIP_MACH64LM, "Mach 64 LM" }, + { PCI_CHIP_MACH64LN, "Mach 64 LN" }, + { PCI_CHIP_MACH64LP, "Mach 64 LP" }, + { PCI_CHIP_MACH64LQ, "Mach 64 LQ" }, + { PCI_CHIP_MACH64LR, "Mach 64 LR" }, + { PCI_CHIP_MACH64LS, "Mach 64 LS" }, + { PCI_CHIP_MACH64VT, "Mach 64 VT" }, + { PCI_CHIP_MACH64VU, "Mach 64 VU" }, + { PCI_CHIP_MACH64VV, "Mach 64 VV" }, + { PCI_CHIP_R200_QI, "R200 QI" }, + { PCI_CHIP_R200_QJ, "R200 QJ" }, + { PCI_CHIP_R200_QK, "R200 QK" }, + { PCI_CHIP_RS300_5836, "R300 5836" }, + { PCI_CHIP_RS300_5837, "R300 5837" }, + { PCI_CHIP_RV250_Le, "RV250 Le" }, + { PCI_CHIP_RV250_Ln, "RV250 Ln" }, + {-1, NULL} +}; + static DriverPtr driver; static ModuleInfoPtr info; static SymTabPtr chips; @@ -336,6 +382,7 @@ const OptionInfoRec *tmp; SymTabPtr ctmp; int count; + SymTabRec *symptr; /* XXX If the module is already in the list, then it means that * it is now being properly loaded by xf86cfg and the "fake" entry @@ -365,6 +412,13 @@ } else ptr->option = NULL; + + /* Exception handling: ati driver does not call xf86MatchPciInstances(), + below is workaround */ + if ((vendor == -1 || !chips) && (!strcmp(name, "ati"))) { + vendor = PCI_VENDOR_ATI; + chips = ATIChipsets; + } if (vendor != -1 && chips) { ptr->vendor = vendor; for (count = 0, ctmp = chips; ctmp->name; ctmp++, count++) @@ -437,6 +491,9 @@ /* XXX Xf86cfg isn't able to provide enough wrapper functions * to these drivers. Maybe the drivers could also be changed * to work better when being loaded "just for testing" */ + /* Workaround for ati is in place, and vmware no longer causes problem, + * do not need to do the following to make ati/vmware duplicate */ + /* if (type == VideoModule) { module_type = VideoModule; AddModuleOptions("vmware", NULL); @@ -443,6 +500,7 @@ AddModuleOptions("ati", NULL); module_type = NullModule; } + */ } void @@ -452,12 +510,16 @@ } int -xf86cfgCheckModule(void) +xf86cfgCheckModule(ModuleType modtype) { int errmaj, errmin; ModuleDescPtr module; int nfonts; FontModule *fonts, *pfont_module; + char name[64]; + int i = 0; + void (*Identify)(); + Bool (*Probe)(); driver = NULL; chips = NULL; @@ -473,14 +535,35 @@ } else if (driver && driver->AvailableOptions) { /* at least fbdev does not call xf86MatchPciInstances in Probe */ + /* ati driver is known to fail in probing, but we still need to + load it because it loads r128 and radeon symbles */ + if (!strcmp(*ploaderList, "ati")) + AddModuleOptions(*ploaderList, NULL); if (driver->Identify) - (*driver->Identify)(-1); + (*driver->Identify)(-1); if (driver->Probe) - (*driver->Probe)(driver, PROBE_DETECT); + (*driver->Probe)(driver, PROBE_DETECT); AddModuleOptions(*ploaderList, (*driver->AvailableOptions)(-1, -1)); } else if (info && info->AvailableOptions) AddModuleOptions(*ploaderList, (*info->AvailableOptions)(NULL)); + /* Exception handling: some video drivers (radeon, r128) do not call + xf86AddDriver(), therefore driver is NULL. Below is workaround */ + else if (!driver && (modtype == VideoModule)) { + for (i = 0; i < strlen(ploaderList[0]); i++) + name[i] = (char) toupper(ploaderList[0][i]); + name[i] = '\0'; + driver = (DriverPtr) LoaderSymbol(name); + strncpy(&name[i], "Identify", strlen("Identify") + 1); + Identify = (void (*) ()) LoaderSymbol(name); + if (Identify) + (*Identify)(-1); + strncpy(&name[i], "Probe", strlen("Probe") + 1); + Probe = (Bool (*) ()) LoaderSymbol(name); + if (Probe) + (*Probe)(driver, PROBE_DETECT); + AddModuleOptions(*ploaderList, NULL); + } if (!noverify) { XF86ModuleData *initdata = NULL; --- XORG-X11R6.8.2/xc/programs/Xserver/hw/xfree86/xf86cfg/dummygen.c 1969-12-31 16:00:00.000000000 -0800 +++ sun-src/xc/programs/Xserver/hw/xfree86/xf86cfg/dummygen.c 2005-06-27 18:27:03.249551000 -0700 @@ -0,0 +1,280 @@ +/* $XdotOrg: $ */ +/* Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * + * 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, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * 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 + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +#include +#include +#include + +#define MAXSYMS 256 +#define MAXLINE 512 + +static char *dixsymfile = "../loader/dixsym.c"; +static char *misymfile = "../loader/misym.c"; +static char *fontsymfile = "../loader/fontsym.c"; +static char *extsymfile = "../loader/extsym.c"; +static char *xf86symfile = "../loader/xf86sym.c"; +static char *xorgsymfile = "loadmod.c"; +static char *outputfile = "dummy.c"; + +static char *xf86excludesyms[MAXSYMS]; +static char line[MAXLINE]; +static int endfile; +static FILE *ofp; + +static char *dixexcludesyms[ ] = { + "Xstrdup", + "XNFstrdup", + "LogVWrite", + "FatalError", + "ErrorF", + "VErrorF", + "Error", + "kNFalloc", + "XNFalloc", + "XNFcalloc", + "XNFrealloc", + "Xalloc", + "Xcalloc", + "Xfree", + "Xrealloc", + NULL +}; + +static char *xf86initexcludesyms[ ] = { + "xf86GetErrno", + "xf86ErrorF", + "xf86strlcat", + "xf86strlcpy", + "xf86strncat", + "xf86HUGE_VAL", + NULL +}; + +typedef enum { + RET_EOF = 0, + RET_DEF, + RET_FUNC, + RET_VAR, + RET_COM, + RET_OTHER +} rettype; + +static void +errexit(char *format, char *str) { + int i; + char *p; + + if (str) + fprintf (stderr, format, str); + else + fprintf (stderr, format); + + i = 0; + while (xf86excludesyms[i]) + free(xf86excludesyms[i++]); + exit (1); +} + +static rettype +readline(FILE *fp) { + char ch; + int i = 0; + + endfile = 0; + + /* skip leading spaces */ + while ((ch = fgetc(fp)) == ' '); + + line[i] = ch; + while (((line[i] != '\n') && (line[i] != EOF)) || + ((line[i] == '\n') && (line[i-1] == '\\'))) { + if ((line[i] == '\n') && (line[i-1] == '\\')) + i--; + else + if (++i >= MAXLINE) + errexit("Line exceeds maximum.\n", NULL); + line[i] = fgetc(fp); + } + + if (line[i] == '\n') + line[i] = '\0'; + else + if (line[i] == EOF) { + if (i == 0) + return (RET_EOF); + else + endfile = 1; + } + + /* Processing line */ + if ((line[0] == '/' && line[1] == '*') || (line[0] == '*')) + return (RET_COM); + if (!strncmp(line, "#if", 3) || !strncmp(line, "#else", 5) || + !strncmp(line, "#endif", 6) || !strncmp(line, "# if", 4) || + !strncmp(line, "# else", 6) || !strncmp(line, "# endif", 7)) + return (RET_DEF); + if (!strncmp(line, "SYMFUNC", 7) && strncmp(line, "SYMFUNCALIAS", 12)) + return (RET_FUNC); + if (!strncmp(line, "SYMVAR", 6)) + return (RET_VAR); + + return (RET_OTHER); +} + +void +processsyms(char *file, char **exclude) { + FILE *fp; + int i; + int skip; + rettype ret; + char *p, *q; + + if (!(fp = fopen(file, "r"))) + errexit("Open %s failed\n", file); + + fprintf(ofp, "\n/* Functions and variable from %s */\n", file); + + while ((ret = readline(fp)) != RET_EOF) { + if ((ret == RET_COM) || (ret == RET_OTHER)) + continue; + + if (ret == RET_DEF) + fprintf(ofp, "%s\n", line); + + if ((ret == RET_FUNC) || (ret == RET_VAR)) { + if (!(p = strchr(line, '('))) + errexit("Format error: %s\n", line); + if (!(q = strchr(p, ')'))) + errexit("Format error: %s\n", line); + *q = '\0'; + p++; + if (exclude) { + i = 0; + skip = 0; + while (exclude[i]) { + if (!strcmp(p, exclude[i])) { + skip = 1; + break; + } + i++; + } + if (skip) + continue; + } + + if (ret == RET_FUNC) + fprintf(ofp, " void %s( ) { }\n", p); + else + fprintf(ofp, " int %s;\n", p); + + if (endfile) { + fclose(fp); + return; + } + } + } + + fclose(fp); + return; +} + +int +main(int argc, char *argv[]) { + int i, len; + rettype ret; + char *p, *q; + FILE *fp; + + /* Initialize xf86excludesyms[] */ + for (i = 0; i < MAXSYMS; i++) + xf86excludesyms[i] = 0; + + /* Create xf86excludesyms[] */ + i = 0; + while (xf86initexcludesyms[i]) { + if (i >= MAXSYMS) + errexit("Error: xf86 exclude symbols exceeds MAXSYMS\n", NULL); + len = strlen(xf86initexcludesyms[i]); + if (xf86excludesyms[i] = malloc(len + 1)) { + memcpy((void *)xf86excludesyms[i], + (void *)xf86initexcludesyms[i], len); + xf86excludesyms[i][len] = '\0'; + i++; + } + else + errexit("Error: malloc failed\n", NULL); + } + + if (!(fp = fopen(xorgsymfile, "r"))) + errexit("Open %s failed\n", xorgsymfile); + + while ((ret = readline(fp)) != RET_EOF) { + if (i >= MAXSYMS) + errexit("Error: xf86 exclude symbols exceeds MAXSYMS\n", NULL); + if ((ret == RET_COM) || (ret == RET_OTHER)) + continue; + + if ((ret == RET_FUNC) || (ret == RET_VAR)) { + if (!(p = strchr(line, '('))) + errexit("Format error: %s\n", line); + if (!(q = strchr(p, ')'))) + errexit("Format error: %s\n", line); + *q = '\0'; + p++; + len = strlen(p); + if (xf86excludesyms[i] = malloc(len + 1)) { + memcpy((void *)xf86excludesyms[i], p, len); + xf86excludesyms[i][len] = '\0'; + i++; + } + else + errexit("Error: malloc failed\n", NULL); + } + if (endfile) + break; + } + + + if (!(ofp = fopen(outputfile, "w"))) + errexit("Open %s failed\n", outputfile); + + processsyms(dixsymfile, dixexcludesyms); + processsyms(misymfile, NULL); + processsyms(fontsymfile, NULL); + processsyms(extsymfile, NULL); + processsyms(xf86symfile, xf86excludesyms); + + fclose(ofp); + + i = 0; + while (xf86excludesyms[i]) + free(xf86excludesyms[i++]); + + return (0); +}