asm: clean up reg.S with fancy macro

This commit is contained in:
Michael Shaw 2023-10-20 13:33:39 -04:00
commit 158004fd88

View file

@ -1,33 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
.global cr3_read
cr3_read:
movq %cr3, %rax
ret
.global cr3_write #define genrw(reg) \
cr3_write: .global reg##_read; \
movq %rdi, %cr3 reg##_read: \
ret movq %##reg, %rax; \
ret; \
.global reg##_write; \
reg##_write: \
movq %rdi, %##reg; \
ret;
.global rsp_read
rsp_read:
movq %rsp, %rax
ret
.global rbp_read genrw(rsp)
rbp_read: genrw(rbp)
movq %rbp, %rax genrw(cr3)
ret
.global rsp_write
rsp_write:
movq %rdi, %rsp
ret
.global rbp_write
rbp_write:
movq %rdi, %rbp
ret
.global stack_init .global stack_init
stack_init: stack_init: