📄 hal_diag.c
字号:
//=============================================================================//// hal_diag.c//// HAL diagnostic output code////=============================================================================//####COPYRIGHTBEGIN####// // ------------------------------------------- // The contents of this file are subject to the Red Hat eCos Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.redhat.com/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations under // the License. // // The Original Code is eCos - Embedded Configurable Operating System, // released September 30, 1998. // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // //####COPYRIGHTEND####//=============================================================================//#####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 <cyg/infra/cyg_type.h> // base types#include <cyg/hal/hal_diag.h>#include <cyg/hal/plf_misc.h>//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------#if defined(CYGSEM_HAL_I386_PC_DIAG_SCREEN)//-----------------------------------------------------------------------------// 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; pc_outb(DisplayPort, 0x0e ); pc_outb(DisplayPort+1, pos >> 8 ); pc_outb(DisplayPort, 0x0f ); pc_outb(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, 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, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0x15, 0x15, 0x15, 0x15, },{ 0x10, 0x10, 0x10, 0x10, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0xFF, 0xFF, 0xFF, 0xFF, },{ 0xFF, 0xFF, 0xFF, 0xFF, },// 0x50{ 0x04, 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{ 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, }, };static int KBIndexTab[8] = { 0, 1, 2, 2, 3, 3, 3, 3 };//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -