add a class to allocate and manage user space stacks
This commit is contained in:
parent
1db93e5b12
commit
2eefda6114
6 changed files with 67 additions and 7 deletions
30
zion/memory/user_stack_manager.h
Normal file
30
zion/memory/user_stack_manager.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Per-process class to manage user stacks.
|
||||
//
|
||||
// User stacks live at
|
||||
// 0x00007FF0 00000000 - 0x00007FFF FFFFFFFF
|
||||
// and grow downwards.
|
||||
//
|
||||
// Each user stack gets 1 MiB (0x100000 bytes)
|
||||
// less a page boundary.
|
||||
// with 1 page allocated at a time.
|
||||
// TODO: consider increasing this.
|
||||
class UserStackManager {
|
||||
public:
|
||||
UserStackManager() {}
|
||||
UserStackManager(const UserStackManager&) = delete;
|
||||
|
||||
uint64_t NewUserStack();
|
||||
void FreeUserStack(uint64_t stack_ptr);
|
||||
|
||||
private:
|
||||
const uint64_t kStackMax = 0x00008000'00000000;
|
||||
const uint64_t kStackMin = 0x00007FF0'00000000;
|
||||
const uint64_t kStackSize = 0x100000;
|
||||
|
||||
uint64_t next_stack_ = kStackMax;
|
||||
uint64_t freed_stacks_ = 0;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue