aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/arch/cpu/initialization.cpp20
-rw-r--r--arch/x86_64/arch/cpu/interrupts.cpp4
-rw-r--r--arch/x86_64/arch/cpu/task_state_segment.hpp21
3 files changed, 33 insertions, 12 deletions
diff --git a/arch/x86_64/arch/cpu/initialization.cpp b/arch/x86_64/arch/cpu/initialization.cpp
index 67bc2a4d..be1cc9f8 100644
--- a/arch/x86_64/arch/cpu/initialization.cpp
+++ b/arch/x86_64/arch/cpu/initialization.cpp
@@ -8,7 +8,9 @@
#include <kstd/print.hpp>
+#include <array>
#include <bit>
+#include <cstddef>
#include <cstdint>
namespace arch::cpu
@@ -111,11 +113,27 @@ namespace arch::cpu
(address >> 32) & 0xffff'ffff, // NOLINT(readability-magic-numbers)
};
}
+
+ [[gnu::section(".ist1_stack")]] auto constinit ist1_stack = std::array<std::byte, 4096>{};
+
+ auto constinit tss = task_state_segment{
+ .rsp0 = nullptr,
+ .rsp1 = nullptr,
+ .rsp2 = nullptr,
+ .ist1 = ist1_stack.data() + ist1_stack.size(),
+ .ist2 = nullptr,
+ .ist3 = nullptr,
+ .ist4 = nullptr,
+ .ist5 = nullptr,
+ .ist6 = nullptr,
+ .ist7 = nullptr,
+ .io_map_base_address = 0,
+ };
+
} // namespace
auto initialize_descriptors() -> void
{
- auto static tss = task_state_segment{};
auto static tss_descriptor = make_tss_descriptor(&tss);
auto static gdt = global_descriptor_table{
diff --git a/arch/x86_64/arch/cpu/interrupts.cpp b/arch/x86_64/arch/cpu/interrupts.cpp
index 2fdc4671..cf225a90 100644
--- a/arch/x86_64/arch/cpu/interrupts.cpp
+++ b/arch/x86_64/arch/cpu/interrupts.cpp
@@ -167,10 +167,12 @@ namespace arch::cpu
{
for (auto i = 0uz; i < 256; ++i)
{
+ auto ist_selector = static_cast<std::uint8_t>(i == 8 ? 1 : 0);
+
m_descriptors[i] = gate_descriptor{
.offset_low = static_cast<std::uint16_t>(isr_stub_table[i] & 0xffff), // NOLINT(readability-magic-numbers)
.m_code_segment = segment_selector{0, false, 1},
- .interrupt_stack_table_selector = 0,
+ .interrupt_stack_table_selector = ist_selector,
.gate_type = (i < 32 && i != 2) ? gate_type::trap_gate : gate_type::interrupt_gate,
.descriptor_privilege_level = 0,
.present = true,
diff --git a/arch/x86_64/arch/cpu/task_state_segment.hpp b/arch/x86_64/arch/cpu/task_state_segment.hpp
index ab141f4c..f8b257d4 100644
--- a/arch/x86_64/arch/cpu/task_state_segment.hpp
+++ b/arch/x86_64/arch/cpu/task_state_segment.hpp
@@ -1,6 +1,7 @@
#ifndef TEACHOS_ARCH_X86_64_TASK_STATE_SEGMENT_HPP
#define TEACHOS_ARCH_X86_64_TASK_STATE_SEGMENT_HPP
+#include <cstddef>
#include <cstdint>
namespace arch::cpu
@@ -9,17 +10,17 @@ namespace arch::cpu
struct [[gnu::packed]] task_state_segment
{
std::uint32_t : 32;
- std::uint64_t rsp0 = {};
- std::uint64_t rsp1 = {};
- std::uint64_t rsp2 = {};
+ std::byte * rsp0 = {};
+ std::byte * rsp1 = {};
+ std::byte * rsp2 = {};
std::uint64_t : 64;
- std::uint64_t ist1 = {};
- std::uint64_t ist2 = {};
- std::uint64_t ist3 = {};
- std::uint64_t ist4 = {};
- std::uint64_t ist5 = {};
- std::uint64_t ist6 = {};
- std::uint64_t ist7 = {};
+ std::byte * ist1 = {};
+ std::byte * ist2 = {};
+ std::byte * ist3 = {};
+ std::byte * ist4 = {};
+ std::byte * ist5 = {};
+ std::byte * ist6 = {};
+ std::byte * ist7 = {};
std::uint64_t : 64;
std::uint16_t : 16;
std::uint16_t io_map_base_address = {};