From 2d3399ab6072acd85811a54fce8eff50628888b6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 24 Jul 2025 16:35:34 +0000 Subject: x86_64: move files out of the way --- .../interrupt_descriptor_table/gate_descriptor.hpp | 69 ------- .../interrupt_descriptor_table/idt_flags.hpp | 81 -------- .../interrupt_descriptor_table.hpp | 24 --- .../interrupt_descriptor_table_pointer.hpp | 40 ---- .../interrupt_descriptor_table/ist_offset.hpp | 45 ----- .../segment_selector.hpp | 105 ----------- .../x86_64/include/arch/context_switching/main.hpp | 51 ----- .../segment_descriptor_table/access_byte.hpp | 104 ----------- .../segment_descriptor_table/gdt_flags.hpp | 93 ---------- .../global_descriptor_table.hpp | 37 ---- .../global_descriptor_table_pointer.hpp | 41 ---- .../segment_descriptor_base.hpp | 73 -------- .../segment_descriptor_extension.hpp | 74 -------- .../segment_descriptor_type.hpp | 27 --- .../task_state_segment.hpp | 32 ---- .../arch/context_switching/syscall/main.hpp | 88 --------- .../context_switching/syscall/syscall_enable.hpp | 18 -- .../context_switching/syscall/syscall_handler.hpp | 18 -- .../include/arch/exception_handling/assert.hpp | 17 -- .../include/arch/exception_handling/panic.hpp | 23 --- .../generic_interrupt_handler.hpp | 34 ---- arch/x86_64/include/arch/kernel/cpu/call.hpp | 30 --- arch/x86_64/include/arch/kernel/cpu/gdtr.hpp | 27 --- arch/x86_64/include/arch/kernel/cpu/idtr.hpp | 27 --- arch/x86_64/include/arch/kernel/cpu/if.hpp | 21 --- arch/x86_64/include/arch/kernel/cpu/msr.hpp | 64 ------- .../include/arch/kernel/cpu/segment_register.hpp | 97 ---------- arch/x86_64/include/arch/kernel/cpu/tr.hpp | 24 --- arch/x86_64/include/arch/kernel/halt.hpp | 13 -- arch/x86_64/include/arch/kernel/main.hpp | 13 -- .../arch/memory/allocator/area_frame_allocator.hpp | 67 ------- .../include/arch/memory/allocator/concept.hpp | 21 --- .../arch/memory/allocator/tiny_frame_allocator.hpp | 74 -------- .../include/arch/memory/heap/bump_allocator.hpp | 48 ----- .../arch/memory/heap/global_heap_allocator.hpp | 118 ------------ .../include/arch/memory/heap/heap_allocator.hpp | 45 ----- .../arch/memory/heap/linked_list_allocator.hpp | 120 ------------ .../include/arch/memory/heap/memory_block.hpp | 39 ---- .../arch/memory/heap/user_heap_allocator.hpp | 149 --------------- arch/x86_64/include/arch/memory/main.hpp | 30 --- .../arch/memory/multiboot/elf_symbols_section.hpp | 170 ----------------- .../include/arch/memory/multiboot/reader.hpp | 58 ------ .../arch/memory/paging/active_page_table.hpp | 206 --------------------- .../arch/memory/paging/inactive_page_table.hpp | 39 ---- .../include/arch/memory/paging/kernel_mapper.hpp | 180 ------------------ .../include/arch/memory/paging/page_entry.hpp | 121 ------------ .../include/arch/memory/paging/page_table.hpp | 157 ---------------- .../include/arch/memory/paging/temporary_page.hpp | 64 ------- .../include/arch/memory/paging/virtual_page.hpp | 91 --------- arch/x86_64/include/arch/user/main.hpp | 16 -- .../interrupt_descriptor_table/gate_descriptor.hpp | 69 +++++++ .../interrupt_descriptor_table/idt_flags.hpp | 81 ++++++++ .../interrupt_descriptor_table.hpp | 24 +++ .../interrupt_descriptor_table_pointer.hpp | 40 ++++ .../interrupt_descriptor_table/ist_offset.hpp | 45 +++++ .../segment_selector.hpp | 105 +++++++++++ .../pre/include/arch/context_switching/main.hpp | 51 +++++ .../segment_descriptor_table/access_byte.hpp | 104 +++++++++++ .../segment_descriptor_table/gdt_flags.hpp | 93 ++++++++++ .../global_descriptor_table.hpp | 37 ++++ .../global_descriptor_table_pointer.hpp | 41 ++++ .../segment_descriptor_base.hpp | 73 ++++++++ .../segment_descriptor_extension.hpp | 74 ++++++++ .../segment_descriptor_type.hpp | 27 +++ .../task_state_segment.hpp | 32 ++++ .../arch/context_switching/syscall/main.hpp | 88 +++++++++ .../context_switching/syscall/syscall_enable.hpp | 18 ++ .../context_switching/syscall/syscall_handler.hpp | 18 ++ .../pre/include/arch/exception_handling/assert.hpp | 17 ++ .../pre/include/arch/exception_handling/panic.hpp | 23 +++ .../generic_interrupt_handler.hpp | 34 ++++ arch/x86_64/pre/include/arch/kernel/cpu/call.hpp | 30 +++ arch/x86_64/pre/include/arch/kernel/cpu/gdtr.hpp | 27 +++ arch/x86_64/pre/include/arch/kernel/cpu/idtr.hpp | 27 +++ arch/x86_64/pre/include/arch/kernel/cpu/if.hpp | 21 +++ arch/x86_64/pre/include/arch/kernel/cpu/msr.hpp | 64 +++++++ .../include/arch/kernel/cpu/segment_register.hpp | 97 ++++++++++ arch/x86_64/pre/include/arch/kernel/cpu/tr.hpp | 24 +++ arch/x86_64/pre/include/arch/kernel/halt.hpp | 13 ++ arch/x86_64/pre/include/arch/kernel/main.hpp | 13 ++ .../arch/memory/allocator/area_frame_allocator.hpp | 67 +++++++ .../pre/include/arch/memory/allocator/concept.hpp | 21 +++ .../arch/memory/allocator/tiny_frame_allocator.hpp | 74 ++++++++ .../include/arch/memory/heap/bump_allocator.hpp | 48 +++++ .../arch/memory/heap/global_heap_allocator.hpp | 118 ++++++++++++ .../include/arch/memory/heap/heap_allocator.hpp | 45 +++++ .../arch/memory/heap/linked_list_allocator.hpp | 120 ++++++++++++ .../pre/include/arch/memory/heap/memory_block.hpp | 39 ++++ .../arch/memory/heap/user_heap_allocator.hpp | 149 +++++++++++++++ arch/x86_64/pre/include/arch/memory/main.hpp | 30 +++ .../arch/memory/multiboot/elf_symbols_section.hpp | 170 +++++++++++++++++ .../pre/include/arch/memory/multiboot/reader.hpp | 58 ++++++ .../arch/memory/paging/active_page_table.hpp | 206 +++++++++++++++++++++ .../arch/memory/paging/inactive_page_table.hpp | 39 ++++ .../include/arch/memory/paging/kernel_mapper.hpp | 180 ++++++++++++++++++ .../pre/include/arch/memory/paging/page_entry.hpp | 121 ++++++++++++ .../pre/include/arch/memory/paging/page_table.hpp | 157 ++++++++++++++++ .../include/arch/memory/paging/temporary_page.hpp | 64 +++++++ .../include/arch/memory/paging/virtual_page.hpp | 91 +++++++++ arch/x86_64/pre/include/arch/user/main.hpp | 16 ++ .../interrupt_descriptor_table/gate_descriptor.cpp | 24 +++ .../interrupt_descriptor_table/idt_flags.cpp | 17 ++ .../interrupt_descriptor_table.cpp | 53 ++++++ .../interrupt_descriptor_table_pointer.cpp | 13 ++ .../interrupt_descriptor_table/ist_offset.cpp | 10 + .../segment_selector.cpp | 15 ++ arch/x86_64/pre/src/context_switching/main.cpp | 63 +++++++ .../segment_descriptor_table/access_byte.cpp | 17 ++ .../segment_descriptor_table/gdt_flags.cpp | 20 ++ .../global_descriptor_table.cpp | 109 +++++++++++ .../global_descriptor_table_pointer.cpp | 11 ++ .../segment_descriptor_base.cpp | 38 ++++ .../segment_descriptor_extension.cpp | 24 +++ .../pre/src/context_switching/syscall/main.cpp | 35 ++++ .../context_switching/syscall/syscall_enable.cpp | 32 ++++ .../context_switching/syscall/syscall_handler.cpp | 118 ++++++++++++ arch/x86_64/pre/src/exception_handling/abort.cpp | 15 ++ arch/x86_64/pre/src/exception_handling/assert.cpp | 15 ++ arch/x86_64/pre/src/exception_handling/panic.cpp | 22 +++ .../pre/src/exception_handling/pure_virtual.cpp | 6 + .../generic_interrupt_handler.cpp | 13 ++ arch/x86_64/pre/src/kernel/cpu/call.cpp | 9 + arch/x86_64/pre/src/kernel/cpu/gdtr.cpp | 19 ++ arch/x86_64/pre/src/kernel/cpu/idtr.cpp | 18 ++ arch/x86_64/pre/src/kernel/cpu/if.cpp | 7 + arch/x86_64/pre/src/kernel/cpu/msr.cpp | 31 ++++ .../x86_64/pre/src/kernel/cpu/segment_register.cpp | 98 ++++++++++ arch/x86_64/pre/src/kernel/cpu/tr.cpp | 16 ++ arch/x86_64/pre/src/kernel/main.cpp | 71 +++++++ .../src/memory/allocator/area_frame_allocator.cpp | 85 +++++++++ .../src/memory/allocator/tiny_frame_allocator.cpp | 34 ++++ arch/x86_64/pre/src/memory/heap/bump_allocator.cpp | 54 ++++++ .../pre/src/memory/heap/global_heap_allocator.cpp | 135 ++++++++++++++ .../pre/src/memory/heap/linked_list_allocator.cpp | 177 ++++++++++++++++++ arch/x86_64/pre/src/memory/heap/memory_block.cpp | 15 ++ .../pre/src/memory/heap/user_heap_allocator.cpp | 200 ++++++++++++++++++++ arch/x86_64/pre/src/memory/main.cpp | 77 ++++++++ .../src/memory/multiboot/elf_symbols_section.cpp | 13 ++ arch/x86_64/pre/src/memory/multiboot/reader.cpp | 135 ++++++++++++++ .../pre/src/memory/paging/active_page_table.cpp | 98 ++++++++++ .../pre/src/memory/paging/inactive_page_table.cpp | 20 ++ arch/x86_64/pre/src/memory/paging/page_entry.cpp | 63 +++++++ arch/x86_64/pre/src/memory/paging/page_table.cpp | 128 +++++++++++++ .../pre/src/memory/paging/temporary_page.cpp | 29 +++ arch/x86_64/pre/src/memory/paging/virtual_page.cpp | 33 ++++ arch/x86_64/pre/src/user/main.cpp | 35 ++++ .../interrupt_descriptor_table/gate_descriptor.cpp | 24 --- .../interrupt_descriptor_table/idt_flags.cpp | 17 -- .../interrupt_descriptor_table.cpp | 53 ------ .../interrupt_descriptor_table_pointer.cpp | 13 -- .../interrupt_descriptor_table/ist_offset.cpp | 10 - .../segment_selector.cpp | 15 -- arch/x86_64/src/context_switching/main.cpp | 63 ------- .../segment_descriptor_table/access_byte.cpp | 17 -- .../segment_descriptor_table/gdt_flags.cpp | 20 -- .../global_descriptor_table.cpp | 109 ----------- .../global_descriptor_table_pointer.cpp | 11 -- .../segment_descriptor_base.cpp | 38 ---- .../segment_descriptor_extension.cpp | 24 --- arch/x86_64/src/context_switching/syscall/main.cpp | 35 ---- .../context_switching/syscall/syscall_enable.cpp | 32 ---- .../context_switching/syscall/syscall_handler.cpp | 118 ------------ arch/x86_64/src/exception_handling/abort.cpp | 15 -- arch/x86_64/src/exception_handling/assert.cpp | 15 -- arch/x86_64/src/exception_handling/panic.cpp | 22 --- .../x86_64/src/exception_handling/pure_virtual.cpp | 6 - .../generic_interrupt_handler.cpp | 13 -- arch/x86_64/src/kernel/cpu/call.cpp | 9 - arch/x86_64/src/kernel/cpu/gdtr.cpp | 19 -- arch/x86_64/src/kernel/cpu/idtr.cpp | 18 -- arch/x86_64/src/kernel/cpu/if.cpp | 7 - arch/x86_64/src/kernel/cpu/msr.cpp | 31 ---- arch/x86_64/src/kernel/cpu/segment_register.cpp | 98 ---------- arch/x86_64/src/kernel/cpu/tr.cpp | 16 -- arch/x86_64/src/kernel/main.cpp | 71 ------- .../src/memory/allocator/area_frame_allocator.cpp | 85 --------- .../src/memory/allocator/tiny_frame_allocator.cpp | 34 ---- arch/x86_64/src/memory/heap/bump_allocator.cpp | 54 ------ .../src/memory/heap/global_heap_allocator.cpp | 135 -------------- .../src/memory/heap/linked_list_allocator.cpp | 177 ------------------ arch/x86_64/src/memory/heap/memory_block.cpp | 15 -- .../x86_64/src/memory/heap/user_heap_allocator.cpp | 200 -------------------- arch/x86_64/src/memory/main.cpp | 77 -------- .../src/memory/multiboot/elf_symbols_section.cpp | 13 -- arch/x86_64/src/memory/multiboot/reader.cpp | 135 -------------- .../x86_64/src/memory/paging/active_page_table.cpp | 98 ---------- .../src/memory/paging/inactive_page_table.cpp | 20 -- arch/x86_64/src/memory/paging/page_entry.cpp | 63 ------- arch/x86_64/src/memory/paging/page_table.cpp | 128 ------------- arch/x86_64/src/memory/paging/temporary_page.cpp | 29 --- arch/x86_64/src/memory/paging/virtual_page.cpp | 33 ---- arch/x86_64/src/user/main.cpp | 35 ---- 192 files changed, 5493 insertions(+), 5493 deletions(-) delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/ist_offset.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/main.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/segment_descriptor_base.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/segment_descriptor_extension.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/segment_descriptor_type.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/segment_descriptor_table/task_state_segment.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/syscall/main.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/syscall/syscall_enable.hpp delete mode 100644 arch/x86_64/include/arch/context_switching/syscall/syscall_handler.hpp delete mode 100644 arch/x86_64/include/arch/exception_handling/assert.hpp delete mode 100644 arch/x86_64/include/arch/exception_handling/panic.hpp delete mode 100644 arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/call.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/gdtr.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/idtr.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/if.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/msr.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/segment_register.hpp delete mode 100644 arch/x86_64/include/arch/kernel/cpu/tr.hpp delete mode 100644 arch/x86_64/include/arch/kernel/halt.hpp delete mode 100644 arch/x86_64/include/arch/kernel/main.hpp delete mode 100644 arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/allocator/concept.hpp delete mode 100644 arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/bump_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/heap_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/memory_block.hpp delete mode 100644 arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp delete mode 100644 arch/x86_64/include/arch/memory/main.hpp delete mode 100644 arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp delete mode 100644 arch/x86_64/include/arch/memory/multiboot/reader.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/active_page_table.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/inactive_page_table.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/page_entry.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/page_table.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/temporary_page.hpp delete mode 100644 arch/x86_64/include/arch/memory/paging/virtual_page.hpp delete mode 100644 arch/x86_64/include/arch/user/main.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/ist_offset.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/main.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/access_byte.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/segment_descriptor_base.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/segment_descriptor_extension.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/segment_descriptor_type.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/segment_descriptor_table/task_state_segment.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/syscall/syscall_enable.hpp create mode 100644 arch/x86_64/pre/include/arch/context_switching/syscall/syscall_handler.hpp create mode 100644 arch/x86_64/pre/include/arch/exception_handling/assert.hpp create mode 100644 arch/x86_64/pre/include/arch/exception_handling/panic.hpp create mode 100644 arch/x86_64/pre/include/arch/interrupt_handling/generic_interrupt_handler.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/call.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/gdtr.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/idtr.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/if.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/msr.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/segment_register.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/cpu/tr.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/halt.hpp create mode 100644 arch/x86_64/pre/include/arch/kernel/main.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/allocator/area_frame_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/allocator/concept.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/bump_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/memory_block.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/main.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/multiboot/elf_symbols_section.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/inactive_page_table.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/page_entry.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/page_table.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/temporary_page.hpp create mode 100644 arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp create mode 100644 arch/x86_64/pre/include/arch/user/main.hpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/idt_flags.cpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/ist_offset.cpp create mode 100644 arch/x86_64/pre/src/context_switching/interrupt_descriptor_table/segment_selector.cpp create mode 100644 arch/x86_64/pre/src/context_switching/main.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/access_byte.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/gdt_flags.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/global_descriptor_table.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/global_descriptor_table_pointer.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/segment_descriptor_base.cpp create mode 100644 arch/x86_64/pre/src/context_switching/segment_descriptor_table/segment_descriptor_extension.cpp create mode 100644 arch/x86_64/pre/src/context_switching/syscall/main.cpp create mode 100644 arch/x86_64/pre/src/context_switching/syscall/syscall_enable.cpp create mode 100644 arch/x86_64/pre/src/context_switching/syscall/syscall_handler.cpp create mode 100644 arch/x86_64/pre/src/exception_handling/abort.cpp create mode 100644 arch/x86_64/pre/src/exception_handling/assert.cpp create mode 100644 arch/x86_64/pre/src/exception_handling/panic.cpp create mode 100644 arch/x86_64/pre/src/exception_handling/pure_virtual.cpp create mode 100644 arch/x86_64/pre/src/interrupt_handling/generic_interrupt_handler.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/call.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/gdtr.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/idtr.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/if.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/msr.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/segment_register.cpp create mode 100644 arch/x86_64/pre/src/kernel/cpu/tr.cpp create mode 100644 arch/x86_64/pre/src/kernel/main.cpp create mode 100644 arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/allocator/tiny_frame_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/heap/bump_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/heap/linked_list_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/heap/memory_block.cpp create mode 100644 arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp create mode 100644 arch/x86_64/pre/src/memory/main.cpp create mode 100644 arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp create mode 100644 arch/x86_64/pre/src/memory/multiboot/reader.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/active_page_table.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/inactive_page_table.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/page_entry.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/page_table.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/temporary_page.cpp create mode 100644 arch/x86_64/pre/src/memory/paging/virtual_page.cpp create mode 100644 arch/x86_64/pre/src/user/main.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/gate_descriptor.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/idt_flags.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/ist_offset.cpp delete mode 100644 arch/x86_64/src/context_switching/interrupt_descriptor_table/segment_selector.cpp delete mode 100644 arch/x86_64/src/context_switching/main.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/access_byte.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/gdt_flags.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/global_descriptor_table.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/global_descriptor_table_pointer.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/segment_descriptor_base.cpp delete mode 100644 arch/x86_64/src/context_switching/segment_descriptor_table/segment_descriptor_extension.cpp delete mode 100644 arch/x86_64/src/context_switching/syscall/main.cpp delete mode 100644 arch/x86_64/src/context_switching/syscall/syscall_enable.cpp delete mode 100644 arch/x86_64/src/context_switching/syscall/syscall_handler.cpp delete mode 100644 arch/x86_64/src/exception_handling/abort.cpp delete mode 100644 arch/x86_64/src/exception_handling/assert.cpp delete mode 100644 arch/x86_64/src/exception_handling/panic.cpp delete mode 100644 arch/x86_64/src/exception_handling/pure_virtual.cpp delete mode 100644 arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/call.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/gdtr.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/idtr.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/if.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/msr.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/segment_register.cpp delete mode 100644 arch/x86_64/src/kernel/cpu/tr.cpp delete mode 100644 arch/x86_64/src/kernel/main.cpp delete mode 100644 arch/x86_64/src/memory/allocator/area_frame_allocator.cpp delete mode 100644 arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp delete mode 100644 arch/x86_64/src/memory/heap/bump_allocator.cpp delete mode 100644 arch/x86_64/src/memory/heap/global_heap_allocator.cpp delete mode 100644 arch/x86_64/src/memory/heap/linked_list_allocator.cpp delete mode 100644 arch/x86_64/src/memory/heap/memory_block.cpp delete mode 100644 arch/x86_64/src/memory/heap/user_heap_allocator.cpp delete mode 100644 arch/x86_64/src/memory/main.cpp delete mode 100644 arch/x86_64/src/memory/multiboot/elf_symbols_section.cpp delete mode 100644 arch/x86_64/src/memory/multiboot/reader.cpp delete mode 100644 arch/x86_64/src/memory/paging/active_page_table.cpp delete mode 100644 arch/x86_64/src/memory/paging/inactive_page_table.cpp delete mode 100644 arch/x86_64/src/memory/paging/page_entry.cpp delete mode 100644 arch/x86_64/src/memory/paging/page_table.cpp delete mode 100644 arch/x86_64/src/memory/paging/temporary_page.cpp delete mode 100644 arch/x86_64/src/memory/paging/virtual_page.cpp delete mode 100644 arch/x86_64/src/user/main.cpp (limited to 'arch') diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp deleted file mode 100644 index 07110c8..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP - -#include "arch/context_switching/interrupt_descriptor_table/idt_flags.hpp" -#include "arch/context_switching/interrupt_descriptor_table/ist_offset.hpp" -#include "arch/context_switching/interrupt_descriptor_table/segment_selector.hpp" - -#include -#include - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - __extension__ typedef __int128 int128_t; - __extension__ typedef unsigned __int128 uint128_t; - - /** - * @brief Defines helper function for all states and the actual data the gate descriptor can have. - */ - struct [[gnu::packed]] gate_descriptor - { - /** - * @brief Default Constructor. - */ - gate_descriptor() = default; - - /** - * @brief Constructor. - * - * @note Created gate descriptor copies the given bytes into these components ending with a 32 bit reserved - * field that has to be used, because the 64-bit gate descriptor needs to be big enough for two 32-bit gate - * descriptor. - * - 16 bit Segment Selector - * - 3 bit Interrupt Stack Table Offset - * - 8 bit Type and Flags - * - 64 bit Offset - * - * @param flags Copies the bits set from the given data into the individual components of a gate - * descriptor. - */ - explicit gate_descriptor(uint128_t flags); - - /** - * @brief Constructor. - * - * @param selector, ist, flags, offset Copies the bits set from the given data into the individual components of - * a gate descriptor. - */ - gate_descriptor(segment_selector selector, ist_offset ist, idt_flags flags, uint64_t offset); - - /** - * @brief Allows to compare the underlying bits of two instances. - * - * @param other Other instance that we want to compare with. - * @return Whether the underlying set bits of both types are the same. - */ - auto operator==(gate_descriptor const & other) const -> bool = default; - - private: - // The order in private variables starts for the first variable being the rightmost bit. - uint16_t _offset_1 = {}; ///< Lower 16 bits of handler function address (0 - 15) - segment_selector _selector = {}; ///< Segment selector (16 - 31) - ist_offset _ist = {}; ///< Interrupt Stack Table offset (32 - 39) - idt_flags _flags = {}; ///< Gate Type and Flags (40 - 47) - uint64_t _offset_2 : 48 = {}; ///< Upper 48 bits of handler function address (48 - 95) - uint32_t : 32; ///< Reserved field used to ensure this struct is 128 bits big (96 - 127) - }; -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_GATE_DESCRIPTOR_HPP diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp deleted file mode 100644 index 5104c36..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/idt_flags.hpp +++ /dev/null @@ -1,81 +0,0 @@ - -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IDT_FLAGS_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IDT_FLAGS_HPP - -#include -#include - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - /** - * @brief Defines helper function for all states that the access byte field of a segment descriptor can - * have. - */ - struct [[gnu::packed]] idt_flags - { - /** - * @brief Possible set bits in our underlying bits and the meaning when they are set. - */ - enum bitset : uint8_t - { - INTERRUPT_GATE = 0b01110, ///< The actual type of gate segment is a interrupt gate. - TRAP_GATE = 0b01111, ///< The actual type of gate segment is a trap gate. - DESCRIPTOR_LEVEL_KERNEL = - 0U << 5U, ///< Highest privileged level used by the kernel to allow for full access of resources. - DESCRIPTOR_LEVEL_ADMIN = - 1U << 5U, ///< 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. - DESCRIPTOR_LEVEL_PRIVILEGED_USER = - 2U << 5U, ///< 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. - DESCRIPTOR_LEVEL_USER = 3U << 5U, ///< Restricts access to only application and their specific memory. - PRESENT = 1U << 7U, ///< Present bit; Allows an entry to refer to a valid segment. - ///< Must be set (1) for any valid segment. - }; - - /** - * @brief Default Constructor. - */ - idt_flags() = default; - - /** - * @brief Constructor. - * - * @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. - */ - idt_flags(uint8_t flags); - - /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. - * - * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * data. Any additional bits that are set are not relevant. - * - * @param other Flags that we want to compare against and check if the underlying data has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying data. - */ - auto contains_flags(std::bitset<8U> other) const -> bool; - - /** - * @brief Allows to compare the underlying bits of two instances. - * - * @param other Other instance that we want to compare with. - * @return Whether the underlying set bits of both types are the same. - */ - auto operator==(idt_flags const & other) const -> bool = default; - - /** - * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. - * - * @param other Additional bits that should be set. - */ - auto operator|=(std::bitset<8U> other) -> void; - - private: - uint8_t _flags = {}; ///< Underlying bits used to read the flags from. - }; -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IDT_FLAGS_HPP \ No newline at end of file diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp deleted file mode 100644 index b388e0e..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP - -#include "arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp" - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - /** - * @brief Updates the IDTR with the created interrupt descriptor table. If it has not been created yet this - * method will create it. - */ - auto update_interrupt_descriptor_table_register() -> void; - - /** - * @brief Creates the interrupt descriptor table, with the minimum required configuration. If this method is called - * more than once, the previously created instance is returned instead. - * - * @return Reference to the created interrupt_descriptor_table. - */ - auto get_or_create_interrupt_descriptor_table() -> interrupt_descriptor_table &; - -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_HPP diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp deleted file mode 100644 index 7fe933b..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table_pointer.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP - -#include "arch/context_switching/interrupt_descriptor_table/gate_descriptor.hpp" -#include "arch/stl/vector.hpp" - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - using interrupt_descriptor_table = stl::vector; - - /** - * @brief Represents a pointer to the Interrupt Descriptor Table (IDT). - * - * This structure is used to store the base address and length of the IDT. - */ - struct [[gnu::packed]] interrupt_descriptor_table_pointer - { - /** - * @brief Default constructor. - */ - interrupt_descriptor_table_pointer() = default; - - /** - * @brief Constructor. - */ - interrupt_descriptor_table_pointer(uint16_t table_length, gate_descriptor * address); - - /** - * @brief Defaulted three-way comparsion operator. - */ - auto operator<=>(interrupt_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. - gate_descriptor * address = {}; ///< Non-owning pointer to the IDT base address. - }; - -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_INTERRUPT_DESCRIPTOR_TABLE_POINTER_HPP diff --git a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/ist_offset.hpp b/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/ist_offset.hpp deleted file mode 100644 index e45bcf4..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/ist_offset.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IST_OFFSET_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IST_OFFSET_HPP - -#include -#include - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - /** - * @brief Defines helper function for all states that the interrupt stack table offset field of a gate descriptor can - * have. Is automatically increased to one byte in size, to include the following 5 reserved bits in the gate - * descriptor. - */ - struct [[gnu::packed]] ist_offset - { - /** - * @brief Default Constructor. - */ - ist_offset() = default; - - /** - * @brief Constructor. - * - * @param offset Offset into the interrupt stack table. A value of of 0 means we do not switch stacks, whereas 1 - 7 - * mean we switch to the n-th stack in the Interrupt Stack Table, contained in the TSS if the gate descriptor that - * contains this field is called. - */ - ist_offset(uint8_t offset); - - /** - * @brief Allows to compare the underlying set bits of two instances. - * - * @param other Other instance that we want to compare with. - * @return Whether the underlying set bits of both types are the same. - */ - auto operator==(ist_offset const & other) const -> bool = default; - - private: - uint8_t _ist : 3 = {}; ///< Offset into the interrupt stack table. A value of of 0 means we do not switch stacks, - ///< whereas 1 - 7 mean we switch to the n-th stack in the Interrupt Stack Table, contained - ///< in the TSS if the gate descriptor that contains this field is called. - }; -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_IST_OFFSET_HPP 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 deleted file mode 100644 index 2a7704e..0000000 --- a/arch/x86_64/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_SEGMENT_SELECTOR_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_SEGMENT_SELECTOR_HPP - -#include -#include - -namespace teachos::arch::context_switching::interrupt_descriptor_table -{ - /** - * @brief Represents a segment selector in the x86_64 architecture, which points to a valid code segment in the global - * descriptor table. - * - * A segment selector is a 16-bit identifier used to select a segment descriptor - * from the Global Descriptor Table (GDT) or the Local Descriptor Table (LDT). - * It contains an index, a table indicator (TI), and a requested privilege level (RPL). - */ - struct [[gnu::packed]] segment_selector - { - /** - * @brief Possible set bits in our underlying bits and the meaning when they are set. - */ - enum bitset : uint8_t - { - REQUEST_LEVEL_KERNEL = - 0U << 0U, ///< Highest privileged level used by the kernel to allow for full access of resources. - REQUEST_LEVEL_ADMIN = - 1U << 0U, ///< 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. - REQUEST_LEVEL_PRIVILEGED_USER = - 2U << 0U, ///< 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. - REQUEST_LEVEL_USER = 3U << 0U, ///< Restricts access to only application and their specific memory. - LOCAL_DESCRIPTOR_TABLE = 1U << 2U, ///< Wheter the index referes to an entry in the local or global descriptor - ///< table. If enabled the index points to a local descriptor table, if it is - ///< cleared it referes to a global descriptor table instead. - }; - - /** - * @brief Default constructor. - */ - segment_selector() = default; - - /** - * @brief Constructor. - * - * @param index Index into the local or global descriptor table. Processor multiplies the index value by 8 (number - * of bytes in 32-bit segment descriptor) and adds the result to the base GDT or LDT address. - * @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. - */ - constexpr segment_selector(uint16_t index, uint8_t flags) - : _flags(flags) - , _index(index) - { - // Nothing to do. - } - - /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. - * - * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * data. Any additional bits that are set are not relevant. - * - * @param other Flags that we want to compare against and check if the underlying data has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying data. - */ - auto contains_flags(std::bitset<3U> other) const -> bool; - - /** - * @brief Gets the index into the global descriptor table or the local 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. - */ - auto operator<=>(segment_selector const & other) const -> std::strong_ordering = default; - - /** - * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. - * - * @param other Additional bits that should be set. - */ - auto operator|=(std::bitset<3U> other) -> void; - - /** - * @brief Cast the underlying data into a combined 16-bit form, that contains all data. - * - * @return Underlying value combined into it's full size. - */ - operator uint16_t() const; - - private: - uint8_t _flags : 3 = {}; ///< Underlying bits used to read the flags from. - uint16_t _index : 13 = - {}; ///< Index into the local or global descriptor table. Processor multiplies the index value by 16 (number of - ///< bytes in segment descriptor) and adds the result to the base address. - }; -} // namespace teachos::arch::context_switching::interrupt_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_INTERRUPT_DESCRIPTOR_TABLE_SEGMENT_SELECTOR_HPP diff --git a/arch/x86_64/include/arch/context_switching/main.hpp b/arch/x86_64/include/arch/context_switching/main.hpp deleted file mode 100644 index f8477ea..0000000 --- a/arch/x86_64/include/arch/context_switching/main.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_MAIN_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_MAIN_HPP - -#include "arch/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.hpp" -#include "arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp" - -namespace teachos::arch::context_switching -{ - /** - * @brief Contains the references to the tables required for context switching - */ - struct descriptor_tables - { - segment_descriptor_table::global_descriptor_table & gdt; ///< Reference to the global descriptor table. - interrupt_descriptor_table::interrupt_descriptor_table & idt; ///< Reference to the interrupt descriptor table. - }; - - /** - * @brief Creates the Interrupt Descriptor Table and Global Descriptor Table as a static variable the first time this - * method is called and update IDTR and GDTR registers values. - * - * @note Subsequent calls after the first one, will simply return the previously created tables, but not update the - * registers again. - * - * @return References to the statically created Interrupt Descriptor and Global Descriptor Table. - */ - auto initialize_descriptor_tables() -> descriptor_tables; - - /** - * @brief Switches from the current Kernel Mode (Level 0) to User Mode (Level 3). Will simply use predefined Segment - * Selectors for the User Data and User Code Segment, which are Index 3 and 4 in the GDT respectively. - */ - auto switch_to_user_mode() -> void; - - /** - * @brief Switches from the current Code and Data Segment to the given Code and Data Segment. - * - * @note This method will additionally call initialize_descriptor_tables, to ensure the GDTR and IDTR have been setup - * correctly before attempting to switch the context. This switch is achieved using a far return, which will once - * executed call the given void function. - * - * @param data_segment Data Segment that the SS, DS; ES, FS and GS register will be set too. - * @param code_segment Code Segment that the CS register will be set too. - * @param return_function Function that will be called once the switch has been achieved. - */ - auto switch_context(interrupt_descriptor_table::segment_selector data_segment, - interrupt_descriptor_table::segment_selector code_segment, void (*return_function)()) -> void; - -} // namespace teachos::arch::context_switching - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_MAIN_HPP diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp deleted file mode 100644 index 7450330..0000000 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/access_byte.hpp +++ /dev/null @@ -1,104 +0,0 @@ - -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_ACCESS_BYTE_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_ACCESS_BYTE_HPP - -#include -#include - -namespace teachos::arch::context_switching::segment_descriptor_table -{ - /** - * @brief Defines helper function for all states that the access byte field of a segment descriptor can - * have. - */ - struct [[gnu::packed]] access_byte - { - /** - * @brief Possible set bits in our underlying bits 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. - CODE_OR_DATA_SEGMENT = 1U << 4U, ///< Defines a system segment (if 0) or a code/data segment (if 1). - DESCRIPTOR_LEVEL_KERNEL = - 0U << 5U, ///< Highest privileged level used by the kernel to allow for full access of resources. - DESCRIPTOR_LEVEL_ADMIN = - 1U << 5U, ///< 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. - DESCRIPTOR_LEVEL_PRIVILEGED_USER = - 2U << 5U, ///< 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. - DESCRIPTOR_LEVEL_USER = 3U << 5U, ///< Restricts access to only application and their specific memory. - PRESENT = 1U << 7U, ///< Present bit; Allows an entry to refer to a valid segment. - ///< Must be set (1) for any valid segment. - }; - - /** - * @brief Default Constructor. - */ - access_byte() = default; - - /** - * @brief Constructor. - * - * @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); - - /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. - * - * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * data. Any additional bits that are set are not relevant. - * - * @param other Flags that we want to compare against and check if the underlying data has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying data. - */ - auto contains_flags(std::bitset<8U> other) const -> bool; - - /** - * @brief Allows to compare the underlying data of two instances. - * - * @param other Other instance that we want to compare with. - * @return Whether the underlying data of both types is the same. - */ - auto operator==(access_byte const & other) const -> bool = default; - - /** - * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. - * - * @param other Additional bits that should be set. - */ - auto operator|=(std::bitset<8U> other) -> void; - - private: - uint8_t _flags = {}; ///< Underlying bits used to read the flags from. - }; -} // namespace teachos::arch::context_switching::segment_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_ACCESS_BYTE_HPP \ No newline at end of file diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp deleted file mode 100644 index e24b988..0000000 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/gdt_flags.hpp +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GDT_FLAGS_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GDT_FLAGS_HPP - -#include "arch/context_switching/segment_descriptor_table/segment_descriptor_type.hpp" - -#include - -namespace teachos::arch::context_switching::segment_descriptor_table -{ - /** - * @brief Defines helper function for all states that the flags field of a segment descriptor can - * have. - */ - struct [[gnu::packed]] gdt_flags - { - /** - * @brief Possible set bits in our underlying bits and the meaning when they are set. - */ - enum bitset : uint8_t - { - LONG_MODE = 1U << 1U, ///< Defines in IA-32e mode (64-bit code and 32-bit compatability mode) if the segment - ///< contains 64-bit code. Otherwise this bit should always be 0. Enable if instructions - ///< are executed in 64-bit code, otherwise they are executed in compatability 32-bit mode. - ///< If this bit is set the 3rd bit needs to be clear (0). - UPPER_BOUND = 1U << 2U, ///< Specifies the upper bound of the segment for expand down data segment. Enable for 4 - ///< GiB, 4 KiB otherwise. - STACK_POINTER_SIZE = 1U << 2U, ///< Specifies the size of the Stack Pointer (SP) for stack segments used for - ///< implicit stack operations. Enable for 32 bit, 16 bit otherwise. - DEFAULT_LENGTH = 1U << 2U, ///< Indicates the default length for code segments with effective addresses and - ///< operands. Enable for 32 bit, 16 bit otherwise. - GRANULARITY = 1U << 3U, ///< Indicates the size the Limit value in the segment descriptor is scaled by 1 Byte - ///< blocks if the bit is not set or by 4 KiB blocks if the bit is set. - }; - - /** - * @brief Default Constructor. - */ - gdt_flags() = default; - - /** - * @brief Constructor. - * - * @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, std::bitset<20U> limit); - - /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying data. - * - * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng - * data. Any additional bits that are set are not relevant. - * - * @param other Flags that we want to compare against and check if the underlying data has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying data. - */ - 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 set bits of two instances. - * - * @param other Other instance that we want to compare with. - * @return Whether the underlying set bits of both types are the same. - */ - auto operator==(gdt_flags const & other) const -> bool = default; - - /** - * @brief Combines all bits that are set in the std::bitset flags with the bits already set in the underlying data. - * - * @param other Additional bits that should be set. - */ - auto operator|=(std::bitset<4U> other) -> void; - - private: - uint8_t _limit_2 : 4 = {}; ///< Second part of the limit field. - uint8_t _flags : 4 = {}; ///< Underlying bits used to read the flags from. - }; -} // namespace teachos::arch::context_switching::segment_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GDT_FLAGS_HPP diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp deleted file mode 100644 index 44f2692..0000000 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_HPP - -#include "arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp" -#include "arch/context_switching/segment_descriptor_table/task_state_segment.hpp" - -namespace teachos::arch::context_switching::segment_descriptor_table -{ - /** - * @brief Creates the global descriptor table, with the minimum required configuration. If this method is called more - * than once, the previously created instance is returned instead. - * - * @return Reference to the created global_descriptor_table. - */ - auto get_or_create_gdt() -> global_descriptor_table &; - - /** - * @brief Updates the GDTR with the created global descriptor table. If it has not been created yet this - * method will create it. - * - * @note This method will only set the GDTR, but for the processor to actually register the change a far jump - * has to be executed. This also has to be done before updating the TR. - */ - auto update_gdtr() -> void; - - /** - * @brief Updates the TR with the created task state segment. If it has not been created yet this - * method will create it. - * - * @note This method should only be called after update_gdtr() and a far jump has been - * executed. Because before that trying to access the segment will cause an exception. - */ - auto update_tss_register() -> void; - -} // namespace teachos::arch::context_switching::segment_descriptor_table - -#endif // TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_HPP diff --git a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp b/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp deleted file mode 100644 index 292ff70..0000000 --- a/arch/x86_64/include/arch/context_switching/segment_descriptor_table/global_descriptor_table_pointer.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_POINTER_HPP -#define TEACHOS_ARCH_X86_64_CONTEXT_SWITCHING_SEGMENT_DESCRIPTOR_TABLE_GLOBAL_DESCRIPTOR_TABLE_POINTER_HPP - -#include "arch/stl/vector.hpp" - -#include - -namespace teachos::arch::context_switching::segment_descriptor_table -{ - using global_descriptor_table = stl::vector; - - /** - * @brief Represents a pointer to the Global Descriptor Table (GDT). - * - * 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 [[gnu::packed]] global_descriptor_table_pointer - { - /** - * @brief Default constructor. - */ - global_descriptor_table_pointer() = default; - - /** - * @brief Constructor. - */ - global_descriptor_table_pointer(uint16_t table_length, uint64_t * 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. - uint64_t * address = {}; ///< Non-owning pointer to the GDT base address. - }; -} // namespace teachos::arch::context_switching::segment_descriptor_table - -#endif