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

📄 hercules.c

📁 Linux下的类似softice的调试工具
💻 C
字号:
/****************************************************************************** * * Copyright (c) 2003 Gerhard W. Gruber * * PROJECT: pICE * $Source: /cvsroot/pice/pice/module/hercules.c,v $ * $Revision: 1.5 $ * $Date: 2004/02/17 23:07:36 $ * $Author: lightweave $ * $Name:  $ * * $Log: hercules.c,v $ * Revision 1.5  2004/02/17 23:07:36  lightweave * * Improved the DEBUG facillity and replaced the configuration handler with a * new code which now can read MS Windows INI style files. See CHANGES.txt for * more details. * Also added a macro which prevents compiling for kernels before 2.4.19. * * Revision 1.4  2003/06/18 22:00:22  lightweave * DEBUG and DEBUG_SERIAL added * * *****************************************************************************/static char *ident = "$Header: /cvsroot/pice/pice/module/hercules.c,v 1.5 2004/02/17 23:07:36 lightweave Exp $";/*++Copyright (c) 1998-2001 Klaus P. GerlicherModule Name:    hercules.cAbstract:	    HW dependent draw routinesEnvironment:    Kernel mode onlyAuthor:    Klaus P. GerlicherRevision History:    04-Aug-1998:	created    15-Nov-2000:    general cleanup of source files    Copyright notice:  This file may be distributed under the terms of the GNU Public License.--*/////////////////////////////////////////////////////// INCLUDES////#include "remods.h"#include <linux/pci.h>#include <asm/io.h>#include <asm/delay.h>#include <linux/ctype.h>#include "precomp.h"#include "charset.h"#include "logo.h"////////////////////////////////////////////////////// PROTOTYPES////////////////////////////////////////////////////////// DEFINES////////////////////////////////////////////////////////// GLOBALS////// cursor stateBOOLEAN bRev=FALSE;// HERCULES graphics adapter stuff// 43 line graphics modeUCHAR MGATable43[]={53,45,46, 7,96, 2,91,91, 2, 3, 0, 0, 0, 0, 0, 0};PUCHAR pVgaOffset[4];// END of HERCULES graphics adapter stuff// used for HERCULES graphics modeWINDOW wWindowHercGraph[4]={	{1,3,1,0,FALSE},	{5,6,1,0,FALSE},	{12,19,1,0,FALSE},	{32,12,1,0,FALSE}};// used for HERCUELS text and VGA text modeWINDOW wWindowHerc[4]={	{1,3,1,0,FALSE},	{5,4,1,0,FALSE},	{10,9,1,0,FALSE},	{20,4,1,0,FALSE}};PUCHAR pScreenBufferHercules;struct _attr{    union    {        struct        {                UCHAR fgcol : 4;            UCHAR bkcol : 3;            UCHAR blink : 1;        }bits;        UCHAR Asuchar;    }u;}attr;//*************************************************************************// SetForegroundColorVga()////*************************************************************************void SetForegroundColorHercules(ECOLORS col){    attr.u.bits.fgcol = col;    attr.u.bits.blink = 0;}//*************************************************************************// SetBackgroundColorVga()////*************************************************************************void SetBackgroundColorHercules(ECOLORS col){    attr.u.bits.bkcol = col;    attr.u.bits.blink = 0;}//*************************************************************************// PrintGrafHercules()////*************************************************************************void PrintGrafHercules(ULONG x,ULONG y,UCHAR c){    ULONG i;    PUCHAR p;    ULONG _line = y<<3;        	if(!pScreenBufferHercules)		return;    p=&cGraphTable[(ULONG)c<<3];    if((attr.u.bits.bkcol == COLOR_FOREGROUND && attr.u.bits.fgcol == COLOR_BACKGROUND) ||       (attr.u.bits.bkcol == COLOR_CAPTION && attr.u.bits.fgcol == COLOR_TEXT) )	    for(i=0 ;i<8 ;i++,_line++)	    {            *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = ~*p++;        }    else	    for(i=0 ;i<8 ;i++,_line++)	    {            *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = *p++;        }}//*************************************************************************// FlushHercules()////*************************************************************************void FlushHercules(void){    ENTER_FUNC();    LEAVE_FUNC();}//*************************************************************************// ShowCursor()//// show hardware cursor//*************************************************************************void ShowCursorHercules(void){    ENTER_FUNC();	    bCursorEnabled=TRUE;        LEAVE_FUNC();}//*************************************************************************// HideCursorHercules()//// hide hardware cursor//*************************************************************************void HideCursorHercules(void){    ENTER_FUNC();	    bCursorEnabled=FALSE;    LEAVE_FUNC();}//*************************************************************************// CopyLineTo()//// copy a line from src to dest//*************************************************************************void CopyLineToHercules(USHORT dest,USHORT src){	USHORT i;	PULONG pDest,pSrc;    ENTER_FUNC();    dest <<= 3;    src <<= 3;	for(i=0;i<8;i++)	{		(PUCHAR)pDest = (PUCHAR)pScreenBufferHercules + ( ( ( dest+i )&3) <<13 )+	90 * ((dest+i) >> 2);		(PUCHAR)pSrc = (PUCHAR)pScreenBufferHercules + ( ( ( src+i )&3) <<13 )+	90 * ((src+i) >> 2);        PICE_memcpy(pDest,pSrc,GLOBAL_SCREEN_WIDTH);	}    LEAVE_FUNC();}//*************************************************************************// InvertLineHercules()//// invert a line on the screen//*************************************************************************void InvertLineHercules(ULONG line){    ULONG i,j;    ULONG _line = line<<3;	PUSHORT p;    //ENTER_FUNC();	for(j=0;j<8;j++)	{		p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );		for(i=0;i<(GLOBAL_SCREEN_WIDTH>>1);i++)		{			p[i]=~p[i];		}		_line++;	}    //LEAVE_FUNC();}//*************************************************************************// HatchLineHercules()//// hatches a line on the screen//*************************************************************************void HatchLineHercules(ULONG line){	USHORT cc;    ULONG i,j;    ULONG _line = (line<<3) ;	PUSHORT p;    USHORT mask_odd[]={0x8888,0x2222};    USHORT mask_even[]={0xaaaa,0x5555};    PUSHORT pmask;    ENTER_FUNC();    pmask = (line&1)?mask_odd:mask_even;	for(j=0;j<8;j++,_line++)	{		p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );		for(i=0;i<(GLOBAL_SCREEN_WIDTH/sizeof(USHORT));i++)		{			cc = p[i];			p[i]=(p[i]^pmask[j&1])|cc;		}	}    LEAVE_FUNC();}//*************************************************************************// ClrLineHercules()//// clear a line on the screen//*************************************************************************void ClrLineHercules(ULONG line){    ULONG j;    BOOLEAN bTemplateLine=( (USHORT)line==wWindow[DATA_WINDOW].y-1 ||                            (USHORT)line==wWindow[SOURCE_WINDOW].y-1 ||                            (USHORT)line==wWindow[OUTPUT_WINDOW].y-1 ||                            0);	ULONG _line = line<<3;    ULONG cc=0;   	PUCHAR p;//    ENTER_FUNC();    if(line > GLOBAL_SCREEN_HEIGHT )    {        DPRINT(PICE_DEBUG, DBT_HERCULES, DBL_INFO, "line %u is out of screen\n",line);        //LEAVE_FUNC();        return;    }    if(attr.u.bits.bkcol == COLOR_CAPTION && attr.u.bits.fgcol == COLOR_TEXT )        cc=~cc;    if(bTemplateLine)    {	    for(j=0;j<8;j++,_line++)	    {            p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );/*			if(j==2 || j==5)cc=0xFF;			else if(j==3)cc=0xaa;			else if(j==4)cc=0x55;			else cc = 0;*/			if(j==2 || j==5)cc=0xFF;			else cc = 0;		    PICE_memset(p,(UCHAR)cc,GLOBAL_SCREEN_WIDTH);	    }    }    else    {        for(j=0;j<8;j++,_line++)        {            p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );            PICE_memset(p,(UCHAR)cc,GLOBAL_SCREEN_WIDTH);        }    }    //LEAVE_FUNC();}//*************************************************************************// PrintLogoHercules()////*************************************************************************void PrintLogoHercules(BOOLEAN bShow){    LONG x,y;    PUCHAR p;    p=(PUCHAR)pScreenBufferHercules;    for(y=0;y<24;y++)    {        for(x=0;x<8;x++)        {    	    p[ ( 0x2000* (( y + 8 ) & 0x3) )+	    	    ( 90* ( (y + 8 ) >> 2) )+		        (81+x)] = cLogo[y*8+x];        }    }}//*************************************************************************// PrintCursorHercules()//// emulate a blinking cursor block//*************************************************************************void PrintCursorHercules(BOOLEAN bForce){    static ULONG count=0;	if( (bForce) || ((count++>100) && bCursorEnabled)  )	{    	ULONG i;	    ULONG x,y;        ULONG _line;        x=wWindow[OUTPUT_WINDOW].usCurX;        y=wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].usCurY;        _line = y<<3;		for(i=0;i<8;i++,_line++)		{            *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) ^= 0xFF ;		}		bRev=!bRev;        count=0;    }    __udelay(2500);}//*************************************************************************// SaveGraphicsHercules()////*************************************************************************void SaveGraphicsStateHercules(void){    // not implemented}//*************************************************************************// RestoreGraphicsStateHercules()////*************************************************************************void RestoreGraphicsStateHercules(void){    // not implemented}//*************************************************************************// ConsoleInitHercules()//// init terminal screen//*************************************************************************BOOLEAN ConsoleInitHercules(void) {   BOOLEAN bResult = FALSE;   PUCHAR pMGATable = MGATable43;   UCHAR i,reg,data;   ENTER_FUNC();   ohandlers.CopyLineTo            = CopyLineToHercules;   ohandlers.PrintGraf             = PrintGrafHercules;   ohandlers.Flush                 = FlushHercules;   ohandlers.ClrLine               = ClrLineHercules;   ohandlers.InvertLine            = InvertLineHercules;   ohandlers.HatchLine             = HatchLineHercules;   ohandlers.PrintLogo             = PrintLogoHercules;   ohandlers.PrintCursor           = PrintCursorHercules;   ohandlers.SaveGraphicsState     = SaveGraphicsStateHercules;   ohandlers.RestoreGraphicsState  = RestoreGraphicsStateHercules;   ohandlers.ShowCursor            = ShowCursorHercules;   ohandlers.HideCursor            = HideCursorHercules;   ohandlers.SetForegroundColor    = SetForegroundColorHercules;   ohandlers.SetBackgroundColor    = SetBackgroundColorHercules;      ihandlers.GetKeyPolled          = KeyboardGetKeyPolled;   ihandlers.FlushKeyboardQueue    = KeyboardFlushKeyboardQueue;   // enable monochrome passthrough on BX type chipset   EnablePassThrough();   // init HERCULES adapter   outb_p(0,0x3b8);   outb_p(0x03,0x3bf);   for(i=0;i<sizeof(MGATable43);i++)    {       reg=i;       outb_p(reg,0x3b4);      data=pMGATable[i];       outb_p(data,0x3b5);   }   outb_p(0x0a,0x3b8);   SetWindowGeometry(wWindowHercGraph);    GLOBAL_SCREEN_WIDTH = 90;   GLOBAL_SCREEN_HEIGHT = 45;   attr.u.Asuchar = 0x07;   pScreenBufferHercules=ioremap(0xb0000,FRAMEBUFFER_SIZE);    DPRINT(PICE_DEBUG, DBT_HERCULES, DBL_INFO, "VGA memory phys. 0xb0000 mapped to virt. 0x%p\n",pScreenBufferHercules);    if(pScreenBufferHercules)   {      for(i=0;i<4;i++)      {	 pVgaOffset[i] = (PUCHAR)pScreenBufferHercules+0x2000*i;	 DPRINT(PICE_DEBUG, DBT_HERCULES, DBL_INFO, "VGA offset %u = 0x%p\n",i, pVgaOffset[i]);       }      bResult = TRUE;      PICE_memset(pScreenBufferHercules,0x0,FRAMEBUFFER_SIZE);      EmptyRingBuffer();          DPRINT(PICE_DEBUG, DBT_HERCULES, DBL_INFO, "ConsoleInitHercules() SUCCESS!\n");    }   LEAVE_FUNC();   return bResult;}//*************************************************************************// ConsoleShutdownHercules()//// exit terminal screen//*************************************************************************void ConsoleShutdownHercules(void) {    ENTER_FUNC();    // HERC video off    outb_p(0,0x3b8);   outb_p(0,0x3bf);   if(pScreenBufferHercules)      iounmap(pScreenBufferHercules);    LEAVE_FUNC();}

⌨️ 快捷键说明

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