diff --git a/Makefile b/Makefile index f820122..4ec67ff 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,7 @@ CFLAGS += -Wall \ -I src/include \ -O0 \ -ggdb3 \ - -g \ - #-fno-omit-frame-pointer + -g CDEBUG = -g LDFLAGS += -m elf_x86_64 \ -nostdlib \ @@ -95,9 +94,9 @@ all: -no-emul-boot -boot-load-size 4 -boot-info-table \ --efi-boot limine-uefi-cd.bin \ -efi-boot-part --efi-boot-image --protective-msdos-label \ - iso_root -o $(BUILD_DIR)/SFB25.iso + iso_root -o $(BUILD_DIR)/Neobbo.iso # Install Limine stage 1 and 2 for legacy BIOS boot. - ./limine/limine bios-install $(BUILD_DIR)/SFB25.iso + ./limine/limine bios-install $(BUILD_DIR)/Neobbo.iso disk: dd if=/dev/zero of=disk.img bs=1M count=128 elftest: diff --git a/autodebug.sh b/autodebug.sh index 88ab342..cf4f1f9 100755 --- a/autodebug.sh +++ b/autodebug.sh @@ -12,7 +12,7 @@ qemu-system-x86_64 -s -S "$@" & sleep 1 -"$termname" -e gdb -ex 'target remote localhost:1234' -ex 'break _start' -ex 'continue' build/SFB25.elf +"$termname" -e gdb -ex 'target remote localhost:1234' -ex 'break _start' build/Neobbo.elf diff --git a/limine.conf b/limine.conf index aeac6c8..de39890 100644 --- a/limine.conf +++ b/limine.conf @@ -7,7 +7,7 @@ timeout: 0 protocol: limine # Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located. - kernel_path: boot():/SFB25.elf + kernel_path: boot():/Neobbo.elf # Same thing, but without KASLR. /Neobbo (KASLR off) @@ -17,4 +17,4 @@ timeout: 0 kaslr: no # Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located. - kernel_path: boot():/SFB25.elf \ No newline at end of file + kernel_path: boot():/Neobbo.elf \ No newline at end of file diff --git a/src/flanterm b/src/flanterm index 55d228f..cc71c67 160000 --- a/src/flanterm +++ b/src/flanterm @@ -1 +1 @@ -Subproject commit 55d228ff16234513b0df0dd12de8bc58160fc196 +Subproject commit cc71c677566453be4d1e821ede227a101868638c diff --git a/src/hal/idt.c b/src/hal/idt.c index a22ac0b..25987e6 100644 --- a/src/hal/idt.c +++ b/src/hal/idt.c @@ -239,7 +239,10 @@ void interrupt_handler(interrupt_frame *r){ if(r->int_no == 69 && get_cpu_struct_initialized() && get_cpu_struct()->scheduler_initialized){ - enter_scheduler(); + if(get_cpu_struct()->current_process->state == RUNNING){ + enter_scheduler(); + } + } if(r->int_no == 70){ diff --git a/src/main.c b/src/main.c index a03690b..6045df7 100644 --- a/src/main.c +++ b/src/main.c @@ -75,7 +75,7 @@ void _start(void){ NULL, NULL, NULL, 0, 0, 1, 0, 0, - 0 + 0, 0 ); kprintf("Welcome to Neobbo{n}"); diff --git a/src/scheduler/sched.asm b/src/scheduler/sched.asm index a66472c..87c9c4f 100644 --- a/src/scheduler/sched.asm +++ b/src/scheduler/sched.asm @@ -3,19 +3,11 @@ global switch_context global get_context global restore_stack -; switch_context(struct context **old, *struct context new) +; switch_context(struct context **old, struct context *new) ; ^RDI ^RSI switch_context: - push rdi - push rsi - push rdx - push rcx push rbx push rbp - push r8 - push r9 - push r10 - push r11 push r12 push r13 push r14 @@ -28,15 +20,7 @@ switch_context: pop r14 pop r13 pop r12 - pop r11 - pop r10 - pop r9 - pop r8 pop rbp pop rbx - pop rcx - pop rdx - pop rsi - pop rdi ret diff --git a/src/scheduler/sched.c b/src/scheduler/sched.c index 207622a..eb4c613 100644 --- a/src/scheduler/sched.c +++ b/src/scheduler/sched.c @@ -16,20 +16,15 @@ int next_pid = 1; void idle_task(){ for(;;){ - kprintf("Idle!!1\n"); } } void test_task(){ - for(;;){ - kprintf("Hello world from scheduled task!\n"); - } + kprintf("Hello world from scheduled task!\n"); } void best_task(){ - for(;;){ - kprintf("Hello world I am best\n"); - } + kprintf("Hello world I am best\n"); } /* Setup a process structure */ @@ -115,19 +110,18 @@ void scheduler_init(){ for(;;){ for(; i < PROC_MAX; i++){ if(proc_list[i].state == READY){ + asm("sti"); proc *prev = state->current_process; prev->state = READY; state->current_process = &proc_list[i]; state->current_process->state = RUNNING; switch_context(&(get_cpu_struct()->scheduler_context), get_cpu_struct()->current_process->context); - } } - i = 1; + i = 0; } } void enter_scheduler(){ - switch_context(&get_cpu_struct()->current_process->context, (get_cpu_struct()->scheduler_context)); - + switch_context(&get_cpu_struct()->current_process->context, get_cpu_struct()->scheduler_context); } \ No newline at end of file diff --git a/src/scheduler/sched.h b/src/scheduler/sched.h index 470e755..2fd4488 100644 --- a/src/scheduler/sched.h +++ b/src/scheduler/sched.h @@ -10,7 +10,7 @@ typedef enum proc_state { }proc_state; typedef struct context { - uint64_t r15, r14, r13, r12, r11, r10, r9, r8, rbp, rbx, rcx, rdx, rsi, rdi, rip; + uint64_t r15, r14, r13, r12, rbp, rbx, rip; } context; typedef struct proc {