Compare commits
No commits in common. "cf160d12606d5640ed9bafa11d853b48fcbfd3d6" and "cf3f61e37371745c0eaf4af2c5ba3f59b03cbcb1" have entirely different histories.
cf160d1260
...
cf3f61e373
@ -7,5 +7,4 @@ namespace Utilities
|
||||
uint64_t size); // Returns how many blocks of size blocksize does size occupy.
|
||||
|
||||
uint64_t get_rflags();
|
||||
uint64_t get_top_of_stack(uint64_t bottom, uint64_t stack_pages);
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
#include "misc/utils.h"
|
||||
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE 4096
|
||||
#endif
|
||||
|
||||
uint64_t Utilities::get_blocks_from_size(uint64_t blocksize, uint64_t size)
|
||||
{
|
||||
return (size + (blocksize - 1)) / blocksize;
|
||||
@ -13,9 +9,4 @@ extern "C" uint64_t asm_get_rflags();
|
||||
uint64_t Utilities::get_rflags()
|
||||
{
|
||||
return asm_get_rflags();
|
||||
}
|
||||
|
||||
uint64_t Utilities::get_top_of_stack(uint64_t bottom, uint64_t stack_pages)
|
||||
{
|
||||
return bottom + (stack_pages * PAGE_SIZE) - sizeof(uintptr_t);
|
||||
}
|
@ -7,7 +7,6 @@
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "memory/VMM.h"
|
||||
#include "misc/hang.h"
|
||||
#include "misc/utils.h"
|
||||
#include "panic/Panic.h"
|
||||
#include "std/stdlib.h"
|
||||
#include "std/string.h"
|
||||
@ -36,7 +35,7 @@ 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.rsp = Utilities::get_top_of_stack((uint64_t)MemoryManager::get_page(), 1);
|
||||
idle_task.regs.rsp = (uint64_t)MemoryManager::get_page();
|
||||
idle_task.regs.cs = 0x08;
|
||||
idle_task.regs.ss = 0x10;
|
||||
idle_task.regs.rflags = (1 << 21) | (1 << 9);
|
||||
@ -65,11 +64,12 @@ void Scheduler::add_kernel_task(void (*task)(void))
|
||||
new_task->regs.rip = (uint64_t)task;
|
||||
new_task->allocated_stack =
|
||||
(uint64_t)MemoryManager::get_pages(TASK_PAGES_IN_STACK); // 16 KB is enough for everyone, right?
|
||||
new_task->regs.rsp = Utilities::get_top_of_stack(new_task->allocated_stack, TASK_PAGES_IN_STACK);
|
||||
new_task->regs.rsp = new_task->allocated_stack + (PAGE_SIZE * TASK_PAGES_IN_STACK) - sizeof(uintptr_t);
|
||||
new_task->regs.cs = 0x08;
|
||||
new_task->regs.ss = 0x10;
|
||||
new_task->regs.ds = 0x10;
|
||||
new_task->regs.rflags = Utilities::get_rflags() | 0x200; // enable interrupts
|
||||
asm volatile("pushfq; movq (%%rsp), %%rax; movq %%rax, %0; popfq;" : "=m"(new_task->regs.rflags)::"%rax");
|
||||
new_task->regs.rflags |= 0x200; // enable interrupts
|
||||
new_task->task_sleep = 0;
|
||||
new_task->task_time = 0;
|
||||
new_task->cpu_time = 0;
|
||||
@ -92,7 +92,7 @@ void Scheduler::add_user_task(void* task)
|
||||
new_task->regs.rip = (uint64_t)task;
|
||||
new_task->allocated_stack = (uint64_t)MemoryManager::get_pages(
|
||||
TASK_PAGES_IN_STACK, MAP_READ_WRITE | MAP_USER); // 16 KB is enough for everyone, right?
|
||||
new_task->regs.rsp = Utilities::get_top_of_stack(new_task->allocated_stack, TASK_PAGES_IN_STACK);
|
||||
new_task->regs.rsp = new_task->allocated_stack + (PAGE_SIZE * TASK_PAGES_IN_STACK) - sizeof(uintptr_t);
|
||||
new_task->regs.cs = 0x18 | 0x03;
|
||||
new_task->regs.ss = 0x20 | 0x03;
|
||||
new_task->regs.ds = 0x20 | 0x03;
|
||||
@ -128,7 +128,7 @@ void Scheduler::load_user_task(const char* filename)
|
||||
new_task->image = image;
|
||||
new_task->allocated_stack = (uint64_t)MemoryManager::get_pages(
|
||||
TASK_PAGES_IN_STACK, MAP_READ_WRITE | MAP_USER); // 16 KB is enough for everyone, right?
|
||||
new_task->regs.rsp = Utilities::get_top_of_stack(new_task->allocated_stack, TASK_PAGES_IN_STACK);
|
||||
new_task->regs.rsp = new_task->allocated_stack + (PAGE_SIZE * TASK_PAGES_IN_STACK) - sizeof(uintptr_t);
|
||||
new_task->regs.cs = 0x18 | 0x03;
|
||||
new_task->regs.ss = 0x20 | 0x03;
|
||||
new_task->regs.ds = 0x20 | 0x03;
|
||||
|
Loading…
x
Reference in New Issue
Block a user