Kernel: fix ARCH() macro and add helper macros for push/pop

This commit is contained in:
Bananymous 2023-02-19 18:17:53 +02:00
parent 0506fee34a
commit feaeee11e5
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,8 @@
#pragma once
#define x86_64 1
#define i386 2
#define ARCH(arch) (__arch == arch)
#if !defined(__arch) || (__arch != x86_64 && __arch != i386)
@ -8,8 +11,10 @@
#if ARCH(x86_64)
#define read_rsp(rsp) asm volatile("movq %%rsp, %0" : "=r"(rsp))
#define read_rbp(rbp) asm volatile("movq %%rbp, %0" : "=r"(rbp))
#define push_callee_saved() asm volatile("pushq %rbx; pushq %rbp; pushq %r12; pushq %r13; pushq %r14; pushq %r15")
#define pop_callee_saved() asm volatile("popq %r15; popq %r14; popq %r13; popq %r12; popq %rbp; popq %rbx")
#else
#define read_rsp(rsp) asm volatile("movl %%esp, %0" : "=r"(rsp))
#define read_rbp(rbp) asm volatile("movl %%ebp, %0" : "=r"(rbp))
#define push_callee_saved() asm volatile("pushal")
#define pop_callee_saved() asm volatile("popal")
#endif