📄 s3misc.c
字号:
/* We found some ram, but is it ours? */ s3DisableLinear(); /* move it up by 12MB */ outb(vgaCRIndex, 0x5a); outb(vgaCRReg, 0xC0); s3EnableLinear(); if (!s3TryAddress(poker, pVal, addr, 2)) { addr += (0x0C<<20); xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem, s3BankSize); s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION, (pointer)addr, s3BankSize); if (s3NewMmio) { xf86UnMapVidMem(scr_index, MMIO_REGION, s3MmioMem, S3_NEWMMIO_REGSIZE); s3MmioMem = xf86MapVidMem(scr_index, MMIO_REGION, (pointer)(addr+S3_NEWMMIO_REGBASE), S3_NEWMMIO_REGSIZE); } if (s3TryAddress((long *)s3VideoMem, pVal, addr, 3)) { ErrorF("%s %s: Local bus LAW is 0x%03Xxxxxx\n", XCONFIG_PROBED, s3InfoRec.name, (i2 << 4 | 0x0c)); s3LinearAperture = TRUE; break; } /* * Special test for Diamond Stealth Pro. * On this card, bits 6 and 7 of register 0x5a * control address bits A29 and A26 rather than * A22 and A23. Don't ask we why. */ addr = (i2 << 24) | 0x24000000; xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem, s3BankSize); s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION, (pointer)addr, s3BankSize); if (s3NewMmio) { xf86UnMapVidMem(scr_index, MMIO_REGION, s3MmioMem, S3_NEWMMIO_REGSIZE); s3MmioMem = xf86MapVidMem(scr_index, MMIO_REGION, (pointer)(addr+S3_NEWMMIO_REGBASE), S3_NEWMMIO_REGSIZE); } if (s3TryAddress((long *)s3VideoMem, pVal, addr, 4)) { ErrorF("%s %s: Local bus LAW is 0x%03Xxxxxx\n", XCONFIG_PROBED, s3InfoRec.name, (i2 | 0x24) << 4); s3LinearAperture = TRUE; break; } } else { ErrorF("%s %s: linear framebuffer found, but", XCONFIG_PROBED, s3InfoRec.name); ErrorF(" it appears to be in a cachable\n"); ErrorF("\t address range.\n"); CachedFrameBuffer = TRUE; } s3DisableLinear(); outb(vgaCRIndex, 0x5a); outb(vgaCRReg, 0x00); /* reset for next probe */ s3EnableLinear(); } xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem, s3BankSize); if (s3NewMmio) xf86UnMapVidMem(scr_index, MMIO_REGION, s3MmioMem, S3_NEWMMIO_REGSIZE); }#ifdef PC98_PWLB }#endif } } /* The UnMap can unmap all mapped regions, so make sure vgaBase is still mapped */ xf86MapDisplay(scr_index, VGA_REGION); if (!s3LinearAperture) { ErrorF("%s %s: %s local bus framebuffer -", XCONFIG_PROBED, s3InfoRec.name, (CachedFrameBuffer? "Can't use": "Couldn't find")); ErrorF(" linear access disabled\n"); s3BankSize = 0x10000; s3VideoMem = NULL; addr = 0xA0000; } s3DisableLinear(); } } /* No linear mapping */ if (!s3VideoMem) { s3VideoMem = vgaBase; addr = 0xA0000; if (s3NewMmio) { /* doesn't work without linear mapping (yet?) */ ErrorF("%s %s: Chipset \"newmmio\" needs linear framebuffer\n", XCONFIG_GIVEN, s3InfoRec.name); ErrorF("\t\tplease specify Chipset \"mmio_928\"\n"); /* disable mmio and LB, try to avoid crashing the PC */ outb(vgaCRIndex, 0x53); outb(vgaCRReg, 0x00); outb(vgaCRIndex, 0x58); outb(vgaCRReg, 0x00); } /* If using VGA aperture, set it up */ if (s3BankSize == 0x10000) {#ifndef PC98 outb(vgaCRIndex, 0x59); outb(vgaCRReg, 0x00); outb(vgaCRIndex, 0x5a); outb(vgaCRReg, 0x0a);#else switch( pc98BoardType & 0xf0 ){ case PCSKB4: outb(vgaCRIndex, 0x59); outb(vgaCRReg, SKB4_WinAdd >> 8); outb(vgaCRIndex, 0x5a); outb(vgaCRReg, SKB4_WinAdd & 0xff); addr = SKB4_WinAdd << 16; break; case NECWAB: outb(vgaCRIndex, 0x59); outb(vgaCRReg, 0x00); outb(vgaCRIndex, 0x5a); outb(vgaCRReg, NEC_WinAdd ); addr = NEC_WinAdd << 16; break; default: outb(vgaCRIndex, 0x59); outb(vgaCRReg, 0x00); outb(vgaCRIndex, 0x5a); outb(vgaCRReg, 0x0a); }#endif s3LinApOpt = 0x14; } }#ifdef XFreeXDGA s3InfoRec.physBase = addr; s3InfoRec.physSize = s3BankSize;#endif /* Save CR59, CR5A for future calls to s3Init() */ outb(vgaCRIndex, 0x59); s3Port59 = inb(vgaCRReg); outb(vgaCRIndex, 0x5A); s3Port5A = inb(vgaCRReg); } else s3Init(s3InfoRec.modes); /* BL: for new mmio we enable linear mode */ if (s3NewMmio) { unsigned char tmp; unsigned long ltmp; WaitIdle(); outb(vgaCRIndex, 0x39); outb(vgaCRReg, 0xa5); outb (vgaCRIndex, 0x53); tmp = inb(vgaCRReg); outb (vgaCRReg, tmp | 0x18); /* old and new mmio enabled */ outb (vgaCRIndex, 0x58); outb (vgaCRReg, (s3LinApOpt & ~0x4) | s3SAM256); /* window size for linear mode */ *(volatile int *)s3VideoMem = 0x12345678; if ((ltmp = *(volatile int *)s3VideoMem) != 0x12345678) ErrorF("new mmio linear mode doesn't work ltmp %x\n",ltmp); } /* end BL */ s3InitEnvironment(); AlreadyInited = TRUE; s3ImageInit();#ifndef OSKIT /* avoid bogus bug messages for old chips */ if (serverGeneration == 1 && S3_x64_SERIES(s3ChipId)) { /* now testing Trio32 BITBLT bug * using a 2*2 pixel pattern BLT from (0,0) to (0,2) */ pat = (unsigned char*) xcalloc(s3Bpp, 2 * 2); /* init source pattern: 2*2 pixel checker pattern (glyph source) */ pat[0 * s3Bpp] = pat[3 * s3Bpp] = 0; pat[1 * s3Bpp] = pat[2 * s3Bpp] = 1; (*s3ImageWriteFunc)(0, 0, 2, 2, (char*)pat, 2 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); /* first test original BITBLT; then workaround */ for (s3Trio32FCBug = 0; s3Trio32FCBug < 2; s3Trio32FCBug++) { /* init destination (all bits set) */ for(i = 0; i < s3Bpp * 2 * 2; i++) pat[i] = (char)0xff; s3ImageWriteNoMem(0, 2, 2, 2, (char*)pat, 2 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); BLOCK_CURSOR; if (s3Trio32FCBug) { WaitQueue16_32(2, 3); SET_BKGD_MIX(BSS_BKGDCOL | MIX_OR); SET_BKGD_COLOR(0); } else { WaitQueue(1); SET_BKGD_MIX(BSS_BKGDCOL | MIX_DST); } WaitQueue16_32(3, 6); SET_FRGD_COLOR(1); SET_RD_MASK(1); SET_WRT_MASK(~0); WaitQueue(5); SET_PIX_CNTL(MIXSEL_EXPBLT | COLCMPOP_F); SET_FRGD_MIX(FSS_FRGDCOL | MIX_SRC); SET_CURPT(0,0); WaitQueue(5); SET_DESTSTP(0,2); SET_AXIS_PCNT(1, 1); SET_CMD(CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA); /* read back the destination */ WaitIdle(); (*s3ImageReadFunc)(0, 2, 2, 2, (char*)pat, 2 * s3Bpp, 0, 0, ~0);#ifdef DEBUG_TRI32_BITBLT_TEST for(i = 0; i < s3Bpp * 2 * 2; i++) ErrorF("%s %s: BITBLT %2d %02x\n", XCONFIG_PROBED, s3InfoRec.name, i, pat[i]&0xff); ErrorF("\n"); ErrorF("%s %s: ", XCONFIG_PROBED, s3InfoRec.name); for(i=k=0; i<8; i++) for(j=0; j<s3Bpp; j++,k++) ErrorF(" %02x", (k ^ ((dash_test_pattern & (1<<(15-i))) ? 0xff : 0))); ErrorF("\n\n");#endif if (pat[0] == 0xff && pat[3 * s3Bpp] == 0xff) break; /* BITBLT worked */ } /* clear source and destination patterns on the screen */ for(i = 0; i < s3Bpp * 2 * 2; i++) pat[i] = blackPixel; (*s3ImageWriteFunc)(0, 0, 2, 2, (char*)pat, 2 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); (*s3ImageWriteFunc)(0, 2, 2, 2, (char*)pat, 2 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); if (s3Trio32FCBug > 1) { ErrorF("%s %s: WARNING: BITBLT malfunction --\n" "\tplease report to XFree86@XFree86.Org\n", XCONFIG_PROBED, s3InfoRec.name); } else if (s3Trio32FCBug) { ErrorF("%s %s: BITBLT malfunction, using workaround code\n", XCONFIG_PROBED, s3InfoRec.name); } xfree(pat); /* restore read mask */ WaitQueue16_32(1, 2); SET_RD_MASK(0); /* now testing S3 968 dashed line bug :-( * using an 8 pixel line (0,0) to (7,0) */ pat = (unsigned char*) xcalloc(s3Bpp, 8); /* first test original dashed line code (MIX_DST); * then workaround ( MIX_OR zero) */ for (s3_968_DashBug = 0; s3_968_DashBug < 2; s3_968_DashBug++) { /* init region with backgound pattern */ for(i=0; i<s3Bpp*8; i++) pat[i] = i; (*s3ImageWriteFunc)(0, 0, 8, 1, (char*)pat, 8 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); /* read back the destination */ WaitIdle(); (*s3ImageReadFunc)(0, 0, 8, 1, (char*)pat, 8 * s3Bpp, 0, 0, ~0); BLOCK_CURSOR; WaitQueue16_32(3,4); SET_FRGD_MIX(FSS_FRGDCOL | MIX_XOR); if (s3_968_DashBug) { SET_BKGD_COLOR(0); SET_BKGD_MIX(BSS_BKGDCOL | MIX_OR); } else { SET_BKGD_MIX(BSS_BKGDCOL | MIX_DST); } WaitQueue16_32(4,6); SET_WRT_MASK(~0); SET_FRGD_COLOR(~0); SET_PIX_CNTL(MIXSEL_EXPPC | COLCMPOP_F); WaitQueue(7); SET_CURPT(0,0); SET_MAJ_AXIS_PCNT(8-1); SET_DESTSTP(2*(0-8), 2*0); SET_ERR_TERM(2*0 - 8 -1); SET_CMD(CMD_LINE | DRAW | LASTPIX | PLANAR | INC_X | INC_Y | PCDATA | _16BIT | WRTDATA); SET_PIX_TRANS_W(dash_test_pattern); /* read back the destination */ WaitIdle(); (*s3ImageReadFunc)(0, 0, 8, 1, (char*)pat, 8 * s3Bpp, 0, 0, ~0);#ifdef DEBUG_968_DASH_TEST ErrorF("%s %s: DASH968 %d ", XCONFIG_PROBED, s3InfoRec.name,s3_968_DashBug); for(i = 0; i < s3Bpp * 8; i++) ErrorF(" %02x", pat[i]&0xff); ErrorF("\n"); ErrorF("%s %s: ", XCONFIG_PROBED, s3InfoRec.name); for(i=k=0; i<8; i++) for(j=0; j<s3Bpp; j++,k++) ErrorF(" %02x", (k ^ ((dash_test_pattern & (1<<(15-i))) ? 0xff : 0))); ErrorF("\n\n");#endif ok = 1; for(i=k=0; i<8; i++) for(j=0; j<s3Bpp; j++,k++) if (pat[k] != (k ^ ((dash_test_pattern & (1<<(15-i))) ? 0xff : 0))) ok = 0; if (ok) break; /* dashed line worked */ } /* clear the test region */ for(i=0; i<s3Bpp*8; i++) pat[i] = blackPixel; (*s3ImageWriteFunc)(0, 0, 8, 1, (char*)pat, 8 * s3Bpp, 0, 0, (short) s3alu[GXcopy], ~0); if (s3_968_DashBug > 1) { ErrorF("%s %s: WARNING: S3 968 dashed line malfunction --\n" "\tplease report to XFree86@XFree86.Org\n", XCONFIG_PROBED, s3InfoRec.name); } else if (s3_968_DashBug) { ErrorF("%s %s: S3 968 dashed line malfunction, using workaround code\n", XCONFIG_PROBED, s3InfoRec.name); } xfree(pat); }#endif /* !OSKIT */ WaitQueue16_32(3,4); SET_FRGD_COLOR(1); SET_PIX_CNTL(MIXSEL_EXPBLT | COLCMPOP_F);#ifndef OSKIT xf86InitCache(s3CacheMoveBlock); s3FontCache8Init();#endif /* !OSKIT */ /* * Take display resolution from the -dpi flag if specified */ if (monitorResolution) displayResolution = monitorResolution; if (!s3ScreenInit(pScreen, (pointer) s3VideoMem, s3InfoRec.virtualX, s3InfoRec.virtualY, displayResolution, displayResolution, s3DisplayWidth)) return (FALSE);#ifndef OSKIT switch (s3InfoRec.bitsPerPixel) { case 8: pScreen->InstallColormap = s3InstallColormap; pScreen->UninstallColormap = s3UninstallColormap; pScreen->ListInstalledColormaps = s3ListInstalledColormaps; pScreen->StoreColors = s3StoreColors; break; case 16: case 24: case 32: pScreen->InstallColormap = cfbInstallColormap; pScreen->UninstallColormap = cfbUninstallColormap; pScreen->ListInstalledColormaps = cfbListInstalledColormaps; pScreen->StoreColors = (void (*)())NoopDDA; } pScreen->QueryBestSize = s3QueryBestSize; xf86PointerScreenFuncs.WarpCursor = s3WarpCursor; (void)s3CursorInit(0, pScreen);#endif /* !OSKIT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -