NOVA
Stripped down NOVA kernel for the OSY course
include
ec.h
1
/*
2
* Execution Context
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 "regs.h"
23
#include "tss.h"
24
#include "kalloc.h"
25
#include "memory.h"
26
#include "stdio.h"
27
28
class
Ec
29
{
30
private
:
31
Exc_regs
regs;
32
33
/* Minimal and current break address (shared by all execution contexts) */
34
static
mword break_min, break_current;
35
36
REGPARM (1)
37
static
void
handle_exc (
Exc_regs
*)
asm
(
"exc_handler"
);
38
39
NORETURN
40
static
void
handle_tss()
asm
(
"tss_handler"
);
41
42
static
bool
handle_exc_ts (
Exc_regs
*);
43
44
ALWAYS_INLINE
45
inline
Sys_regs
*sys_regs() {
return
®s; }
46
47
ALWAYS_INLINE
48
inline
Exc_regs
*exc_regs() {
return
®s; }
49
50
public
:
51
static
Ec
* current;
/* Currently running execution context */
52
Ec
* next;
53
54
Ec
();
55
56
/* Switch to this execution context. Execution will continue
57
* with Ec::ret_user_sysexit(). */
58
ALWAYS_INLINE NORETURN
59
inline
void
make_current()
60
{
61
current =
this
;
62
Tss::run.sp0 =
reinterpret_cast<
mword
>
(exc_regs() + 1);
63
Ec::ret_user_sysexit();
64
UNREACHED;
// Tell the compiler to not generate function epilog
65
}
66
67
HOT NORETURN
68
static
void
ret_user_sysexit();
69
70
NORETURN
71
static
void
ret_user_iret()
asm
(
"ret_user_iret"
);
72
73
NORETURN
74
static
void
idle();
75
76
static
void
root_setup (mword);
77
78
HOT NORETURN REGPARM_1
79
static
void
syscall_handler
(uint8 a)
asm
(
"syscall_handler"
);
80
81
ALWAYS_INLINE
82
static
inline
void
*
operator
new
(size_t) {
return
Kalloc::allocator.alloc(
sizeof
(
Ec
)); }
83
84
ALWAYS_INLINE
85
static
inline
void
operator
delete
(
void
*) {
/* nop */
}
86
};
Ec
Definition:
ec.h:29
Ec::syscall_handler
HOT NORETURN static REGPARM_1 void syscall_handler(uint8 a) asm("syscall_handler")
System call handler.
Definition:
ec_syscall.cc:16
Exc_regs
Definition:
regs.h:44
Sys_regs
Definition:
regs.h:26
Generated by
1.9.1