dead@root 2

This commit is contained in:
assada 2024-05-21 18:37:03 +03:00
parent 0e5bd43f55
commit c8fe14b21d
Signed by: assada
GPG Key ID: D4860A938E541F06
8 changed files with 73 additions and 7 deletions

View File

@ -6,10 +6,10 @@ AS = i686-elf-as
LD = i686-elf-gcc
GRUB_FILE = grub-file
GRUB_MKRESCUE = grub-mkrescue
KERNEL = myos.bin
ISO = myos.iso
KERNEL = deados.bin
ISO = deados.iso
SOURCES_C = kernel.c tty.c idt.c timer.c io.c vga.c gdt.c sys.c irq.c isr.c keyboard.c shell.c string.c
SOURCES_C = kernel.c tty.c idt.c timer.c io.c vga.c gdt.c sys.c irq.c isr.c keyboard.c shell.c string.c user_space.c syscall.c
SOURCES_ASM = boot.s idt_load.s gdt_flush.s pit_handler.s irq_e.s isr_e.s
OBJECTS = $(SOURCES_ASM:.s=.o) $(SOURCES_C:.c=.o)

View File

@ -1,3 +1,3 @@
menuentry "dead" {
multiboot /boot/myos.bin
menuentry "deadOS" {
multiboot /boot/deados.bin
}

View File

@ -9,6 +9,8 @@
#include "interrupts.h"
#include "keyboard.h"
#include "shell.h"
#include "user_space.h"
#include "syscall.h"
void kernel_main(void)
{
@ -35,6 +37,9 @@ void kernel_main(void)
terminal_printc("\n");
delay(500);
}
// syscall_init();
// enter_user_space();
shell_init();
}

View File

@ -13,7 +13,7 @@ void shell_init(void)
while (true)
{
terminal_printc("\n");
terminal_printc("&7root@dead: /> ");
terminal_printc("&7dead@&croot&7: /> ");
i = 0;
c = 0;
@ -106,7 +106,7 @@ void shell_parse_input(char *input)
else
{
terminal_printc("Unknown command: '");
terminal_printc(command);
terminal_writestring(command);
terminal_printc("'\n");
terminal_printc("Type 'help' to print out the list of commands.\n");
}

26
syscall.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdint.h>
#include "interrupts.h"
#include "syscall.h"
#include "tty.h"
void test_syscall()
{
terminal_printc("Test syscall called\n");
}
void syscall_handler(Stack *registers)
{
int sys_index = registers->eax;
if (sys_index != 0)
{
return;
}
test_syscall();
}
void syscall_init(void)
{
isr_install_handler(128, syscall_handler);
}

6
syscall.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef SYSCALL_H
#define SYSCALL_H
void syscall_init(void);
#endif

23
user_space.c Normal file
View File

@ -0,0 +1,23 @@
#include "user_space.h"
void enter_user_space(void)
{
asm volatile(" cli; \
mov $0x23, %ax; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %gs; \
mov %esp, %eax; \
pushl $0x23; \
pushl %eax; \
pushf; \
popl %eax; \
orl $0x200, %eax; \
pushl %eax; \
pushl $0x1B; \
push $1f; \
iret; \
1: \
");
}

6
user_space.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _USER_SPACE_H
#define _USER_SPACE_H
void enter_user_space(void);
#endif