git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: Optimize the context switch overhead
[lunaix-os.git]
/
lunaix-os
/
includes
/
hal
/
cpu.h
diff --git
a/lunaix-os/includes/hal/cpu.h
b/lunaix-os/includes/hal/cpu.h
index ae9926b7c0e6e6bedfd8d497cea59dc9e6c67d63..3b77c7eb12aeca27205d8406f738ae5c8a17f0c2 100644
(file)
--- a/
lunaix-os/includes/hal/cpu.h
+++ b/
lunaix-os/includes/hal/cpu.h
@@
-39,7
+39,7
@@
cpu_has_apic();
static inline reg32
cpu_rcr0()
{
static inline reg32
cpu_rcr0()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr0,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr0,%0" : "=r"(val));
return val;
}
@@
-47,7
+47,7
@@
cpu_rcr0()
static inline reg32
cpu_rcr2()
{
static inline reg32
cpu_rcr2()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr2,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr2,%0" : "=r"(val));
return val;
}
@@
-55,15
+55,23
@@
cpu_rcr2()
static inline reg32
cpu_rcr3()
{
static inline reg32
cpu_rcr3()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr3,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr3,%0" : "=r"(val));
return val;
}
+static inline reg32
+cpu_rcr4()
+{
+ ptr_t val;
+ asm volatile("movl %%cr4,%0" : "=r"(val));
+ return val;
+}
+
static inline reg32
cpu_reflags()
{
static inline reg32
cpu_reflags()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("pushf\n"
"popl %0\n"
: "=r"(val)::);
asm volatile("pushf\n"
"popl %0\n"
: "=r"(val)::);
@@
-90,9
+98,9
@@
cpu_lcr3(reg32 v)
}
static inline void
}
static inline void
-cpu_invplg(
void*
va)
+cpu_invplg(
ptr_t
va)
{
{
- asm volatile("invlpg (%0)" ::"r"(
(uintptr_t)
va) : "memory");
+ asm volatile("invlpg (%0)" ::"r"(va) : "memory");
}
static inline void
}
static inline void
@@
-129,4
+137,10
@@
cpu_rdmsr(u32_t msr_idx, u32_t* reg_high, u32_t* reg_low);
void
cpu_wrmsr(u32_t msr_idx, u32_t reg_high, u32_t reg_low);
void
cpu_wrmsr(u32_t msr_idx, u32_t reg_high, u32_t reg_low);
+static inline void
+cpu_ldvmspace(ptr_t vms)
+{
+ cpu_lcr3(vms);
+}
+
#endif
\ No newline at end of file
#endif
\ No newline at end of file