2012-02-29 18:15:28 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
This file is part of Sortix.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Sortix is free software: you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Sortix 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 GNU General Public License for more
|
|
|
|
details.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
x86-family/idt.cpp
|
|
|
|
Initializes and handles the IDT.
|
2012-02-29 18:15:28 -05:00
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2012-03-21 19:52:29 -04:00
|
|
|
#include <sortix/kernel/platform.h>
|
2012-09-22 14:38:34 -04:00
|
|
|
#include <string.h>
|
2012-02-29 18:15:28 -05:00
|
|
|
#include "idt.h"
|
|
|
|
|
|
|
|
namespace Sortix
|
|
|
|
{
|
|
|
|
namespace IDT
|
|
|
|
{
|
|
|
|
extern "C" void idt_flush(addr_t);
|
|
|
|
|
|
|
|
idt_entry_t idt_entries[256];
|
|
|
|
idt_ptr_t idt_ptr;
|
|
|
|
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
idt_ptr.limit = sizeof(idt_entry_t) * 256 - 1;
|
|
|
|
idt_ptr.base = (addr_t) &idt_entries;
|
|
|
|
|
2012-09-22 14:38:34 -04:00
|
|
|
memset(&idt_entries, 0, sizeof(idt_entry_t)*256);
|
2012-02-29 18:15:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void Flush()
|
|
|
|
{
|
|
|
|
idt_flush((addr_t) &idt_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetGate(uint8_t num, addr_t base, uint16_t sel, uint8_t flags)
|
|
|
|
{
|
|
|
|
idt_entries[num].base_low = base & 0xFFFF;
|
|
|
|
idt_entries[num].base_high = (base >> 16) & 0xFFFF;
|
|
|
|
#ifdef PLATFORM_X64
|
|
|
|
idt_entries[num].base_highest = (base >> 32 ) & 0xFFFFFFFFU;
|
|
|
|
idt_entries[num].zero1 = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
idt_entries[num].sel = sel;
|
|
|
|
idt_entries[num].always0 = 0;
|
|
|
|
idt_entries[num].flags = flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|