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

📄 error.h

📁 FritzOS - 简单的C++开发OS的实例// 英文
💻 H
字号:
/* error.h : FritzOS Error Header File For The FritzOS C++ Kernel   Copyright (C) 2002 Tom Fritz * This program is a part of the FritzOS kernel, and may be freely * copied under the terms of the GNU General Public License (GPL), * version 2, or at your option any later version.   For more info, look at the COPYING file.*/// defines:#ifndef ERROR_H#define ERROR_H#ifndef FSTDIO_H#error error.h needs fstdio.h . it should be in the include directory.#endif// voids:// panic functionvoid panic( char* msg, int errlev );		// 3 error levels supported// Put the registers on the screen:void DumpRegs();// Externs in kernelasm.asm, for getting register values:extern "C" unsigned long geteax();extern "C" unsigned long getebx();extern "C" unsigned long getecx();extern "C" unsigned long getedx();extern "C" unsigned int getcs();extern "C" unsigned int getds();extern "C" unsigned int getes();extern "C" unsigned int getfs();extern "C" unsigned int getgs();extern "C" unsigned int getss();extern "C" unsigned long getedi();extern "C" unsigned long getesi();extern "C" unsigned long getebp();extern "C" unsigned long getesp();extern "C" unsigned long geteflags();////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Example:	panic( /*The Message*/, /*The level of the error*/ );void panic( char* msg, int errlev ){	// Save the current textmode text color:	int txtclr;	txtclr = textattrib;	setcolor( RED_BLACK );		// FritzOS Error Color	clrscr();			// Clear the screen	Print( "FritzOS Error: %s\n", msg );	// Dump the registers:	DumpRegs();	switch ( errlev )	{		// The higher the error level, the more restrictions.		// Error Level 0		case 0:			// Error Level 0 just prints the error and waits for a key to press, then returns.			Print( "\nPress a key to continue.\n" );			// Wait for a key:			getch();			clrscr();	// Clear the screen			// Return:			break;		// Error Level 1		case 1:			// Error Level 1 prints the error and waits for a key press to reboot.			Print( "\nPress a key to reboot.\n" );			// Wait for a key:			getch();			// Reboot:			reboot();			// If the computer didn't reboot, let user know.			Print( "Sorry, FritzOS could not reboot the computer. Please turn off the\n" );			Print( "computer, then back on.\n" );			// Nothing to do, Freeze();			Freeze();			// Return ( this never happens ):			break;		// Error Level 2		case 2:			// Error Level 2 just prints the error, and freezes.			Print( "\nComputer Frozen\nPlease turn off the computer, then back on.\n" );			// Nothing to do, Freeze();			Freeze();			// Return ( this never happens ):			break;		// Else, nothing		default:			break;	// Return	}	// Put back the saved color:	setcolor( txtclr );}//************************************************************************************************************//// Example: DumpRegs();		// Registers Dumped.void DumpRegs(){	// Print All 32-Bit registers ( actually, most ) and even EFLAGS.	Print( "Register Dump:\n" );	Print( "EAX=0x%x\tEBX=0x%x\tECX=0x%x\tEDX=0x%x\n", geteax(), getebx(), getecx(), getedx() );	Print( "CS=0x%x\tDS=0x%x\tES=0x%x\tFS=0x%x\n", getcs(), getds(), getes(), getfs() );	Print( "SS=0x%x\tESP=0x%x\tEFLAGS=0x%x", getss(), getesp(), geteflags() );}#endif// end of error.h

⌨️ 快捷键说明

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