Manage KernelStacks separately rather than just allocing bytes.

Create a global KernelStackManager that will handle the relevant allocs.
This commit is contained in:
Drew Galbraith 2023-05-30 21:27:20 -07:00
parent 3c3341a90f
commit f22dd66c8d
9 changed files with 104 additions and 24 deletions

View file

@ -0,0 +1,27 @@
#pragma once
#include <stdint.h>
// KernelStackManager doles out kernel stacks.
//
// KernelStacks are in the region:
// 0xFFFFFFFF 90000000 - 0xFFFFFFFF 9FFFFFFF
//
// Each kernel stack is 12 KiB with a 4 Kib page boundary.
//
// It is global object that is only exposed via internal linkage
// to the VirtualMemory class. All kernel stacks should be created through that
// class.
class KernelStackManager {
public:
static void Init();
uint64_t* AllocateKernelStack();
void FreeKernelStack(uint64_t stack_base);
private:
KernelStackManager();
uint64_t next_stack_addr_;
uint64_t freed_stack_cnt_ = 0;
};