reboot syscall and shell cmd using ps2 controller
This commit is contained in:
parent
352d51f610
commit
cf1d99fb79
BIN
boot/initrd
BIN
boot/initrd
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
15
user/shell.c
15
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() {
|
||||
|
@ -32,7 +42,10 @@ void _start() {
|
|||
read(0, buf1, 256);
|
||||
if (!strcmp(buf1, "SKIBIDI")) {
|
||||
puts("dop dop yes yes!\n");
|
||||
} else {
|
||||
} else if (!strcmp(buf1, "REBOOT")) {
|
||||
reboot();
|
||||
}
|
||||
else {
|
||||
puts("unknown command!\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user