aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/kernel')
-rw-r--r--arch/x86_64/src/kernel/cpu/lgdt.cpp13
-rw-r--r--arch/x86_64/src/kernel/cpu/ss.cpp8
-rw-r--r--arch/x86_64/src/kernel/main.cpp13
3 files changed, 15 insertions, 19 deletions
diff --git a/arch/x86_64/src/kernel/cpu/lgdt.cpp b/arch/x86_64/src/kernel/cpu/lgdt.cpp
index 70a48dd..386914f 100644
--- a/arch/x86_64/src/kernel/cpu/lgdt.cpp
+++ b/arch/x86_64/src/kernel/cpu/lgdt.cpp
@@ -4,14 +4,17 @@
namespace teachos::arch::kernel::cpu
{
+ auto store_global_descriptor_table() -> context_switching::descriptor_table::global_descriptor_table_pointer
+ {
+ context_switching::descriptor_table::global_descriptor_table_pointer current_value{};
+ asm("sgdt %[output]" : [output] "=m"(current_value));
+ return current_value;
+ }
+
auto
load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer const & gdt_pointer)
-> void
{
- // TODO: build lgdt argument from global_descriptor_table_pointer (don't know how yet)
- // asm volatile("lgdt (%0)" : : "r"(gdt_pointer));
- if (gdt_pointer.table_length)
- {
- }
+ asm volatile("lgdt %[input]" : /* no output from call */ : [input] "m"(gdt_pointer));
}
} // namespace teachos::arch::kernel::cpu
diff --git a/arch/x86_64/src/kernel/cpu/ss.cpp b/arch/x86_64/src/kernel/cpu/ss.cpp
index 9c8dd61..1f28e7f 100644
--- a/arch/x86_64/src/kernel/cpu/ss.cpp
+++ b/arch/x86_64/src/kernel/cpu/ss.cpp
@@ -19,15 +19,15 @@ namespace teachos::arch::kernel::cpu
auto read_ss() -> uint16_t
{
- uint16_t ss;
- asm volatile("mov %%ss, %0" : "=r"(ss));
- return ss;
+ uint16_t segment_selector;
+ asm volatile("mov %%ss, %[output]" : [output] "=r"(segment_selector));
+ return segment_selector;
}
auto write_ss(segment_selector selector) -> void
{
uint16_t ss = selector.to_uint16();
- asm volatile("mov %0, %%ss" ::"r"(ss));
+ asm volatile("mov %[input], %%ss" : /* no output from call */ : [input] "r"(ss));
}
} // namespace teachos::arch::kernel::cpu \ No newline at end of file
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 4db9599..2c0b6c8 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -1,6 +1,7 @@
#include "arch/kernel/main.hpp"
#include "arch/context_switching/descriptor_table/global_descriptor_table.hpp"
+#include "arch/kernel/cpu/lgdt.hpp"
#include "arch/memory/heap/bump_allocator.hpp"
#include "arch/memory/heap/global_heap_allocator.hpp"
#include "arch/memory/main.hpp"
@@ -60,16 +61,8 @@ namespace teachos::arch::kernel
heap_test();
- context_switching::descriptor_table::global_descriptor_table global_descriptor_table{
- context_switching::descriptor_table::initialize_global_descriptor_table()};
-
- decltype(auto) x = global_descriptor_table.at(1);
- if (global_descriptor_table.size() == 0)
- {
- }
- if (x.get_segment_type() == context_switching::descriptor_table::segment_descriptor_type::CODE_SEGMENT)
- {
- }
+ auto global_descriptor_table = context_switching::descriptor_table::initialize_global_descriptor_table();
+ (void)global_descriptor_table.at(1);
video::vga::text::write("GDT FILLED", video::vga::text::common_attributes::green_on_black);
}
} // namespace teachos::arch::kernel