mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
Kernel: Abstract platform-specific current time methods from Scheduler
This change ensures that the scheduler doesn't depend on a platform specific or arch-specific code when it initializes itself, but rather we ensure that in compile-time we will generate the appropriate code to find the correct arch-specific current time methods.
This commit is contained in:
parent
c439a34ff7
commit
3651d9701e
5 changed files with 71 additions and 11 deletions
28
Kernel/Arch/x86/CurrentTime.cpp
Normal file
28
Kernel/Arch/x86/CurrentTime.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/CurrentTime.h>
|
||||
#include <Kernel/Arch/x86/ASM_wrapper.h>
|
||||
#include <Kernel/Arch/x86/Processor.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
static u64 current_time_tsc()
|
||||
{
|
||||
return read_tsc();
|
||||
}
|
||||
|
||||
fptr optional_current_time()
|
||||
{
|
||||
VERIFY(Processor::is_initialized()); // sanity check
|
||||
// Figure out a good scheduling time source
|
||||
if (Processor::current().has_feature(CPUFeature::TSC) && Processor::current().has_feature(CPUFeature::CONSTANT_TSC)) {
|
||||
return current_time_tsc;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue