summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/amd64
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-06-08 18:05:18 -0400
committerIan Moffett <ian@osmora.org>2024-06-08 18:05:18 -0400
commitaec200a3b8b4d5aabcc945536f9c872e7b4e4996 (patch)
tree373e49cf43708a49c8f9260da4e477b7ab68c41c /sys/arch/amd64/amd64
parentf8ce8234aa7247c8f3a4317f5671b5fd40ffb8c8 (diff)
kernel/amd64: lapic: Serialize lapic_timer_init()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r--sys/arch/amd64/amd64/lapic.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c
index 3a87b74..7b3bd98 100644
--- a/sys/arch/amd64/amd64/lapic.c
+++ b/sys/arch/amd64/amd64/lapic.c
@@ -32,6 +32,7 @@
#include <sys/panic.h>
#include <sys/mmio.h>
#include <sys/syslog.h>
+#include <sys/spinlock.h>
#include <dev/timer.h>
#include <machine/intr.h>
#include <machine/isa/i8254.h>
@@ -262,6 +263,9 @@ lapic_timer_init(void)
uint16_t ticks_start, ticks_end;
size_t ticks_total, freq;
const uint16_t MAX_SAMPLES = 0xFFFF;
+ static struct spinlock lock = {0};
+
+ spinlock_acquire(&lock);
lapic_timer_stop();
i8254_set_reload(MAX_SAMPLES);
@@ -275,6 +279,8 @@ lapic_timer_init(void)
freq = (MAX_SAMPLES / ticks_total) * I8254_DIVIDEND;
lapic_timer_stop();
+
+ spinlock_release(&lock);
return freq;
}