📄 kernel32.cpp
字号:
/* kernel32.cpp : FritzOS C++ Kernel Copyright (C) 2002 Tom Fritz ********************************************************* THE MAIN C++ CODE OF FRITZOS ********************************************************* * 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.*/#include "../include/fstdio.h" // need printf, setcolor, and freeze#include "../include/keys.h" // need getch for getting keys fromt he keyboard#include "../include/detect.h" // For detecting color or mono video cards#include "../include/error.h" // Need panic#include "msgs.h" // Messages// Define the FritzOS version, so all I have to do is change this when it prints the version#define FOSVERSIONFULL 0#define FOSVERSIONDOT 7// Main Function of FritzOS:extern "C" void start(); // NOTE: I use the "EXTERN" directive so this can be called in the ASM // module...other wise...this function's name is mangled.// Function for detecting the video card before FritzOS is loaded:extern "C" void CheckVid(); // NOTE: I use the extern "C" directive so this can be called in the ASM // module...other wise...this function's name is mangled.// For getting the character pressedUCHAR ch;////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FritzOS Main Kernel:extern void start() // Got here from kernelasm.asm{ // ... the GDT was loaded before here // Put back the default color, LoadingGDTMsg changed it to blue: setcolor( WHITE_BLACK ); // Tell about FritzOS... Print( "FritzOS Version %d.%d Booted.\n", FOSVERSIONFULL, FOSVERSIONDOT ); Print( "Copyright (C) 2002 Tom Fritz\n" ); // Me Print( "FritzOS comes with ABSOLUTELY NO WARRANTY; for details look in the COPYING file.\n" ); Print( "(The COPYING file should be with the downloaded source code of FritzOS)\n" ); Print( "This is free software, and you are welcome to redistribute it\n" ); Print( "under certain conditions; look at the COPYING file for details.\n" ); // Test Key Handeling: // Let User Know that we are testing the keys: // Change Color To Green On Black: setcolor( GREEN_BLACK ); Print( "Testing Key Handing ( Polling ) press numbers, letters and symbols, and F1-3 to test \the panic function:\t" ); // Set Typing Color To MAGENTA_BLACK setcolor( MAGENTA_BLACK ); while ( TRUE ) { ch = getch(); // Get the key // F1 Pressed, panic level 1 if ( ch == KF1 ) panic( "Test Key F1", 0 ); // F1 Pressed, panic level 2 else if ( ch == KF2 ) panic( "Test Key F2", 1 ); // F1 Pressed, panic level 3 else if ( ch == KF3 ) panic( "Test Key F3", 2 ); // Backspace pressed, blank the current character: else if ( ch == BACKSPACE ) // Put a blank character: Print( "\b \b" ); // Just a normal character: else putch( ch ); // Just Echo it. } Freeze();}//************************************************************************************************************//// Check if FritzOS is on a computer with a video color or mono card -- FritzOS needs a color card.void CheckVid(){ // Let user know that we are... Print( "Detecting Color Video Card:\t" ); if ( DetectVidCard() == COLORCARD ) { // There's a color card..ok...go on to FritzOS and print a message: setcolor( BLUE_BLACK ); // Blue on black text Print( "[OK]\n" ); setcolor( WHITE_BLACK ); // return default color return; } // There's not a color card, a mono card...let user know and wait for a key to reboot. else if ( DetectVidCard() == MONOCARD ) { setcolor( RED_BLACK ); // Red on black text Print( "[NO]\n" ); setcolor( WHITE_BLACK ); // return default color Print( "Sorry, FritzOS can only be used on color video cards. You are using a\n" ); Print( "mono video card.\n\tPlease Press A Key To Reboot:\t" ); // wait for a key to reboot: getch(); // Reboot: reboot(); // If couldn't reboot, let user know: Print( "Sorry, FritzOS could not reboot your computer. Please turn it off and then back on." ); Freeze(); // Nothing to do, Freeze. }}// End of kernel32.cpp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -