diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-06 07:47:27 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-06 07:47:27 +0000 |
| commit | 350aedae0e50749f9821ac7dc6b8316cf35f24bb (patch) | |
| tree | 21f3c67a1648d5950718dc5b0db32e45b870641f /arch/x86_64/src/kernel/main.cpp | |
| parent | a8852f91967a7e55e62e30f5cc07d076092b8b78 (diff) | |
| download | teachos-350aedae0e50749f9821ac7dc6b8316cf35f24bb.tar.xz teachos-350aedae0e50749f9821ac7dc6b8316cf35f24bb.zip | |
wip context switch in asm
Diffstat (limited to 'arch/x86_64/src/kernel/main.cpp')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 7d4173e..52799f0 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -52,12 +52,24 @@ namespace teachos::arch::kernel } [[gnu::naked]] - auto push_code_segment(context_switching::interrupt_descriptor_table::segment_selector segment_selector) -> void + auto push_code_segment(context_switching::interrupt_descriptor_table::segment_selector segment_selector_a, + context_switching::interrupt_descriptor_table::segment_selector segment_selector_b) -> void { asm volatile("push %%rbp\n" "push %[input]" : /* No output from call */ - : [input] "m"(segment_selector)); + : [input] "m"(segment_selector_a)); + asm volatile("mov %[input], %%ax\n" + "mov %%ax, %%ss\n" + "mov %%ax, %%ds\n" + "mov %%ax, %%es\n" + "mov %%ax, %%fs\n" + "mov %%ax, %%gs" + : /* No output from call */ + : [input] "m"(segment_selector_b)); + asm volatile("iret" + : /* No output from call */ + : /* No input to call */); } [[gnu::naked]] @@ -88,16 +100,13 @@ namespace teachos::arch::kernel // - Push return instruction pointer // - Push return code segment selector - context_switching::interrupt_descriptor_table::segment_selector user_code_segment_selector{ - 3U, context_switching::interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_USER}; - push_code_segment(user_code_segment_selector); - - context_switching::interrupt_descriptor_table::segment_selector user_data_segment_selector{ - 4U, context_switching::interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_USER}; - kernel::cpu::set_segment_registers(user_data_segment_selector); + // context_switching::interrupt_descriptor_table::segment_selector user_code_segment_selector{ + // 3U, context_switching::interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_USER}; + // context_switching::interrupt_descriptor_table::segment_selector user_data_segment_selector{ + // 4U, context_switching::interrupt_descriptor_table::segment_selector::REQUEST_LEVEL_USER}; + // push_code_segment(user_code_segment_selector, user_data_segment_selector); - // IRET - iret(); + boot::context_switch(); (void)descriptor_tables; } |
