MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / setupStack

Method setupStack

source/kernel/kthread.cpp:82–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void KThread::setupStack() {
83 U32 stack = memory->mmap(this, 0, MAX_STACK_SIZE, K_PROT_NONE, K_MAP_ANONYMOUS|K_MAP_PRIVATE, -1, 0);
84 // will all by on demand
85 memory->mprotect(this, stack + K_PAGE_SIZE, MAX_STACK_SIZE - 2 * K_PAGE_SIZE, K_PROT_READ | K_PROT_WRITE);
86 U32 stackPageCount = MAX_STACK_SIZE >> K_PAGE_SHIFT;
87 U32 stackPageStart = stack >> K_PAGE_SHIFT;
88 this->cpu->reg[4].u32 = (stackPageStart + stackPageCount - 1) << K_PAGE_SHIFT;
89 // touch the first 16 pages now so that they are ready
90 for (int i = 1; i < 17; i++) {
91 memory->readd(this->cpu->reg[4].u32 - K_PAGE_SIZE * i);
92 }
93}
94
95KThread::KThread(U32 id, const KProcessPtr& process) :
96 id(id),

Callers 2

resetMethod · 0.95
startProcessMethod · 0.80

Calls 3

mmapMethod · 0.80
mprotectMethod · 0.80
readdMethod · 0.45

Tested by

no test coverage detected