From 8d39f3f67734bf39cada370c39243e6ef33bf4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sun, 18 May 2025 14:45:05 +0000 Subject: Make new usable for both kernel and user calls --- .../interrupt_descriptor_table/segment_selector.hpp | 8 ++++++++ arch/x86_64/include/arch/context_switching/syscall/main.hpp | 3 +++ arch/x86_64/include/arch/kernel/cpu/segment_register.hpp | 1 + arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp | 6 ++++++ 4 files changed, 18 insertions(+) (limited to 'arch/x86_64/include') diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp index 5be449f..82719bc 100644 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp +++ b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp @@ -66,6 +66,14 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table */ auto contains_flags(std::bitset<3U> other) const -> bool; + /** + * @brief Gets the index into the global descriptor table this segment selector is pointing too. + * + * @return Underlying value of the index field, bit 3 - 16. + */ + [[gnu::section(".user_text")]] + auto get_index() const -> uint16_t; + /** * @brief Defaulted three-way comparsion operator. */ diff --git a/arch/x86_64/include/arch/context_switching/syscall/main.hpp b/arch/x86_64/include/arch/context_switching/syscall/main.hpp index 9d61f97..e391c1f 100644 --- a/arch/x86_64/include/arch/context_switching/syscall/main.hpp +++ b/arch/x86_64/include/arch/context_switching/syscall/main.hpp @@ -19,6 +19,9 @@ namespace teachos::arch::context_switching::syscall /// parameters and uses them as out parameters instead, where arg_0 is the start of the newly /// mapped heap area and arg_1 is the size of the entire area. Can be less than 100 KiB if less /// space remains. + ASSERT = 3U, /// Loads the arg_0 parameter as a boolean which needs to be true or it will print the message in + /// arg_1 parameter onto the VGA buffer screen, keep it as a nullptr if it shouldn't print anything + /// and then it halts the further execution of the application. }; /** diff --git a/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp b/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp index 36ada23..a236452 100644 --- a/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp +++ b/arch/x86_64/include/arch/kernel/cpu/segment_register.hpp @@ -31,6 +31,7 @@ namespace teachos::arch::kernel::cpu * * @return Segment Selector pointing to the currently loaded Code Segment. */ + [[gnu::section(".user_text")]] auto read_code_segment_register() -> context_switching::interrupt_descriptor_table::segment_selector; /** diff --git a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp index 6fcab6f..c98c130 100644 --- a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp @@ -97,16 +97,22 @@ namespace teachos::arch::memory::heap }; } // namespace teachos::arch::memory::heap +[[gnu::section(".user_text")]] auto operator new(std::size_t size) -> void *; +[[gnu::section(".user_text")]] auto operator delete(void * pointer) noexcept -> void; +[[gnu::section(".user_text")]] auto operator delete(void * pointer, std::size_t size) noexcept -> void; +[[gnu::section(".user_text")]] auto operator new[](std::size_t size) -> void *; +[[gnu::section(".user_text")]] auto operator delete[](void * pointer) noexcept -> void; +[[gnu::section(".user_text")]] auto operator delete[](void * pointer, std::size_t size) noexcept -> void; #endif // TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP -- cgit v1.2.3