/*
 * Do all things that need root privileges early 
 * and revoke those priviledges 
 */
_X_EXPORT void
xf86PrivilegedInit(void)
{
    xf86EnableIO();
    checkDevMem(TRUE);
    pci_system_init();
    xf86OpenConsole();
}
Example #2
0
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
    pVidMem->linearSupported = TRUE;
    pVidMem->mapMem = ppcMapVidMem;
    pVidMem->unmapMem = ppcUnmapVidMem;
    pVidMem->initialised = TRUE;
    xf86EnableIO();
}
Example #3
0
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
    xf86OpenConsole();
    
    pVidMem->initialised = TRUE;
    
    pci_system_init_dev_mem(xf86Info.consoleFd);
    xf86EnableIO();
}
Example #4
0
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
    xf86OpenConsole();
    
    pVidMem->linearSupported = TRUE;
    pVidMem->mapMem = ppcMapVidMem;
    pVidMem->unmapMem = ppcUnmapVidMem;
    pVidMem->initialised = TRUE;
    
    pci_system_init_dev_mem(xf86Info.consoleFd);
    xf86EnableIO();
}
Example #5
0
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");
}
Example #6
0
/*
 * xf86VTSwitch --
 *      Handle requests for switching the vt.
 */
static void
xf86VTSwitch(void)
{
  int i;
  static int prevSIGIO;
  InputInfoPtr pInfo;
  IHPtr ih;

  DebugF("xf86VTSwitch()\n");

#ifdef XFreeXDGA
  if(!DGAVTSwitch())
	return;
#endif

  /*
   * Since all screens are currently all in the same state it is sufficient
   * check the first.  This might change in future.
   */
  if (xf86Screens[0]->vtSema) {

    DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
	   BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
#ifdef DPMSExtension
    if (DPMSPowerLevel != DPMSModeOn)
	DPMSSet(serverClient, DPMSModeOn);
#endif
    for (i = 0; i < xf86NumScreens; i++) {
      if (!(dispatchException & DE_TERMINATE))
	if (xf86Screens[i]->EnableDisableFBAccess)
	  (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
    }

    /*
     * Keep the order: Disable Device > LeaveVT
     *                        EnterVT > EnableDevice
     */
    for (ih = InputHandlers; ih; ih = ih->next)
      xf86DisableInputHandler(ih);
    for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
      if (pInfo->dev) {
          xf86ReleaseKeys(pInfo->dev);
          ProcessInputEvents();
          DisableDevice(pInfo->dev, TRUE);
      }
    }

    prevSIGIO = xf86BlockSIGIO();
    for (i = 0; i < xf86NumScreens; i++)
	xf86Screens[i]->LeaveVT(i, 0);

    xf86AccessLeave();      /* We need this here, otherwise */

    if (!xf86VTSwitchAway()) {
      /*
       * switch failed
       */

      DebugF("xf86VTSwitch: Leave failed\n");
      xf86AccessEnter();
      for (i = 0; i < xf86NumScreens; i++) {
	if (!xf86Screens[i]->EnterVT(i, 0))
	  FatalError("EnterVT failed for screen %d\n", i);
      }
      if (!(dispatchException & DE_TERMINATE)) {
	for (i = 0; i < xf86NumScreens; i++) {
	  if (xf86Screens[i]->EnableDisableFBAccess)
	    (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
	}
      }
      dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);

      pInfo = xf86InputDevs;
      while (pInfo) {
        if (pInfo->dev)
            EnableDevice(pInfo->dev, TRUE);
	pInfo = pInfo->next;
      }
      for (ih = InputHandlers; ih; ih = ih->next)
        xf86EnableInputHandler(ih);

      xf86UnblockSIGIO(prevSIGIO);

    } else {
#ifdef XF86PM
	  if (xf86OSPMClose)
	      xf86OSPMClose();
	  xf86OSPMClose = NULL;
#endif

	for (i = 0; i < xf86NumScreens; i++) {
 	    /*
 	     * zero all access functions to
 	     * trap calls when switched away.
 	     */
	    xf86Screens[i]->vtSema = FALSE;
	}
	if (xorgHWAccess)
	    xf86DisableIO();
    }
  } else {
    DebugF("xf86VTSwitch: Entering\n");
    if (!xf86VTSwitchTo()) return;

#ifdef XF86PM
    xf86OSPMClose = xf86OSPMOpen();
#endif

    if (xorgHWAccess)
	xf86EnableIO();
    xf86AccessEnter();
    for (i = 0; i < xf86NumScreens; i++) {
      xf86Screens[i]->vtSema = TRUE;
      if (!xf86Screens[i]->EnterVT(i, 0))
	  FatalError("EnterVT failed for screen %d\n", i);
    }
    for (i = 0; i < xf86NumScreens; i++) {
      if (xf86Screens[i]->EnableDisableFBAccess)
	(*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
    }

    /* Turn screen saver off when switching back */
    dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);

    pInfo = xf86InputDevs;
    while (pInfo) {
      if (pInfo->dev)
          EnableDevice(pInfo->dev, TRUE);
      pInfo = pInfo->next;
    }

    for (ih = InputHandlers; ih; ih = ih->next)
      xf86EnableInputHandler(ih);

    xf86UnblockSIGIO(prevSIGIO);
  }
}
Example #7
0
/*
 * 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);
}
Example #8
0
int main(void)
{
    int i, HTotal, HDisplay, HSyncStart, HSyncEnd,
    VTotal, VDisplay, VSyncStart, VSyncEnd;
    unsigned char storeReg, bpp, shift, IOSS = 0, MSS = 0, again = 0;
    unsigned short port;
    int isHiQV = 0;
    int is69030 = 0;

    xf86EnableIO();

    printf("0x3C6\t0x%X\n",inw(0x3C6));

/* Check to see if the Chip is HiQV */
    outb(0x3D6,0x02);
    storeReg = inb(0x3D7);
    if (storeReg == 0xE0	/* CT65550 */
	|| storeReg == 0xE4	/* CT65554 */
	|| storeReg == 0xE5	/* CT65555 */
	|| storeReg == 0xF4	/* CT68554 */
	|| storeReg == 0xC0)	/* CT69000 */
    {
	isHiQV = 1;
    } else if (storeReg == 0x30) {
      outb(0x3D6,0x03);
      storeReg = inb(0x3D7);
      if (storeReg == 0xC) {
	isHiQV = 1;
	is69030 = 1;
	IOSS=inb(0x3CD);
	MSS=inb(0x3CB);
	outb(0x3CD,((IOSS&0xE0)| 0x11));  /* Select Channel 0 */
	outb(0x3CB,((MSS&0xF0)| 0x8));
	again = 1;
	printf("Pipeline A:\n");
      }
    }

 again:
    printf("port 0x3D6 (C&T)\n");
    storeReg = inb(0x3D6);
    shift = 3;
    if (isHiQV==1) {
	outw(0x102,1);	/*global enable, VGA awake*/
	printf("0x%2.2X\n",inb(0x3C3)&0xFF);
	outb(0x3C3,0);	/*disable VGA*/
	outb(0x3C3,1);	/*enable VGA*/
	for(i = 0;i < 0xFF;i++){
	    outb(0x3D6,i);
	    printf("XR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D7)&0xFF);
	}
	outb(0x3D6,0xE2);
	bpp = inb(0x3D7)&0xF0;
    } else {
	outb(0x3D6, 0x70);
	outw(0x3D6, (inw(0x3D6) | 0x8070));
	outw(0x46E8,0x0016);	/*setup mode*/
	outw(0x102,1);	/*global enable, VGA awake*/
	outw(0x46E8,0x000E);	/*exit from setup mode*/
	printf("0x%2.2X\n",inb(0x3C3)&0xFF);
	outb(0x3C3,0);	/*disable VGA*/
	outw(0x46E8,0x0000);	/*exit from setup mode*/
	outw(0x46E8,0x000E);	/*exit from setup mode*/
	outb(0x3C3,1);	/*enable VGA*/
	outw(0x46E8,0x0000);	/*exit from setup mode*/
	for(i = 0;i < 0x80;i++){
	    outb(0x3D6,i);
	    printf("XR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D7)&0xFF);
	}
	outb(0x3D6,0x2B);
	bpp = inb(0x3D7)&0xF0;
    }

    switch(bpp){
      case 0x20:
	bpp = 4;
	break;
      case 0x30:
	bpp = 8;
	break;
      case 0x40:
	bpp = 16;
	shift = 2;
	break;
      case 0x50:
	bpp = 24;
	break;
      default:
	bpp = 0;
    }
    outb(0x3D6,storeReg);

    printf("\nport 0x3D4 (CRTC)\n");
    storeReg = inb(0x3D4);
    if (isHiQV==1) {
	for(i = 0;i < 0x7F;i++){
	    outb(0x3D4,i);
	    printf("CR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D5)&0xFF);
	}
	outb(0x3D4,storeReg);
	printf("\nport 0x3D0 (Flat Panel)\n");
	storeReg = inb(0x3D0);
	for(i = 0;i < 0x7F;i++){
	    outb(0x3D0,i);
	    printf("FR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D1)&0xFF);
	}
	outb(0x3D1,storeReg);
	printf("\nport 0x3D2 (Multimedia)\n");
	storeReg = inb(0x3D2);
	for(i = 0;i < 0x7F;i++){
	    outb(0x3D2,i);
	    printf("MR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D3)&0xFF);
	}
	outb(0x3D3,storeReg);
    } else {
	for(i = 0;i < 0x40;i++){
	    outb(0x3D4,i);
	    printf("CR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D5)&0xFF);
	}
	outb(0x3D4,storeReg);
    }


    printf("port 0x3CE (GC)\n");
    storeReg = inb(0x3CE);
    for(i = 0;i < 0x10;i++){
	outb(0x3CE,i);
	printf("GC 0x%2.2X\t0x%2.2X\n",i,inb(0x3CF)&0xFF);
    }
    outb(0x3CE,storeReg);
    printf("port 0x3C4 (Sequencer)\n");
    storeReg = inb(0x3C4);
    for(i = 0;i < 0x10;i++){
	outb(0x3C4,i);
	printf("SQ 0x%2.2X\t0x%X2.2\n",i,inb(0x3C5)&0xFF);
    }
    outb(0x3C4,storeReg);


    printf("port 0x3C0 (Attribute)\n");
    inb(0x3DA);
    storeReg = inb(0x3C0);
    for(i = 0;i < 0xFF;i++){
	inb(0x3DA);
	outb(0x3C0,i);
	printf("AT 0x%2.2X\t0x%2.2X\n",i,inb(0x3C1)&0xFF);
    }
    inb(0x3DA);
    outb(0x3C0,storeReg);

    printf("0x3CC\t0x%X\n",inb(0x3CC)&0xFF);
    printf("0x3C2\t0x%X\n",inb(0x3C2)&0xFF);
    printf("0x3C3\t0x%X\n",inb(0x3C2)&0xFF);
    printf("0x3CA\t0x%X\n",inb(0x3CA)&0xFF);
    printf("0x3DA\t0x%X\n",inb(0x3DA)&0xFF);

    printf("\nRAMDAC\nport\tvalue\n");
    for(port = 0x83C6; port < 0x83CA;port++){
      printf("0x%4X\t0x%4X\n",port,inw(port));
    }

    if (isHiQV!=1) {
	printf("\nBitBLT\nport\tvalue\n");
	for(port = 0x83D0; port <= 0x9FD0;port+=0x400){
	    printf("0x%4.4X\t0x%4X\n",port,inw(port));
	}

	printf("\nH/W cursor\nport\tvalue\n");
	for(port = 0xA3D0; port <= 0xB3D0;port+=0x400){
	    printf("0x%4.4X\t0x%4X\n",port,inw(port));
	}


	outb(0x3D6, 0x70);
	outw(0x3D6, (inw(0x3D6) | 0x8070));

	printf("0x46E8\t0x%8X\n",inl(0x46E8));
	printf("0x4AE8\t0x%8X\n",inl(0x4AE8));
	printf("0x102\t0x%8X\n",inl(0x102));
	printf("0x103\t0x%8X\n",inl(0x103));

    }

    storeReg = inb(0x3D4);
    {
	unsigned char tmp;

	outb(0x3D4,0);
	HTotal = ((inb(0x3D5)&0xFF) + 5) << shift;
	outb(0x3D4,1);
	HDisplay = ((inb(0x3D5)&0xFF) + 1) << shift;
	outb(0x3D4,4);
	HSyncStart = inb(0x3D5)&0xFF;
	outb(0x3D4,5);
	HSyncEnd = inb(0x3D5)&0x1F;
	HSyncEnd |= HSyncStart & ~0x1F;
	if (HSyncStart > HSyncEnd)
	    HSyncEnd += (0x1F + 1);
	HSyncStart++;
	HSyncEnd++;
	HSyncStart <<= shift;
	HSyncEnd <<= shift;

	outb(0x3D4,6);
	VTotal = inb(0x3D5)&0xFF;
	outb(0x3D4,7);
	tmp = inb(0x3D5)&0xFF;
	VTotal |= (tmp&0x1) << 8;
	VTotal |= (tmp&0x20) << 4;
	VTotal += 2;
	VDisplay = (tmp&0x2) << 7;
	VDisplay |= (tmp&0x40) << 3;
	VSyncStart = (tmp&0x4) << 6;
	VSyncStart |= (tmp&0x80) << 2;
	outb(0x3D4,0x12);
	VDisplay |= inb(0x3D5)&0xFF;
	VDisplay += 1;
	outb(0x3D4,0x10);
	VSyncStart |= inb(0x3D5)&0xFF;
	outb(0x3D4,0x11);
	VSyncEnd = inb(0x3D5)&0xF;
	VSyncEnd |= VSyncStart & ~0xF;
	if (VSyncStart > VSyncEnd)
	    VSyncEnd += (0xF + 1);
	VSyncStart++;
	VSyncEnd++;

    }
    outb(0x3D4,storeReg);

    printf("\nModeLine with port 0x3D4 (CRTC) %d %d %d %d %d %d %d %d\n",
	   HDisplay, HSyncStart, HSyncEnd, HTotal,
	   VDisplay, VSyncStart, VSyncEnd, VTotal);


    if (is69030==1) {
      if (again==1) {
	again=0;
	printf("\n\nPipeline B:\n");
	outb(0x3CD,((IOSS&0xE0)| 0x1F));  /* Select Channel 1 */
	outb(0x3CB,((MSS&0xF0)| 0xF));
	goto again;
      } else {
	outb(0x3CD,IOSS);
	outb(0x3CB,MSS);
	printf("\n\n0x3CB\t0x%X  (MSS)\n",inb(0x3CB)&0xFF);
	printf("0x3CD\t0x%X  (IOSS)\n",inb(0x3CD)&0xFF);
      }
    }
    xf86DisableIO();
    return 0;
}
Example #9
0
void
ppcPciIoMap(int bus)
{
	xf86EnableIO();
}
Example #10
0
int
main(int argc, char *argv[])
{
    pciConfigPtr pPCI, *pcrpp = NULL;
    int Verbose = 0;
    int i = 0;
    int force = 0;
    int c;

    xf86Info.pciFlags = PCIProbe1;

    while ((c = getopt(argc, argv, "?v12OfV:")) != -1)
	switch(c) {
	case 'v':
	    Verbose++;
	    break;
	case '1':
	    xf86Info.pciFlags = PCIProbe1;
	    break;
	case '2':
	    xf86Info.pciFlags = PCIProbe2;
	    break;
	case 'O':
	    xf86Info.pciFlags = PCIOsConfig;
	    break;
	case 'f':
	    force = 1;
	    break;
	case 'V':
	    xf86Verbose = atoi(optarg);
	    break;
	case '?':
	default:
	    usage();
	    exit (1);
	    break;
	}

    if (force)
	switch (xf86Info.pciFlags) {
	case PCIProbe1:
	    xf86Info.pciFlags = PCIForceConfig1;
	    break;
	case PCIProbe2:
	    xf86Info.pciFlags = PCIForceConfig2;
	    break;
	default:
	    break;
	}

    xf86EnableIO();
    pcrpp = xf86scanpci(0);

    if (!pcrpp) {
	printf("No PCI devices found\n");
	xf86DisableIO();
	exit (1);
    }

    while ((pPCI = pcrpp[i++]))
	identify_card(pPCI, Verbose);

    if (Verbose > 1) {
	printf("\nPCI bus linkages:\n\n");

	for (i = 0;  i < MAX_PCI_BUSES;  i++) {
	    pciBusInfo_t *pBusInfo;

	    if (!(pBusInfo = pciBusInfo[i]))
		continue;

	    if ((pPCI = pBusInfo->bridge))
		printf("PCI bus 0x%04x has parent bridge 0x%04x:0x%02x:0x%1x\n",
		       i, pPCI->busnum, pPCI->devnum, pPCI->funcnum);
	    else
		printf("PCI bus 0x%04x has no parent\n", i);
	}
    }

    xf86DisableIO();
    exit(0);
}