115 lines
2.3 KiB
C
115 lines
2.3 KiB
C
#include <stdint.h>
|
|
#include <socks/init.h>
|
|
#include <socks/clock.h>
|
|
#include <socks/input.h>
|
|
#include <socks/panic.h>
|
|
#include <socks/test.h>
|
|
#include <socks/printk.h>
|
|
#include <socks/device.h>
|
|
#include <socks/tty.h>
|
|
#include <socks/kext.h>
|
|
#include <socks/object.h>
|
|
#include <socks/sched.h>
|
|
#include <socks/machine/init.h>
|
|
#include <socks/cpu.h>
|
|
|
|
#ifdef KEXT_NET_DOORSTUCK_SOCKS_FBCON
|
|
#include <socks/fbcon.h>
|
|
#endif
|
|
|
|
extern unsigned long get_rflags(void);
|
|
|
|
extern char __pstart[], __pend[];
|
|
|
|
void print_kernel_banner(void)
|
|
{
|
|
printk("Socks kernel version " BUILD_ID);
|
|
}
|
|
|
|
static void hang(void)
|
|
{
|
|
while (1) {
|
|
printk("tick");
|
|
milli_sleep(2000);
|
|
}
|
|
}
|
|
|
|
void background_thread(void)
|
|
{
|
|
printk("background_thread() running on processor %u", this_cpu());
|
|
milli_sleep(500);
|
|
|
|
while (1) {
|
|
//printk("tock");
|
|
milli_sleep(2000);
|
|
}
|
|
}
|
|
|
|
static void putchar(char c)
|
|
{
|
|
unsigned long flags;
|
|
struct queue *consoles = get_consoles(&flags);
|
|
queue_foreach(struct console, con, consoles, c_list) {
|
|
console_write(con, &c, 1);
|
|
}
|
|
|
|
put_consoles(consoles, flags);
|
|
}
|
|
|
|
void kernel_init(uintptr_t arg)
|
|
{
|
|
ml_init(arg);
|
|
|
|
kern_status_t status;
|
|
status = scan_internal_kexts();
|
|
if (status != KERN_OK) {
|
|
panic("scan_internal_kexts() failed with code %s", kern_status_string(status));
|
|
}
|
|
|
|
status = bring_internal_kexts_online();
|
|
if (status != KERN_OK) {
|
|
panic("bring_internal_kexts_online() failed with code %s", kern_status_string(status));
|
|
}
|
|
|
|
scan_all_buses();
|
|
|
|
printk("kernel_init() running on processor %u", this_cpu());
|
|
|
|
#ifdef KEXT_NET_DOORSTUCK_SOCKS_FBCON
|
|
struct object *fb;
|
|
status = object_get("/dev/video/fb0", &fb);
|
|
if (status == KERN_OK) {
|
|
#if 0
|
|
struct framebuffer_varinfo fb_mode;
|
|
struct device *fbdev = cast_to_device(fb);
|
|
framebuffer_get_varinfo(fbdev, &fb_mode);
|
|
fb_mode.fb_xres = 1024;
|
|
fb_mode.fb_yres = 768;
|
|
fb_mode.fb_bpp = 24;
|
|
fb_mode.fb_flags = FB_MODE_RGB;
|
|
framebuffer_set_varinfo(fbdev, &fb_mode);
|
|
#endif
|
|
|
|
start_console_on_framebuffer(cast_to_device(fb));
|
|
}
|
|
#endif
|
|
struct object *tty0;
|
|
status = object_get("/dev/tty/tty0", &tty0);
|
|
if (status == KERN_OK) {
|
|
tty_set_foreground(cast_to_device(tty0));
|
|
}
|
|
|
|
create_kernel_thread(background_thread);
|
|
|
|
struct object *kbd;
|
|
|
|
run_all_tests();
|
|
|
|
status = object_get("/dev/input/input0", &kbd);
|
|
if (status == KERN_OK) {
|
|
tty_connect_foreground_input_device(cast_to_device(kbd));
|
|
}
|
|
|
|
hang();
|
|
}
|