summaryrefslogtreecommitdiff
path: root/Kernel/Time
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-03-06 11:08:03 +0200
committerAndreas Kling <kling@serenityos.org>2021-03-06 15:58:24 +0100
commitb807e725e050b64f51ab22950a765cda5584ece9 (patch)
tree9848f4030034434af93a7a3f03935f0a18d13348 /Kernel/Time
parentbbe1d7e2397781c353fa33f71d3b320207606a52 (diff)
downloadserenity-b807e725e050b64f51ab22950a765cda5584ece9.zip
Kernel: Address all 32 HPET comparators correctly
Instead of declaring a reserved area from byte 0x160 to 0x400, we change the declaration of TimerStructure array to be 32 units. Also, a static_assert was added, to ensure that the calculation is right.
Diffstat (limited to 'Kernel/Time')
-rw-r--r--Kernel/Time/HPET.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp
index 71603bba23..ef904ec89d 100644
--- a/Kernel/Time/HPET.cpp
+++ b/Kernel/Time/HPET.cpp
@@ -92,14 +92,18 @@ struct [[gnu::packed]] HPETRegistersBlock {
u8 reserved2[0xF0 - 0x28];
HPETRegister main_counter_value;
u64 reserved3;
- TimerStructure timers[3];
- u8 reserved4[0x400 - 0x160];
+ TimerStructure timers[32];
};
static_assert(__builtin_offsetof(HPETRegistersBlock, main_counter_value) == 0xf0);
static_assert(__builtin_offsetof(HPETRegistersBlock, timers[0]) == 0x100);
static_assert(__builtin_offsetof(HPETRegistersBlock, timers[1]) == 0x120);
+// Note: The HPET specification says it reserves the range of byte 0x160 to
+// 0x400 for comparators 3-31, but for implementing all 32 comparators the HPET
+// MMIO space has to be 1280 bytes and not 1024 bytes.
+static_assert(sizeof(HPETRegistersBlock) == 0x500);
+
static u64 read_register_safe64(const HPETRegister& reg)
{
// As per 2.4.7 this reads the 64 bit value in a consistent manner