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

📄 pcmb_screen.c

📁 eCos操作系统源码
💻 C
📖 第 1 页 / 共 2 页
字号:
//=============================================================================////      pcmb_screen.c////      HAL diagnostic output code////=============================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//=============================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   proven// Contributors:proven// Date:        1998-10-05// Purpose:     HAL diagnostic output// Description: Implementations of HAL diagnostic output support.////####DESCRIPTIONEND####////=============================================================================#include <pkgconf/hal.h>#include <pkgconf/hal_i386_pcmb.h>#if CYGINT_HAL_I386_PCMB_SCREEN_SUPPORT#include <cyg/infra/cyg_type.h>         // base types#include <cyg/hal/hal_arch.h>           // basic machine info#include <cyg/hal/hal_intr.h>           // interrupt macros#include <cyg/hal/hal_io.h>             // IO macros#include <cyg/hal/drv_api.h>#include <cyg/hal/hal_if.h>             // interface API#include <cyg/hal/hal_misc.h>#include <cyg/hal/pcmb_serial.h>// Index into pc_ser_channels[] for screen entry.#define PCMB_PORT_INDEX (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS - 1)//-----------------------------------------------------------------------------// Screen output definitions...static short 		*DisplayBuffer = (short *)0xB8000;static short		DisplayAttr = 0x0700;static	short		DisplayPort = 0x03d4;static	int		XPos;static	int		YPos;static	int		ScreenWidth = 80;static  int		ScreenLength = 25;//-----------------------------------------------------------------------------static void MoveLine(	short 	*dest,	short 	*src,	int	count		){	while( count-- ) *dest++ = *src++;	} /* MoveLine *///-----------------------------------------------------------------------------static void FillLine(	short  *dest,	short  val,	int    count){	while( count-- ) *dest++ = val;	} /* FillLine *///-----------------------------------------------------------------------------void ClearScreen(void){    FillLine(DisplayBuffer, ' ' | DisplayAttr, ScreenWidth*ScreenLength);	} /* ClearScreen */void MoveCursor(	void){	int pos = XPos + YPos * ScreenWidth;	HAL_WRITE_UINT8(DisplayPort, 0x0e );	HAL_WRITE_UINT8(DisplayPort+1, pos >> 8 );	HAL_WRITE_UINT8(DisplayPort, 0x0f );	HAL_WRITE_UINT8(DisplayPort+1, pos & 0xFF );	} /* MoveCursor *///-----------------------------------------------------------------------------void ScrollUp(	int	lines){//	Report_Function(ScrollUp)	int rest = ScreenLength - lines;		MoveLine	(		DisplayBuffer,		DisplayBuffer+(lines*ScreenWidth),		rest*ScreenWidth	);	FillLine	(		DisplayBuffer+(rest*ScreenWidth),		' ' | DisplayAttr,		lines*ScreenWidth	);	} /* ScrollUp *///-----------------------------------------------------------------------------void ScrollDown(	int	lines){//	Report_Function(ScrollDown)	int rest = ScreenLength - lines;	short *db = DisplayBuffer+(ScreenWidth*(ScreenLength-1));		while( rest )	{		MoveLine		(			db,			db-ScreenWidth,			ScreenWidth		);		rest--;		db -= ScreenWidth;	}	FillLine	(		DisplayBuffer,		' ' | DisplayAttr,		lines*ScreenWidth	);	} /* ScrollDown *///-----------------------------------------------------------------------------void NewLine(	void){	XPos = 0;	YPos++;		if( YPos >= ScreenLength )	{		YPos = ScreenLength-1;		ScrollUp(1);	}	MoveCursor();	} /* NewLine *///-----------------------------------------------------------------------------void DisplayChar(	char	ch){	DisplayBuffer[XPos + YPos*ScreenWidth] = ch | DisplayAttr;	XPos++;	if( XPos >= ScreenWidth )	{		XPos = 0;		YPos++;		if( YPos >= ScreenLength )		{			YPos = ScreenLength-1;			ScrollUp(1);		}	}	MoveCursor();	} /* DisplayChar *///-----------------------------------------------------------------------------// Keyboard definitions#define	KBDATAPORT	0x0060		// data I/O port#define	KBCMDPORT	0x0064		// command port (write)#define	KBSTATPORT	0x0064		// status port	(read)// Scan codes#define	LSHIFT		0x2a#define	RSHIFT		0x36#define	CTRL		0x1d#define	ALT		    0x38#define	CAPS		0x3a#define	NUMS		0x45#define	BREAK		0x80// Bits for KBFlags#define	KBNormal	0x0000#define	KBShift		0x0001#define	KBCtrl		0x0002#define KBAlt		0x0004#define	KBIndex		0x0007	// mask for the above#define	KBExtend	0x0010#define	KBAck		0x0020#define	KBResend	0x0040#define	KBShiftL	(0x0080 | KBShift)#define	KBShiftR	(0x0100 | KBShift)#define	KBCtrlL		(0x0200 | KBCtrl)#define	KBCtrlR		(0x0400 | KBCtrl)#define	KBAltL		(0x0800 | KBAlt)#define	KBAltR		(0x1000 | KBAlt)#define	KBCapsLock	0x2000#define	KBNumLock	0x4000//-----------------------------------------------------------------------------// Keyboard Variablesstatic	int	KBFlags = 0;static	CYG_BYTE	KBPending = 0xFF;static	CYG_BYTE	KBScanTable[128][4] ={//	Normal		Shift		Control		Alt// 0x00{	0xFF,		0xFF,		0xFF,		0xFF,   },{	0x1b,		0x1b,		0x1b,		0xFF,	},{	'1',		'!',		0xFF,		0xFF,	},{	'2',		'"',		0xFF,		0xFF,	},{	'3',		'#',		0xFF,		0xFF,	},{	'4',		'$',		0xFF,		0xFF,	},{	'5',		'%',		0xFF,		0xFF,	},{	'6',		'^',		0xFF,		0xFF,	},{	'7',		'&',		0xFF,		0xFF,	},{	'8',		'*',		0xFF,		0xFF,	},{	'9',		'(',		0xFF,		0xFF,	},{	'0',		')',		0xFF,		0xFF,	},{	'-',		'_',		0xFF,		0xFF,	},{	'=',		'+',		0xFF,		0xFF,	},{	'\b',		'\b',		0xFF,		0xFF,	},{	'\t',		'\t',		0xFF,		0xFF,	},// 0x10{	'q',		'Q',		0x11,		0xFF,	},{	'w',		'W',		0x17,		0xFF,	},{	'e',		'E',		0x05,		0xFF,	},{	'r',		'R',		0x12,		0xFF,	},{	't',		'T',		0x14,		0xFF,	},{	'y',		'Y',		0x19,		0xFF,	},{	'u',		'U',		0x15,		0xFF,	},{	'i',		'I',		0x09,		0xFF,	},{	'o',		'O',		0x0F,		0xFF,	},{	'p',		'P',		0x10,		0xFF,	},{	'[',		'{',		0x1b,		0xFF,	},{	']',		'}',		0x1d,		0xFF,	},{	'\r',		'\r',		'\n',		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	'a',		'A',		0x01,		0xFF,	},{	's',		'S',		0x13,		0xFF,	},// 0x20{	'd',		'D',		0x04,		0xFF,	},{	'f',		'F',		0x06,		0xFF,	},{	'g',		'G',		0x07,		0xFF,	},{	'h',		'H',		0x08,		0xFF,	},{	'j',		'J',		0x0a,		0xFF,	},{	'k',		'K',		0x0b,		0xFF,	},{	'l',		'L',		0x0c,		0xFF,	},{	';',		':',		0xFF,		0xFF,	},{	0x27,		'@',		0xFF,		0xFF,	},{	'#',		'~',		0xFF,		0xFF,	},{	'`',		'~',		0xFF,		0xFF,	},{	'\\',		'|',		0x1C,		0xFF,	},{	'z',		'Z',		0x1A,		0xFF,	},{	'x',		'X',		0x18,		0xFF,	},{	'c',		'C',		0x03,		0xFF,	},{	'v',		'V',		0x16,		0xFF,	},// 0x30{	'b',		'B',		0x02,		0xFF,	},{	'n',		'N',		0x0E,		0xFF,	},{	'm',		'M',		0x0D,		0xFF,	},{	',',		'<',		0xFF,		0xFF,	},{	'.',		'>',		0xFF,		0xFF,	},{	'/',		'?',		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	'*',		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	' ',		' ',		' ',		' ',	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xF1,		0xE1,		0xFF,		0xFF,	},{	0xF2,		0xE2,		0xFF,		0xFF,	},{	0xF3,		0xE3,		0xFF,		0xFF,	},{	0xF4,		0xE4,		0xFF,		0xFF,	},{	0xF5,		0xE5,		0xFF,		0xFF,	},// 0x40{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	'7',		0xFF,		0xFF,		0xFF,	},{	'8',		0x15,		0x15,		0x15,	},{	'9',		0x10,		0x10,		0x10,	},{	'-',		0xFF,		0xFF,		0xFF,	},{	'4',		0xFF,		0xFF,		0xFF,	},{	'5',		0xFF,		0xFF,		0xFF,	},{	'6',		0xFF,		0xFF,		0xFF,	},{	'+',		0xFF,		0xFF,		0xFF,	},{	'1',		0xFF,		0xFF,		0xFF,	},// 0x50{	'2',		0x04,		0x04,		0x04,	},{	'3',		0x0e,		0x0e,		0x0e,	},{	'0',		0xFF,		0xFF,		0xFF,	},{	'.',		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},// 0x60{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},// 0x70{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},{	0xFF,		0xFF,		0xFF,		0xFF,	},

⌨️ 快捷键说明

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