mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-13 08:19:15 +00:00
.github
.vscode
arch
core
exec
files
include
boot
cpu
filesystem
memory
brk.hpp
macro.hpp
physical.hpp
smart_heap.hpp
stack.hpp
swap_pt.hpp
table.hpp
virtual.hpp
vma.hpp
net
stb
syscall
abi.h
acpi.hpp
bitmap.hpp
cargs.h
convert.h
cpu.hpp
crc32.h
cwalk.h
debug.h
disk.hpp
display.hpp
driver.hpp
dumper.hpp
elf.h
exec.hpp
filesystem.hpp
hashmap.hpp
ini.h
intrin.hpp
ints.hpp
io.h
kconfig.hpp
kshell.hpp
lock.hpp
md5.h
memory.hpp
msexec.h
pci.hpp
power.hpp
printf.h
rand.hpp
scheduler.hpp
signal.hpp
smart_ptr.hpp
smp.hpp
symbols.hpp
syscalls.hpp
targp.h
task.hpp
time.hpp
types.h
uart.hpp
vm.hpp
include_std
kshell
library
network
profiling
storage
syscalls
tasking
tests
virtualization
.gdbinit
.gitignore
CREDITS.md
Doxyfile
ISSUES.md
LICENSE.md
LICENSES.md
Makefile
README.md
TODO.md
driver.h
dump.sh
kernel.cpp
kernel.h
kernel_config.cpp
kernel_thread.cpp
kernel_vfs.cpp
syscalls.h
115 lines
2.5 KiB
C++
115 lines
2.5 KiB
C++
/*
|
|
This file is part of Fennix Kernel.
|
|
|
|
Fennix Kernel is free software: you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation, either version 3 of
|
|
the License, or (at your option) any later version.
|
|
|
|
Fennix Kernel is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __FENNIX_KERNEL_MEMORY_STACK_GUARD_H__
|
|
#define __FENNIX_KERNEL_MEMORY_STACK_GUARD_H__
|
|
|
|
#include <types.h>
|
|
#include <vector>
|
|
|
|
#include <memory/table.hpp>
|
|
|
|
namespace Memory
|
|
{
|
|
class StackGuard
|
|
{
|
|
private:
|
|
struct AllocatedPages
|
|
{
|
|
void *PhysicalAddress;
|
|
void *VirtualAddress;
|
|
};
|
|
|
|
void *StackBottom = nullptr;
|
|
void *StackTop = nullptr;
|
|
void *StackPhysicalBottom = nullptr;
|
|
void *StackPhysicalTop = nullptr;
|
|
uint64_t Size = 0;
|
|
bool UserMode = false;
|
|
bool Expanded = false;
|
|
VirtualMemoryArea *vma = nullptr;
|
|
std::vector<AllocatedPages> AllocatedPagesList;
|
|
|
|
public:
|
|
std::vector<AllocatedPages> GetAllocatedPages()
|
|
{
|
|
return AllocatedPagesList;
|
|
}
|
|
|
|
/** Fork stack guard */
|
|
void Fork(StackGuard *Parent);
|
|
|
|
/** For general info */
|
|
uint64_t GetSize() { return Size; }
|
|
|
|
/** For general info */
|
|
bool GetUserMode() { return UserMode; }
|
|
|
|
/** For general info */
|
|
bool IsExpanded() { return Expanded; }
|
|
|
|
/** For general info */
|
|
void *GetStackBottom() { return StackBottom; }
|
|
|
|
/** For RSP */
|
|
void *GetStackTop() { return StackTop; }
|
|
|
|
/**
|
|
* For general info (avoid if possible)
|
|
*
|
|
* @note This can be used only if the
|
|
* stack was NOT expanded.
|
|
*/
|
|
void *GetStackPhysicalBottom()
|
|
{
|
|
if (Expanded)
|
|
return nullptr;
|
|
return StackPhysicalBottom;
|
|
}
|
|
|
|
/**
|
|
* For general info (avoid if possible)
|
|
*
|
|
* @note This can be used only if the
|
|
* stack was NOT expanded.
|
|
*/
|
|
void *GetStackPhysicalTop()
|
|
{
|
|
if (Expanded)
|
|
return nullptr;
|
|
return StackPhysicalTop;
|
|
}
|
|
|
|
/**
|
|
* Called by exception handler */
|
|
bool Expand(uintptr_t FaultAddress);
|
|
|
|
/**
|
|
* Construct a new Stack Guard object
|
|
* @param User Stack for user mode?
|
|
*/
|
|
StackGuard(bool User, VirtualMemoryArea *vma);
|
|
|
|
/**
|
|
* Destroy the Stack Guard object
|
|
*/
|
|
~StackGuard();
|
|
};
|
|
}
|
|
|
|
#endif // !__FENNIX_KERNEL_MEMORY_STACK_GUARD_H__
|