xf86init.c
来自「基于组件方式开发操作系统的OSKIT源代码」· C语言 代码 · 共 868 行 · 第 1/2 页
C
868 行
/* * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.66.2.2 1997/06/29 08:43:36 dawes Exp $ * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Thomas Roell not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Thomas Roell makes no representations * about the suitability of this software for any purpose. It is provided * "as is" without express or implied warranty. * * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THOMAS ROELL BE LIABLE FOR 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. *//* $XConsortium: xf86Init.c /main/37 1996/10/23 18:43:39 kaleb $ */#ifndef X_NOT_STDC_ENV#include <stdlib.h>#elseextern int atoi();#endif#define NEED_EVENTS#include "X.h"#include "Xmd.h"#include "Xproto.h"#ifndef OSKIT#include "input.h"#include "servermd.h"#endif /* !OSKIT */#include "scrnintstr.h"#ifndef OSKIT#include "site.h"#endif /* !OSKIT */#include "compiler.h"#include "xf86.h"#include "xf86Procs.h"#include "xf86_OSlib.h"#ifndef OSKIT#include "xf86Version.h"#include "mipointer.h"#ifdef XINPUT#include "XI.h"#include "XIproto.h"#include "xf86_Config.h"#include "xf86Xinput.h"#else#include "inputstr.h"#endif#include "opaque.h"#endif /* !OSKIT */#ifdef XTESTEXT1#include "atKeynames.h"extern int xtest_command_key;#endif /* XTESTEXT1 */#ifdef PC98#include "pc98_vers.h"#endif#ifdef __EMX__#define seteuid(x) /*nothing*/#define setruid(x) /*nothing*/#endif/* xf86Exiting is set while the screen is shutting down (even on a reset) */Bool xf86Exiting = FALSE;Bool xf86Resetting = FALSE;Bool xf86ProbeFailed = TRUE;Bool xf86FlipPixels = FALSE;#ifdef XF86VIDMODEBool xf86VidModeEnabled = TRUE;Bool xf86VidModeAllowNonLocal = FALSE;#endif#ifdef XF86MISCBool xf86MiscModInDevEnabled = TRUE;Bool xf86MiscModInDevAllowNonLocal = FALSE;#endifBool xf86AllowMouseOpenFail = FALSE;PciProbeType xf86PCIFlags = PCIProbe1;Bool xf86ScreensOpen = FALSE;int xf86Verbose = 1;Bool xf86fpFlag = FALSE;Bool xf86coFlag = FALSE;Bool xf86sFlag = FALSE;Bool xf86ProbeOnly = FALSE;char xf86ConfigFile[PATH_MAX] = "";int xf86bpp = -1;xrgb xf86weight = { 0, 0, 0 } ; /* RGB weighting at 16 bpp */double xf86rGamma=1.0, xf86gGamma=1.0, xf86bGamma=1.0;unsigned char xf86rGammaMap[256], xf86gGammaMap[256], xf86bGammaMap[256];char *xf86ServerName = NULL;Bool xf86BestRefresh = FALSE;int vgaIOBase = 0x3d0;int vgaCRIndex = 0x3d4;int vgaCRReg = 0x3d5;static void xf86PrintBanner(#if NeedFunctionPrototypes void#endif );static void xf86PrintConfig(#if NeedFunctionPrototypes void#endif );#ifdef DO_CHECK_BETAvoid xf86CheckBeta(#if NeedFunctionPrototypes int, char *#endif );static int extraDays = 0;static char *expKey = NULL;#endifextern ScrnInfoPtr xf86Screens[];extern int xf86MaxScreens;extern double pow();#ifdef USE_XF86_SERVERLOCKextern void xf86UnlockServer();#endif#ifdef __EMX__extern void os2ServerVideoAccess();#endifxf86InfoRec xf86Info;int xf86ScreenIndex;/* * InitOutput -- * Initialize screenInfo for all actually accessible framebuffers. * That includes vt-manager setup, querying all possible devices and * collecting the pixmap formats. */void#ifndef OSKITInitOutput(pScreenInfo, argc, argv)#elseInitOutput(pScreenInfo)#endif ScreenInfo *pScreenInfo;#ifndef OSKIT int argc; char **argv;#endif{ int i, j, scr_index; static int numFormats = 0; static PixmapFormatRec formats[MAXFORMATS]; static unsigned long generation = 0; int any_screens = 0; #ifdef __EMX__ os2ServerVideoAccess(); /* See if we have access to the screen before doing anything */#endif if (serverGeneration == 1) {#ifndef OSKIT if ((xf86ServerName = strrchr(argv[0], '/')) != 0) xf86ServerName++; else xf86ServerName = argv[0];#endif /* !OSKIT */#ifdef DO_CHECK_BETA xf86CheckBeta(extraDays, expKey);#endif#ifndef OSKIT xf86PrintBanner();#endif /* !OSKIT */ xf86PrintConfig(); xf86OpenConsole();#if !defined(AMOEBA) && !defined(MINIX) && !defined (OSKIT) /* * If VTInit was set, run that program with consoleFd as stdin and stdout */ if (xf86Info.vtinit) { switch(fork()) { case -1: FatalError("Fork failed for VTInit (%s)\n", strerror(errno)); break; case 0: /* child */ setuid(getuid()); /* set stdin, stdout to the consoleFd */ for (i = 0; i < 2; i++) { if (xf86Info.consoleFd != i) { close(i); dup(xf86Info.consoleFd); } } execl("/bin/sh", "sh", "-c", xf86Info.vtinit, NULL); ErrorF("Warning: exec of /bin/sh failed for VTInit (%s)\n", strerror(errno)); exit(255); break; default: /* parent */ wait(NULL); } }#endif /* !AMOEBA && !MINIX */#ifndef OSKIT /* Do this after XF86Config is read (it's normally in OsInit()) */ OsInitColors();#endif /* !OSKIT */ for (i=0; i<256; i++) { xf86rGammaMap[i] = (int)(pow(i/255.0,xf86rGamma)*255.0+0.5); xf86gGammaMap[i] = (int)(pow(i/255.0,xf86gGamma)*255.0+0.5); xf86bGammaMap[i] = (int)(pow(i/255.0,xf86bGamma)*255.0+0.5); } xf86Config(TRUE); /* Probe displays, and resolve modes */#ifdef XKB xf86InitXkb();#endif#ifndef OSKIT /* * collect all possible formats */ formats[0].depth = 1; formats[0].bitsPerPixel = 1; formats[0].scanlinePad = BITMAP_SCANLINE_PAD; numFormats++; for ( i=0; i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured; i++ ) { /* * At least one probe function succeeded. */ any_screens = 1; /* * add new pixmap format */ for ( j=0; j < numFormats; j++ ) { if (formats[j].depth == xf86Screens[i]->depth && formats[j].bitsPerPixel == xf86Screens[i]->bitsPerPixel) break; /* found */ } if (j == numFormats) { /* not already there */ formats[j].depth = xf86Screens[i]->depth; formats[j].bitsPerPixel = xf86Screens[i]->bitsPerPixel; formats[j].scanlinePad = BITMAP_SCANLINE_PAD; numFormats++; if ( numFormats > MAXFORMATS ) FatalError( "Too many pixmap formats! Exiting\n" ); } } if (!any_screens) if (xf86ProbeFailed) ErrorF("\n *** None of the configured devices were detected.***\n\n"); else ErrorF( "\n *** A configured device found, but display modes could not be resolved.***\n\n"); if (xf86ProbeOnly) { xf86VTSema = FALSE; OsCleanup(); AbortDDX(); fflush(stderr); exit(0); }#endif /* !OSKIT */ } else { /* * serverGeneration != 1; some OSs have to do things here, too. */ xf86OpenConsole(); }#ifndef OSKIT /* * Install signal handler for unexpected signals */ if (!xf86Info.notrapSignals) { xf86Info.caughtSignal=FALSE; signal(SIGSEGV,xf86SigHandler); signal(SIGILL,xf86SigHandler);#ifdef SIGEMT signal(SIGEMT,xf86SigHandler);#endif signal(SIGFPE,xf86SigHandler);#ifdef SIGBUS signal(SIGBUS,xf86SigHandler);#endif#ifdef SIGSYS signal(SIGSYS,xf86SigHandler);#endif#ifdef SIGXCPU signal(SIGXCPU,xf86SigHandler);#endif#ifdef SIGXFSZ signal(SIGXFSZ,xf86SigHandler);#endif } /* * Use the previous collected parts to setup pScreenInfo */ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; pScreenInfo->numPixmapFormats = numFormats; for ( i=0; i < numFormats; i++ ) pScreenInfo->formats[i] = formats[i];#endif /* !OSKIT */ if (generation != serverGeneration) { xf86ScreenIndex = AllocateScreenPrivateIndex(); generation = serverGeneration; } for ( i=0; i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured; i++ ) { /* * On a server-reset, we have explicitely to remap all stuff ... * (At startuptime this is implicitely done by probing the device */ if (serverGeneration != 1) { xf86Resetting = TRUE; xf86Exiting = FALSE;#ifdef HAS_USL_VTS if (!xf86VTSema) ioctl(xf86Info.consoleFd,VT_RELDISP,VT_ACKACQ);#endif xf86VTSema = TRUE; (xf86Screens[i]->EnterLeaveVT)(ENTER, i); xf86Resetting = FALSE; }#ifdef SCO else { /* * Under SCO we must ack that we got the console at startup, * I think this is the safest way to assure it */ static int once = 1; if (once) { once = 0; if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) ErrorF("VT_ACKACQ failed"); } }#endif /* SCO */#ifdef OSKIT scr_index = AddScreen(xf86Screens[i]->Init, NULL, 0);#else scr_index = AddScreen(xf86Screens[i]->Init, argc, argv);#endif /* !OSKIT */ if (scr_index > -1) { screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr = (pointer)xf86Screens[i]; }#ifndef OSKIT /* * Here we have to let the driver getting access of the VT. Note that * this doesn't mean that the graphics board may access automatically * the monitor. If the monitor is shared this is done in xf86CrossScreen! */ if (!xf86Info.sharedMonitor) (xf86Screens[i]->EnterLeaveMonitor)(ENTER);#endif /* !OSKIT */ }#if !defined(AMOEBA) && !defined(OSKIT) RegisterBlockAndWakeupHandlers(xf86Block, xf86Wakeup, (void *)0);#endif}#ifndef OSKIT/* * InitInput -- * Initialize all supported input devices...what else is there * besides pointer and keyboard? Two DeviceRec's are allocated and * registered as the system pointer and keyboard devices. */voidInitInput(argc, argv) int argc; char **argv;{ xf86Info.vtRequestsPending = FALSE; xf86Info.inputPending = FALSE;#ifdef XTESTEXT1 xtest_command_key = KEY_Begin + MIN_KEYCODE;#endif /* XTESTEXT1 */ xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE); xf86Info.pMouse = AddInputDevice(xf86Info.mouseDev->mseProc, TRUE); RegisterKeyboardDevice(xf86Info.pKeyboard); RegisterPointerDevice(xf86Info.pMouse); #ifdef XINPUT
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?