linuxdebug/kernel/universe.c

51 lines
2.1 KiB
C
Raw Normal View History

2024-07-16 15:50:57 +02:00
#include <linux/hrtimer.h>
#include <linux/printk.h>
#include <linux/delay.h>
static struct hrtimer timer;
static void boom(void) {
printk("⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠤⢒⣦⠶⠶⠶⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⢀⡴⠋⠿⠀⠀⠈⠋⠀⠀⠀⠁⠙⠷⣦⣤⣀⠀⠀⠀⠀⠀\n");
printk(" ⠀⢀⡴⠶⣴⠻⠀⠀⠐⣶⠞⠁⠀⢀⠀⠀⠀⣀⠀⠙⠀⠹⢶⣀⠀⠀⠀\n");
printk(" ⢠⡿⠀⠀⠗⠀⠀⠀⠀⠃⠀⠀⢰⣏⠁⠀⠀⠈⡏⠉⠀⠀⠸⡏⢣⠀⠀\n");
printk(" ⣺⠂⠀⣖⠀⠀⠀⠀⢀⡀⢀⣹⣦⡽⣦⣴⣤⣀⢠⡀⠀⢀⠀⠑⠼⣇⠀\n");
printk(" ⠹⡟⡄⢈⣩⠀⠀⠲⠾⠛⡛⠋⠉⠀⡀⢀⣿⠙⠾⣦⡐⢿⡁⠀⡀⢸⡀\n");
printk(" ⠀⢿⣷⡀⠀⢚⡀⠈⢉⡳⢵⡄⢠⠀⠇⣿⣿⠒⠚⠍⠁⢀⣤⡰⠛⠛⠁\n");
printk(" ⠀⠀⠈⠛⠛⠋⠈⠉⠉⠙⠓⣷⠸⣼⣸⢻⣛⠓⠶⠞⠓⠛⠉⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⢀⣠⡴⣞⣭⣿⡄⠋⡇⢸⢥⡽⢳⣤⡀⠀⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠐⣯⡁⣉⠛⢏⣸⣇⣷⣉⣿⡴⢧⠈⠊⠹⣧⡀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠙⠶⣷⣆⣀⣌⠁⠘⣁⣨⡀⢈⣀⣰⣠⣿⠇⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⣿⣷⠛⡋⣏⠙⠿⠛⠉⠉⠁⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⢻⠀⡇⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⢸⠃⡇⢻⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠀⠀⡀⣴⣿⠟⠀⠀⣷⠈⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
printk(" ⠀⠀⠀⠀⠀⠀⠀⠀⠐⠋⠁⠠⠃⠀⠈⠀⠈⠙⠂⠀⠀⠀⠀⠀⠀⠀⠀\n");
}
static enum hrtimer_restart sst_cb(struct hrtimer *timer) {
timer = NULL;
printk("Three...\n");
mdelay(1000);
printk("two...\n");
mdelay(1000);
printk("one...\n");
mdelay(1000);
boom();
// Marvin knows everything about cookies.
//timer->function = NULL;
return HRTIMER_NORESTART;
}
void arm_sst(void) {
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
timer.function = sst_cb;
printk("Armed the universe's timer.\n");
hrtimer_start(&timer, ms_to_ktime(75000), HRTIMER_MODE_REL);
}