summaryrefslogtreecommitdiff
path: root/kernel/arch/i386
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-10-31 14:28:15 +0100
committerAnton Kling <anton@kling.gg>2023-10-31 14:28:15 +0100
commit6c227820a80fb18c9c04b588aa1cb7aa23fbc4ac (patch)
treeccb9849884f92dadc4801d3b93ba351f8a962630 /kernel/arch/i386
parentb416c3704a36f0c055fdb51ad014c9f4787aee91 (diff)
Kernel: Remove all O0 optimizations on functions.
The kernel can now fully compile under O3 without any noticable problems :)
Diffstat (limited to 'kernel/arch/i386')
-rw-r--r--kernel/arch/i386/mmu.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/kernel/arch/i386/mmu.c b/kernel/arch/i386/mmu.c
index f4246d4..6b2f704 100644
--- a/kernel/arch/i386/mmu.c
+++ b/kernel/arch/i386/mmu.c
@@ -430,18 +430,15 @@ void *virtual_to_physical(void *address, PageDirectory *directory) {
}
extern uint32_t inital_esp;
-void __attribute__((optimize("O0")))
+void
move_stack(uint32_t new_stack_address, uint32_t size) {
- mmu_allocate_region((void *)(new_stack_address - size), size,
- MMU_FLAG_KERNEL, NULL);
+ mmu_allocate_region((void *)(new_stack_address - size), size, MMU_FLAG_KERNEL,
+ NULL);
uint32_t old_stack_pointer, old_base_pointer;
- register uint32_t eax asm("eax");
- asm volatile("mov %esp, %eax");
- old_stack_pointer = eax;
- asm volatile("mov %ebp, %eax");
- old_base_pointer = eax;
+ asm volatile("mov %%esp, %0" : "=r"(old_stack_pointer));
+ asm volatile("mov %%ebp, %0" : "=r"(old_base_pointer));
uint32_t new_stack_pointer =
old_stack_pointer + ((uint32_t)new_stack_address - inital_esp);
@@ -463,10 +460,8 @@ move_stack(uint32_t new_stack_address, uint32_t size) {
inital_esp = new_stack_pointer;
// Actually change the stack
- eax = new_stack_pointer;
- asm volatile("mov %eax, %esp");
- eax = new_base_pointer;
- asm volatile("mov %eax, %ebp");
+ asm volatile("mov %0, %%esp" ::"irm"(new_stack_pointer));
+ asm volatile("mov %0, %%ebp" ::"irm"(new_base_pointer));
}
// C strings have a unknown length so it does not makes sense to check