mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added Counter() function to CPU
This commit is contained in:
parent
f3cfc623d8
commit
99606bed00
18
Core/CPU.cpp
18
Core/CPU.cpp
@ -240,6 +240,24 @@ namespace CPU
|
|||||||
trace("Features for BSP initialized.");
|
trace("Features for BSP initialized.");
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Counter()
|
||||||
|
{
|
||||||
|
// TODO: Get the counter from the x2APIC or any other timer that is available. (TSC is not available on all CPUs)
|
||||||
|
#if defined(__amd64__)
|
||||||
|
uint64_t counter;
|
||||||
|
asmv("rdtsc"
|
||||||
|
: "=A"(counter));
|
||||||
|
return counter;
|
||||||
|
#elif defined(__i386__)
|
||||||
|
return 0;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
uint64_t counter;
|
||||||
|
asmv("mrs %0, cntvct_el0"
|
||||||
|
: "=r"(counter));
|
||||||
|
return counter;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,9 @@ namespace CPU
|
|||||||
/** @brief To be used only once. */
|
/** @brief To be used only once. */
|
||||||
void InitializeFeatures();
|
void InitializeFeatures();
|
||||||
|
|
||||||
|
/** @brief Get CPU counter value. */
|
||||||
|
uint64_t Counter();
|
||||||
|
|
||||||
namespace MemBar
|
namespace MemBar
|
||||||
{
|
{
|
||||||
__attribute__((no_stack_protector)) static inline void Barrier()
|
__attribute__((no_stack_protector)) static inline void Barrier()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user