From 01c73f84744f1a859fd6d5fab83525abf1f4315f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 1 Nov 2023 14:45:43 -0400 Subject: [PATCH] Add check that PIT ISR is firing --- src/hulk/hulk.d | 10 ++++++++++ src/hulk/time.d | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hulk/hulk.d b/src/hulk/hulk.d index d20a80f..916a2f5 100644 --- a/src/hulk/hulk.d +++ b/src/hulk/hulk.d @@ -24,6 +24,7 @@ import hulk.rtc; import hulk.serial; import hulk.usb; import hulk.pit; +import hulk.time; extern extern(C) __gshared ubyte _hulk_bss_size; @@ -87,6 +88,15 @@ void hulk_start() Usb.initialize(); sti(); + /* Check that PIT millisecond interrupt is firing. */ + size_t uptime = Time.uptime(); + while (Time.uptime() <= uptime) + { + } + Klog.writefln("\a5HULK Initialization Complete!"); + + /* Idle loop. */ + Time.msleep(1); for (;;) { hlt(); diff --git a/src/hulk/time.d b/src/hulk/time.d index 4acf673..1a422cb 100644 --- a/src/hulk/time.d +++ b/src/hulk/time.d @@ -23,7 +23,7 @@ struct Time */ public static @property ulong uptime() { - return s_uptime; + return volatileLoad(&s_uptime); } /** @@ -35,7 +35,7 @@ struct Time public static void msleep(ulong count) { ulong wait_for = s_uptime + count + 1; - while (volatileLoad(&s_uptime) < wait_for) + while (uptime() < wait_for) { } }