mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-08-13 23:34:16 +00:00
.devcontainer
.github
.vscode
Bootloader
Drivers
Kernel
.vscode
arch
core
drivers
exec
files
include
boot
cpu
filesystem
interface
kexcept
memory
brk.hpp
kstack.hpp
macro.hpp
physical.hpp
stack.hpp
swap_pt.hpp
table.hpp
va.hpp
virtual.hpp
vma.hpp
net
stb
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
kcon.hpp
kconfig.hpp
kshell.hpp
lock.hpp
macho.h
md5.h
memory.hpp
msexec.h
pci.hpp
power.hpp
printf.h
rand.hpp
ring.hpp
scheduler.hpp
signal.hpp
smp.hpp
static_vector
symbols.hpp
syscalls.hpp
targp.h
task.hpp
time.hpp
tty.hpp
types.h
uart.hpp
vm.hpp
include_std
kshell
library
network
profiling
storage
subsystem
syscalls
tasking
tests
tty
virtualization
.editorconfig
.gdbinit
.gitignore
ISSUES.md
Makefile
README.md
TODO.md
dump.sh
kernel.cpp
kernel.h
kernel_config.cpp
kernel_thread.cpp
kernel_vfs.cpp
Userspace
initrd
tools
.editorconfig
.gitignore
.gitlab-ci.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CREDITS.md
Doxyfile
Fennix Bootloader.code-workspace
Fennix Drivers.code-workspace
Fennix Kernel.code-workspace
Fennix Userspace.code-workspace
Fennix Website.code-workspace
Fennix.code-workspace
INSTALL.md
LICENSE.md
LICENSES.md
Makefile
README.md
SECURITY.md
STYLE_GUIDE.md
cliff.toml
config.mk
Kernel didn't mapped the pages correctly Signed-off-by: EnderIce2 <enderice2@protonmail.com>
116 lines
2.5 KiB
C++
116 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 <list>
|
|
|
|
#include <memory/table.hpp>
|
|
#include <memory/vma.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 CurrentSize = 0;
|
|
bool UserMode = false;
|
|
bool Expanded = false;
|
|
VirtualMemoryArea *vma = nullptr;
|
|
std::list<AllocatedPages> AllocatedPagesList;
|
|
|
|
public:
|
|
std::list<AllocatedPages> GetAllocatedPages()
|
|
{
|
|
return AllocatedPagesList;
|
|
}
|
|
|
|
/** Fork stack guard */
|
|
void Fork(StackGuard *Parent);
|
|
|
|
/** For general info */
|
|
uint64_t GetSize() { return CurrentSize; }
|
|
|
|
/** 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__
|