aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/pre/src/context_switching
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/pre/src/context_switching')
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp24
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/idt_flags.cpp20
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp53
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp13
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/ist_offset.cpp10
-rw-r--r--arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/segment_selector.cpp24
6 files changed, 0 insertions, 144 deletions
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp
deleted file mode 100644
index 28f289c..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- gate_descriptor::gate_descriptor(uint128_t flags)
- : _offset_1(flags)
- , _selector(flags >> 19U, flags >> 16U)
- , _ist(flags >> 32U)
- , _flags(flags >> 40U)
- , _offset_2(flags >> 48U)
- {
- // Nothing to do.
- }
-
- gate_descriptor::gate_descriptor(segment_selector selector, ist_offset ist, idt_flags flags, uint64_t offset)
- : _offset_1(offset)
- , _selector(selector)
- , _ist(ist)
- , _flags(flags)
- , _offset_2(offset >> 16U)
- {
- // Nothing to do.
- }
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/idt_flags.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/idt_flags.cpp
deleted file mode 100644
index f3b9d5e..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/idt_flags.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/idt_flags.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- idt_flags::idt_flags(uint8_t flags)
- : _flags(flags)
- {
- // Nothing to do.
- }
-
- auto idt_flags::contains_flags(std::bitset<8U> other) const -> bool
- {
- return (std::bitset<8U>{_flags} & other) == other;
- }
-
- auto idt_flags::operator|=(std::bitset<8U> other) -> void
- {
- _flags |= other.to_ulong();
- }
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp
deleted file mode 100644
index 8640385..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp"
-
-#include "arch/exception_handling/assert.hpp"
-#include "arch/interrupt_handling/generic_interrupt_handler.hpp"
-#include "arch/kernel/cpu/idtr.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- namespace
- {
- /// @brief Amount of currently reserved interrupt indicies.
- /// See https://wiki.osdev.org/Interrupt_Descriptor_Table#IDT_items for more information.
- constexpr uint16_t RESERVED_INTERRUPT_COUNT = 256U;
-
- auto create_interrupt_descriptor_table() -> interrupt_descriptor_table
- {
- interrupt_descriptor_table interrupt_descriptor_table{RESERVED_INTERRUPT_COUNT};
-
- uint64_t offset = reinterpret_cast<uint64_t>(interrupt_handling::generic_interrupt_handler);
- segment_selector selector{1U, segment_selector::REQUEST_LEVEL_KERNEL};
- ist_offset ist{0U};
- idt_flags flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::INTERRUPT_GATE | idt_flags::PRESENT};
-
- for (std::size_t i = 0; i < interrupt_descriptor_table.size(); i++)
- {
- interrupt_descriptor_table.at(i) = {selector, ist, flags, offset};
- }
-
- return interrupt_descriptor_table;
- }
- } // namespace
-
- auto get_or_create_interrupt_descriptor_table() -> interrupt_descriptor_table &
- {
- // Interrupt Descriptor Table needs to be kept alive
- interrupt_descriptor_table static idt = create_interrupt_descriptor_table();
- return idt;
- }
-
- auto update_interrupt_descriptor_table_register() -> void
- {
- decltype(auto) idt = get_or_create_interrupt_descriptor_table();
-
- interrupt_descriptor_table_pointer idt_pointer{static_cast<uint16_t>((idt.size() * sizeof(gate_descriptor)) - 1),
- idt.data()};
- kernel::cpu::load_interrupt_descriptor_table(idt_pointer);
-
- auto const stored_gdt_pointer = kernel::cpu::store_interrupt_descriptor_table();
- arch::exception_handling::assert(
- idt_pointer == stored_gdt_pointer,
- "[Interrupt Descriptor Table] Loaded IDTR value is not the same as the stored value.");
- }
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp
deleted file mode 100644
index 7bcbae6..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- interrupt_descriptor_table_pointer::interrupt_descriptor_table_pointer(uint16_t table_length,
- gate_descriptor * address)
- : table_length(table_length)
- , address(address)
- {
- // Nothing to do.
- }
-
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/ist_offset.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/ist_offset.cpp
deleted file mode 100644
index a70e75d..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/ist_offset.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/ist_offset.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- ist_offset::ist_offset(uint8_t index)
- : _ist(index)
- {
- // Nothing to do.
- }
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/segment_selector.cpp b/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/segment_selector.cpp
deleted file mode 100644
index 25ba859..0000000
--- a/arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/segment_selector.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "arch/context_switching/interrupt_descriptor_table/segment_selector.hpp"
-
-namespace teachos::arch::context_switching::interrupt_descriptor_table
-{
- auto segment_selector::contains_flags(std::bitset<3U> other) const -> bool
- {
- return (std::bitset<3U>{_flags} & other) == other;
- }
-
- auto segment_selector::get_index() const -> uint16_t
- {
- return _index;
- }
-
- auto segment_selector::operator|=(std::bitset<3U> other) -> void
- {
- _flags |= other.to_ulong();
- }
-
- segment_selector::operator uint16_t() const
- {
- return *reinterpret_cast<uint16_t const *>(this);
- }
-} // namespace teachos::arch::context_switching::interrupt_descriptor_table