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:
|
_main:
|
||||||
xor rbp, rbp
|
xor rbp, rbp
|
||||||
call _start
|
call _start
|
||||||
|
cli
|
||||||
|
.hang:
|
||||||
|
hlt
|
||||||
|
jmp .hang
|
||||||
|
|
||||||
global _userspace
|
global idle_task_function
|
||||||
_userspace:
|
idle_task_function:
|
||||||
mov rdi, 4000 ; 4000 ms / 4 seconds
|
sti
|
||||||
mov rax, 2 ; sys_sleep
|
.idle:
|
||||||
int 42h
|
hlt
|
||||||
cmp rax, 0
|
jmp .idle
|
||||||
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
|
|
@ -25,10 +25,7 @@ static Task* sched_current_task;
|
|||||||
static Task* base_task;
|
static Task* base_task;
|
||||||
static Task* end_task;
|
static Task* end_task;
|
||||||
|
|
||||||
static void idle_task_function()
|
extern "C" void idle_task_function();
|
||||||
{
|
|
||||||
while (1) asm volatile("hlt");
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t frequency;
|
static uint64_t frequency;
|
||||||
|
|
||||||
@ -36,12 +33,11 @@ void Scheduler::init()
|
|||||||
{
|
{
|
||||||
memset(&idle_task, 0, sizeof(Task));
|
memset(&idle_task, 0, sizeof(Task));
|
||||||
idle_task.id = free_tid++;
|
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.rsp = (uint64_t)MemoryManager::get_page();
|
||||||
idle_task.regs.cs = 0x08;
|
idle_task.regs.cs = 0x08;
|
||||||
idle_task.regs.ss = 0x10;
|
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 = (1 << 21) | (1 << 9);
|
||||||
idle_task.regs.rflags |= 0x200;
|
|
||||||
idle_task.task_sleep = 1000;
|
idle_task.task_sleep = 1000;
|
||||||
idle_task.state = idle_task.Idle;
|
idle_task.state = idle_task.Idle;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user