📄 mach32info.c
字号:
/* mach32info.c prints out some info about your mach32card *//* Please report the info it produces if the mach32driver of svgalib *//* works not like expected. *//* This tool is part of svgalib. Although it's output maybe useful to *//* debug Xfree86 Mach32 Servers, I am NOT related to Xfree86!! *//* PLEASE DO NOT SEND ME (MICHAEL WELLER) ANY XFREE86 BUG REPORTS!!! *//* Thanx in advance. *//* This tool is free software; you can redistribute it and/or *//* modify it without any restrictions. This tool is distributed *//* in the hope that it will be useful, but without any warranty. *//* Copyright 1994 by Michael Weller *//* eowmob@exp-math.uni-essen.de mat42b@aixrs1.hrz.uni-essen.de *//* eowmob@pollux.exp-math.uni-essen.de *//* * MICHAEL WELLER DISCLAIMS ALL WARRANTIES WITH REGARD * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL MICHAEL WELLER 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. * *//* This tool contains one routine out of Xfree86, therefore I repeat *//* its copyright here: (Actually it is longer than the copied code) *//* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Wexelblat <dwex@goblin.org> * * 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 names of Orest Zborowski and David Wexelblat * not be used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. Orest Zborowski * and David Wexelblat make no representations about the suitability of this * software for any purpose. It is provided "as is" without express or * implied warranty. * * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT 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. * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * Copyright 1993 by Kevin E. Martin, Chapel Hill, North Carolina. * * 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, KEVIN E. MARTIN, AND RICKARD E. FAITH DISCLAIM ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHORS * 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. * * Author: Thomas Roell, roell@informatik.tu-muenchen.de * * Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu) * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu) * Rewritten for the Mach32 by Kevin E. Martin (martin@cs.unc.edu) * */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>/* Some stuff for the ATI VGA */#define ATIPORT 0x1ce#define ATIOFF 0x80#define ATISEL(reg) (ATIOFF+reg)/* Ports we use: */#define SUBSYS_CNTL 0x42E8#define GE_STAT 0x9AE8#define CONF_STAT1 0x12EE#define CONF_STAT2 0x16EE#define MISC_OPTIONS 0x36EE#define MEM_CFG 0x5EEE#define MEM_BNDRY 0x42EE#define SCRATCH_PAD_0 0x52EE#define DESTX_DIASTP 0x8EE8#define R_SRC_X 0xDAEE#define R_EXT_GE_CONF 0x8EEE#define CHIP_ID 0xFAEE#define MAX_WAITSTATES 0x6AEE#define LOCAL_CNTL 0x32EE#define R_MISC_CNTL 0x92EE#define PCI_CNTL 0x22EE#define DISP_STATUS 0x2E8#define DISP_CNTL 0x22E8#define CLOCK_SEL 0x4AEE#define H_DISP 0x06E8#define H_TOTAL 0x02E8#define H_SYNC_WID 0x0EE8#define H_SYNC_STRT 0x0AE8#define V_DISP 0x16E8#define V_SYNC_STRT 0x1AE8#define V_SYNC_WID 0x1EE8#define V_TOTAL 0x12E8#define R_H_TOTAL 0xB2EE#define R_H_SYNC_STRT 0xB6EE#define R_H_SYNC_WID 0xBAEE#define R_V_TOTAL 0xC2EE#define R_V_DISP 0xC6EE#define R_V_SYNC_STRT 0xCAEE#define R_V_SYNC_WID 0xD2EE/* Bit masks: */#define GE_BUSY 0x0200/* Chip_id's */#define ATI68800_3 ('A'*256+'A')#define ATI68800_6 ('X'*256+'X')#define ATI68800_6HX ('H'*256+'X')#define ATI68800LX ('L'*256+'X')#define ATI68800AX ('A'*256+'X')static inline void port_out(int value, int port){ __asm__ volatile ("outb %0,%1" ::"a" ((unsigned char) value), "d"((unsigned short) port));}static inline void port_outw(int value, int port){ __asm__ volatile ("outw %0,%1" ::"a" ((unsigned short) value), "d"((unsigned short) port));}static inline int port_in(int port){ unsigned char value; __asm__ volatile ("inb %1,%0" :"=a" (value) :"d"((unsigned short) port)); return value;}static inline int port_inw(int port){ unsigned short value; __asm__ volatile ("inw %1,%0" :"=a" (value) :"d"((unsigned short) port)); return value;}#define inb port_in#define inw port_inw#define outb(port, value) port_out(value, port)#define outw(port, value) port_outw(value, port)int force = 0, chip_id, bus;unsigned short eeprom[128];char *pel_width[] ={" 4bpp", " 8bpp", " 16bpp", " 24bpp"};char *bpp16mode[] ={" 5-5-5", " 5-6-5", " 6-5-5", " 6-6-4"};char *bpp24mode[] ={" RGB", " RGBa", " BGR", " aBGR"};char *bustype[] ={" 16-bit ISA", " EISA", " 16-bit MicroChannel", " 32-bit MicroChannel", " LocalBus SX, 386SX", " LocalBus 1/2, 386DX", " LocalBus 1/2, 486DX", " PCI"};char *memtype3[] ={" 256Kx4 DRAM", " 256Kx4 VRAM, 512 bit serial transfer", " 256Kx4 VRAM, 256 bit serial transfer", " 256Kx16 DRAM", " invalid", " invalid", " invalid", " invalid"};char *memtype6[] ={" 256Kx4 DRAM", " 256Kx4 VRAM, 512 bit serial transfer", " 256Kx16 VRAM, 256 bit serial transfer", " 256Kx16 DRAM", " 256Kx4 Graphics DRAM", " 256Kx4 VRAM, 512 bit split transfer", " 256Kx16 VRAM, 256 bit split transfer", " invalid"};char *dactype[] ={" ATI-68830 (Type 0)", " SC-11483 (Type 1)", " ATI-68875 (Type 2)", " Bt-476 (Type 3)", " Bt-481 (Type 4)", " ATI-68860 (Type 5)", " Unknown type 6", " Unknown type 7"};char *localbus[] ={" reserved", " LOCAL#2", " LOCAL#3", " LOCAL#1"};char *aperture[] ={" memory aperture disabled", " 1 MB memory aperture", " 4 MB memory aperture", " reserved"};char *mono_color[] ={" white", " green", " amber", " reserved"};char *videomonames[] ={"lores color - secondary", "(hires) color - secondary", "monochrome - secondary", "lores color - primary", "hires color - primary", "monochrome - primary"};char *clockdiv[] ={" 1", " 2", " reserved", " reserved"};char *transwid[] ={" auto select", " 16 bit", " 8 bit", " 8 bit hostdata/16 bit other"};char *vgabound[] ={" shared", " 256 KB", " 512 KB", " 1 MB"};char *maxpix[] ={" 8 bpp", " 16 bpp", " 24 bpp", " reserved"};static int mach32_clocks[16];void puttable(int table);void usage(void){ fputs("Usage: mach32info {info|force}\n" " prints out almost all the info about your mach32 card from configuration\n" " registers and Mach32 EEPROM. It also measures the Mach32 clocks. A\n" " completely idle system is required when these measurements are being\n" " performed. During these measurements, the video signals will be screwed up\n" " for about 3-4 seconds.\n" "* If your monitor does not switch off when getting a video signal it can't\n" " stand (fixed freq. monitors) better switch it off before starting\n" " mach32info. Your computer will beep when it is finished probing.\n" " You can redirect the 'stdout' of 'mach32info' to some file for viewing\n" " the results easier. Do not redirect 'stderr' as you won't hear the beep.\n" "* The 'force' option disables the sanity check that tries to detect the\n" " presence of the mach32. Do not use this option unless you are really,\n" " really sure that you have a Mach32 compatible vga card installed.\n" "* This tool is part of svgalib. Although it's output maybe useful to debug\n" " Xfree86 Mach32 Servers, I am NOT related to Xfree86! PLEASE DO NOT SEND\n" " ME (MICHAEL WELLER) ANY XFREE86 BUG REPORTS! Thanx in advance.\n" "* Note that this tool comes WITHOUT ANY WARRANTY! Use it at your OWN risk!\n" "* Warning, this tool does not check for VC changes etc.. Just let it run in\n" " its own virtual console and don't try to fool it.\n" "Please report any problems with running 'mach32info' or with config-\n" "uring the 'svgalib' mach32 driver to 'eowmob@exp-math.uni-essen.de'.\n" "Include the results from running this test with your report.\n", stderr); exit(2);}static void mach32_i_bltwait(){ int i; for (i = 0; i < 100000; i++) if (!(inw(GE_STAT) & (GE_BUSY | 1))) break; if (i >= 100000) puts("GE idled out");}static int mach32_test(){ int result = 0; short tmp; tmp = inw(SCRATCH_PAD_0); outw(SCRATCH_PAD_0, 0x5555); mach32_i_bltwait(); if (inw(SCRATCH_PAD_0) == 0x5555) { outw(SCRATCH_PAD_0, 0x2a2a); mach32_i_bltwait(); if (inw(SCRATCH_PAD_0) == 0x2a2a) { /* Aha.. 8514/a detected.. */ result = 1; } } outw(SCRATCH_PAD_0, tmp); if (!result) goto quit;/* Now ensure it is not a plain 8514/a: */ result = 0; outw(DESTX_DIASTP, 0xaaaa); mach32_i_bltwait(); if (inw(R_SRC_X) == 0x02aa) { outw(DESTX_DIASTP, 0x5555); mach32_i_bltwait(); if (inw(R_SRC_X) == 0x0555) result = 1; } quit: return result;}static void mach32_wait(){/* Wait for at least 22 us.. (got that out of a BIOS disassemble on my 486/50 ;-) ) ... */ register int i; volatile dummy; for (i = 0; i < 16; i++) dummy++; /*Dummy is volatile.. */}static int mach32_eeclock(register int ati33){ outw(ATIPORT, ati33 |= 0x200); /* clock on */ mach32_wait(); outw(ATIPORT, ati33 &= ~0x200); /* clock off */ mach32_wait(); return ati33;}static void mach32_eekeyout(register int ati33, register int offset, register int mask){ do { if (mask & offset) ati33 |= 0x100; else ati33 &= ~0x100; outw(ATIPORT, ati33); mach32_eeclock(ati33); } while (mask >>= 1);}static int mach32_eeget(int offset){ register int ati33; register int result, i;/* get current ATI33 */ outb(ATIPORT, ATISEL(0x33)); ati33 = ((int) inw(ATIPORT + 1)) << 8; ati33 |= ATISEL(0x33);/* prepare offset.. cut and add header and trailer */ offset = (0x600 | (offset & 0x7f)) << 1;/* enable eeprom sequence */ ati33 = mach32_eeclock(ati33);/*input to zero.. */ outw(ATIPORT, ati33 &= ~0x100);/*enable to one */ outw(ATIPORT, ati33 |= 0x400); mach32_eeclock(ati33);/*select to one */ outw(ATIPORT, ati33 |= 0x800); mach32_eeclock(ati33); mach32_eekeyout(ati33, offset, 0x800); for (i = 0, result = 0; i < 16; i++) { result <<= 1; outb(ATIPORT, ATISEL(0x37)); if (inb(ATIPORT + 1) & 0x8) result |= 1; mach32_eeclock(ati33); }/*deselect... */ outw(ATIPORT, ati33 &= ~0x800); mach32_eeclock(ati33);/*disable... */ outw(ATIPORT, ati33 &= ~0x400); mach32_eeclock(ati33); return result;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -