aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--arch/x86_64/CMakeLists.txt8
-rw-r--r--arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp67
-rw-r--r--arch/x86_64/include/arch/context_switching/descriptor_table/gdt_flags.hpp25
-rw-r--r--arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp22
-rw-r--r--arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp16
-rw-r--r--arch/x86_64/include/arch/context_switching/descriptor_table/type_field.hpp84
-rw-r--r--arch/x86_64/include/arch/kernel/cpu/lgdt.hpp11
-rw-r--r--arch/x86_64/include/arch/memory/allocator/physical_frame.hpp6
-rw-r--r--arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp4
-rw-r--r--arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp6
-rw-r--r--arch/x86_64/include/arch/memory/multiboot/memory_map.hpp6
-rw-r--r--arch/x86_64/include/arch/memory/paging/virtual_page.hpp2
-rw-r--r--arch/x86_64/include/arch/stl/container.hpp (renamed from arch/x86_64/include/arch/shared/container.hpp)10
-rw-r--r--arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp (renamed from arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp)10
-rw-r--r--arch/x86_64/include/arch/stl/forward_value_iterator.hpp (renamed from arch/x86_64/include/arch/shared/forward_value_iterator.hpp)10
-rw-r--r--arch/x86_64/include/arch/stl/mutex.hpp (renamed from arch/x86_64/include/arch/shared/mutex.hpp)10
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/access_byte.cpp10
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/gdt_flags.cpp14
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp40
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp12
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/segment_descriptor.cpp17
-rw-r--r--arch/x86_64/src/context_switching/descriptor_table/type_field.cpp12
-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
-rw-r--r--arch/x86_64/src/memory/heap/linked_list_allocator.cpp2
-rw-r--r--arch/x86_64/src/stl/mutex.cpp (renamed from arch/x86_64/src/shared/mutex.cpp)6
28 files changed, 210 insertions, 242 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index daf87b8..c895618 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,11 +123,11 @@ add_library("_context" OBJECT)
add_library("teachos::context_switching" ALIAS "_context")
#[============================================================================[
-# The Shared Library
+# The Context switching Library
#]============================================================================]
-add_library("_shared" OBJECT)
-add_library("teachos::shared" ALIAS "_shared")
+add_library("_stl" OBJECT)
+add_library("teachos::stl" ALIAS "_stl")
#[============================================================================[
# The Kernel
@@ -143,7 +143,7 @@ target_link_libraries("_kernel" PRIVATE
"teachos::video"
"teachos::memory"
"teachos::exception"
- "teachos::shared"
+ "teachos::stl"
"teachos::context_switching"
)
diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt
index 53339d2..912daf6 100644
--- a/arch/x86_64/CMakeLists.txt
+++ b/arch/x86_64/CMakeLists.txt
@@ -65,11 +65,11 @@ target_sources("_memory" PRIVATE
)
#[============================================================================[
-# The Shared Library
+# The STL Library
#]============================================================================]
-target_sources("_shared" PRIVATE
- "src/shared/mutex.cpp"
+target_sources("_stl" PRIVATE
+ "src/stl/mutex.cpp"
)
#[============================================================================[
@@ -91,8 +91,8 @@ target_sources("_context" PRIVATE
"src/context_switching/descriptor_table/access_byte.cpp"
"src/context_switching/descriptor_table/gdt_flags.cpp"
"src/context_switching/descriptor_table/global_descriptor_table.cpp"
+ "src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp"
"src/context_switching/descriptor_table/segment_descriptor.cpp"
- "src/context_switching/descriptor_table/type_field.cpp"
)
#[============================================================================[
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp
index dc4de03..bafce8d 100644
--- a/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp
+++ b/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp
@@ -2,9 +2,8 @@
#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_ACCESS_BYTE_HPP
#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_ACCESS_BYTE_HPP
-#include "arch/context_switching/descriptor_table/type_field.hpp"
-
#include <bitset>
+#include <cstdint>
namespace teachos::arch::context_switching::descriptor_table
{
@@ -12,24 +11,49 @@ namespace teachos::arch::context_switching::descriptor_table
* @brief Defines helper function for all states that the access byte field of a segment descriptor can
* have.
*/
- struct access_byte
+ struct [[gnu::packed]] access_byte
{
/**
* @brief Possible set bits in our underlying std::bitset and the meaning when they are set.
*/
enum bitset : uint8_t
{
- CODE_OR_DATA_SEGMENT = 1U << 0U, ///< Defines a system segment (if 0) or a code/data segment (if 1).
- ACCESS_LEVEL_KERNEL = 0, ///< Highest privileged level used by the kernel to allow for full access of resources.
+ ACCESSED =
+ 1U
+ << 0U, ///< Whether the segment has been accessed since the last time the operating system has cleared the
+ ///< flag. If enabled it has been accessed, otherwise it has not been accessed since the last clear.
+ WRITABLE = 1U << 1U, ///< Indicates if the data segment is writable or not. If enabled the code segment allows
+ ///< read and write access, otherwise only read access is possible.
+ READABLE = 1U << 1U, ///< Indicates if the code segment is readable or not. If enabled the code segment allows
+ ///< read and execute access, otherwise only executable access is possible.
+ CONFORMING =
+ 1U << 2U, ///< Indicates if the code is allowed to be executed by different access levels
+ ///< (higher or lower) in code segments. If enabled the code segment allows access, otherwise
+ ///< access from different privilege levels with throw a General-Protectione exception.
+ EXPAND_DOWN = 1U << 2U, ///< Indicates if the expansion direction is up or down in data segments. If enabled the
+ ///< data segment expands downwards, otherwise it expands upwards.
+ CODE_SEGMENT = 1U << 3U, ///< Further defines the actual type of the segment. If enabled this segment is a code
+ ///< segment, otherwise its a data segment.
+ LOCAL_DESCRIPTOR_TABLE = 2, ///< The actual type of sytem segment is a local descriptor table.
+ TASK_STATE_SEGMENT_AVAILABLE =
+ 9, ///< The actual type of sytem segment is a task state segment that is still available.
+ TASK_STATE_SEGMENT_BUSY = 11, ///< The actual type of sytem segment is a task state segment that is currently in
+ ///< use and therefore busy.
+ CALL_GATE = 11, ///< The actual type of sytem segment is a call gate.
+ INTERRUPT_GATE = 14, ///< The actual type of sytem segment is a interrupt gate.
+ TRAP_GATE = 15, ///< The actual type of sytem segment is a trap gate.
+ CODE_OR_DATA_SEGMENT = 1U << 4U, ///< Defines a system segment (if 0) or a code/data segment (if 1).
+ ACCESS_LEVEL_KERNEL =
+ 0U << 4U, ///< Highest privileged level used by the kernel to allow for full access of resources.
ACCESS_LEVEL_ADMIN =
- 2, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more
- ///< than two privilege levels are required, otherwise using Level 3 and Level 0 is recommended.
+ 2U << 4U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more
+ ///< than two privilege levels are required, otherwise using Level 3 and Level 0 is recommended.
ACCESS_LEVEL_PRIVILEGED_USER =
- 4, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more than
- ///< two privilege levels are required, otherwise using Level 3 and Level 0 is recommended.
- ACCESS_LEVEL_USER = 6, ///< Restricts access to only application and their specific memory.
- PRESENT = 1U << 3U, ///< Present bit; Allows an entry to refer to a valid segment.
- ///< Must be set (1) for any valid segment.
+ 4U << 4U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more
+ ///< than two privilege levels are required, otherwise using Level 3 and Level 0 is recommended.
+ ACCESS_LEVEL_USER = 6U << 4U, ///< Restricts access to only application and their specific memory.
+ PRESENT = 1U << 3U << 4U, ///< Present bit; Allows an entry to refer to a valid segment.
+ ///< Must be set (1) for any valid segment.
};
/**
@@ -40,10 +64,11 @@ namespace teachos::arch::context_switching::descriptor_table
/**
* @brief Constructor.
*
- * @param flags Left-most four bits of the access_byte.
- * @param type_field Right-most four bits of the access_byte representing the type_field.
+ * @param flags Allows to set flags for the access byte field using the unscoped enum contained in this class, used
+ * to allow for direct integer conversion. This value is saved and can later be used to check whether certain flags
+ * are enabled or not using contains_flags method.
*/
- access_byte(uint8_t flags, uint8_t type_field);
+ access_byte(uint8_t flags);
/**
* @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset.
@@ -54,14 +79,7 @@ namespace teachos::arch::context_switching::descriptor_table
* @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set.
* @return Whether the given flags are a subset or equivalent with the underlying std::bitset.
*/
- auto contains_flags(std::bitset<4U> other) const -> bool;
-
- /**
- * @brief Returns the type field of the access byte.
- *
- * @return Copy of the underlying type field bits.
- */
- auto get_type_field() const -> type_field;
+ auto contains_flags(std::bitset<8U> other) const -> bool;
/**
* @brief Allows to compare the underlying std::bitset of two instances.
@@ -72,8 +90,7 @@ namespace teachos::arch::context_switching::descriptor_table
auto operator==(access_byte const & other) const -> bool = default;
private:
- std::bitset<4U> _flags = {}; ///< Underlying bitset used to read the flags from.
- type_field _type = {}; ///< Field specifying the type of the segment descriptor and its settings.
+ uint8_t _flags = {}; ///< Underlying bitset used to read the flags from.
};
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/gdt_flags.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/gdt_flags.hpp
index f27284e..11f5dd4 100644
--- a/arch/x86_64/include/arch/context_switching/descriptor_table/gdt_flags.hpp
+++ b/arch/x86_64/include/arch/context_switching/descriptor_table/gdt_flags.hpp
@@ -11,7 +11,7 @@ namespace teachos::arch::context_switching::descriptor_table
* @brief Defines helper function for all states that the flags field of a segment descriptor can
* have.
*/
- struct gdt_flags
+ struct [[gnu::packed]] gdt_flags
{
/**
* @brief Possible set bits in our underlying std::bitset and the meaning when they are set.
@@ -40,11 +40,14 @@ namespace teachos::arch::context_switching::descriptor_table
/**
* @brief Constructor.
*
- * @param flags Actual value read from the elf section header, which should be converted into a std::bitset, to
- * allow reading the state of single bits more easily. Only the rightmost 3 bit of the value will actually be
- * converted into the std::bitset, because the leftmost 4 bit are irrelevant and the 4th bit is reserved.
+ * @param flags Allows to set flags for the flags field using the unscoped enum contained in this class, used to
+ * allow for direct integer conversion. This value is saved and can later be used to check whether certain flags are
+ * enabled or not using contains_flags method.
+ * @param limit Does not necessarily make sense in the gdt flags type, but because the flags alone are only 4 bit
+ * the type would still require the space for a complete bit. Therefore the 4 bit segment limit field before the
+ * flags field is included in this type to ensure we actually contain 8 bit of data.
*/
- gdt_flags(uint8_t flags);
+ gdt_flags(uint8_t flags, std::bitset<20U> limit);
/**
* @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset.
@@ -58,6 +61,15 @@ namespace teachos::arch::context_switching::descriptor_table
auto contains_flags(std::bitset<4U> other) const -> bool;
/**
+ * @brief Get part of the segment limit that is saved in the gdt flags. This does not necessarily make sense in this
+ * object, but it has to be included here because a struct can not be smaller than a full byte. Therefore we include
+ * the 4 bit segment limit field so that it results in a compelte byte with the addtional 4 bit of gdt flags.
+ *
+ * @return 4-bit limit segment
+ */
+ auto get_limit() const -> std::bitset<4U>;
+
+ /**
* @brief Allows to compare the underlying std::bitset of two instances.
*
* @param other Other instance that we want to compare with.
@@ -66,7 +78,8 @@ namespace teachos::arch::context_switching::descriptor_table
auto operator==(gdt_flags const & other) const -> bool = default;
private:
- std::bitset<4U> _flags = {}; ///< Underlying bitset used to read the flags from.
+ uint8_t _limit_2 : 4 = {};
+ uint8_t _flags : 4 = {}; ///< Underlying bitset used to read the flags from.
};
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp
index d4febe1..ed17be3 100644
--- a/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp
+++ b/arch/x86_64/include/arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp
@@ -16,10 +16,26 @@ namespace teachos::arch::context_switching::descriptor_table
* This structure is used to store the base address and length of the GDT.
* It is used when loading or modifying the GDT during context switching.
*/
- struct global_descriptor_table_pointer
+ struct [[gnu::packed]] global_descriptor_table_pointer
{
- std::size_t table_length; ///< The size of the GDT in bytes.
- global_descriptor_table * address; ///< Pointer to the GDT base address.
+ /**
+ * @brief Default constructor.
+ */
+ global_descriptor_table_pointer() = default;
+
+ /**
+ * @brief Constructor.
+ */
+ global_descriptor_table_pointer(uint16_t table_length, global_descriptor_table * address);
+
+ /**
+ * @brief Defaulted three-way comparsion operator.
+ */
+ auto operator<=>(global_descriptor_table_pointer const & other) const -> std::strong_ordering = default;
+
+ private:
+ uint16_t table_length = {}; ///< The amount of segment descriptor entries in the global descriptor table - 1.
+ global_descriptor_table * address = {}; ///< Non-owning pointer to the GDT base address.
};
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp
index 86b6c75..7106771 100644
--- a/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp
+++ b/arch/x86_64/include/arch/context_switching/descriptor_table/segment_descriptor.hpp
@@ -4,7 +4,6 @@
#include "arch/context_switching/descriptor_table/access_byte.hpp"
#include "arch/context_switching/descriptor_table/gdt_flags.hpp"
#include "arch/context_switching/descriptor_table/segment_descriptor_type.hpp"
-#include "arch/context_switching/descriptor_table/type_field.hpp"
namespace teachos::arch::context_switching::descriptor_table
{
@@ -14,7 +13,7 @@ namespace teachos::arch::context_switching::descriptor_table
/**
* @brief Defines helper function for all states and the actual data the segment descriptor can have.
*/
- struct segment_descriptor
+ struct [[gnu::packed]] segment_descriptor
{
/**
* @brief Default Constructor.
@@ -52,13 +51,12 @@ namespace teachos::arch::context_switching::descriptor_table
private:
// The order in private variables starts for the first variable being the rightmost bit.
- uint16_t _limit_1 = {}; ///< First part of the limit field (0 - 15)
- std::bitset<24U> _base_1 = {}; ///< First part of the base field (16 - 39)
- access_byte _access = {}; ///< Access byte field (40 - 47)
- std::bitset<4U> _limit_2 = {}; ///< Second part of the limit field (48 - 51)
- gdt_flags _flag = {}; ///< Flags field (52 - 55)
- std::bitset<40U> _base_2 = {}; ///< Second part of the base field (56 - 95)
- uint32_t _reserved = {}; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127)
+ uint16_t _limit_1 = {}; ///< First part of the limit field (0 - 15)
+ uint32_t _base_1 : 24 = {}; ///< First part of the base field (16 - 39)
+ access_byte _access = {}; ///< Access byte field (40 - 47)
+ gdt_flags _flag = {}; ///< Second part of the limit field + Flags field (48 - 55)
+ uint64_t _base_2 : 40 = {}; ///< Second part of the base field (56 - 95)
+ uint32_t _reserved = {}; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127)
};
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/type_field.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/type_field.hpp
deleted file mode 100644
index 3822f9c..0000000
--- a/arch/x86_64/include/arch/context_switching/descriptor_table/type_field.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_TYPE_FIELD_HPP
-#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_TYPE_FIELD_HPP
-
-#include "arch/context_switching/descriptor_table/segment_descriptor_type.hpp"
-
-#include <bitset>
-
-namespace teachos::arch::context_switching::descriptor_table
-{
- /**
- * @brief Defines helper function for all states that the flags field of a segment descriptor can
- * have.
- */
- struct type_field
- {
- /**
- * @brief Possible set bits in our underlying std::bitset and the meaning when they are set.
- */
- enum bitset : uint8_t
- {
- ACCESSED =
- 1U
- << 0U, ///< Whether the segment has been accessed since the last time the operating system has cleared the
- ///< flag. If enabled it has been accessed, otherwise it has not been accessed since the last clear.
- WRITABLE = 1U << 1U, ///< Indicates if the data segment is writable or not. If enabled the code segment allows
- ///< read and write access, otherwise only read access is possible.
- READABLE = 1U << 1U, ///< Indicates if the code segment is readable or not. If enabled the code segment allows
- ///< read and execute access, otherwise only executable access is possible.
- CONFORMING =
- 1U << 2U, ///< Indicates if the code is allowed to be executed by different access levels
- ///< (higher or lower) in code segments. If enabled the code segment allows access, otherwise
- ///< access from different privilege levels with throw a General-Protectione exception.
- EXPAND_DOWN = 1U << 2U, ///< Indicates if the expansion direction is up or down in data segments. If enabled the
- ///< data segment expands downwards, otherwise it expands upwards.
- CODE_SEGMENT = 1U << 3U, ///< Further defines the actual type of the segment. If enabled this segment is a code
- ///< segment, otherwise its a data segment.
- LOCAL_DESCRIPTOR_TABLE = 2, ///< The actual type of sytem segment is a local descriptor table.
- TASK_STATE_SEGMENT_AVAILABLE =
- 9, ///< The actual type of sytem segment is a task state segment that is still available.
- TASK_STATE_SEGMENT_BUSY = 11, ///< The actual type of sytem segment is a task state segment that is currently in
- ///< use and therefore busy.
- CALL_GATE = 11, ///< The actual type of sytem segment is a call gate.
- INTERRUPT_GATE = 14, ///< The actual type of sytem segment is a interrupt gate.
- TRAP_GATE = 15 ///< The actual type of sytem segment is a trap gate.
- };
-
- /**
- * @brief Default Constructor.
- */
- type_field() = default;
-
- /**
- * @brief Constructor.
- *
- * @param flags Actual value read from the elf section header, which should be converted into a std::bitset, to
- * allow reading the state of single bits more easily.
- */
- type_field(uint8_t flags);
-
- /**
- * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset.
- *
- * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng
- * std::bitset. Any additional bits that are set are not relevant.
- *
- * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set.
- * @return Whether the given flags are a subset or equivalent with the underlying std::bitset.
- */
- auto contains_flags(std::bitset<4U> other) const -> bool;
-
- /**
- * @brief Allows to compare the underlying std::bitset of two instances.
- *
- * @param other Other instance that we want to compare with.
- * @return Whether the underlying std::bitset of both types is the same.
- */
- auto operator==(type_field const & other) const -> bool = default;
-
- private:
- std::bitset<4U> _flags = {}; ///< Underlying bitset used to read the flags from.
- };
-} // namespace teachos::arch::context_switching::descriptor_table
-
-#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_DESCRIPTOR_TABLE_TYPE_FIELD_HPP
diff --git a/arch/x86_64/include/arch/kernel/cpu/lgdt.hpp b/arch/x86_64/include/arch/kernel/cpu/lgdt.hpp
index 633d460..85e2949 100644
--- a/arch/x86_64/include/arch/kernel/cpu/lgdt.hpp
+++ b/arch/x86_64/include/arch/kernel/cpu/lgdt.hpp
@@ -8,10 +8,19 @@
namespace teachos::arch::kernel::cpu
{
+
+ /**
+ * @brief Returns the value in the GDTR register.
+ *
+ * @return Value of GDTR register.
+ */
+ auto store_global_descriptor_table() -> context_switching::descriptor_table::global_descriptor_table_pointer;
+
/**
* @brief Loads the global_descriptor_table_pointer into the global descriptor table register (GDTR).
*/
- auto load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer gdt_pointer)
+ auto
+ load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer const & gdt_pointer)
-> void;
} // namespace teachos::arch::kernel::cpu
diff --git a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
index 7f04042..7ea5517 100644
--- a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
@@ -1,8 +1,8 @@
#ifndef TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_PHYSICAL_FRAME_HPP
#define TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_PHYSICAL_FRAME_HPP
-#include "arch/shared/container.hpp"
-#include "arch/shared/forward_value_iterator.hpp"
+#include "arch/stl/container.hpp"
+#include "arch/stl/forward_value_iterator.hpp"
#include <compare>
#include <cstdint>
@@ -79,7 +79,7 @@ namespace teachos::arch::memory::allocator
{}; ///< Index number of the current physical frame, used to distinguish it from other frames.
};
- typedef shared::container<shared::forward_value_iterator<physical_frame>> frame_container;
+ typedef stl::container<stl::forward_value_iterator<physical_frame>> frame_container;
} // namespace teachos::arch::memory::allocator
diff --git a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
index df9e370..da3c8ff 100644
--- a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp
@@ -3,7 +3,7 @@
#include "arch/memory/heap/heap_allocator.hpp"
#include "arch/memory/heap/memory_block.hpp"
-#include "arch/shared/mutex.hpp"
+#include "arch/stl/mutex.hpp"
namespace teachos::arch::memory::heap
{
@@ -114,7 +114,7 @@ namespace teachos::arch::memory::heap
std::size_t heap_start; ///< Start of the allocatable heap area.
std::size_t heap_end; ///< End of the allocatable heap area.
memory_block * first; ///< First free entry in our memory.
- shared::mutex mutex; ///< Mutex to ensure only one thread calls allocate or deallocate at once.
+ stl::mutex mutex; ///< Mutex to ensure only one thread calls allocate or deallocate at once.
};
extern linked_list_allocator kernel_heap;
diff --git a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
index e8f6b0a..4c7470b 100644
--- a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
+++ b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
@@ -2,8 +2,8 @@
#define TEACHOS_ARCH_X86_64_MEMORY_MULTIBOOT_ELF_SYBOLS_SECTION_HPP
#include "arch/memory/multiboot/info.hpp"
-#include "arch/shared/container.hpp"
-#include "arch/shared/contiguous_pointer_iterator.hpp"
+#include "arch/stl/container.hpp"
+#include "arch/stl/contiguous_pointer_iterator.hpp"
#include <bitset>
#include <cstdint>
@@ -162,7 +162,7 @@ namespace teachos::arch::memory::multiboot
///< contained in the section, to ensure byte alignment is actually 4 byte.
};
- typedef shared::container<shared::contiguous_pointer_iterator<elf_section_header>> elf_section_header_container;
+ typedef stl::container<stl::contiguous_pointer_iterator<elf_section_header>> elf_section_header_container;
} // namespace teachos::arch::memory::multiboot
diff --git a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
index c28c986..cc8db8c 100644
--- a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
+++ b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
@@ -2,8 +2,8 @@
#define TEACHOS_ARCH_X86_64_MEMORY_MULTIBOOT_MEMORY_MAP_HPP
#include "arch/memory/multiboot/info.hpp"
-#include "arch/shared/container.hpp"
-#include "arch/shared/contiguous_pointer_iterator.hpp"
+#include "arch/stl/container.hpp"
+#include "arch/stl/contiguous_pointer_iterator.hpp"
#include <cstdint>
@@ -46,7 +46,7 @@ namespace teachos::arch::memory::multiboot
struct memory_area entries; ///< Specific memory regions.
};
- typedef shared::container<shared::contiguous_pointer_iterator<memory_area>> memory_area_container;
+ typedef stl::container<stl::contiguous_pointer_iterator<memory_area>> memory_area_container;
} // namespace teachos::arch::memory::multiboot
diff --git a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
index d820e82..d9164a0 100644
--- a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
+++ b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp
@@ -84,7 +84,7 @@ namespace teachos::arch::memory::paging
{}; ///< Index number of the current virtual page, used to distinguish it from other pages.
};
- typedef shared::container<shared::forward_value_iterator<virtual_page>> page_container;
+ typedef stl::container<stl::forward_value_iterator<virtual_page>> page_container;
} // namespace teachos::arch::memory::paging
diff --git a/arch/x86_64/include/arch/shared/container.hpp b/arch/x86_64/include/arch/stl/container.hpp
index f2fd1dc..b0f513b 100644
--- a/arch/x86_64/include/arch/shared/container.hpp
+++ b/arch/x86_64/include/arch/stl/container.hpp
@@ -1,9 +1,9 @@
-#ifndef TEACHOS_ARCH_X86_64_SHARED_CONTAINER_HPP
-#define TEACHOS_ARCH_X86_64_SHARED_CONTAINER_HPP
+#ifndef TEACHOS_ARCH_X86_64_STL_CONTAINER_HPP
+#define TEACHOS_ARCH_X86_64_STL_CONTAINER_HPP
#include <iterator>
-namespace teachos::arch::shared
+namespace teachos::arch::stl
{
/**
* @brief Minimal iterator concept required for usage in container
@@ -78,6 +78,6 @@ namespace teachos::arch::shared
iterator end_itr = {}; ///< Pointer to one pas the last element of the given template type.
};
-} // namespace teachos::arch::shared
+} // namespace teachos::arch::stl
-#endif // TEACHOS_ARCH_X86_64_SHARED_CONTAINER_HPP
+#endif // TEACHOS_ARCH_X86_64_STL_CONTAINER_HPP
diff --git a/arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp b/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp
index e2520dc..d15d2e2 100644
--- a/arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp
+++ b/arch/x86_64/include/arch/stl/contiguous_pointer_iterator.hpp
@@ -1,9 +1,9 @@
-#ifndef TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
-#define TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_STL_CONTIGUOUS_POINTER_ITERATOR_HPP
+#define TEACHOS_ARCH_X86_64_STL_CONTIGUOUS_POINTER_ITERATOR_HPP
#include <iterator>
-namespace teachos::arch::shared
+namespace teachos::arch::stl
{
/**
* @brief Generic contiguous iterator for given template type. Allows to easily use this iterator instance in
@@ -185,6 +185,6 @@ namespace teachos::arch::shared
{}; ///< Underlying value the iterator is currently pointing too and should increment or decrement.
};
-} // namespace teachos::arch::shared
+} // namespace teachos::arch::stl
-#endif // TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
+#endif // TEACHOS_ARCH_X86_64_STL_CONTIGUOUS_POINTER_ITERATOR_HPP
diff --git a/arch/x86_64/include/arch/shared/forward_value_iterator.hpp b/arch/x86_64/include/arch/stl/forward_value_iterator.hpp
index c5dfc06..7c30964 100644
--- a/arch/x86_64/include/arch/shared/forward_value_iterator.hpp
+++ b/arch/x86_64/include/arch/stl/forward_value_iterator.hpp
@@ -1,9 +1,9 @@
-#ifndef TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
-#define TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_STL_FORWARD_VALUE_ITERATOR_HPP
+#define TEACHOS_ARCH_X86_64_STL_FORWARD_VALUE_ITERATOR_HPP
#include <iterator>
-namespace teachos::arch::shared
+namespace teachos::arch::stl
{
/**
* @brief Concept for a type to have a post and prefix increment operator, that returns the correct type.
@@ -105,6 +105,6 @@ namespace teachos::arch::shared
{}; ///< Underlying value the iterator is currently pointing too and should increment or decrement.
};
-} // namespace teachos::arch::shared
+} // namespace teachos::arch::stl
-#endif // TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
+#endif // TEACHOS_ARCH_X86_64_STL_FORWARD_VALUE_ITERATOR_HPP
diff --git a/arch/x86_64/include/arch/shared/mutex.hpp b/arch/x86_64/include/arch/stl/mutex.hpp
index b18a8b3..d8fd9dc 100644
--- a/arch/x86_64/include/arch/shared/mutex.hpp
+++ b/arch/x86_64/include/arch/stl/mutex.hpp
@@ -1,9 +1,9 @@
-#ifndef TEACHOS_ARCH_X86_64_SHARED_MUTEX_HPP
-#define TEACHOS_ARCH_X86_64_SHARED_MUTEX_HPP
+#ifndef TEACHOS_ARCH_X86_64_STL_MUTEX_HPP
+#define TEACHOS_ARCH_X86_64_STL_MUTEX_HPP
#include <atomic>
-namespace teachos::arch::shared
+namespace teachos::arch::stl
{
/**
* @brief Custom mutex implementation, that simply wraps an atomic boolean to keep track if the mutex is already in
@@ -52,6 +52,6 @@ namespace teachos::arch::shared
std::atomic<bool> locked = {false}; // Atomic boolean to track if mutex is locked or not.
};
-} // namespace teachos::arch::shared
+} // namespace teachos::arch::stl
-#endif // TEACHOS_ARCH_X86_64_SHARED_MUTEX_HPP
+#endif // TEACHOS_ARCH_X86_64_STL_MUTEX_HPP
diff --git a/arch/x86_64/src/context_switching/descriptor_table/access_byte.cpp b/arch/x86_64/src/context_switching/descriptor_table/access_byte.cpp
index 4e5459f..6b54451 100644
--- a/arch/x86_64/src/context_switching/descriptor_table/access_byte.cpp
+++ b/arch/x86_64/src/context_switching/descriptor_table/access_byte.cpp
@@ -2,14 +2,14 @@
namespace teachos::arch::context_switching::descriptor_table
{
- access_byte::access_byte(uint8_t flags, uint8_t type_field)
+ access_byte::access_byte(uint8_t flags)
: _flags(flags)
- , _type(type_field)
{
// Nothing to do.
}
- auto access_byte::contains_flags(std::bitset<4U> other) const -> bool { return (_flags & other) == other; }
-
- auto access_byte::get_type_field() const -> type_field { return _type; }
+ auto access_byte::contains_flags(std::bitset<8U> other) const -> bool
+ {
+ return (std::bitset<8U>{_flags} & other) == other;
+ }
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/gdt_flags.cpp b/arch/x86_64/src/context_switching/descriptor_table/gdt_flags.cpp
index 65f2e90..9e95182 100644
--- a/arch/x86_64/src/context_switching/descriptor_table/gdt_flags.cpp
+++ b/arch/x86_64/src/context_switching/descriptor_table/gdt_flags.cpp
@@ -1,14 +1,18 @@
#include "arch/context_switching/descriptor_table/gdt_flags.hpp"
-#include "arch/exception_handling/assert.hpp"
-
namespace teachos::arch::context_switching::descriptor_table
{
- gdt_flags::gdt_flags(uint8_t flags)
- : _flags(flags)
+ gdt_flags::gdt_flags(uint8_t flags, std::bitset<20U> limit)
+ : _limit_2(limit.to_ulong() >> 16U)
+ , _flags(flags)
{
// Nothing to do.
}
- auto gdt_flags::contains_flags(std::bitset<4U> other) const -> bool { return (_flags & other) == other; }
+ auto gdt_flags::contains_flags(std::bitset<4U> other) const -> bool
+ {
+ return (std::bitset<4U>{_flags} & other) == other;
+ }
+
+ auto descriptor_table::gdt_flags::get_limit() const -> std::bitset<4U> { return std::bitset<4U>{_limit_2}; }
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp
index f4ea61b..c5554a7 100644
--- a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp
+++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp
@@ -1,6 +1,7 @@
#include "arch/context_switching/descriptor_table/global_descriptor_table.hpp"
#include "arch/context_switching/descriptor_table/segment_descriptor.hpp"
+#include "arch/exception_handling/assert.hpp"
#include "arch/kernel/cpu/lgdt.hpp"
#include "arch/stl/vector.hpp"
@@ -10,33 +11,32 @@ namespace teachos::arch::context_switching::descriptor_table
{
segment_descriptor null_segment{0};
+ std::bitset<20U> limit{0xFFFFF};
// Kernel space code segment
access_byte kernel_code_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_KERNEL |
- access_byte::CODE_OR_DATA_SEGMENT,
- type_field::CODE_SEGMENT | type_field::READABLE};
- gdt_flags kernel_code_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::LENGTH};
- segment_descriptor kernel_code_segment{kernel_code_access_byte, kernel_code_gdt_flags, 0, 0xFFFFF};
+ access_byte::CODE_OR_DATA_SEGMENT | access_byte::CODE_SEGMENT |
+ access_byte::READABLE};
+ gdt_flags kernel_code_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::LENGTH, limit};
+ segment_descriptor kernel_code_segment{kernel_code_access_byte, kernel_code_gdt_flags, 0, limit};
// Kernel space data segment
access_byte kernel_data_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_KERNEL |
- access_byte::CODE_OR_DATA_SEGMENT,
- type_field::WRITABLE};
- gdt_flags kernel_data_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::UPPER_BOUND};
- segment_descriptor kernel_data_segment{kernel_data_access_byte, kernel_data_gdt_flags, 0, 0xFFFFF};
+ access_byte::CODE_OR_DATA_SEGMENT | access_byte::WRITABLE};
+ gdt_flags kernel_data_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::UPPER_BOUND, limit};
+ segment_descriptor kernel_data_segment{kernel_data_access_byte, kernel_data_gdt_flags, 0, limit};
// User space code segment
access_byte user_code_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_USER |
- access_byte::CODE_OR_DATA_SEGMENT,
- type_field::CODE_SEGMENT | type_field::READABLE};
- gdt_flags user_code_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::LENGTH};
- segment_descriptor user_code_segment{user_code_access_byte, user_code_gdt_flags, 0, 0xFFFFF};
+ access_byte::CODE_OR_DATA_SEGMENT | access_byte::CODE_SEGMENT |
+ access_byte::READABLE};
+ gdt_flags user_code_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::LENGTH, limit};
+ segment_descriptor user_code_segment{user_code_access_byte, user_code_gdt_flags, 0, limit};
// User space data segment
access_byte user_data_access_byte{access_byte::PRESENT | access_byte::ACCESS_LEVEL_USER |
- access_byte::CODE_OR_DATA_SEGMENT,
- type_field::WRITABLE};
- gdt_flags user_data_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::UPPER_BOUND};
- segment_descriptor user_data_segment{user_data_access_byte, user_data_gdt_flags, 0, 0xFFFFF};
+ access_byte::CODE_OR_DATA_SEGMENT | access_byte::WRITABLE};
+ gdt_flags user_data_gdt_flags{gdt_flags::GRANULARITY | gdt_flags::UPPER_BOUND, limit};
+ segment_descriptor user_data_segment{user_data_access_byte, user_data_gdt_flags, 0, limit};
stl::vector<segment_descriptor> global_descriptor_table{null_segment, kernel_code_segment, kernel_data_segment,
user_code_segment, user_data_segment};
@@ -46,8 +46,14 @@ namespace teachos::arch::context_switching::descriptor_table
auto initialize_global_descriptor_table() -> global_descriptor_table
{
decltype(auto) gdt = create_global_descriptor_table();
- global_descriptor_table_pointer gdt_pointer{gdt.size() - 1, &gdt};
+ global_descriptor_table_pointer gdt_pointer{static_cast<uint16_t>(gdt.size() - 1), &gdt};
kernel::cpu::load_global_descriptor_table(gdt_pointer);
+
+ auto stored_gdt_pointer = kernel::cpu::store_global_descriptor_table();
+ arch::exception_handling::assert(
+ gdt_pointer == stored_gdt_pointer,
+ "[Global Descriptor Table] Loaded GDTR value is not the same as the stored value.");
+
return gdt;
}
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp
new file mode 100644
index 0000000..f552496
--- /dev/null
+++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table_pointer.cpp
@@ -0,0 +1,12 @@
+#include "arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp"
+
+namespace teachos::arch::context_switching::descriptor_table
+{
+ global_descriptor_table_pointer::global_descriptor_table_pointer(uint16_t table_length,
+ global_descriptor_table * address)
+ : table_length(table_length)
+ , address(address)
+ {
+ // Nothing to do.
+ }
+} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/segment_descriptor.cpp b/arch/x86_64/src/context_switching/descriptor_table/segment_descriptor.cpp
index a743ad2..c1a46a6 100644
--- a/arch/x86_64/src/context_switching/descriptor_table/segment_descriptor.cpp
+++ b/arch/x86_64/src/context_switching/descriptor_table/segment_descriptor.cpp
@@ -5,9 +5,8 @@ namespace teachos::arch::context_switching::descriptor_table
segment_descriptor::segment_descriptor(uint128_t flags)
: _limit_1(flags << 112U)
, _base_1((flags >> 16U) << 88U)
- , _access((flags >> 44U) << 80U, (flags >> 40U) << 84U)
- , _limit_2((flags >> 48U) << 72U)
- , _flag((flags >> 52U) << 72U)
+ , _access((flags >> 40U) << 80U)
+ , _flag((flags >> 52U) << 72U, (flags >> 48U) << 72U)
, _base_2((flags >> 56U) << 32U)
, _reserved(flags >> 96U)
{
@@ -16,10 +15,9 @@ namespace teachos::arch::context_switching::descriptor_table
segment_descriptor::segment_descriptor(access_byte access_byte, gdt_flags flags, uint64_t base,
std::bitset<20U> limit)
- : _limit_1((limit.to_ulong() << 4U) >> 16U)
+ : _limit_1(limit.to_ulong())
, _base_1((base << 40U) >> 40U)
, _access(access_byte)
- , _limit_2(limit.to_ulong() >> 16U)
, _flag(flags)
, _base_2(base >> 24U)
, _reserved(0U)
@@ -33,12 +31,7 @@ namespace teachos::arch::context_switching::descriptor_table
{
return segment_descriptor_type::SYSTEM_SEGMENT;
}
-
- if (_access.get_type_field().contains_flags(type_field::CODE_SEGMENT))
- {
- return segment_descriptor_type::CODE_SEGMENT;
- }
-
- return segment_descriptor_type::DATA_SEGMENT;
+ return _access.contains_flags(access_byte::CODE_SEGMENT) ? segment_descriptor_type::CODE_SEGMENT
+ : segment_descriptor_type::DATA_SEGMENT;
}
} // namespace teachos::arch::context_switching::descriptor_table
diff --git a/arch/x86_64/src/context_switching/descriptor_table/type_field.cpp b/arch/x86_64/src/context_switching/descriptor_table/type_field.cpp
deleted file mode 100644
index d967a97..0000000
--- a/arch/x86_64/src/context_switching/descriptor_table/type_field.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "arch/context_switching/descriptor_table/type_field.hpp"
-
-namespace teachos::arch::context_switching::descriptor_table
-{
- type_field::type_field(uint8_t flags)
- : _flags(flags)
- {
- // Nothing to do.
- }
-
- auto type_field::contains_flags(std::bitset<4U> other) const -> bool { return (_flags & other) == other; }
-} // namespace teachos::arch::context_switching::descriptor_table
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
diff --git a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
index a824c8a..5101ab2 100644
--- a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
+++ b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
@@ -11,7 +11,7 @@ namespace teachos::arch::memory::heap
: heap_start(heap_start)
, heap_end(heap_end)
, first(nullptr)
- , mutex{shared::mutex{}}
+ , mutex{stl::mutex{}}
{
auto const heap_size = heap_end - heap_start;
exception_handling::assert(
diff --git a/arch/x86_64/src/shared/mutex.cpp b/arch/x86_64/src/stl/mutex.cpp
index 6598255..232a11c 100644
--- a/arch/x86_64/src/shared/mutex.cpp
+++ b/arch/x86_64/src/stl/mutex.cpp
@@ -1,6 +1,6 @@
-#include "arch/shared/mutex.hpp"
+#include "arch/stl/mutex.hpp"
-namespace teachos::arch::shared
+namespace teachos::arch::stl
{
auto mutex::lock() -> void
{
@@ -13,4 +13,4 @@ namespace teachos::arch::shared
auto mutex::try_lock() -> bool { return !locked.exchange(true, std::memory_order_acquire); }
auto mutex::unlock() -> void { locked.store(false, std::memory_order_release); }
-} // namespace teachos::arch::shared
+} // namespace teachos::arch::stl