⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mach32info.c

📁 linux 下svgalib编的一个界面程序示例
💻 C
📖 第 1 页 / 共 3 页
字号:
    j = inw(MEM_CFG);    printf("\nMEM_CFG:\t\t%04x\n", j);    putstr("Memory aperture", aperture[j & 3]);    putint("Memory aperture page (for 1MB aperture)", "  %d", (j >> 2) & 3);    if ((bus == 7) || (((bus == 5) || (bus == 6)) && (inw(CONF_STAT2) & 0x2000)))	putint("Memory aperture location (0-4 GB)", "  %d MB", j >> 4);    else {	putint("Reserved (7:4)", "  %x", (j >> 4) & 0xf);	putint("Memory aperture location (0-128 MB)", "  %d MB", j >> 8);    }    j = inw(LOCAL_CNTL);    printf("\nLOCAL_CNTL:\t\t%04x\n", j);    putflag("6 clock non page cycle", j & 0x0001);    putflag("7 clock non page cycle", j & 0x0002);    putflag("1/2 memory clock CAS precharge time", j & 0x0004);    putflag("RAMDAC clocked on positive clock edge", j & 0x0008);    putflag("FIFO testing", j & 0x0010);    if (chip_id == ATI68800_3)	putint("Filtering of 1 clock IOW low or high pulse", "  %d", (j >> 5) & 3);    else {	putflag("Memory mapped registers", j & 0x0020);	putflag("Local Bus BIOS ROM decode", j & 0x0040);    }    putint("ROM wait states", "  %d", (j >> 7) & 7);    putint("Memory read wait states", "  %d", (j >> 10) & 3);    if (chip_id == ATI68800AX)	putint("Additional I/O waitstates", "  %d", (j >> 12) & 15);    else	putint("Minimum Local Bus waistates", "  %d", (j >> 12) & 15);    j = inw(R_MISC_CNTL);    printf("\nR_MISC_CNTL:\t\t%04x\n", j);    putint("Reserved (3:0)", "  %x", j & 15);    putint("ROM page select", "  %d KB", (j >> 3) & 0x1e);    putint("Blank adjust (delays BLANK_1_PCLK for RAMDAC type 2)", "  %d", (j >> 8) & 3);    putint("Pixel data skew from PCLK (pixel delay)", "  %d", (j >> 10) & 3);    putint("Reserved (15:12)", "  %x", (j >> 12) & 15);    j = inw(PCI_CNTL);    printf("\nPCI_CNTL:\t\t%04x\n", j);    putint("RAMDAC read/write waitstates", "  %d", j & 7);    putflag("Target abort cycle", j & 0x0004);    putflag("PCI RAMDAC delay", j & 0x0010);    putflag("Snooping on DAC read", j & 0x0020);    putflag("0 waitstates on aperture burst write", j & 0x0040);    putflag("Fast memory mapped I/O read/write", j & 0x0080);    putint("Reserved (15:8)", "  %02x", (j >> 8) & 0xff);    fputs("\nReading in EEPROM... (some screen flicker will occur)", stdout);    fflush(stdout);    for (i = 0; i < 128; i++)	eeprom[i] = mach32_eeget(i);    puts(" ...done.\n");    fputs("EEPROM contents:", stdout);    for (i = 0; i < 128; i++) {	if (i & 7)	    putchar(' ');	else	    fputs("\n   ", stdout);	printf(" %02x-%04x", i, eeprom[i]);    }    puts("\n\nDecoded info out of EEPROM:");    putword(0);    putint("EEPROM write counter", "  %d", eeprom[0]);    putword(1);    switch (eeprom[1] & 0xff) {    case 0x00:	ptr = "  disabled";	break;    case 0x08:	ptr = "  secondary address";	break;    case 0x18:	ptr = "  primary address";	break;    default:	ptr = "  reserved";    }    putstr("Mouse address select", ptr);    switch ((eeprom[1] >> 8) & 0xff) {    case 0x20:	ptr = "  IRQ 5";	break;    case 0x28:	ptr = "  IRQ 4";	break;    case 0x30:	ptr = "  IRQ 3";	break;    case 0x38:	ptr = "  IRQ 2";	break;    default:	ptr = "  reserved";    }    putstr("Mouse interrupt handler select", ptr);    j = putword(2);    switch ((j >> 8) & 0xff) {    case 0x03:    case 0x05:    case 0x07:    case 0x09:    case 0x0b:    case 0x12:    case 0x13:    case 0x15:    case 0x17:    case 0x19:    case 0x1b:	sprintf(ptr = buffer, "  %cGA %s", (j & 0x1000) ? 'E' : 'V',		videomonames[(((j >> 8) & 0xf) - 1) >> 1]);	break;    case 0x20:	ptr = "  CGA";	break;    case 0x30:	ptr = "  Hercules 720x348";	break;    case 0x40:	ptr = "  Hercules 640x400";	break;    default:	ptr = "  reserved";    }    putstr("Power up video mode", ptr);    putstr("Monochrome color", mono_color[(j >> 6) & 3]);    putflag("Dual monitor", j & 0x0020);    putstr("Power up font", (j & 0x0010) ? "  8x16 or 9x16" : "  8x14 or 9x14");    putint("VGA Bus I/O", "  %d bits", (j & 0x0008) + 8);    putflag("0 waitstates RAM read/write", j & 0x0004);    putflag("0 waitstates ROM read", j & 0x0002);    putflag("ROM 16 bit", j & 0x0001);    j = putword(3);    putflag("Scrolling fix", j & 0x8000);    putflag("Korean BIOS support", j & 0x4000);    putint("Reserved (13:4)", "  %03xh", (j >> 4) & 0x3ff);    putint("EEPROM table revision", "  %d", j & 15);    j = putword(4);    putint("Custom monitor indices", "  %04x", j);    j = putword(5);    putstr("Host data transfer width", transwid[(j >> 14) & 3]);    putint("Monitor code", "  %02xh", (j >> 8) & 0x3f);    putint("Reserved (7)", "  %d", (j >> 7) & 1);    putstr("VGA boundary", vgabound[(j >> 4) & 3]);    putflag("Monitor alias", j & 0x0008);    putint("Monitor alias setting", "  %d", j & 0x0007);    j = putword(6);    putint("Memory aperture location", "  %d MB", (j >> 4));    j &= 15;    putstr("Memory aperture size", aperture[(j > 3) ? 3 : j]);    j = putword(7);    putstr("Offset to 640x480 mode table", offset(buffer, j));    putint("Reserved (7:2)", "  %02xh", (j >> 2) & 0x3f);    putflag("Use stored params for 640x480", j & 2);    putflag("640x480 72Hz", j & 1);    j = putword(8);    putstr("Offset to 800x600 mode table", offset(buffer, j));    putflag("Use stored params for 800x600", j & 0x80);    putint("Reserved (6)", "  %d", (j >> 6) & 1);    putflag("800x600 72Hz", j & 0x20);    putflag("800x600 70Hz", j & 0x10);    putflag("800x600 60Hz", j & 8);    putflag("800x600 56Hz", j & 4);    putflag("800x600 89Hz Interlaced", j & 2);    putflag("800x600 95Hz Interlaced", j & 1);    j = putword(9);    putstr("Offset to 1024x768 mode table", offset(buffer, j));    putflag("Use stored params for 1024x768", j & 0x80);    putint("Reserved (6:5)", "  %d", (j >> 5) & 3);    putflag("1024x768 66Hz", j & 0x10);    putflag("1024x768 72Hz", j & 8);    putflag("1024x768 70Hz", j & 4);    putflag("1024x768 60Hz", j & 2);    putflag("1024x768 87Hz Interlaced", j & 1);    j = putword(10);    putstr("Offset to 1280x1024 mode table", offset(buffer, j));    putflag("Use stored params for 1280x1024", j & 0x80);    putint("Reserved (6:2)", "  %02xh", (j >> 2) & 0x1f);    putflag("1280x1024 95Hz Interlaced", j & 2);    putflag("1280x1024 87Hz Interlaced", j & 1);    j = putword(11);    putstr("Offset to alternate mode table", offset(buffer, j));    putflag("Use stored params for alternate", j & 0x80);    putint("Reserved (6:2)", "  %02xh", (j >> 2) & 0x1f);    putflag("1152x900", j & 2);    putflag("1120x760", j & 1);    for (j = 0; j < 7; j++)	puttable(j);    puts("\n EEPROM Words 76h-7dh:  reserved.");    j = putword(0x7e);    putint("Reserved (15)", "  %d", j >> 15);    putflag("VGA circuitry", j & 0x4000);    putint("Memory size", "  %d KB", 1 << (((j >> 11) & 7) + 8));    putstr("DAC type", dactype[(j >> 8) & 7]);    putint("Reserved (7:0)", "  %02xh", j & 0xff);    j = putword(0x7f);    putint("EEPROM Checksum", "  %04x", j);    j = 0;    for (i = 0; i <= 0x7f;)	j += eeprom[i++];    printf("\nEEPROM contents sum up to %04x:%04x.\n", j >> 16, j & 0xffff);    if (!(j & 0xffff)) {	puts("ATI style checksum.");    } else {	j -= (eeprom[0x7f] << 1) - 1;	if (!(j & 0xffff))	    puts("AST style checksum.");	else	    puts(		    "WARNING! Strange EEPROM checksum!\n"		    "Be sure that:\n"		    "1. You installed the Mach32 correctly with the ATI install tool from\n"		    "   DOS (yuck!).\n"		    "2. Wrote the proper config to the EEPROM with it.\n"		    "3. DOS bios reads out the Mach32 EEPROM with out problems and obeys\n"		  "   all settings (for example, power up video mode).\n"		    "If you can't get a correct checksum, read the section \"EEPROM woes\"\n"		    "in \"README.mach32\" of your svgalib distribution.\n"		);    }    return 0;}void puttable(int table){    int i;    int clock;    char buffer[80];    unsigned short *tab;    tab = eeprom + (table * 15 + 0xd);    printf("\n EEPROM Words %02xh-%02xh:\tCRT Parameter table %d", table * 15 + 0xd,	   (table + 1) * 15 + 0xc, table + 1);    if (tab[10] & 0x3f00)	puts(":");    else {	puts("  .....................  invalid");	return;    }    table = tab[0];    putstr("Vertical sync polarity", (table & 0x8000) ? "  -" : "  +");    putstr("Horizontal sync polarity", (table & 0x4000) ? "  -" : "  +");    putflag("Interlace", table & 0x2000);    putflag("Multiplex pixels", table & 0x1000);    i = (table >> 9) & 7;    putstr("Maximum pixel depth", maxpix[(i > 3) ? 3 : i]);    putstr("Parameter type", (table & 0x0100) ? "  8514/Mach32" : "  VGA");    putstr("Dotclock select", (table & 0x0080) ? "  user supplied" : "  default");    putstr("Usage of CRTC parameters", (table & 0x0040) ? "  all"	   : "  sync polarities only");    putint("Dotclock chip select", "  #%d", table & 15);    clock = mach32_clocks[table & 15];    putstr("Dotclock divide by", clockdiv[(table >> 4) & 3]);    if (!(table & 0x20))	if (table & 0x10)	    clock /= 2;    if (clock)	putint("Pixel clock (approximate value)", "  %d MHz", (int) (clock + 0.5));    else	putstr("Pixel clock", "  (sorry, don't know the frequency)");    if (table & 0x0100) {	/*8514/Mach32 */	double fclock, lilen;	int xpels = ((tab[3] & 0xff) + 1) << 3, ypels = tab[6], xtotal = ((tab[3] >> 8) + 1) << 3,	 ytotal = tab[5], xstart = ((tab[4] >> 8) + 1) << 3, ystart = tab[7],	 xsync = (tab[4] & 0x1f) * 8, ysync = (tab[8] >> 8) & 0x1f;	puts("  Mach32 / 8514/A CRT parameters:");	putint("Video fifo 16bpp", "  %d", tab[2] & 0xff);	putint("Video fifo 24bpp", "  %d", tab[2] >> 8);	putint("H_TOTAL", "  %d", tab[3] >> 8);	putint("H_DISP", "  %d", tab[3] & 0xff);	putint("H_SYNC_STRT", "  %d", tab[4] >> 8);	putint("H_SYNC_WID", "  %02xh", tab[4] & 0xff);	putint("V_TOTAL", "  %xh", tab[5]);	putint("V_DISP", "  %xh", tab[6]);	putint("V_SYNC_STRT", "  %xh", tab[7]);	putint("V_SYNC_WID", "  %02xh", tab[8] >> 8);	putint("DISP_CNTL", "  %02xh", tab[8] & 0xff);	putint("CLOCK_SEL", "  %xh", tab[9]);	clock = mach32_clocks[(tab[9] >> 2) & 15];	if (!(tab[9] & 0x40))	    clock *= 2;	puts("  Resulting video timings:");	if (clock) {	    sprintf(buffer, "  %.1f MHz", fclock = ((double) clock) / 2);	} else {	    sprintf(buffer, "  #%d, don't know clock frequency, so no timings",		    (tab[9] >> 2) & 15);	    fclock = 0;	}	putstr("Pixel clock", buffer);	switch (tab[8] & 0x6) {	case 0:	    ypels = ((ypels >> 2) & ~1) | (ypels & 1);	    ytotal = ((ytotal >> 2) & ~1) | (ytotal & 1);	    ystart = ((ystart >> 2) & ~1) | (ystart & 1);	    break;	case 2:	    ypels = ((ypels >> 1) & 0xFFFC) | (ypels & 3);	    ytotal = ((ytotal >> 1) & 0xFFFC) | (ytotal & 3);	    ystart = ((ystart >> 1) & 0xFFFC) | (ystart & 3);	    break;	default:	    puts("  Unknown DISP_CNTL, vertical values are probably wrong.");	}	ypels++;	ytotal++;	ystart++;	sprintf(buffer, "  %d x %d%s", xpels, ypels, (tab[8] & 0x10) ? ", Interlaced" :		"");	putstr("Resolution", buffer);	if (clock) {	    sprintf(buffer, "  %.3f KHz", lilen = (fclock * 1e3) / xtotal);	    putstr("Horizontal frequency", buffer);	    sprintf(buffer, "  %.2f Hz", (lilen * 1000) / ytotal);	    putstr("Vertical frequency", buffer);	} else	    lilen = 0;	putstr("Horizontal sync polarity", (tab[4] & 0x20) ? "  -" : "  +");	putstr("Horizontal sync width", hsyncstr(xsync, clock, fclock));	putstr("Horizontal front porch", hsyncstr(xstart - xpels, clock, fclock));	putstr("Horizontal back porch", hsyncstr(xtotal - xsync - xstart,						 clock, fclock));	putstr("Horizontal active time", hsyncstr(xpels, clock, fclock));	putstr("Horizontal blank time", hsyncstr(xtotal - xpels, clock, fclock));	putstr("Vertical sync polarity", (tab[8] & 0x2000) ? "  -" : "  +");	putstr("Vertical sync width", vsyncstr(ysync, clock, lilen));	putstr("Vertical front porch", vsyncstr(ystart - ypels, clock, lilen));	putstr("Vertical back porch", vsyncstr(ytotal - ysync - ystart,					       clock, lilen));	putstr("Vertical active time", vsyncstr(ypels, clock, lilen));	putstr("Vertical blank time", vsyncstr(ytotal - ypels, clock, lilen));    } else {			/*VGA mode */	puts("  VGA CRT parameters:");	putint("VIDEO_MODE_SEL_1", "  %02xh", tab[1] >> 8);	putint("VIDEO_MODE_SEL_2", "  %02xh", tab[1] & 0xff);	putint("VIDEO_MODE_SEL_3", "  %02xh", tab[2] >> 8);	putint("VIDEO_MODE_SEL_4", "  %02xh", tab[2] & 0xff);	putint("H_TOTAL (CRT00)", "  %02xh", tab[3] >> 8);	putint("V_TOTAL (CRT06)", "  %02xh", tab[3] & 0xff);	putint("H_RETRACE_START (CRT04)", "  %02xh", tab[4] >> 8);	putint("H_RETRACE_END (CRT05)", "  %02xh", tab[4] & 0xff);	putint("V_RETRACE_START (CRT10)", "  %02xh", tab[5] >> 8);	putint("V_RETRACE_END (CRT11)", "  %02xh", tab[5] & 0xff);	putint("H_BLANK_START (CRT02)", "  %02xh", tab[6] >> 8);	putint("H_BLANK_END (CRT03)", "  %02xh", tab[6] & 0xff);	putint("V_BLANK_START (CRT15)", "  %02xh", tab[7] >> 8);	putint("V_BLANK_END (CRT16)", "  %02xh", tab[7] & 0xff);	putint("CRT_OVERFLOW (CRT07)", "  %02xh", tab[8] >> 8);	putint("MAX_SCANLINE (CRT09)", "  %02xh", tab[8] & 0xff);	putint("V_DISPLAYED (CRT12)", "  %02xh", tab[9] >> 8);	putint("CRT_MODE (CRT17)", "  %02xh", tab[9] & 0xff);	puts(		"  Resulting video timings  .........................  not implemented for VGA"	    );    }    table = tab[10];    puts("  Additional mode flags:");    putflag("Pixel clock divide by 2", table & 0x8000);    putflag("Multiplex (MUX flag)", table & 0x4000);    putint("Size of mode table", "  %d words", (table >> 8) & 0x3f);    putstr("Offset to alternate table", offset(buffer, (table << 8) & 0xff00));    putint("Horizontal overscan", "  %d", tab[11]);    putint("Vertival overscan", "  %d", tab[12]);    putint("Overscan color blue", "  %d", tab[13] >> 8);    putint("Overscan color index 8bpp", "  %d", tab[13] & 0xff);    putint("Overscan color red", "  %d", tab[14] >> 8);    putint("Overscan color green", "  %d", tab[14] & 0xff);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -