NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
idt.h
1/*
2 * Interrupt Descriptor Table (IDT)
3 *
4 * Copyright (C) 2009-2011 Udo Steinberg <udo@hypervisor.org>
5 * Economic rights: Technische Universitaet Dresden (Germany)
6 *
7 * This file is part of the NOVA microhypervisor.
8 *
9 * NOVA is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * NOVA is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License version 2 for more details.
17 */
18
19#pragma once
20
21#include "compiler.h"
22#include "descriptor.h"
23#include "vectors.h"
24
25class Idt : public Descriptor
26{
27 private:
28 uint32 val[sizeof (mword) / 2];
29
30 ALWAYS_INLINE
31 inline void set (Type type, unsigned dpl, unsigned selector, mword offset)
32 {
33 val[0] = static_cast<uint32>(selector << 16 | (offset & 0xffff));
34 val[1] = static_cast<uint32>((offset & 0xffff0000) | 1u << 15 | dpl << 13 | type);
35 }
36
37 public:
38 static Idt idt[VEC_MAX];
39
40 INIT
41 static void build();
42
43 ALWAYS_INLINE
44 static inline void load()
45 {
46 Pseudo_descriptor d (sizeof(idt) - 1, reinterpret_cast<mword>(idt));
47 asm volatile("lidt %0" : : "m" (d));
48 }
49};
Definition descriptor.h:25
Definition idt.h:26
Definition descriptor.h:70