[Zion] Return freed kernel stacks to pool.
This commit is contained in:
parent
8fb5b7c03c
commit
d1ace374b6
|
@ -15,6 +15,9 @@ void KernelStackManager::SetupInterruptStack() {
|
|||
}
|
||||
|
||||
uint64_t KernelStackManager::AllocateKernelStack() {
|
||||
if (!free_stacks_.empty()) {
|
||||
return free_stacks_.PopFront();
|
||||
}
|
||||
next_stack_addr_ += kKernelStackOffset;
|
||||
if (next_stack_addr_ >= kKernelStackEnd) {
|
||||
panic("No more kernel stack space");
|
||||
|
@ -24,6 +27,9 @@ uint64_t KernelStackManager::AllocateKernelStack() {
|
|||
}
|
||||
|
||||
void KernelStackManager::FreeKernelStack(uint64_t stack_base) {
|
||||
freed_stack_cnt_++;
|
||||
dbgln("Freed kernel stacks using {} KiB", freed_stack_cnt_ * 12);
|
||||
// TODO: Validate this value.
|
||||
if ((stack_base & 0x3FF8) != 0x3FF8) {
|
||||
dbgln("Odd kernel stack free {x}", stack_base);
|
||||
}
|
||||
free_stacks_.PushFront(stack_base);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// KernelStackManager doles out kernel stacks.
|
||||
|
@ -24,5 +25,6 @@ class KernelStackManager {
|
|||
|
||||
private:
|
||||
uint64_t next_stack_addr_;
|
||||
uint64_t freed_stack_cnt_ = 0;
|
||||
|
||||
glcr::LinkedList<uint64_t> free_stacks_;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue