summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-11 12:51:40 -0400
committerIan Moffett <ian@osmora.org>2024-03-11 12:51:40 -0400
commit50bf5cc0bca1b0cb9dbaf461a41b80725baabba1 (patch)
treede36a59881933c55f299cc9ae5eb898c274b4022 /sys
parent9211231b616354537aa447708cb2f90123b8f092 (diff)
kernel/amd64: Add control register r/w helpers
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/arch/amd64/cpu.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h
index e2ed851..1968569 100644
--- a/sys/include/arch/amd64/cpu.h
+++ b/sys/include/arch/amd64/cpu.h
@@ -110,6 +110,34 @@ amd64_read_gs_base(void)
return rdmsr(IA32_KERNEL_GS_BASE);
}
+static inline uint64_t
+amd64_read_cr0(void)
+{
+ uint64_t cr0;
+ __ASMV("mov %%cr0, %0" : "=r" (cr0) :: "memory");
+ return cr0;
+}
+
+static inline void
+amd64_write_cr0(uint64_t val)
+{
+ __ASMV("mov %0, %%cr0" :: "r" (val) : "memory");
+}
+
+static inline uint64_t
+amd64_read_cr4(void)
+{
+ uint64_t cr4;
+ __ASMV("mov %%cr4, %0" : "=r" (cr4) :: "memory");
+ return cr4;
+}
+
+static inline void
+amd64_write_cr4(uint64_t val)
+{
+ __ASMV("mov %0, %%cr4" :: "r" (val) : "memory");
+}
+
struct cpu_info *amd64_this_cpu(void);
#endif /* !_AMD64_CPU_H_ */