summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-19 11:28:43 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-19 11:31:18 +0200
commit46ff281695fc6daa1897de4f4693c7407abaced0 (patch)
tree8ff418e135ca3597f292f2e89aefb8b5e9854d35 /Kernel/init.cpp
parent2d1d01661b0c21fad05532f8a0bbfe0efbe2663a (diff)
downloadserenity-46ff281695fc6daa1897de4f4693c7407abaced0.zip
Turn the syscall interrupt into a trap (by switching the gate type.)
This leaves interrupts enabled while we're in the kernel, which is precisely what we want. This uncovered a horrendous problem with kernel tasks silently overflowing their stacks. For now I've simply increased the stack size but I need a more MMU-y solution for this eventually.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r--Kernel/init.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 85f6dbb537..5ab81f4005 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -25,6 +25,9 @@
#include "MemoryManager.h"
#include <ELFLoader/ELFLoader.h>
+#define TEST_ELF_LOADER
+#define TEST_CRASHY_USER_PROCESSES
+
#if 0
/* Keyboard LED disco task ;^) */
@@ -63,6 +66,18 @@ static void motd_main()
}
}
+static void syscall_test_main() NORETURN;
+static void syscall_test_main()
+{
+ kprintf("Hello in syscall_test_main!\n");
+ for (;;) {
+ Userspace::getuid();
+// Userspace::yield();
+ //kprintf("getuid(): %u\n", Userspace::getuid());
+ sleep(1 * TICKS_PER_SECOND);
+ }
+}
+
static void user_main() NORETURN;
static void user_main()
{
@@ -106,7 +121,7 @@ void banner()
void init()
{
- disableInterrupts();
+ cli();
kmalloc_init();
vga_init();
@@ -123,6 +138,8 @@ void init()
Keyboard::initialize();
Task::initialize();
+ VirtualFileSystem::initializeGlobals();
+
memset(&system, 0, sizeof(system));
WORD base_memory = (CMOS::read(0x16) << 8) | CMOS::read(0x15);
@@ -138,12 +155,12 @@ void init()
//new Task(led_disco, "led-disco", IPC::Handle::Any, Task::Ring0);
scheduleNewTask();
- enableInterrupts();
-
banner();
+ sti();
Disk::initialize();
+#if 1
auto vfs = make<VirtualFileSystem>();
auto dev_zero = make<ZeroDevice>();
@@ -164,11 +181,13 @@ void init()
vfs->mountRoot(e2fs.copyRef());
- //new Task(motd_main, "motd", IPC::Handle::MotdTask, Task::Ring0);
+#ifdef TEST_CRASHY_USER_PROCESSES
new Task(user_main, "user", IPC::Handle::UserTask, Task::Ring3);
new Task(user_kprintf_main, "user_kprintf", IPC::Handle::UserTask, Task::Ring3);
+#endif
//vfs->listDirectory("/");
+#endif
#if 1
{
@@ -182,6 +201,7 @@ void init()
}
#endif
+#ifdef TEST_ELF_LOADER
{
auto testExecutable = vfs->open("/_hello.o");
ASSERT(testExecutable);
@@ -197,9 +217,11 @@ void init()
kprintf("elf_entry: %p\n", elf_entry);
int rc = reinterpret_cast<MainFunctionPtr>(elf_entry)();
kprintf("it returned %d\n", rc);
-
- HANG;
}
+#endif
+
+ new Task(motd_main, "motd", IPC::Handle::MotdTask, Task::Ring0);
+ new Task(syscall_test_main, "syscall_test", IPC::Handle::MotdTask, Task::Ring0);
// The idle task will spend its eternity here for now.
for (;;) {