aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/kernel/cpu')
-rw-r--r--arch/x86_64/src/kernel/cpu/ss.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/arch/x86_64/src/kernel/cpu/ss.cpp b/arch/x86_64/src/kernel/cpu/ss.cpp
index 1f28e7f..0978eca 100644
--- a/arch/x86_64/src/kernel/cpu/ss.cpp
+++ b/arch/x86_64/src/kernel/cpu/ss.cpp
@@ -2,32 +2,15 @@
namespace teachos::arch::kernel::cpu
{
- segment_selector::segment_selector(uint16_t index, std::bitset<1U> table_indicator,
- std::bitset<2U> requested_privilege_level)
- : index(index)
- , table_indicator(table_indicator)
- , requested_privilege_level(requested_privilege_level)
+ auto read_ss() -> context_switching::interrupt_descriptor_table::segment_selector
{
- // Nothing to do
- }
-
- auto segment_selector::to_uint16() const -> uint16_t
- {
- return static_cast<uint16_t>((index << 3) | (table_indicator.to_ulong() << 2) |
- requested_privilege_level.to_ulong());
- }
-
- auto read_ss() -> uint16_t
- {
- uint16_t segment_selector;
- asm volatile("mov %%ss, %[output]" : [output] "=r"(segment_selector));
+ context_switching::interrupt_descriptor_table::segment_selector segment_selector{};
+ asm volatile("mov %%ss, %[output]" : [output] "=m"(segment_selector));
return segment_selector;
}
- auto write_ss(segment_selector selector) -> void
+ auto write_ss(context_switching::interrupt_descriptor_table::segment_selector selector) -> void
{
- uint16_t ss = selector.to_uint16();
- asm volatile("mov %[input], %%ss" : /* no output from call */ : [input] "r"(ss));
+ asm volatile("mov %[input], %%ss" : /* no output from call */ : [input] "m"(selector));
}
-
-} // namespace teachos::arch::kernel::cpu \ No newline at end of file
+} // namespace teachos::arch::kernel::cpu