2023-12-30 09:09:18 +00:00
|
|
|
#include <socks/arg.h>
|
2023-04-30 21:09:36 +01:00
|
|
|
#include <socks/clock.h>
|
2024-09-17 17:47:50 +01:00
|
|
|
#include <socks/cpu.h>
|
2023-05-10 20:34:53 +01:00
|
|
|
#include <socks/device.h>
|
2024-09-17 17:47:50 +01:00
|
|
|
#include <socks/init.h>
|
|
|
|
|
#include <socks/input.h>
|
2023-04-08 09:27:21 +01:00
|
|
|
#include <socks/kext.h>
|
2023-12-30 09:09:18 +00:00
|
|
|
#include <socks/libc/stdio.h>
|
2022-12-21 08:29:33 +00:00
|
|
|
#include <socks/machine/init.h>
|
2024-09-17 17:47:50 +01:00
|
|
|
#include <socks/object.h>
|
|
|
|
|
#include <socks/panic.h>
|
|
|
|
|
#include <socks/printk.h>
|
|
|
|
|
#include <socks/sched.h>
|
|
|
|
|
#include <socks/test.h>
|
|
|
|
|
#include <socks/tty.h>
|
|
|
|
|
#include <stdint.h>
|
2023-02-04 19:03:45 +00:00
|
|
|
|
2023-06-10 21:41:07 +01:00
|
|
|
#ifdef KEXT_NET_DOORSTUCK_SOCKS_FBCON
|
|
|
|
|
#include <socks/fbcon.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-02-04 19:03:45 +00:00
|
|
|
extern unsigned long get_rflags(void);
|
2022-12-21 08:29:33 +00:00
|
|
|
|
2023-02-05 10:50:13 +00:00
|
|
|
extern char __pstart[], __pend[];
|
|
|
|
|
|
2023-02-04 19:19:48 +00:00
|
|
|
void print_kernel_banner(void)
|
|
|
|
|
{
|
|
|
|
|
printk("Socks kernel version " BUILD_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-10 20:34:53 +01:00
|
|
|
static void hang(void)
|
|
|
|
|
{
|
|
|
|
|
while (1) {
|
2023-12-30 09:09:18 +00:00
|
|
|
printk("%d: tick", this_cpu());
|
2023-05-10 20:34:53 +01:00
|
|
|
milli_sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 21:43:18 +01:00
|
|
|
void background_thread(void)
|
|
|
|
|
{
|
|
|
|
|
printk("background_thread() running on processor %u", this_cpu());
|
2023-12-30 09:09:18 +00:00
|
|
|
milli_sleep(1000);
|
2023-05-07 12:38:06 +01:00
|
|
|
|
2023-05-04 21:43:18 +01:00
|
|
|
while (1) {
|
2023-12-30 09:09:18 +00:00
|
|
|
printk("%d: tock", this_cpu());
|
2023-05-10 20:34:53 +01:00
|
|
|
milli_sleep(2000);
|
2023-05-04 21:43:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-10 20:34:53 +01:00
|
|
|
static void putchar(char c)
|
|
|
|
|
{
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
struct queue *consoles = get_consoles(&flags);
|
2024-09-17 17:47:50 +01:00
|
|
|
queue_foreach(struct console, con, consoles, c_list)
|
|
|
|
|
{
|
2023-05-10 20:34:53 +01:00
|
|
|
console_write(con, &c, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
put_consoles(consoles, flags);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-21 08:29:33 +00:00
|
|
|
void kernel_init(uintptr_t arg)
|
|
|
|
|
{
|
2023-02-03 20:24:27 +00:00
|
|
|
ml_init(arg);
|
2023-02-26 10:05:39 +00:00
|
|
|
|
2023-03-18 19:35:00 +00:00
|
|
|
printk("kernel_init() running on processor %u", this_cpu());
|
|
|
|
|
|
2023-05-04 21:43:18 +01:00
|
|
|
create_kernel_thread(background_thread);
|
|
|
|
|
|
2023-05-10 20:34:53 +01:00
|
|
|
hang();
|
2022-12-21 08:29:33 +00:00
|
|
|
}
|