📄 x86.h
字号:
/* x86.h : FritzOS x86 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.*//* This file is for using the x86 instructions in C*/// defines:#ifndef X86_H#define X86_H// If someone wants to use sti or cli in a more understanding way, define enable_ints and disable_ints#define enable_ints sti#define disable_ints cli// voids:// inb: get a byte from the selected port__inline__ unsigned inportb(unsigned port);// outb: send the selected byte to the selected port__inline__ void outportb(unsigned port, unsigned val);// Enable Interrupts:__inline__ void sti();// Disable Interrupts:__inline__ void cli();// A reboot function for rebooting the computer:void reboot();// data:int checkints; // for checking if interrupts are disabled or enabled//***********************************************************************************************************//__inline__ unsigned inportb(unsigned port){ unsigned ret_val; __asm__ __volatile__("inb %w1,%b0" : "=a"(ret_val) : "d"(port)); return ret_val;}//***********************************************************************************************************//__inline__ void outportb(unsigned port, unsigned val){ __asm__ __volatile__("outb %b0,%w1" : : "a"(val), "d"(port));}//***********************************************************************************************************//void reboot(){ int temp; // A temporary int for storing keyboard info. The keyboard can be use to // reboot the PC // Get ready for reboot...flush the keyboard controller do { temp = inportb( 0x64 ); if ( temp & 1 ) inportb( 0x60 ); } while ( temp & 2 ); // Reboot the computer... outportb(0x64, 0xFE); // If this didn't reboot the computer...let the code that calles this handle that.}//***********************************************************************************************************//__inline__ void sti(){ __asm__ __volatile__( "sti" ); // Enable ints // Set checkints to 1 - on checkints = 1;}//***********************************************************************************************************//__inline__ void cli(){ __asm__ __volatile__( "cli" ); // Disable ints // Set checkints to 0 - off checkints = 0;}#endif// end of x86.h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -