Working on scheduling
This commit is contained in:
parent
cfcb806ebf
commit
edfbfdad14
9 changed files with 19 additions and 39 deletions
7
Makefile
7
Makefile
|
|
@ -20,8 +20,7 @@ CFLAGS += -Wall \
|
||||||
-I src/include \
|
-I src/include \
|
||||||
-O0 \
|
-O0 \
|
||||||
-ggdb3 \
|
-ggdb3 \
|
||||||
-g \
|
-g
|
||||||
#-fno-omit-frame-pointer
|
|
||||||
CDEBUG = -g
|
CDEBUG = -g
|
||||||
LDFLAGS += -m elf_x86_64 \
|
LDFLAGS += -m elf_x86_64 \
|
||||||
-nostdlib \
|
-nostdlib \
|
||||||
|
|
@ -95,9 +94,9 @@ all:
|
||||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||||
--efi-boot limine-uefi-cd.bin \
|
--efi-boot limine-uefi-cd.bin \
|
||||||
-efi-boot-part --efi-boot-image --protective-msdos-label \
|
-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.
|
# 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:
|
disk:
|
||||||
dd if=/dev/zero of=disk.img bs=1M count=128
|
dd if=/dev/zero of=disk.img bs=1M count=128
|
||||||
elftest:
|
elftest:
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ qemu-system-x86_64 -s -S "$@" &
|
||||||
|
|
||||||
sleep 1
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ timeout: 0
|
||||||
protocol: limine
|
protocol: limine
|
||||||
|
|
||||||
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
|
# 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.
|
# Same thing, but without KASLR.
|
||||||
/Neobbo (KASLR off)
|
/Neobbo (KASLR off)
|
||||||
|
|
@ -17,4 +17,4 @@ timeout: 0
|
||||||
kaslr: no
|
kaslr: no
|
||||||
|
|
||||||
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
|
# 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
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 55d228ff16234513b0df0dd12de8bc58160fc196
|
Subproject commit cc71c677566453be4d1e821ede227a101868638c
|
||||||
|
|
@ -239,9 +239,12 @@ void interrupt_handler(interrupt_frame *r){
|
||||||
|
|
||||||
if(r->int_no == 69 && get_cpu_struct_initialized()
|
if(r->int_no == 69 && get_cpu_struct_initialized()
|
||||||
&& get_cpu_struct()->scheduler_initialized){
|
&& get_cpu_struct()->scheduler_initialized){
|
||||||
|
if(get_cpu_struct()->current_process->state == RUNNING){
|
||||||
enter_scheduler();
|
enter_scheduler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(r->int_no == 70){
|
if(r->int_no == 70){
|
||||||
for(;;){
|
for(;;){
|
||||||
asm("cli;hlt");
|
asm("cli;hlt");
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ void _start(void){
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, 0, 0, 1,
|
NULL, 0, 0, 1,
|
||||||
0, 0,
|
0, 0,
|
||||||
0
|
0, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
kprintf("Welcome to Neobbo{n}");
|
kprintf("Welcome to Neobbo{n}");
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,11 @@ global switch_context
|
||||||
global get_context
|
global get_context
|
||||||
global restore_stack
|
global restore_stack
|
||||||
|
|
||||||
; switch_context(struct context **old, *struct context new)
|
; switch_context(struct context **old, struct context *new)
|
||||||
; ^RDI ^RSI
|
; ^RDI ^RSI
|
||||||
switch_context:
|
switch_context:
|
||||||
push rdi
|
|
||||||
push rsi
|
|
||||||
push rdx
|
|
||||||
push rcx
|
|
||||||
push rbx
|
push rbx
|
||||||
push rbp
|
push rbp
|
||||||
push r8
|
|
||||||
push r9
|
|
||||||
push r10
|
|
||||||
push r11
|
|
||||||
push r12
|
push r12
|
||||||
push r13
|
push r13
|
||||||
push r14
|
push r14
|
||||||
|
|
@ -28,15 +20,7 @@ switch_context:
|
||||||
pop r14
|
pop r14
|
||||||
pop r13
|
pop r13
|
||||||
pop r12
|
pop r12
|
||||||
pop r11
|
|
||||||
pop r10
|
|
||||||
pop r9
|
|
||||||
pop r8
|
|
||||||
pop rbp
|
pop rbp
|
||||||
pop rbx
|
pop rbx
|
||||||
pop rcx
|
|
||||||
pop rdx
|
|
||||||
pop rsi
|
|
||||||
pop rdi
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,15 @@ int next_pid = 1;
|
||||||
|
|
||||||
void idle_task(){
|
void idle_task(){
|
||||||
for(;;){
|
for(;;){
|
||||||
kprintf("Idle!!1\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_task(){
|
void test_task(){
|
||||||
for(;;){
|
|
||||||
kprintf("Hello world from scheduled task!\n");
|
kprintf("Hello world from scheduled task!\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void best_task(){
|
void best_task(){
|
||||||
for(;;){
|
|
||||||
kprintf("Hello world I am best\n");
|
kprintf("Hello world I am best\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup a process structure */
|
/* Setup a process structure */
|
||||||
|
|
@ -115,19 +110,18 @@ void scheduler_init(){
|
||||||
for(;;){
|
for(;;){
|
||||||
for(; i < PROC_MAX; i++){
|
for(; i < PROC_MAX; i++){
|
||||||
if(proc_list[i].state == READY){
|
if(proc_list[i].state == READY){
|
||||||
|
asm("sti");
|
||||||
proc *prev = state->current_process;
|
proc *prev = state->current_process;
|
||||||
prev->state = READY;
|
prev->state = READY;
|
||||||
state->current_process = &proc_list[i];
|
state->current_process = &proc_list[i];
|
||||||
state->current_process->state = RUNNING;
|
state->current_process->state = RUNNING;
|
||||||
switch_context(&(get_cpu_struct()->scheduler_context), get_cpu_struct()->current_process->context);
|
switch_context(&(get_cpu_struct()->scheduler_context), get_cpu_struct()->current_process->context);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = 1;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enter_scheduler(){
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ typedef enum proc_state {
|
||||||
}proc_state;
|
}proc_state;
|
||||||
|
|
||||||
typedef struct context {
|
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;
|
} context;
|
||||||
|
|
||||||
typedef struct proc {
|
typedef struct proc {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue