diff --git a/boot/initrd b/boot/initrd index ddd825f..453728e 100755 Binary files a/boot/initrd and b/boot/initrd differ diff --git a/include/kernel/ps2.h b/include/kernel/ps2.h index 4b6bafc..f21d5f0 100644 --- a/include/kernel/ps2.h +++ b/include/kernel/ps2.h @@ -5,6 +5,8 @@ #define PS2_8042_STATUS 0x64 #define PS2_8042_COMMAND 0x64 +#define ps2_reboot outb(0x64, 0xFE) + // SCANCODES #define KBD_ESC 0x01 #define KBD_1 0x02 diff --git a/kernel/init.asm b/kernel/init.asm index fb16599..34a17cf 100644 --- a/kernel/init.asm +++ b/kernel/init.asm @@ -279,10 +279,12 @@ boot_page_tab: times 1024 dd 0 extern syscall_read extern syscall_write +extern syscall_reboot global syscall_table syscall_table: dd syscall_read dd syscall_write + dd syscall_reboot section .bss align 16 diff --git a/kernel/kernel.c b/kernel/kernel.c index 168c467..f06d8c7 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -44,6 +44,7 @@ void syscall_read(stack_frame_t r) { if (fd == FD_STDOUT) { // Not yet } else if (fd == FD_STDIN) { + // for some reason interrupts are disabled asm volatile ("sti" ::); while (ctx.current_task->stdin[ctx.current_task->stdin_len - 1] != '\n') cpu_relax; if (ctx.current_task->stdin_len > 0) ctx.current_task->stdin[--ctx.current_task->stdin_len] = 0; @@ -53,6 +54,11 @@ void syscall_read(stack_frame_t r) { } } +void syscall_reboot(stack_frame_t r) { + (void)r; + ps2_reboot; +} + void syscall_uptime(stack_frame_t r) { uint64_t *buf = (uint64_t *)r.esi; *buf = ctx.ticks; @@ -191,7 +197,6 @@ void kernel(multiboot_info_t *info) { : "eax", "ecx", "edx" ); - LOG("Switching to ring 3... EIP: 0x%08X ESP: 0x%08X\n", task.eip, task.esp); jmp_user_mode(task.esp, task.eip); diff --git a/kernel/pic.c b/kernel/pic.c index a74cd11..6013df5 100644 --- a/kernel/pic.c +++ b/kernel/pic.c @@ -26,6 +26,6 @@ void pic_remap(int pic1_start, int pic2_start) { outb(PIC_2_DATA, 0x01); // Unmask - outb(PIC_1_DATA, 0b11111101); - outb(PIC_2_DATA, 0b11111101); + outb(PIC_1_DATA, 0b11111100); + outb(PIC_2_DATA, 0b11111100); } diff --git a/user/shell.c b/user/shell.c index 36aa38f..08d6b16 100644 --- a/user/shell.c +++ b/user/shell.c @@ -22,6 +22,16 @@ void read(int fd, void *buf, int size) { ); } +void reboot() { + asm volatile ( + "movl $2, %%eax\n\t" + "int $0x80" + : + : + : "eax" + ); +} + extern char *buf; void _start() { @@ -30,10 +40,13 @@ void _start() { while (1) { puts("> "); read(0, buf1, 256); - if (!strcmp(buf1, "SKIBIDI")) { - puts("dop dop yes yes!\n"); - } else { - puts("unknown command!\n"); - } + if (!strcmp(buf1, "SKIBIDI")) { + puts("dop dop yes yes!\n"); + } else if (!strcmp(buf1, "REBOOT")) { + reboot(); + } + else { + puts("unknown command!\n"); + } } }