intr.c

来自「raywill写的操作系统内核」· C语言 代码 · 共 45 行

C
45
字号
#include <i386/vector.h>		/*regs_t*/
#include <i386/intr.h>
#include <asmcmd.h>

void common_interrupt(regs_t *regs)
{
	static const char * const msg[] =
	{
		"divide error", "debug exception", "NMI", "INT3",
		"INTO", "BOUND exception", "invalid opcode", "no coprocessor",
		"double fault", "coprocessor segment overrun",
			"bad TSS", "segment not present",
		"stack fault", "GPF", "page fault", "xxx",
		"coprocessor error", "alignment check", "xxx", "xxx",
		"xxx", "xxx", "xxx", "xxx",
		"xxx", "xxx", "xxx", "xxx",
		"xxx", "xxx", "xxx", "xxx",
		"IRQ0", "IRQ1", "IRQ2", "IRQ3",
		"IRQ4", "IRQ5", "IRQ6", "IRQ7",
		"IRQ8", "IRQ9", "IRQ10", "IRQ11",
		"IRQ12", "IRQ13", "IRQ14", "IRQ15",
		"syscall"
	};
/**/

		
	switch(regs->which_int)
	{
/* this handler installed at compile-time
Keyboard handler is installed at run-time (see below) */
	case 0x20:	/* timer IRQ 0 */
		print("Timer\n");
/* reset hardware interrupt at 8259 chip */
		outportb(0x20, 0x20);
		break;
	default:
		print("Exception occured: ");
		print(msg[regs->which_int]);
		cli();
		halt();
		while(1);
		break;
	}
}

⌨️ 快捷键说明

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