static Bool VMWAREProbe(DriverPtr drv, int flags) { int numDevSections, numUsed; GDevPtr *devSections; int *usedChips; int i; Bool foundScreen = FALSE; char buildString[sizeof(VMWAREBuildStr)]; RewriteTagString(VMWAREBuildStr, buildString, sizeof(VMWAREBuildStr)); xf86MsgVerb(X_PROBED, 4, "%s", buildString); numDevSections = xf86MatchDevice(VMWARE_DRIVER_NAME, &devSections); if (numDevSections <= 0) { #ifdef DEBUG xf86MsgVerb(X_ERROR, 0, "No vmware driver section\n"); #endif return FALSE; } if (xf86GetPciVideoInfo()) { VmwareLog(("Some PCI Video Info Exists\n")); numUsed = xf86MatchPciInstances(VMWARE_NAME, PCI_VENDOR_ID_VMWARE, VMWAREChipsets, VMWAREPciChipsets, devSections, numDevSections, drv, &usedChips); free(devSections); if (numUsed <= 0) return FALSE; if (flags & PROBE_DETECT) foundScreen = TRUE; else for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn = NULL; VmwareLog(("Even some VMware SVGA PCI instances exists\n")); pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i], VMWAREPciChipsets, NULL, NULL, NULL, NULL, NULL); if (pScrn) { VmwareLog(("And even configuration suceeded\n")); pScrn->driverVersion = VMWARE_DRIVER_VERSION; pScrn->driverName = VMWARE_DRIVER_NAME; pScrn->name = VMWARE_NAME; pScrn->Probe = VMWAREProbe; #ifdef BUILD_VMWGFX vmwgfx_hookup(pScrn); #else vmwlegacy_hookup(pScrn); #endif /* defined(BUILD_VMWGFX) */ pScrn->driverPrivate = pScrn->PreInit; pScrn->PreInit = VMwarePreinitStub; foundScreen = TRUE; } } free(usedChips); } return foundScreen; }
static PMClose lnxAPMOpen(void) { int fd, pfd; DebugF("APM: OSPMOpen called\n"); if (APMihPtr || !xf86Info.pmFlag) return NULL; DebugF("APM: Opening device\n"); if ((fd = open(APM_DEVICE, O_RDWR)) > -1) { if (access(APM_PROC, R_OK) || ((pfd = open(APM_PROC, O_RDONLY)) == -1)) { xf86MsgVerb(X_WARNING, 3, "Cannot open APM (%s) (%s)\n", APM_PROC, strerror(errno)); close(fd); return NULL; } else close(pfd); xf86PMGetEventFromOs = lnxPMGetEventFromOs; xf86PMConfirmEventToOs = lnxPMConfirmEventToOs; APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL); xf86MsgVerb(X_INFO, 3, "Open APM successful\n"); return lnxCloseAPM; } return NULL; }
static void UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) { int i; xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n", Base, Size); for (i = 0; i < MAX_SMEMS; i++) { if (*smems[i].name && smems[i].ptr == Base && smems[i].Size == Size) { if (--smems[i].RefCnt > 0) return; (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); xf86MsgVerb(X_INFO, 3, "UnMapVidMem: smem_create(%s, 0x%08x, ... " "SM_DETACH)\n", smems[i].name, smems[i].ptr); (void)smem_remove(smems[i].name); *smems[i].name = '\0'; smems[i].RefCnt = 0; return; } } xf86MsgVerb(X_WARNING, 2, "UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", Base, Size); }
_X_EXPORT Bool xf86LinearVidMem(void) { int mmapFd; if (apertureDevName) return TRUE; apertureDevName = "/dev/xsvc"; if ((mmapFd = open(apertureDevName, O_RDWR)) < 0) { apertureDevName = "/dev/fbs/aperture"; if((mmapFd = open(apertureDevName, O_RDWR)) < 0) { xf86MsgVerb(X_WARNING, 0, "xf86LinearVidMem: failed to open %s (%s)\n", apertureDevName, strerror(errno)); xf86MsgVerb(X_WARNING, 0, "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc" " device driver required\n"); xf86MsgVerb(X_WARNING, 0, "xf86LinearVidMem: linear memory access disabled\n"); apertureDevName = NULL; return FALSE; } } close(mmapFd); return TRUE; }
Bool xf86AutoConfig(void) { char *deviceList[20]; char **p; const char **cp; char buf[1024]; ConfigStatus ret; listPossibleVideoDrivers(deviceList, 20); for (p = deviceList; *p; p++) { snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); AppendToConfig(buf); snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); AppendToConfig(buf); } AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE); for (p = deviceList; *p; p++) { snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); AppendToConfig(buf); } AppendToConfig(BUILTIN_LAYOUT_SECTION_POST); for (p = deviceList; *p; p++) { free(*p); } xf86MsgVerb(X_DEFAULT, 0, "Using default built-in configuration (%d lines)\n", builtinLines); xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n"); for (cp = builtinConfig; *cp; cp++) xf86ErrorFVerb(3, "\t%s", *cp); xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n"); xf86initConfigFiles(); xf86setBuiltinConfig(builtinConfig); ret = xf86HandleConfigFile(TRUE); FreeConfig(); if (ret != CONFIG_OK) xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n"); return ret == CONFIG_OK; }
_X_EXPORT int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { unsigned char *ptr; int psize; int mlen; psize = xf86getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); ptr = (unsigned char *)mmap_device_memory((caddr_t)0, mlen, PROT_READ, 0, (off_t)Base); if ((long)ptr == -1) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", DEV_MEM, Len, Base, Offset, strerror(errno)); return(-1); } #ifdef DEBUG ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base, ptr[0] | (ptr[1] << 8)); #endif (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap_device_memory((caddr_t)ptr, mlen); #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" "-> %02x %02x %02x %02x...\n", Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); #endif return(Len); }
_X_HIDDEN int sunKbdOpen(const char *devName, pointer options) { int kbdFD; const char *kbdPath = NULL; const char *defaultKbd = "/dev/kbd"; if (options != NULL) { kbdPath = xf86SetStrOption(options, "Device", NULL); } if (kbdPath == NULL) { kbdPath = defaultKbd; } kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK); if (kbdFD == -1) { xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath); } else { xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath); } if ((kbdPath != NULL) && (kbdPath != defaultKbd)) { xfree(kbdPath); } return kbdFD; }
Bool xf86EnableIO() { int fd = xf86Info.consoleFd; xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd); if (ioBase == MAP_FAILED) { ioBase = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0xf2000000); xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase); if (ioBase == MAP_FAILED) { xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n"); return FALSE; } } return TRUE; }
_X_EXPORT int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int rv; if (Base < 0x80000000) { xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base); return 0; } if (kmem == -1) { kmem = open(DEV_MEM, 2); if (kmem == -1) { FatalError("xf86ReadBIOS: open %s", DEV_MEM); } } #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); #endif lseek(kmem, Base + Offset, 0); rv = read(kmem, Buf, Len); return rv; }
int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int rv; static int kmem = -1; if (kmem == -1) { kmem = open(DEV_MEM, 2); if (kmem == -1) { FatalError("xf86ReadBIOS: open %s", DEV_MEM); } } #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); #endif lseek(kmem, Base + Offset, 0); rv = read(kmem, Buf, Len); return rv; }
static Bool linearVidMem() { #ifdef SVR4 return TRUE; #elif defined(HAS_SVR3_MMAPDRV) xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86LinearVidMem: MMAP 2.2.2 called\n"); if(mmapFd >= 0) return TRUE; if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) { if(ioctl(mmapFd, GETVERSION) < 0x0222) { xf86Msg(X_WARNING, "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); xf86ErrorF("\tlinear memory access disabled\n"); return FALSE; } return TRUE; } xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", strerror(errno)); xf86ErrorF("\tlinear memory access disabled\n"); return FALSE; #endif }
/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, and will fail on Linux 2.2 with MTRR support configured out, so verbosity should be chosen appropriately. */ static Bool mtrr_open(int verbosity) { /* Only report absence of /proc/mtrr once. */ static Bool warned = FALSE; if (mtrr_fd == MTRR_FD_UNOPENED) { mtrr_fd = open("/proc/mtrr", O_WRONLY); if (mtrr_fd < 0) mtrr_fd = MTRR_FD_PROBLEM; } if (mtrr_fd == MTRR_FD_PROBLEM) { /* To make sure we only ever warn once, need to check verbosity outside xf86MsgVerb */ if (!warned && verbosity <= xf86GetVerbosity()) { xf86MsgVerb(X_WARNING, verbosity, "System lacks support for changing MTRRs\n"); warned = TRUE; } return FALSE; } else return TRUE; }
/* ARGSUSED */ static void unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) { #if defined (SVR4) munmap(Base, Size); #else /* SVR4 */ #ifdef HAS_SVR3_MMAPDRV xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86UnMapVidMem: UNMapping FrameBuffer\n"); mmapStat(Base,Size); ioctl(mmapFd, UNMAPRM , Base); mmapStat(Base,Size); xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base); #endif /* HAS_SVR3_MMAPDRV */ #endif /* SVR4 */ return; }
void LoaderInit(void) { xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *) xorg_symbols); xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n"); xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); }
static int mmapStat(pointer Base, unsigned long Size) { int nmmreg,i=0,region=-1; mmapinfo_t *ibuf; nmmreg = ioctl(mmapFd, GETNMMREG); if(nmmreg <= 0) xf86MsgVerb(X_INFO, MMAP_DEBUG, "\nNo physical memory mapped currently.\n\n"); else { if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL) xf86Msg(X_WARNING, "Couldn't allocate memory 4 mmapinfo_t\n"); else { if(ioctl(mmapFd, GETMMREG, ibuf) != -1) { xf86MsgVerb(X_INFO, MMAP_DEBUG, "# mmapStat: [Size=%x,Base=%x]\n", Size, Base); xf86MsgVerb(X_INFO, MMAP_DEBUG, "# Physical Address Size Reference Count\n"); for(i = 0; i < nmmreg; i++) { xf86MsgVerb(X_INFO, MMAP_DEBUG, "%-4d 0x%08X %5dk %5d ", i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt); if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) { xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!"); if (region==-1) region=i; } xf86ErrorFVerb(MMAP_DEBUG, "\n"); } xf86ErrorFVerb(MMAP_DEBUG, "\n"); } free(ibuf); } } if (region == -1 && nmmreg > 0) region=region * i; return region; }
int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { unsigned char *ptr; int psize; int mlen; checkDevMem(TRUE); if (devMemFd == -1) { return -1; } psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); if ((long)ptr == -1) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", DEV_MEM, Len, Base, Offset, strerror(errno)); return -1; } #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base, ptr[0] | (ptr[1] << 8)); #endif (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap((caddr_t)ptr, mlen); #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" "-> %02x %02x %02x %02x...\n", Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); #endif return Len; }
static Bool VMwarePciProbe (DriverPtr drv, int entity_num, struct pci_device *device, intptr_t match_data) { ScrnInfoPtr scrn = NULL; scrn = xf86ConfigPciEntity(scrn, 0, entity_num, VMWAREPciChipsets, NULL, NULL, NULL, NULL, NULL); if (scrn != NULL) { scrn->driverVersion = VMWARE_DRIVER_VERSION; scrn->driverName = VMWARE_DRIVER_NAME; scrn->name = VMWARE_NAME; scrn->Probe = NULL; } switch (DEVICE_ID(device)) { case PCI_DEVICE_ID_VMWARE_SVGA2: case PCI_DEVICE_ID_VMWARE_SVGA: xf86MsgVerb(X_INFO, 4, "VMwarePciProbe: Valid device\n"); #ifdef BUILD_VMWGFX vmwgfx_hookup(scrn); #else vmwlegacy_hookup(scrn); #endif /* defined(BUILD_VMWGFX) */ scrn->driverPrivate = scrn->PreInit; scrn->PreInit = VMwarePreinitStub; break; default: xf86MsgVerb(X_INFO, 4, "VMwarePciProbe: Unknown device\n"); } return scrn != NULL; }
static pointer ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { int fd = xf86Info.screenFd; pointer base; #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd); #endif base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); if (base == MAP_FAILED) FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)\n", "xf86MapVidMem", Size, Base, strerror(errno)); return base; }
_X_EXPORT void LoadFont(FontModule * f) { FontModule *newfont; if (f == NULL) return; if (!(newfont = NewFontModule())) return; xf86MsgVerb(X_INFO, 2, "Loading font %s\n", f->name); newfont->name = f->name; newfont->initFunc = f->initFunc; newfont->module = f->module; }
static void * ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { int fd = xf86Info.consoleFd; void *base; #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd); #endif base = mmap(0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base); if (base == MAP_FAILED) FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)", "xf86MapVidMem", Size, Base, strerror(errno)); return base; }
void xf86HandlePMEvents(int fd, void *data) { pmEvent events[MAX_NO_EVENTS]; int i, n; Bool wait = FALSE; if (!xf86PMGetEventFromOs) return; if ((n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS))) { do { for (i = 0; i < n; i++) { const char *str = NULL; int verb = eventName(events[i], &str); xf86MsgVerb(X_INFO, verb, "PM Event received: %s\n", str); DoApmEvent(events[i], FALSE); switch (xf86PMConfirmEventToOs(fd, events[i])) { case PM_WAIT: wait = TRUE; break; case PM_CONTINUE: wait = FALSE; break; case PM_FAILED: DoApmEvent(events[i], TRUE); wait = FALSE; break; default: break; } } if (wait) n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS); else break; } while (1); } }
/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, and will fail on Linux 2.2 with MTRR support configured out, so verbosity should be chosen appropriately. */ static Bool mtrr_open(int verbosity) { /* Only report absence of /proc/mtrr once. */ static Bool warned = FALSE; char **fn; static char *mtrr_files[] = { "/dev/cpu/mtrr", /* Possible future name */ "/proc/mtrr", /* Current name */ NULL }; if (mtrr_fd == MTRR_FD_UNOPENED) { /* So open it. */ for (fn = mtrr_files; mtrr_fd < 0 && *fn; fn++) mtrr_fd = open(*fn, O_WRONLY); if (mtrr_fd < 0) mtrr_fd = MTRR_FD_PROBLEM; } if (mtrr_fd == MTRR_FD_PROBLEM) { /* To make sure we only ever warn once, need to check verbosity outside xf86MsgVerb */ if (!warned && verbosity <= xf86GetVerbosity()) { xf86MsgVerb(X_WARNING, verbosity, "System lacks support for changing MTRRs\n"); warned = TRUE; } return FALSE; } else return TRUE; }
int xf86MatchSbusInstances(const char *driverName, int sbusDevId, GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities) { int i,j; sbusDevicePtr psdp, *psdpp; int numClaimedInstances = 0; int allocatedInstances = 0; int numFound = 0; GDevPtr devBus = NULL; GDevPtr dev = NULL; int *retEntities = NULL; int useProm = 0; struct Inst { sbusDevicePtr sbus; GDevPtr dev; Bool claimed; /* BusID matches with a device section */ } *instances = NULL; *foundEntities = NULL; for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++psdpp) { if (psdp->devId != sbusDevId) continue; if (psdp->fd == -2) continue; ++allocatedInstances; instances = xnfrealloc(instances, allocatedInstances * sizeof(struct Inst)); instances[allocatedInstances - 1].sbus = psdp; instances[allocatedInstances - 1].dev = NULL; instances[allocatedInstances - 1].claimed = FALSE; numFound++; } /* * This may be debatable, but if no SBUS devices with a matching vendor * type is found, return zero now. It is probably not desirable to * allow the config file to override this. */ if (allocatedInstances <= 0) { free(instances); return 0; } if (sparcPromInit() >= 0) useProm = 1; if (xf86DoConfigure && xf86DoConfigurePass1) { GDevPtr pGDev; int actualcards = 0; for (i = 0; i < allocatedInstances; i++) { actualcards++; pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS, instances[i].sbus, -1); if (pGDev) { /* * XF86Match???Instances() treat chipID and chipRev as * overrides, so clobber them here. */ pGDev->chipID = pGDev->chipRev = -1; } } free(instances); if (useProm) sparcPromClose(); return actualcards; } DebugF("%s instances found: %d\n", driverName, allocatedInstances); for (i = 0; i < allocatedInstances; i++) { char *promPath = NULL; psdp = instances[i].sbus; devBus = NULL; dev = NULL; if (useProm && psdp->node.node) promPath = sparcPromNode2Pathname(&psdp->node); for (j = 0; j < numDevs; j++) { if (devList[j]->busID && *devList[j]->busID) { if (xf86CompareSbusBusString(devList[j]->busID, psdp->fbNum)) { if (devBus) xf86MsgVerb(X_WARNING,0, "%s: More than one matching Device section for " "instance (BusID: %s) found: %s\n", driverName,devList[j]->identifier, devList[j]->busID); else devBus = devList[j]; } } else { if (!dev && !devBus) { if (promPath) xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:%s\n", promPath); else xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:fb%d\n", psdp->fbNum); dev = devList[j]; } else xf86MsgVerb(X_WARNING, 0, "%s: More than one matching Device section " "found: %s\n", driverName, devList[j]->identifier); } } if (devBus) dev = devBus; /* busID preferred */ if (!dev && psdp->fd != -2) { if (promPath) { xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " "for instance (BusID SBUS:%s) found\n", driverName, promPath); } else xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " "for instance (BusID SBUS:fb%d) found\n", driverName, psdp->fbNum); } else if (dev) { numClaimedInstances++; instances[i].claimed = TRUE; instances[i].dev = dev; } free(promPath); } DebugF("%s instances found: %d\n", driverName, numClaimedInstances); /* * Of the claimed instances, check that another driver hasn't already * claimed its slot. */ numFound = 0; for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { if (!instances[i].claimed) continue; psdp = instances[i].sbus; if (!xf86CheckSbusSlot(psdp->fbNum)) continue; DebugF("%s: card at fb%d %08x is claimed by a Device section\n", driverName, psdp->fbNum, psdp->node.node); /* Allocate an entry in the lists to be returned */ numFound++; retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); retEntities[numFound - 1] = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,instances[i].dev->active ? TRUE : FALSE); } free(instances); if (numFound > 0) { *foundEntities = retEntities; } if (useProm) sparcPromClose(); return numFound; }
static void ix86PciSelectCfgmech(void) { static Bool beenhere = FALSE; CARD32 mode1Res1 = 0, mode1Res2 = 0, oldVal1 = 0; CARD8 mode2Res1 = 0, mode2Res2 = 0, oldVal2 = 0; int stages = 0; if (beenhere) return; /* Been there, done that */ beenhere = TRUE; /* * Determine if motherboard chipset supports PCI Config Mech 1 or 2 * We rely on xf86Info.pciFlags to tell which mechanisms to try.... */ switch (xf86Info.pciFlags) { case PCIOsConfig: #ifdef ARCH_PCI_OS_INIT return; #endif case PCIProbe1: if (!xf86EnableIO()) return; xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 1\n"); oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("Checking config type 1:\n" "\tinitial value of MODE1_ADDR_REG is 0x%08x\n", oldVal1); ErrorF("\tChecking that all bits in mask 0x7f000000 are clear\n"); } #endif /* Assuming config type 1 to start with */ if ((oldVal1 & 0x7f000000) == 0) { stages |= 0x01; #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tValue indicates possibly config type 1\n"); ErrorF("\tWriting 32-bit value 0x%08x to MODE1_ADDR_REG\n", PCI_EN); #if 0 ErrorF("\tWriting 8-bit value 0x00 to MODE1_ADDR_REG + 3\n"); #endif } #endif ix86Pci0.configMech = PCI_CFG_MECH_1; ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; ix86Pci0.funcs = &ix86Funcs1; outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); #if 0 /* * This seems to cause some Neptune-based PCI machines to switch * from config type 1 to config type 2 */ outb(PCI_CFGMECH1_ADDRESS_REG + 3, 0); #endif mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", mode1Res1); ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); } #endif outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); if (mode1Res1) { stages |= 0x02; #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tValue read back is non-zero, and indicates possible" " config type 1\n"); } #endif if (ix86PciBusCheck()) { #ifdef DEBUGPCI if (xf86Verbose > 2) ErrorF("\tBus check Confirms this: "); #endif xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx, mode1Res1" " = 0x%08lx\n", stages, (unsigned long)oldVal1, (unsigned long)mode1Res1); return; } #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tBus check fails to confirm this, continuing type 1" " check ...\n"); } #endif } stages |= 0x04; #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tWriting 0xff000001 to MODE1_ADDR_REG\n"); } #endif outl(PCI_CFGMECH1_ADDRESS_REG, 0xff000001); mode1Res2 = inl(PCI_CFGMECH1_ADDRESS_REG); #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", mode1Res2); ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); } #endif outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); if ((mode1Res2 & 0x80000001) == 0x80000000) { stages |= 0x08; #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tValue read back has only the msb set\n" "\tThis indicates possible config type 1\n"); } #endif if (ix86PciBusCheck()) { #ifdef DEBUGPCI if (xf86Verbose > 2) ErrorF("\tBus check Confirms this: "); #endif xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", stages, (unsigned long)oldVal1, (unsigned long)mode1Res1, (unsigned long)mode1Res2); return; } #ifdef DEBUGPCI if (xf86Verbose > 2) { ErrorF("\tBus check fails to confirm this.\n"); } #endif } } xf86MsgVerb(X_INFO, 3, "PCI: Standard check for type 1 failed.\n"); xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", stages, (unsigned long)oldVal1, (unsigned long)mode1Res1, (unsigned long)mode1Res2); /* Try config type 2 */ oldVal2 = inb(PCI_CFGMECH2_ENABLE_REG); if ((oldVal2 & 0xf0) == 0) { ix86Pci0.configMech = PCI_CFG_MECH_2; ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; ix86Pci0.funcs = &ix86Funcs2; outb(PCI_CFGMECH2_ENABLE_REG, 0x0e); mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); outb(PCI_CFGMECH2_ENABLE_REG, oldVal2); if (mode2Res1 == 0x0e) { if (ix86PciBusCheck()) { xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); return; } } } break; /* } */ case PCIProbe2: /* { */ if (!xf86EnableIO()) return; /* The scanpci-style detection method */ xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 2\n"); outb(PCI_CFGMECH2_ENABLE_REG, 0x00); outb(PCI_CFGMECH2_FORWARD_REG, 0x00); mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); mode2Res2 = inb(PCI_CFGMECH2_FORWARD_REG); if (mode2Res1 == 0 && mode2Res2 == 0) { xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); ix86Pci0.configMech = PCI_CFG_MECH_2; ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; ix86Pci0.funcs = &ix86Funcs2; return; } oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); if (mode1Res1 == PCI_EN) { xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); ix86Pci0.configMech = PCI_CFG_MECH_1; ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; ix86Pci0.funcs = &ix86Funcs1; return; } break; /* } */ case PCIForceConfig1: if (!xf86EnableIO()) return; xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 1\n"); ix86Pci0.configMech = PCI_CFG_MECH_1; ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; ix86Pci0.funcs = &ix86Funcs1; return; case PCIForceConfig2: if (!xf86EnableIO()) return; xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 2\n"); ix86Pci0.configMech = PCI_CFG_MECH_2; ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; ix86Pci0.funcs = &ix86Funcs2; return; case PCIForceNone: break; } /* No PCI found */ ix86Pci0.configMech = PCI_CFG_MECH_UNKNOWN; xf86MsgVerb(X_INFO, 2, "PCI: No PCI bus found or probed for\n"); }
static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; #if defined(SVR4) fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); if (fd < 0) { FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM, strerror(errno)); } base = mmap((caddr_t)0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, (off_t)Base); close(fd); if (base == MAP_FAILED) { FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", "xf86MapVidMem", Size, Base, strerror(errno)); } #else /* SVR4 */ #ifdef HAS_SVR3_MMAPDRV xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n"); xf86MsgVerb(X_INFO, MMAP_DEBUG, "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); if (ioctl(mmapFd, GETVERSION) == -1) { xf86LinearVidMem(); } xf86MsgVerb(X_INFO, MMAP_DEBUG, "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); xf86MsgVerb(X_INFO, MMAP_DEBUG, "xf86MapVidMem: Screen: %d\n", ScreenNum); mmapStat(Base,Size); /* To force the MMAP driver to provide the address */ base = (pointer)0; xf86MsgVerb(X_INFO, MMAP_DEBUG, "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base); MapDSC.vaddr = (char *)base; MapDSC.physaddr = (char *)Base; MapDSC.length = Size; MapDSC.ioflg = 1; if(mmapFd >= 0) { if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1) { FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", "xf86MapVidMem", Size, Base, strerror(errno)); /* NOTREACHED */ } /* Next time we want the same address! */ MapDSC.vaddr = (char *)base; } xf86MsgVerb(X_INFO, MMAP_DEBUG, "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr); xf86MsgVerb(X_INFO, MMAP_DEBUG, "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr); xf86MsgVerb(X_INFO, MMAP_DEBUG, "MapDSC.length : %d\n", MapDSC.length); mmapStat(Base,Size); xf86MsgVerb(X_INFO, MMAP_DEBUG, "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base); xf86MsgVerb(X_INFO, MMAP_DEBUG, "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n"); #endif /* HAS_SVR3_MMAPDRV */ #endif /* SVR4 */ return base; }
static pointer MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { static int once; int free_slot = -1; int i; if (!once) { atexit(smemCleanup); once = 1; } for (i = 0; i < MAX_SMEMS; i++) { if (!*smems[i].name && free_slot == -1) free_slot = i; if (smems[i].Base == Base && smems[i].Size == Size && *smems[i].name) { smems[i].RefCnt++; return smems[i].ptr; } } if (i == MAX_SMEMS && free_slot == -1) { FatalError("MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n", Base, Size); } i = free_slot; sprintf(smems[i].name, "Video-%d", i); smems[i].Base = Base; smems[i].Size = Size; xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n", Base, Size); #if defined(__powerpc__) if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) { Base = Base | PHYS_IO_MEM_START; } #endif smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE); smems[i].RefCnt = 1; if (smems[i].ptr == NULL) { /* check if there is a stale segment around */ if (smem_remove(smems[i].name) == 0) { xf86Msg(X_INFO, "MapVidMem: removed stale smem_ segment %s\n", smems[i].name); smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE); } if (smems[i].ptr == NULL) { *smems[i].name = '\0'; FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n", Base, Size, strerror(errno)); } } xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n", Base, Size, smems[i].ptr); return smems[i].ptr; }
static Bool CheckRequirements(const XF86ModuleVersionInfo * data, const XF86ModReqInfo * req) { if (!req) return TRUE; if (!data) { xf86MsgVerb(X_WARNING, 2, "No version information to verify\n"); return FALSE; } if (req->majorversion != MAJOR_UNSPEC) { if (data->majorversion != req->majorversion) { xf86MsgVerb(X_WARNING, 2, "Module major version (%d) doesn't match" " required major version (%d)\n", data->majorversion, req->majorversion); return FALSE; } if (req->minorversion != MINOR_UNSPEC) { if (data->minorversion < req->minorversion) { xf86MsgVerb(X_WARNING, 2, "Module minor version (%d) is less" " than the required minor version (%d)\n", data->minorversion, req->minorversion); return FALSE; } if ((data->minorversion == req->minorversion) && (req->patchlevel != PATCH_UNSPEC) && (data->patchlevel < req->patchlevel)) { xf86MsgVerb(X_WARNING, 2, "Module patch level (%d) is less" " than the required patch level (%d)\n", data->patchlevel, req->patchlevel); return FALSE; } } } if (req->moduleclass) { if (!data->moduleclass || strcmp(req->moduleclass, data->moduleclass)) { xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match the" " required class (%s)\n", data->moduleclass ? data->moduleclass : "<NONE>", req->moduleclass); return FALSE; } } else if (req->abiclass != ABI_CLASS_NONE) { if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) { xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the" " required ABI class (%s)\n", data->abiclass ? data->abiclass : "<NONE>", req->abiclass); return FALSE; } } if ((req->abiclass != ABI_CLASS_NONE) && (req->abiversion != ABI_VERS_UNSPEC)) { int reqmaj, reqmin, maj, min; reqmaj = GET_ABI_MAJOR(req->abiversion); maj = GET_ABI_MAJOR(data->abiversion); if (maj != reqmaj) { xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't match" " the required ABI major version (%d)\n", maj, reqmaj); return FALSE; } reqmin = GET_ABI_MINOR(req->abiversion); min = GET_ABI_MINOR(data->abiversion); if (min < reqmin) { xf86MsgVerb(X_WARNING, 2, "Module ABI minor version (%d) is older" " than that required (%d)\n", min, reqmin); return FALSE; } } return TRUE; }
static Bool CheckVersion(const char *module, XF86ModuleVersionInfo * data, const XF86ModReqInfo * req) { int vercode[4]; long ver = data->xf86version; MessageType errtype; xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n", data->modname ? data->modname : "UNKNOWN!", data->vendor ? data->vendor : "UNKNOWN!"); vercode[0] = ver / 10000000; vercode[1] = (ver / 100000) % 100; vercode[2] = (ver / 1000) % 100; vercode[3] = ver % 1000; xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], vercode[2]); if (vercode[3] != 0) xf86ErrorF(".%d", vercode[3]); xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion, data->minorversion, data->patchlevel); if (data->moduleclass) xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass); ver = -1; if (data->abiclass) { int abimaj, abimin; int vermaj, vermin; if (!strcmp(data->abiclass, ABI_CLASS_ANSIC)) ver = LoaderVersionInfo.ansicVersion; else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV)) ver = LoaderVersionInfo.videodrvVersion; else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT)) ver = LoaderVersionInfo.xinputVersion; else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION)) ver = LoaderVersionInfo.extensionVersion; else if (!strcmp(data->abiclass, ABI_CLASS_FONT)) ver = LoaderVersionInfo.fontVersion; abimaj = GET_ABI_MAJOR(data->abiversion); abimin = GET_ABI_MINOR(data->abiversion); xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n", data->abiclass, abimaj, abimin); if (ver != -1) { vermaj = GET_ABI_MAJOR(ver); vermin = GET_ABI_MINOR(ver); if (abimaj != vermaj) { if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) errtype = X_WARNING; else errtype = X_ERROR; xf86MsgVerb(errtype, 0, "module ABI major version (%d) doesn't" " match the server's version (%d)\n", abimaj, vermaj); if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) return FALSE; } else if (abimin > vermin) { if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) errtype = X_WARNING; else errtype = X_ERROR; xf86MsgVerb(errtype, 0, "module ABI minor version (%d) is " "newer than the server's version " "(%d)\n", abimin, vermin); if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) return FALSE; } } } /* Check against requirements that the caller has specified */ if (req) { if (req->majorversion != MAJOR_UNSPEC) { if (data->majorversion != req->majorversion) { xf86MsgVerb(X_WARNING, 2, "module major version (%d) " "doesn't match required major version (%d)\n", data->majorversion, req->majorversion); return FALSE; } else if (req->minorversion != MINOR_UNSPEC) { if (data->minorversion < req->minorversion) { xf86MsgVerb(X_WARNING, 2, "module minor version (%d) " "is less than the required minor version (%d)\n", data->minorversion, req->minorversion); return FALSE; } else if (data->minorversion == req->minorversion && req->patchlevel != PATCH_UNSPEC) { if (data->patchlevel < req->patchlevel) { xf86MsgVerb(X_WARNING, 2, "module patch level (%d) " "is less than the required patch level (%d)\n", data->patchlevel, req->patchlevel); return FALSE; } } } } if (req->moduleclass) { if (!data->moduleclass || strcmp(req->moduleclass, data->moduleclass)) { xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match " "the required class (%s)\n", data->moduleclass ? data->moduleclass : "<NONE>", req->moduleclass); return FALSE; } } else if (req->abiclass != ABI_CLASS_NONE) { if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) { xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the " "required ABI class (%s)\n", data->abiclass ? data->abiclass : "<NONE>", req->abiclass); return FALSE; } } if ((req->abiclass != ABI_CLASS_NONE) && req->abiversion != ABI_VERS_UNSPEC) { int reqmaj, reqmin, maj, min; reqmaj = GET_ABI_MAJOR(req->abiversion); reqmin = GET_ABI_MINOR(req->abiversion); maj = GET_ABI_MAJOR(data->abiversion); min = GET_ABI_MINOR(data->abiversion); if (maj != reqmaj) { xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't " "match the required ABI major version (%d)\n", maj, reqmaj); return FALSE; } /* XXX Maybe this should be the other way around? */ if (min > reqmin) { xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) " "is newer than that available (%d)\n", min, reqmin); return FALSE; } } } return TRUE; }
Bool xf86AutoConfig(void) { const char **p; char buf[1024]; pciVideoPtr *pciptr, info = NULL; char *driver = NULL; ConfigStatus ret; /* Find the primary device, and get some information about it. */ if (xf86PciVideoInfo) { for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) { if (xf86IsPrimaryPci(info)) { break; } } if (!info) { ErrorF("Primary device is not PCI\n"); } } else { ErrorF("xf86PciVideoInfo is not set\n"); } if (info) driver = videoPtrToDriverName(info); AppendToConfig(BUILTIN_MODULE_SECTION); AppendToConfig(BUILTIN_MONITOR_SECTION); if (driver) { snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE, driver, 0, driver); AppendToConfig(buf); ErrorF("New driver is \"%s\"\n", driver); buf[0] = '\t'; AppendToConfig(BUILTIN_DEVICE_SECTION_POST); snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, driver, 0, driver, 0); AppendToConfig(buf); } for (p = deviceList; *p; p++) { snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); AppendToConfig(buf); snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); AppendToConfig(buf); } AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE); if (driver) { snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0); AppendToConfig(buf); } for (p = deviceList; *p; p++) { snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); AppendToConfig(buf); } AppendToConfig(BUILTIN_LAYOUT_SECTION_POST); xf86MsgVerb(X_DEFAULT, 0, "Using default built-in configuration (%d lines)\n", builtinLines); xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n"); for (p = builtinConfig; *p; p++) xf86ErrorFVerb(3, "\t%s", *p); xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n"); xf86setBuiltinConfig(builtinConfig); ret = xf86HandleConfigFile(TRUE); FreeConfig(); if (ret != CONFIG_OK) xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n"); return (ret == CONFIG_OK); }
/* * InitOutput -- * Initialize screenInfo for all actually accessible framebuffers. * That includes vt-manager setup, querying all possible devices and * collecting the pixmap formats. */ void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) { int i, j, k, scr_index, was_blocked = 0; char **modulelist; pointer *optionlist; Pix24Flags screenpix24, pix24; MessageType pix24From = X_DEFAULT; Bool pix24Fail = FALSE; Bool autoconfig = FALSE; GDevPtr configured_device; xf86Initialising = TRUE; if (serverGeneration == 1) { if ((xf86ServerName = strrchr(argv[0], '/')) != 0) xf86ServerName++; else xf86ServerName = argv[0]; xf86PrintBanner(); xf86PrintMarkers(); if (xf86LogFile) { time_t t; const char *ct; t = time(NULL); ct = ctime(&t); xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s", xf86LogFile, ct); } /* Read and parse the config file */ if (!xf86DoConfigure && !xf86DoShowOptions) { switch (xf86HandleConfigFile(FALSE)) { case CONFIG_OK: break; case CONFIG_PARSE_ERROR: xf86Msg(X_ERROR, "Error parsing the config file\n"); return; case CONFIG_NOFILE: autoconfig = TRUE; break; } } InstallSignalHandlers(); /* Initialise the loader */ LoaderInit(); /* Tell the loader the default module search path */ LoaderSetPath(xf86ModulePath); if (xf86Info.ignoreABI) { LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); } if (xf86DoShowOptions) DoShowOptions(); /* Do a general bus probe. This will be a PCI probe for x86 platforms */ xf86BusProbe(); if (xf86DoConfigure) DoConfigure(); if (autoconfig) { if (!xf86AutoConfig()) { xf86Msg(X_ERROR, "Auto configuration failed\n"); return; } } #ifdef XF86PM xf86OSPMClose = xf86OSPMOpen(); #endif /* Load all modules specified explicitly in the config file */ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) { xf86LoadModules(modulelist, optionlist); free(modulelist); free(optionlist); } /* Load all driver modules specified in the config file */ /* If there aren't any specified in the config file, autoconfig them */ /* FIXME: Does not handle multiple active screen sections, but I'm not * sure if we really want to handle that case*/ configured_device = xf86ConfigLayout.screens->screen->device; if ((!configured_device) || (!configured_device->driver)) { if (!autoConfigDevice(configured_device)) { xf86Msg(X_ERROR, "Automatic driver configuration failed\n"); return ; } } if ((modulelist = xf86DriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); free(modulelist); } /* Load all input driver modules specified in the config file. */ if ((modulelist = xf86InputDriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); free(modulelist); } /* * It is expected that xf86AddDriver()/xf86AddInputDriver will be * called for each driver as it is loaded. Those functions save the * module pointers for drivers. * XXX Nothing keeps track of them for other modules. */ /* XXX What do we do if not all of these could be loaded? */ /* * At this point, xf86DriverList[] is all filled in with entries for * each of the drivers to try and xf86NumDrivers has the number of * drivers. If there are none, return now. */ if (xf86NumDrivers == 0) { xf86Msg(X_ERROR, "No drivers available.\n"); return; } /* * Call each of the Identify functions and call the driverFunc to check * if HW access is required. The Identify functions print out some * identifying information, and anything else that might be * needed at this early stage. */ for (i = 0; i < xf86NumDrivers; i++) { if (xf86DriverList[i]->Identify != NULL) xf86DriverList[i]->Identify(0); if (!xorgHWAccess || !xorgHWOpenConsole) { xorgHWFlags flags; if(!xf86DriverList[i]->driverFunc || !xf86DriverList[i]->driverFunc(NULL, GET_REQUIRED_HW_INTERFACES, &flags)) flags = HW_IO; if(NEED_IO_ENABLED(flags)) xorgHWAccess = TRUE; if(!(flags & HW_SKIP_CONSOLE)) xorgHWOpenConsole = TRUE; } } if (xorgHWOpenConsole) xf86OpenConsole(); else xf86Info.dontVTSwitch = TRUE; if (xf86BusConfig() == FALSE) return; xf86PostProbe(); /* * Sort the drivers to match the requested ording. Using a slow * bubble sort. */ for (j = 0; j < xf86NumScreens - 1; j++) { for (i = 0; i < xf86NumScreens - j - 1; i++) { if (xf86Screens[i + 1]->confScreen->screennum < xf86Screens[i]->confScreen->screennum) { ScrnInfoPtr tmpScrn = xf86Screens[i + 1]; xf86Screens[i + 1] = xf86Screens[i]; xf86Screens[i] = tmpScrn; } } } /* Fix up the indexes */ for (i = 0; i < xf86NumScreens; i++) { xf86Screens[i]->scrnIndex = i; } /* * Call the driver's PreInit()'s to complete initialisation for the first * generation. */ for (i = 0; i < xf86NumScreens; i++) { xf86VGAarbiterScrnInit(xf86Screens[i]); xf86VGAarbiterLock(xf86Screens[i]); if (xf86Screens[i]->PreInit && xf86Screens[i]->PreInit(xf86Screens[i], 0)) xf86Screens[i]->configured = TRUE; xf86VGAarbiterUnlock(xf86Screens[i]); } for (i = 0; i < xf86NumScreens; i++) if (!xf86Screens[i]->configured) xf86DeleteScreen(i--, 0); /* * If no screens left, return now. */ if (xf86NumScreens == 0) { xf86Msg(X_ERROR, "Screen(s) found, but none have a usable configuration.\n"); return; } for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->name == NULL) { XNFasprintf(&xf86Screens[i]->name, "screen%d", i); xf86MsgVerb(X_WARNING, 0, "Screen driver %d has no name set, using `%s'.\n", i, xf86Screens[i]->name); } } /* Remove (unload) drivers that are not required */ for (i = 0; i < xf86NumDrivers; i++) if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0) xf86DeleteDriver(i); /* * At this stage we know how many screens there are. */ for (i = 0; i < xf86NumScreens; i++) xf86InitViewport(xf86Screens[i]); /* * Collect all pixmap formats and check for conflicts at the display * level. Should we die here? Or just delete the offending screens? */ screenpix24 = Pix24DontCare; for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->imageByteOrder != xf86Screens[0]->imageByteOrder) FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); if (xf86Screens[i]->bitmapScanlinePad != xf86Screens[0]->bitmapScanlinePad) FatalError("Inconsistent display bitmapScanlinePad. Exiting\n"); if (xf86Screens[i]->bitmapScanlineUnit != xf86Screens[0]->bitmapScanlineUnit) FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n"); if (xf86Screens[i]->bitmapBitOrder != xf86Screens[0]->bitmapBitOrder) FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); /* Determine the depth 24 pixmap format the screens would like */ if (xf86Screens[i]->pixmap24 != Pix24DontCare) { if (screenpix24 == Pix24DontCare) screenpix24 = xf86Screens[i]->pixmap24; else if (screenpix24 != xf86Screens[i]->pixmap24) FatalError("Inconsistent depth 24 pixmap format. Exiting\n"); } } /* check if screenpix24 is consistent with the config/cmdline */ if (xf86Info.pixmap24 != Pix24DontCare) { pix24 = xf86Info.pixmap24; pix24From = xf86Info.pix24From; if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24) pix24Fail = TRUE; } else if (screenpix24 != Pix24DontCare) { pix24 = screenpix24; pix24From = X_PROBED; } else pix24 = Pix24Use32; if (pix24Fail) FatalError("Screen(s) can't use the required depth 24 pixmap format" " (%d). Exiting\n", PIX24TOBPP(pix24)); /* Initialise the depth 24 format */ for (j = 0; j < numFormats && formats[j].depth != 24; j++) ; formats[j].bitsPerPixel = PIX24TOBPP(pix24); /* Collect additional formats */ for (i = 0; i < xf86NumScreens; i++) { for (j = 0; j < xf86Screens[i]->numFormats; j++) { for (k = 0; ; k++) { if (k >= numFormats) { if (k >= MAXFORMATS) FatalError("Too many pixmap formats! Exiting\n"); formats[k] = xf86Screens[i]->formats[j]; numFormats++; break; } if (formats[k].depth == xf86Screens[i]->formats[j].depth) { if ((formats[k].bitsPerPixel == xf86Screens[i]->formats[j].bitsPerPixel) && (formats[k].scanlinePad == xf86Screens[i]->formats[j].scanlinePad)) break; FatalError("Inconsistent pixmap format for depth %d." " Exiting\n", formats[k].depth); } } } } formatsDone = TRUE; if (xf86Info.vtno >= 0 ) { #define VT_ATOM_NAME "XFree86_VT" Atom VTAtom=-1; CARD32 *VT = NULL; int ret; /* This memory needs to stay available until the screen has been initialized, and we can create the property for real. */ if ( (VT = malloc(sizeof(CARD32)))==NULL ) { FatalError("Unable to make VT property - out of memory. Exiting...\n"); } *VT = xf86Info.vtno; VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE); for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) { ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, VTAtom, XA_INTEGER, 32, 1, VT ); if (ret != Success) xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, "Failed to register VT property\n"); } } if (SeatId) { Atom SeatAtom; SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE); for (i = 0; i < xf86NumScreens; i++) { int ret; ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, SeatAtom, XA_STRING, 8, strlen(SeatId)+1, SeatId ); if (ret != Success) { xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, "Failed to register seat property\n"); } } } /* If a screen uses depth 24, show what the pixmap format is */ for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->depth == 24) { xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n", PIX24TOBPP(pix24)); break; } } } else { /* * serverGeneration != 1; some OSs have to do things here, too. */ if (xorgHWOpenConsole) xf86OpenConsole(); #ifdef XF86PM /* should we reopen it here? We need to deal with an already opened device. We could leave this to the OS layer. For now we simply close it here */ if (xf86OSPMClose) xf86OSPMClose(); if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) xf86MsgVerb(X_INFO, 3, "APM registered successfully\n"); #endif /* Make sure full I/O access is enabled */ if (xorgHWAccess) xf86EnableIO(); } /* * Use the previously collected parts to setup pScreenInfo */ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder; pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad; pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit; pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder; pScreenInfo->numPixmapFormats = numFormats; for (i = 0; i < numFormats; i++) pScreenInfo->formats[i] = formats[i]; /* Make sure the server's VT is active */ if (serverGeneration != 1) { xf86Resetting = TRUE; /* All screens are in the same state, so just check the first */ if (!xf86Screens[0]->vtSema) { #ifdef HAS_USL_VTS ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ); #endif xf86AccessEnter(); was_blocked = xf86BlockSIGIO(); } } for (i = 0; i < xf86NumScreens; i++) if (!xf86ColormapAllocatePrivates(xf86Screens[i])) FatalError("Cannot register DDX private keys"); if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) || !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0)) FatalError("Cannot register DDX private keys"); for (i = 0; i < xf86NumScreens; i++) { xf86VGAarbiterLock(xf86Screens[i]); /* * Almost everything uses these defaults, and many of those that * don't, will wrap them. */ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; #ifdef XFreeXDGA xf86Screens[i]->SetDGAMode = xf86SetDGAMode; #endif xf86Screens[i]->DPMSSet = NULL; xf86Screens[i]->LoadPalette = NULL; xf86Screens[i]->SetOverscan = NULL; xf86Screens[i]->DriverFunc = NULL; xf86Screens[i]->pScreen = NULL; scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); xf86VGAarbiterUnlock(xf86Screens[i]); if (scr_index == i) { /* * Hook in our ScrnInfoRec, and initialise some other pScreen * fields. */ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, xf86ScreenKey, xf86Screens[i]); xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; /* The driver should set this, but make sure it is set anyway */ xf86Screens[i]->vtSema = TRUE; } else { /* This shouldn't normally happen */ FatalError("AddScreen/ScreenInit failed for driver %d\n", i); } DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n", i, xf86Screens[i]->pScreen ); DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n", i, xf86Screens[i]->pScreen->CreateWindow ); dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, xf86CreateRootWindowKey, xf86Screens[i]->pScreen->CreateWindow); xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown) { xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC); PictureSetSubpixelOrder (xf86Screens[i]->pScreen, DDC ? (DDC->features.input_type ? SubPixelHorizontalRGB : SubPixelNone) : SubPixelUnknown); } #ifdef RANDR if (!xf86Info.disableRandR) xf86RandRInit (screenInfo.screens[scr_index]); xf86Msg(xf86Info.randRFrom, "RandR %s\n", xf86Info.disableRandR ? "disabled" : "enabled"); #endif } xf86VGAarbiterWrapFunctions(); xf86UnblockSIGIO(was_blocked); xf86InitOrigins(); xf86Resetting = FALSE; xf86Initialising = FALSE; RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup, NULL); }