From 605c3857f684a771f0f1bb6e49c5f56d1d996ba7 Mon Sep 17 00:00:00 2001
From: Armin Luntzer <armin.luntzer@univie.ac.at>
Date: Wed, 6 Jun 2018 14:00:07 +0200
Subject: [PATCH] main: add dummy IRQ demo and twiddle() dummy indicator

---
 init/main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 63414c5..d9b32d6 100644
--- a/init/main.c
+++ b/init/main.c
@@ -18,9 +18,7 @@
 #include <kernel/printk.h>
 #include <modules-image.h>
 
-#ifdef CONFIG_MPPB
 #include <asm/processor.h>
-#endif
 
 /* for our demo */
 #include "xentium_demo.h"
@@ -39,6 +37,27 @@
 #endif /* GCC_VERSION */
 
 
+#include <kernel/irq.h>
+
+irqreturn_t dummy(unsigned int irq, void *userdata)
+{
+	return 0;
+}
+
+
+/**
+ * @brief do something useless
+ */
+
+static void twiddle(void)
+{
+	static int i;
+	const char cursor[] = {'/', '-', '\\', '|'};
+
+	printk("%c\b\b ", cursor[i]);
+
+	i = (i + 1) % ARRAY_SIZE(cursor);
+}
 
 
 /**
@@ -118,6 +137,32 @@ int kernel_main(void)
 	/* run the demo */
 	xen_demo();
 #endif
+	printk(MSG "Boot complete, spinning idly.\n");
+
+	{
+#define GR712_IRL1_GPTIMER_2    10
+
+#define LEON3_TIMER_EN 0x00000001       /* enable counting */
+#define LEON3_TIMER_RL 0x00000002       /* reload at 0     */
+#define LEON3_TIMER_LD 0x00000004       /* load counter    */
+#define LEON3_TIMER_IE 0x00000008       /* irq enable      */
+
+	struct gptimer_unit *mtu = (struct gptimer_unit *) 0x80000300;
+
+	irq_request(8,  ISR_PRIORITY_NOW, dummy, NULL);
+
+        mtu->scaler_reload = 5;
+
+        mtu->timer[0].reload = 10000000 / (mtu->scaler_reload + 1);
+        mtu->timer[0].value = mtu->timer[0].reload;
+        mtu->timer[0].ctrl = LEON3_TIMER_LD | LEON3_TIMER_EN
+                             | LEON3_TIMER_RL | LEON3_TIMER_IE;
+	}
+
+	while(1) {
+		twiddle();
+		cpu_relax();
+	}
 
 	return 0;
 }
-- 
GitLab