aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2025-03-25 16:58:24 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2025-03-25 16:58:24 +0000
commit66fefaeb16bcbc4eae5ce5256ae76f51a155cded (patch)
tree121b05b3764c7825f4f87c43e0bce6dd32707d29 /arch/x86_64/src/kernel
parentccb47845d99e098c183f596cd1a3eb1db5c676da (diff)
downloadteachos-66fefaeb16bcbc4eae5ce5256ae76f51a155cded.tar.xz
teachos-66fefaeb16bcbc4eae5ce5256ae76f51a155cded.zip
Implement idtr structure and document possible flags.
Diffstat (limited to 'arch/x86_64/src/kernel')
-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