diff --git a/Makefile b/Makefile index da31ff4..aa84f4f 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,10 @@ $(BUILDDIR)/%.o: */%.asm qemu: kernel qemu-system-i386 $(QEMUFLAGS) +test: kernel + rm image.img + nasm -fbin test.asm -o image.img + iso: kernel cp $(BUILDDIR)/kernel.bin iso/boot/kernel.bin grub-mkrescue -o $(BUILDDIR)/andewOS.iso iso/ diff --git a/image.img b/image.img index c4b85c4..d7c664a 100644 Binary files a/image.img and b/image.img differ diff --git a/src/kmain.c b/src/kmain.c index cd67f6e..3614af1 100644 --- a/src/kmain.c +++ b/src/kmain.c @@ -31,14 +31,21 @@ struct stack_frame { void syscall_read(struct stack_frame regs) { uint32_t fd = regs.edi; - // char *buf = (char *)regs.esi; + char *buf = (char *)regs.esi; uint32_t count = regs.edx; - if (fd == FD_STDOUT) { - int pages = count / BLOCK_SIZE; - if (pages == 0) { -// memcpy(buf, stdout.data, count); - } + if (fd == FD_STDIN) { + extern char shell_buffer[512]; + extern int shell_index; + asm volatile ("sti" ::); + + while (shell_buffer[shell_index-1] != '\n') + asm volatile ("pause" ::); + asm volatile ("cli" ::); + + memcpy(buf, shell_buffer, count); + memset(shell_buffer, 0, 512); + shell_index = 0; } } diff --git a/src/ps2.c b/src/ps2.c index 2b1b172..9c29b96 100644 --- a/src/ps2.c +++ b/src/ps2.c @@ -171,6 +171,7 @@ void ps2_handler() { break; case KBD_ENTER: printf("\n"); + /* if (strcmp(shell_buffer, "PINGAS") == 0) { printf("andew pingas detected"); } else if (strcmp(shell_buffer, "HELLO") == 0) { @@ -188,7 +189,8 @@ void ps2_handler() { shell_buffer[i] = 0; } shell_index = 0; - printf("\n$ "); + */ + shell_buffer[shell_index++] = '\n'; break; case KBD_LCTRL: // Handle left control key diff --git a/test.a b/test.a deleted file mode 100644 index a0c3005..0000000 --- a/test.a +++ /dev/null @@ -1,15 +0,0 @@ -[org 0x6000] -[bits 32] -_start: - push ebp - mov ebp, esp - ; Syscall #1 = write - mov eax, 1 - ; File descriptor = stdout - mov edi, 0 - ; ESI = buffer - mov esi, buf - int 0x80 - jmp $ - -buf: db "Andew skibidi pomni", 0 diff --git a/test.asm b/test.asm new file mode 100644 index 0000000..3c50150 --- /dev/null +++ b/test.asm @@ -0,0 +1,31 @@ +[org 0x6000] +[bits 32] +_start: + push ebp + mov ebp, esp +.loop: + ; print shell prompt + mov eax, 1 + mov edi, 0 + mov esi, prompt + mov edx, 3 + int 0x80 + + ; read input + mov eax, 0 + mov edi, 1 + mov esi, buf + mov edx, 512 + int 0x80 + + ; echo what was wrote + mov eax, 1 + mov edi, 0 + mov esi, buf + mov edx, 512 + int 0x80 + + jmp .loop + jmp $ + +prompt: db "> ", 0