📄 idt.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 <idt.h>#include <gdt.h>gate *IDT = (gate *)(GDT_SIZE * sizeof(descriptor));void setupIDT(void) { dword IDTR[2]; memset(IDT, 0, IDT_SIZE * sizeof(gate)); IDTR[0] = ((IDT_SIZE * sizeof(gate)) - 1) << 16; IDTR[1] = (dword)IDT; __asm__ __volatile__("lidt (%0)" : : "r" (((byte *)IDTR) + 2));}void interruptIDT(gate *g, word selector, dword offset, byte dpl) { g->offset0_15 = offset; g->offset16_31 = offset >> 16; g->selector = selector; g->zero = 0; g->p = 1; g->dpl = dpl; g->type = 0xE;}void trapIDT(gate *g, word selector, dword offset, byte dpl) { g->offset0_15 = offset; g->offset16_31 = offset >> 16; g->selector = selector; g->zero = 0; g->p = 1; g->dpl = dpl; g->type = 0xF;}void taskIDT(gate *g, word selector, byte dpl){ g->offset0_15 = 0; g->offset16_31 = 0; g->selector = selector; g->zero = 0; g->p = 1; g->dpl = dpl; g->type = 5;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -