Remove _userspace and move the idle task to assembly
This commit is contained in:
parent
6e6cf5b2b0
commit
9012ccc49e
@ -4,41 +4,14 @@ extern _start
|
||||
_main:
|
||||
xor rbp, rbp
|
||||
call _start
|
||||
cli
|
||||
.hang:
|
||||
hlt
|
||||
jmp .hang
|
||||
|
||||
global _userspace
|
||||
_userspace:
|
||||
mov rdi, 4000 ; 4000 ms / 4 seconds
|
||||
mov rax, 2 ; sys_sleep
|
||||
int 42h
|
||||
cmp rax, 0
|
||||
jne .fail ; syscall failed
|
||||
mov rdi, .message
|
||||
mov rsi, 33
|
||||
mov rax, 3 ; sys_write
|
||||
int 42h
|
||||
cmp rax, 33
|
||||
jne .fail ; syscall did not write enough bytes
|
||||
.draw:
|
||||
mov rax, 5 ; sys_rand
|
||||
int 42h
|
||||
mov r9, rax ; color
|
||||
mov rdi, 20 ; x
|
||||
mov rsi, 20 ; y
|
||||
mov r10, 40 ; width
|
||||
mov r8, 30 ; height
|
||||
mov rax, 4 ; sys_paint
|
||||
int 42h
|
||||
cmp rax, 0
|
||||
jne .fail
|
||||
mov rdi, 100
|
||||
mov rax, 2 ; sys_sleep
|
||||
int 42h
|
||||
cmp rax, 0
|
||||
jne .fail
|
||||
jmp .draw
|
||||
.fail:
|
||||
mov rax, 0 ; sys_exit
|
||||
int 42h
|
||||
jmp $ ; sys_exit failed, nothing more we can do
|
||||
.message:
|
||||
db "userspace preparing for painting", 0xA
|
||||
global idle_task_function
|
||||
idle_task_function:
|
||||
sti
|
||||
.idle:
|
||||
hlt
|
||||
jmp .idle
|
@ -25,10 +25,7 @@ static Task* sched_current_task;
|
||||
static Task* base_task;
|
||||
static Task* end_task;
|
||||
|
||||
static void idle_task_function()
|
||||
{
|
||||
while (1) asm volatile("hlt");
|
||||
}
|
||||
extern "C" void idle_task_function();
|
||||
|
||||
static uint64_t frequency;
|
||||
|
||||
@ -36,12 +33,11 @@ void Scheduler::init()
|
||||
{
|
||||
memset(&idle_task, 0, sizeof(Task));
|
||||
idle_task.id = free_tid++;
|
||||
idle_task.regs.rip = (uint64_t)&idle_task_function;
|
||||
idle_task.regs.rip = (uint64_t)idle_task_function;
|
||||
idle_task.regs.rsp = (uint64_t)MemoryManager::get_page();
|
||||
idle_task.regs.cs = 0x08;
|
||||
idle_task.regs.ss = 0x10;
|
||||
asm volatile("pushfq; movq (%%rsp), %%rax; movq %%rax, %0; popfq;" : "=m"(idle_task.regs.rflags)::"%rax");
|
||||
idle_task.regs.rflags |= 0x200;
|
||||
idle_task.regs.rflags = (1 << 21) | (1 << 9);
|
||||
idle_task.task_sleep = 1000;
|
||||
idle_task.state = idle_task.Idle;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user