aboutsummaryrefslogtreecommitdiff
path: root/sys/include/arch/amd64/cpu.h
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-17 20:59:31 -0400
committerIan Moffett <ian@osmora.org>2024-03-17 20:59:31 -0400
commit0776264c266e7c1619b8b8b84d2da5384979bb3c (patch)
tree80b6ded012336e24c72cc2c16e4c3ce952b7b739 /sys/include/arch/amd64/cpu.h
parent7895aaff402a021a1b04645ca8d251f760e5662e (diff)
parent2896f4126de2ee0fd1bab4b960bfb2213c359f18 (diff)
Merge branch 'user' into dev
Diffstat (limited to 'sys/include/arch/amd64/cpu.h')
-rw-r--r--sys/include/arch/amd64/cpu.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h
index e2ed851..ee9bad7 100644
--- a/sys/include/arch/amd64/cpu.h
+++ b/sys/include/arch/amd64/cpu.h
@@ -110,6 +110,46 @@ 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");
+}
+
+static inline void
+amd64_fxsave(void *area)
+{
+ __ASMV("fxsave (%0)" :: "r" (area) : "memory");
+}
+
+static inline void
+amd64_fxrstor(void *area)
+{
+ __ASMV("fxrstor (%0)" :: "r" (area) : "memory");
+}
+
struct cpu_info *amd64_this_cpu(void);
#endif /* !_AMD64_CPU_H_ */