aboutsummaryrefslogtreecommitdiff
path: root/usr/timed.c
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-03-24 18:52:56 -0700
committerChristian Cunningham <cc@localhost>2022-03-24 18:52:56 -0700
commit7753da66d7d72f441dadd76f357fd5ceb50e7c8f (patch)
treec79cee644108ecb65952eff2104127a19e72d0c4 /usr/timed.c
parent78493b1d441ef888910cf958a16f260bc3c1a7bd (diff)
Modularize Userspace
Diffstat (limited to 'usr/timed.c')
-rw-r--r--usr/timed.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/usr/timed.c b/usr/timed.c
new file mode 100644
index 0000000..9247acf
--- /dev/null
+++ b/usr/timed.c
@@ -0,0 +1,43 @@
+#define USR_TIMED_C
+#include <globals.h>
+#include <graphics/lfb.h>
+#include <symbols.h>
+#include <usr/string.h>
+#include <usr/timed.h>
+#include <util/time.h>
+
+void loop(void)
+{
+ static char str[13];
+ static unsigned long previous = 0;
+ char* start;
+ unsigned long current = *(volatile unsigned long*)SYS_TIMER_CHI;
+ start = ulong_to_string(current, str);
+ draw_string(0, 10, " ");
+ draw_string(0, 10, start);
+ start = ulong_to_string(previous, str);
+ draw_string(0, 11, " ");
+ draw_string(0, 11, start);
+ start = ulong_to_string(nextpid, str);
+ draw_string(0, 12, " ");
+ draw_string(0, 12, start);
+ previous++;
+ wait_msec(3000);
+ add_thread(loop, 0, 3);
+}
+
+void loopt(void)
+{
+ static char str[13];
+ static char cnt = 18;
+ draw_string(0, 14, ulong_to_string(*(volatile unsigned long*)SYS_TIMER_CHI, str));
+ cnt--;
+ if (cnt == 6)
+ unsubscribe_irq(SYS_TIMER_3_IRQ);
+ if (cnt == 4)
+ unsubscribe_irq(SYS_TIMER_2_IRQ);
+ else if (cnt == 2)
+ unsubscribe_irq(SYS_TIMER_1_IRQ);
+ else if (cnt == 0)
+ unsubscribe_irq(SYS_TIMER_0_IRQ);
+}