NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
include
gdt.h
1
/*
2
* Global Descriptor Table (GDT)
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 "selectors.h"
24
25
class
Gdt
:
public
Descriptor
26
{
27
private
:
28
uint32 val[2];
29
30
ALWAYS_INLINE
31
inline
void
set (Type type, Granularity gran, Size size,
unsigned
dpl, mword base, mword limit)
32
{
33
val[0] =
static_cast<
uint32
>
(base << 16 | (limit & 0xffff));
34
val[1] =
static_cast<
uint32
>
((base & 0xff000000) | gran | size | (limit & 0xf0000) | 1u << 15 | dpl << 13 | type | (base >> 16 & 0xff));
35
}
36
37
public
:
38
static
Gdt
gdt[SEL_MAX >> 3];
39
40
static
void
build();
41
42
ALWAYS_INLINE
43
static
inline
void
load()
44
{
45
Pseudo_descriptor
d (
sizeof
(gdt) - 1,
reinterpret_cast<
mword
>
(gdt));
46
asm
volatile
(
"lgdt %0"
: :
"m"
(d));
47
}
48
49
ALWAYS_INLINE
50
static
inline
void
unbusy_tss()
51
{
52
gdt[SEL_TSS_RUN >> 3].val[1] &= ~0x200;
53
}
54
};
Descriptor
Definition
descriptor.h:25
Gdt
Definition
gdt.h:26
Pseudo_descriptor
Definition
descriptor.h:70
Generated by
1.14.0