mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
add clflush, mwait and monitor support
This commit is contained in:
parent
b09747e022
commit
f1ed79144a
2 changed files with 22 additions and 1 deletions
|
@ -56,6 +56,7 @@ extern "C" {
|
|||
#define CPU_FEATURE_PGE (1 << 13)
|
||||
#define CPU_FEATURE_PAT (1 << 16)
|
||||
#define CPU_FEATURE_PSE36 (1 << 17)
|
||||
#define CPU_FEATURE_CLFLUSH (1 << 19)
|
||||
#define CPU_FEATURE_MMX (1 << 23)
|
||||
#define CPU_FEATURE_FXSR (1 << 24)
|
||||
#define CPU_FEATURE_SSE (1 << 25)
|
||||
|
@ -310,6 +311,10 @@ inline static uint32_t has_fxsr(void) {
|
|||
return (cpu_info.feature1 & CPU_FEATURE_FXSR);
|
||||
}
|
||||
|
||||
inline static uint32_t has_clflush(void) {
|
||||
return (cpu_info.feature1 & CPU_FEATURE_CLFLUSH);
|
||||
}
|
||||
|
||||
inline static uint32_t has_sse(void) {
|
||||
return (cpu_info.feature1 & CPU_FEATURE_SSE);
|
||||
}
|
||||
|
@ -681,6 +686,21 @@ inline static void invalid_cache(void) {
|
|||
asm volatile ("invd");
|
||||
}
|
||||
|
||||
static inline void monitor(const void *eax, unsigned long ecx, unsigned long edx)
|
||||
{
|
||||
asm volatile("monitor" :: "a" (eax), "c" (ecx), "d"(edx));
|
||||
}
|
||||
|
||||
static inline void mwait(unsigned long eax, unsigned long ecx)
|
||||
{
|
||||
asm volatile("mwait" :: "a" (eax), "c" (ecx));
|
||||
}
|
||||
|
||||
static inline void clflush(volatile void *addr)
|
||||
{
|
||||
asm volatile("clflush %0" : "+m" (*(volatile char *)addr));
|
||||
}
|
||||
|
||||
#if 0
|
||||
// the old way to serialize the store and load operations
|
||||
static inline void mb(void) { asm volatile ("lock; addl $0,0(%%esp)" ::: "memory", "cc"); }
|
||||
|
|
|
@ -552,7 +552,7 @@ int cpu_detection(void) {
|
|||
a = b = c = d = 0;
|
||||
cpuid(1, &a, &b, &cpu_info.feature2, &cpu_info.feature1);
|
||||
|
||||
kprintf("CPU features: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
||||
kprintf("CPU features: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
||||
has_sse() ? "SSE " : "",
|
||||
has_sse2() ? "SSE2 " : "",
|
||||
has_sse3() ? "SSE3 " : "",
|
||||
|
@ -571,6 +571,7 @@ int cpu_detection(void) {
|
|||
has_rdtscp() ? "RDTSCP " : "",
|
||||
has_fsgsbase() ? "FSGSBASE " : "",
|
||||
has_mwait() ? "MWAIT " : "",
|
||||
has_clflush() ? "CLFLUSH " : "",
|
||||
has_bmi1() ? "BMI1 " : "",
|
||||
has_bmi2() ? "BMI2 " : "",
|
||||
has_dca() ? "DCA " : "",
|
||||
|
|
Loading…
Add table
Reference in a new issue