mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
Kernel: Simplify 64-bit HPET reads on x86_64
We don't have to worry about racy 32-bit reads when we're reading the 64-bit HPET value using a 64-bit CPU. :^)
This commit is contained in:
parent
a23edd42b8
commit
63117f826b
1 changed files with 11 additions and 2 deletions
|
@ -46,8 +46,13 @@ enum class TimerConfiguration : u32 {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct [[gnu::packed]] HPETRegister {
|
struct [[gnu::packed]] HPETRegister {
|
||||||
volatile u32 low;
|
union {
|
||||||
volatile u32 high;
|
volatile u64 full;
|
||||||
|
struct {
|
||||||
|
volatile u32 low;
|
||||||
|
volatile u32 high;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct [[gnu::packed]] TimerStructure {
|
struct [[gnu::packed]] TimerStructure {
|
||||||
|
@ -87,6 +92,9 @@ static_assert(AssertSize<HPETRegistersBlock, 0x500>());
|
||||||
|
|
||||||
static u64 read_register_safe64(const HPETRegister& reg)
|
static u64 read_register_safe64(const HPETRegister& reg)
|
||||||
{
|
{
|
||||||
|
#if ARCH(X86_64)
|
||||||
|
return reg.full;
|
||||||
|
#else
|
||||||
// As per 2.4.7 this reads the 64 bit value in a consistent manner
|
// As per 2.4.7 this reads the 64 bit value in a consistent manner
|
||||||
// using only 32 bit reads
|
// using only 32 bit reads
|
||||||
u32 low, high = reg.high;
|
u32 low, high = reg.high;
|
||||||
|
@ -98,6 +106,7 @@ static u64 read_register_safe64(const HPETRegister& reg)
|
||||||
high = new_high;
|
high = new_high;
|
||||||
}
|
}
|
||||||
return ((u64)high << 32) | (u64)low;
|
return ((u64)high << 32) | (u64)low;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static HPET* s_hpet;
|
static HPET* s_hpet;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue