📄 exception.c
字号:
/* * OSV * Copyright (C) 2002 Ciprian DOSOFTEI <rocksoul@mail.com> * All rights reserved. * * http://backster.free.fr/osv * * This file is part of the OSV project. OSV is free software, also known as * "open source"; you can redistribute it and/or modify it under the terms * of the GNU General Public License (GPL), version 2, as published by the Free * Software Foundation (FSF). To explore alternate licensing terms, contact * the author at rocksoul@mail.com or +40740649907. * * OSV is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have * received a copy of the GPL along with OSV; see the file COPYING. If * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA. */#include <exception.h>typedef char ExceptionMessage[32];void setupExceptions(void) { interruptIDT(&IDT[0], KERNEL_CS, (dword)&__DivideError, 0); interruptIDT(&IDT[1], KERNEL_CS, (dword)&__DebugException, 0); interruptIDT(&IDT[2], KERNEL_CS, (dword)&__NonMaskableInterrupt, 0); interruptIDT(&IDT[3], KERNEL_CS, (dword)&__Breakpoint, 3); /* can be called from user mode */ interruptIDT(&IDT[4], KERNEL_CS, (dword)&__Overflow, 0); interruptIDT(&IDT[5], KERNEL_CS, (dword)&__BoundsCheck, 0); interruptIDT(&IDT[6], KERNEL_CS, (dword)&__InvalidOpcode, 0); interruptIDT(&IDT[7], KERNEL_CS, (dword)&__CoprocessorNotAvailable, 0); interruptIDT(&IDT[8], KERNEL_CS, (dword)&__DoubleFault, 0); interruptIDT(&IDT[9], KERNEL_CS, (dword)&__CoprocessorSegmentOverrun, 0); interruptIDT(&IDT[10], KERNEL_CS, (dword)&__InvalidTSS, 0); interruptIDT(&IDT[11], KERNEL_CS, (dword)&__SegmentNotPresent, 0); interruptIDT(&IDT[12], KERNEL_CS, (dword)&__StackException, 0); interruptIDT(&IDT[13], KERNEL_CS, (dword)&__GeneralProtection, 0); interruptIDT(&IDT[14], KERNEL_CS, (dword)&__PageFault, 0); interruptIDT(&IDT[15], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[16], KERNEL_CS, (dword)&__CoprocessorError, 0); interruptIDT(&IDT[17], KERNEL_CS, (dword)&__AlignmentCheck, 0); interruptIDT(&IDT[18], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[19], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[20], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[21], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[22], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[23], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[24], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[25], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[26], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[27], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[28], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[29], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[30], KERNEL_CS, (dword)&__Reserved, 0); interruptIDT(&IDT[31], KERNEL_CS, (dword)&__Reserved, 0);}static const ExceptionMessage exceptionDescription[N_EXCEPTIONS] = { "Divide Error", "Debug Exception", "Non-Maskable Interrupt", "Breakpoint", "Overflow", "Bounds Check", "Invalid Opcode", "Coprocessor Not Available", "Double Fault", "Coprocessor Segment Overrun", "Invalid TSS", "Segment Not Present", "Stack Exception", "General Protection Fault", "Page Fault", "Reserved", "Coprocessor Error", "Alignment Check", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved"};void exceptionHandler(dword edi, dword esi, dword ebp, dword esp, dword ebx, dword edx, dword ecx, dword eax, dword gs, dword fs, dword es, dword ds, dword nr, dword errorCode, dword eip, dword cs, dword eflags){ if (nr != 3) { halt(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -