diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-05-16 09:58:57 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-05-16 09:58:57 +0000 |
| commit | d4cc546df6eba2dd287785f1a63fbcce4a1b9bc0 (patch) | |
| tree | a22b7a91ac0f55c37dbee6516bf9103fcc89b548 /arch | |
| parent | 06b6e20ba921a062b71c86df8859eaaea4b75cb2 (diff) | |
| download | teachos-d4cc546df6eba2dd287785f1a63fbcce4a1b9bc0.tar.xz teachos-d4cc546df6eba2dd287785f1a63fbcce4a1b9bc0.zip | |
Attempt to move atomic into stl text as well
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp | 12 | ||||
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld | 16 | ||||
| -rw-r--r-- | arch/x86_64/src/user/main.cpp | 9 |
3 files changed, 23 insertions, 14 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index ca7e2f9..94c937d 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -144,24 +144,24 @@ namespace teachos::arch::memory::paging // Required to be accessible in User Mode: // - .boot_rodata (Contains constant data stored in ROM) // - .boot_bss (Contains statically allocated variables) - // - .user_text (Contains the actual code executed) + // - .user_text (Contains the actual user code executed) // - .user_data (Contains static user variables) - // - .stl_text (Contains code for custom std implementations) + // - .stl_text (Contains code for custom std implementations and standard library code) if (section.physical_address == 0x100000 /* .boot_rodata */ || section.physical_address == 0x102000 /* .boot_bss */ || - section.physical_address == 0x218000 /* .stl_text */) + section.physical_address == 0x209000 /* .stl_text */) { entry.set_user_accessible(); entry.set_global(); } - // TODO: We should be able to remove this somehow - if (section.physical_address == 0x209000 /* .text */) + // TODO: Can be removed once stl has been completly mapped into stl text + if (section.physical_address == 0x20A000 /* .text */) { entry.set_user_accessible(); } - if (section.physical_address == 0x217000 /* .user_text */ || + if (section.physical_address == 0x218000 /* .user_text */ || section.physical_address == 0x21E000 /* .user_data */) { entry.set_user_accessible(); diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 1925872..e5cbc73 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -85,21 +85,21 @@ SECTIONS KEEP(*crtn.s.o*(.fini)) } - .text ALIGN(4K) : AT(ADDR (.text)) + .stl_text ALIGN(4K) : AT(ADDR (.stl_text)) { - *(.text*) - *(EXCLUDE_FILE (*libstdc++.a) .text .text.*) + *(.stl_text) + KEEP(*libstdc++.a:*(.text .text.*)) + KEEP(*libatomic.a:*(.text .text.*)) /* Attempt to move atomic stl into stl_text as well, doesn't work */ } - .user_text ALIGN(4K) : AT(ADDR (.user_text)) + .text ALIGN(4K) : AT(ADDR (.text)) { - *(.user_text) + *(.text .text.*) } - .stl_text ALIGN(4K) : AT(ADDR (.stl_text)) + .user_text ALIGN(4K) : AT(ADDR (.user_text)) { - *(.stl_text) - *libstdc++.a:*(.text .text.*) + *(.user_text) } .rodata ALIGN(4K) : AT (ADDR (.rodata)) diff --git a/arch/x86_64/src/user/main.cpp b/arch/x86_64/src/user/main.cpp index 59647f8..a435a41 100644 --- a/arch/x86_64/src/user/main.cpp +++ b/arch/x86_64/src/user/main.cpp @@ -3,6 +3,9 @@ #include "arch/context_switching/syscall/main.hpp" #include "arch/memory/heap/global_heap_allocator.hpp" +#include <algorithm> +#include <atomic> + // TODO: Disallow these imports #include "arch/kernel/cpu/if.hpp" #include "arch/video/vga/text.hpp" @@ -17,6 +20,12 @@ namespace teachos::arch::user // kernel::cpu::clear_interrupt_flag(); // Causes crash Kernel Code (.text) is not mapped in User mMde + int test = std::max(5, 10); + (void)test; + + std::atomic<bool> locked = {false}; + locked.exchange(true); + auto address = memory::heap::global_heap_allocator::malloc(8U); (void)address; |
