blob: 661406535227499fcc5cf5d2a590256d08d00aed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "arch/context_switching/main.hpp"
#include "arch/boot/pointers.hpp"
#include "arch/exception_handling/assert.hpp"
#include "arch/kernel/cpu/if.hpp"
#include "arch/kernel/cpu/jmp.hpp"
#include "arch/kernel/cpu/tr.hpp"
namespace teachos::arch::context_switching
{
auto initialize_descriptor_tables() -> descriptor_tables
{
kernel::cpu::clear_interrupt_flag();
segment_descriptor_table::update_global_descriptor_table_register();
interrupt_descriptor_table::update_interrupt_descriptor_table_register();
interrupt_descriptor_table::segment_selector segment_selector{
1U, interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_KERNEL};
kernel::cpu::far_pointer pointer{&boot::reload_segment_register, segment_selector};
kernel::cpu::jmp(pointer);
segment_descriptor_table::update_task_state_segment_register();
kernel::cpu::set_interrupt_flag();
descriptor_tables tables = {segment_descriptor_table::get_or_create_global_descriptor_table(),
interrupt_descriptor_table::get_or_create_interrupt_descriptor_table()};
return tables;
}
} // namespace teachos::arch::context_switching
|