mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
398d271a46
About half of the Processor code is common across architectures, so let's share it with a templated base class. Also, other code that can be shared in some ways, like FPUState and TrapFrame functions, is adjusted here. Functions which cannot be shared trivially (without internal refactoring) are left alone for now.
29 lines
625 B
C++
29 lines
625 B
C++
/*
|
|
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Arch/CurrentTime.h>
|
|
#include <Kernel/Arch/Processor.h>
|
|
#include <Kernel/Arch/x86_64/ASM_wrapper.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;
|
|
}
|
|
|
|
}
|